Skip to content

Stdlib: DOMElement::toggleAttribute() — PHP 8.3 boolean attribute toggle missing (ext/dom/php_dom.c) #16824

Description

@PurHur

Category

stdlib · php-src-strict

Problem

PHP 8.3+ adds DOMElement::toggleAttribute(string $qualifiedName, ?bool $force = null): bool to add/remove boolean attributes. On PHP_COMPILER_PROFILE=8.4, the method is absent and calls fatal.

Repro Zend 8.3+ VM (2026-07-06, profile=8.4)
$el->toggleAttribute('hidden') on fresh <p> true; hasAttribute('hidden') → true Error: Call to undefined method DOMElement::toggleAttribute()
second toggleAttribute('hidden') false; attribute removed (not reached)

php-src reference

PHP implementation target

  • ext/dom/ + existing DOM element VM/JIT paths — PHP implementation; thin C ABI only if unavoidable

Repro

./script/docker-exec.sh -- bash -lc 'export PHP_COMPILER_PROFILE=8.4; php bin/vm.php test/repro/maintainer_gap_dom_element_toggle_attribute.php'

Done when

  • toggleAttribute() add/remove/$force semantics match Zend on VM/JIT/AOT
  • Compliance .phpt guard under test/compliance/cases/stdlib/
  • php-src-strict; no php-compiler-strict shortcut

Activity

  1. added
    enhancementNew feature or request
    phase-4:stdlibPhase 4 – stdlib for web apps
    area:vmVirtual machine
    implementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claim
    on Jul 6, 2026
  2. PurHur commented on Jul 6, 2026

    @PurHur
    OwnerAuthor

    claim: cursor-agent-lane-a — starting this run

  3. PurHur commented on Jul 6, 2026

    @PurHur
    OwnerAuthor

    Merged via #16835

    Verification

    ./script/docker-exec.sh -- bash -lc 'export PHP_COMPILER_PROFILE=8.4; php bin/vm.php test/repro/maintainer_gap_dom_element_toggle_attribute.php'
    # ok
    
    ./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && PHP_COMPILER_PROFILE=8.4 vendor/bin/phpunit --filter dom_element_toggle_attribute'
    # OK (2 tests)
    
    php script/check-selfhost-spine-count-sync.php
    # OK (spine 4156/4156)

    PHP implementation: ext/dom/ElementToggleAttribute.php, VmDom::toggleAttribute() (php-src ext/dom/element.c).

  4. PurHur commented on Jul 7, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib Advanced — batch ext/dom forward registration + htmlspecialchars_decode (#14447, #14448, #14449, #15195, #16824, #2454)

  5. PurHur commented on Jul 7, 2026

    @PurHur
    OwnerAuthor

    Merged in #17081 — DOM Living Standard APIs now register on 8.4.0-dev via builtinAdvertisementVersion(); htmlspecialchars_decode ENT_COMPAT expect aligned with php-src. Verified: CompilerVersionGateTest (Dom), VMTest dom_node_* + htmlspecialchars_decode_flags, DomDocumentVMTest, maintainer_gap dom repros.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web appsstdlib

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions