Skip to content

Stdlib: ReflectionProperty getHooks string keys + getHook() (#4806) - #17258

Merged
PurHur merged 1 commit into
masterfrom
agent/issue-4806-reflection-property-gethooks
Jul 7, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/issue-4806-reflection-property-gethooks

Conversation

@PurHur

@PurHur PurHur commented Jul 7, 2026

Copy link
Copy Markdown
Owner

Summary

  • ReflectionProperty::getHooks() now returns an associative array keyed by "get" / "set" (php-src ext/reflection/php_reflection.c), not numeric PropertyHookType backing indices 0/1.
  • Add ReflectionProperty::getHook(PropertyHookType) returning ReflectionMethod with Zend-style name $prop::get / $prop::set, or null when absent.
  • Note: php-src master stub has no setHook() — issue repro checked; only getHooks/getHook are in php_reflection.stub.php.

php-src reference

  • ext/reflection/php_reflection.c — ReflectionProperty::getHooks, getHook
  • ext/reflection/php_reflection.stub.php

PHP implementation

  • lib/VM/ReflectionPropertyHookSupport.php — string-key hook map + hookReflectionMethod()
  • lib/VM/Builtin/ReflectionPropertyGetHooks.php — HashTable::add('get'|'set', …)
  • lib/VM/Builtin/ReflectionPropertyGetHook.php — new VM builtin

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
PHP_COMPILER_PROFILE=8.4 php bin/vm.php test/repro/maintainer_gap_reflection_property_gethooks.php
# getHooks yes / getHook yes / get,set / getHook-rm

PHP_COMPILER_PROFILE=8.4 php bin/vm.php test/compliance/cases/reflection/reflection_property_hook_gethooks_keys.phpt
# get,set + getHook-rm + $label::get

PHP_COMPILER_PROFILE=8.4 php -d memory_limit=1536M vendor/bin/phpunit --filter reflection_property_hook_gethooks
# OK (1 test)

php bin/compile.php -l test/compliance/cases/reflection/reflection_property_hook_gethooks_keys.phpt
# compile_ok
'

Closes #4806

Made with Cursor

getHooks() returned numeric PropertyHookType indices (0,1) instead of
php-src "get"/"set" keys; add getHook(PropertyHookType) returning
ReflectionMethod with $prop::get|$prop::set display names.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur merged commit b98c2be into master Jul 7, 2026
@PurHur
PurHur deleted the agent/issue-4806-reflection-property-gethooks branch July 7, 2026 17:01
PurHur added a commit that referenced this pull request Jul 7, 2026
…tHook (#17265) (#17266)

Regenerate docs/bootstrap-inventory.md so bootstrap-inventory.php --check
is green after #17257/#17258 added vm.php-path spine files.

Co-authored-by: PurHur <PurHur@users.noreply.github.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
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.

Stdlib: ReflectionProperty::getHooks() / setHook() — PHP 8.4 property hooks reflection (ext/reflection/php_reflection.c)

1 participant