Skip to content

Fix interface property hooks satisfied by plain typed properties (#7311)#7335

Merged
PurHur merged 1 commit into
masterfrom
agent/issue-7311-interface-property-hooks
Jun 7, 2026
Merged

Fix interface property hooks satisfied by plain typed properties (#7311)#7335
PurHur merged 1 commit into
masterfrom
agent/issue-7311-interface-property-hooks

Conversation

@PurHur
Copy link
Copy Markdown
Owner

@PurHur PurHur commented Jun 7, 2026

Summary

  • Plain typed properties on implementing classes now satisfy PHP 8.4 interface { get; } / { get; set; } obligations (zend_property_hooks.c parity)
  • inheritInterfacePropertyHooks / inheritParentPropertyHooks strip abstract/virtual hook metadata when a backing field implements the obligation
  • Compile-time (InterfaceImplementationCheck) and runtime (AbstractPropertyHookCheck) treat declared backing fields as implicit get/set providers

Closes #7311

php-src reference

  • Zend/zend_compile.c — interface property hook validation
  • Zend/zend_property_hooks.c — backing-field satisfaction

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter interface_property_hooks'
# OK (1 test)

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter testImplementedInterfacePropertyHookCompiles'
# OK (1 test)

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php test/repro/maintainer_interface_property_hooks.php'
# 1
# home

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php -r "
interface I { public string \$label { get; } }
class C implements I { public string \$label = \"hi\"; }
\$c = new C();
echo \$c->label, \"\\n\";
"'
# hi

Made with Cursor

…).

Zend 8.4 allows implementing classes to satisfy interface { get; } / { get; set; }
obligations with ordinary typed properties. Sanitize inherited hook metadata at
class link time and treat backing fields as implicit hook providers in compile-time
and runtime abstract-hook checks.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur PurHur merged commit 568b2a8 into master Jun 7, 2026
@PurHur PurHur deleted the agent/issue-7311-interface-property-hooks branch June 7, 2026 04:56
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.

Language: property hooks in interfaces — concrete property must satisfy interface { get; } (PHP 8.4, zend_compile.c)

1 participant