Skip to content

Regression: child can override final plain property on PROFILE=8.4 (re-#22339, Zend/zend_inheritance.c) #22988

Closed

Description

@PurHur

Category

Language · php-src-strict · PHP 8.4 · pillar 4

Problem

PHP 8.4 final plain properties must not be redeclared on a child. #22339 was closed as fixed via FinalPropertyOverrideCheck, but on current master under PHP_COMPILER_PROFILE=8.4 a child can override a final public property (file compile and eval).

Verified 2026-07-25:

Repro Zend 8.4+ VM (2026-07-25)
class A { final public string $x = 'a'; } class B extends A { public string $x = 'b'; } Fatal/Error: cannot override final property runs (SHOULD_NOT_REACH / EVAL_OK + b)

php-src reference

PHP implementation target

  • lib/ inheritance / FinalPropertyOverrideCheck (or equivalent) — reject child redeclaration of final plain properties under forward profile 8.4+
  • PHP-in-PHP only; no new C runtime logic

Repro

./script/docker-exec.sh -- bash -lc 'export PHP_COMPILER_PROFILE=8.4
cat > /tmp/final_prop.php <<'"'"'PHP'"'"'
<?php
class A { final public string $x = 'a'; }
class B extends A { public string $x = 'b'; }
echo "SHOULD_NOT_REACH\n";
PHP
php bin/vm.php /tmp/final_prop.php'

Done when

  • Child override of final plain property errors like Zend under PROFILE=8.4 (file + eval)
  • Compliance .phpt under test/compliance/cases/language/
  • php-src-strict; no php-compiler-strict shortcut

Activity

  1. added
    bugSomething isn't working
    implementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claim
    on Jul 25, 2026
  2. PurHur commented on Jul 25, 2026

    @PurHur
    OwnerAuthor

    claim: Lane C worker — starting this run

  3. PurHur commented on Jul 25, 2026

    @PurHur
    OwnerAuthor

    Merged #23002

    Root cause: same-script FinalPropertyOverrideCheck was green, but separate eval() inheritance never consulted parent propertyFinal in inheritFromParent.

    Fix: reject in VM::inheritFromParent with Zend message Cannot override final property %s::$%s (same shape as final class-const #22329).

    Verification:

    PHP_COMPILER_PROFILE=8.4 php bin/vm.php test/repro/issue_22988_final_plain_property_eval_override.php
    # → PHP Fatal error: Cannot override final property A::$x … exit 255
    
    vendor/bin/phpunit --filter "FinalPropertyOverrideCheckTest|final_plain_property_eval_override|final_plain_property_override_fatal"
    # → OK 12 tests
    
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:compilerCompiler / CFG / JITbugSomething isn't workingimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-2:languagePhase 2 – language features

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions