Skip to content

Language: reject final plain property override across eval (#22988) - #23002

Merged
PurHur merged 1 commit into
masterfrom
agent/issue-22988-final-property-override
Jul 25, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/issue-22988-final-property-override

Conversation

@PurHur

@PurHur PurHur commented Jul 25, 2026

Copy link
Copy Markdown
Owner

Summary

  • Child redeclaration of a parent final plain property already fatals in the same compile unit via FinalPropertyOverrideCheck, but separate eval() inheritance skipped the guard and printed EVAL_OK.
  • Enforce in VM::inheritFromParent (same pattern as final class constants Regression: final class constants can be overridden by child class (re-#4455, Zend/zend_inheritance.c) #22329) so PHP_COMPILER_PROFILE=8.4 matches php-src Zend/zend_inheritance.c.
  • Compliance .phpt + unit test; JIT skips MCJIT inline-eval deferral (same as final_class_const_eval_override).

Closes #22988

php-src reference

  • Zend/zend_inheritance.c — Cannot override final property %s::$%s

PHP implementation

  • lib/VM.php — rejectChildOverrideOfFinalProperty() from inheritFromParent
  • No new C runtime logic

Test plan

  • Issue repro (separate eval):
./script/docker-exec.sh -- bash -lc 'export 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
  • Same-script still rejects at compile time
  • vendor/bin/phpunit --filter "FinalPropertyOverrideCheckTest|final_plain_property_eval_override|final_plain_property_override_fatal" → OK 12 tests

Trust gates (pre-claim snapshot)

  • inventory: OK 6519/6519
  • user_release_ready: no (pre-existing spine-coverage / north-star5-fast red on master — unrelated to this language fix)

Made with Cursor

Same-script FinalPropertyOverrideCheck already fatals, but separate
eval() inheritance skipped the guard. Mirror final class-const
handling in inheritFromParent so PROFILE=8.4 matches zend_inheritance.c.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur merged commit 000efd5 into master Jul 25, 2026
@PurHur
PurHur deleted the agent/issue-22988-final-property-override branch July 25, 2026 11:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant