Skip to content

Language: fix ReflectionProperty::isLazy for lazy modifier (#16953)#16956

Closed
PurHur wants to merge 1 commit into
masterfrom
agent/issue-16953-reflection-islazy
Closed

Language: fix ReflectionProperty::isLazy for lazy modifier (#16953)#16956
PurHur wants to merge 1 commit into
masterfrom
agent/issue-16953-reflection-islazy

Conversation

@PurHur

@PurHur PurHur commented Jul 6, 2026

Copy link
Copy Markdown
Owner

Summary

  • Place /*phpc-lazy-property*/ marker before the visibility keyword so nikic/php-parser attaches it to Stmt\Property comments (same pattern as asymmetric-visibility markers).
  • Recover ZEND_ACC_LAZY at compile time via LazyPropertyRewriter::isLazyFromAttributes() so ClassProperty::$lazy is set and ReflectionProperty::isLazy() matches Zend before/after first read.
  • Fix LazyPropertySupport to use VM\TypeCheck (lazy init path was never exercised while the flag stayed false).

Root cause

LazyPropertyRewriter inserted the marker after public, so nikic did not preserve it on the property stmt; propertyLazy stayed false, defaults were copied at construction, and isLazy() always returned false.

php-src reference

  • ext/reflection/php_reflection.cReflectionProperty::isLazy()
  • Zend/zend_compile.cZEND_ACC_LAZY

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && export PHP_COMPILER_PROFILE=8.4 && php bin/vm.php test/repro/maintainer_gap_lazy_property_modifier_parse.php'
# hello
# ok

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && export PHP_COMPILER_PROFILE=8.4 && php bin/vm.php test/compliance/cases/language/lazy_property_modifier.phpt'
# hello
# not-lazy

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && export PHP_COMPILER_PROFILE=8.4 && php vendor/bin/phpunit --filter "LazyPropertyRewriterTest|lazy_property_modifier|reflection_property_is_lazy"'
# OK

Closes #16953

Made with Cursor

Place phpc-lazy-property marker before visibility so nikic preserves Stmt\Property
comments for ZEND_ACC_LAZY recovery; fix VM\TypeCheck import in lazy init path.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur

PurHur commented Jul 6, 2026

Copy link
Copy Markdown
Owner Author

Superseded by #16955 (merged to master) — same root cause and fix. Closing duplicate.

@PurHur PurHur closed this Jul 6, 2026
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: ReflectionProperty::isLazy() false for lazy-modifier properties (re-#6515, ext/reflection/php_reflection.c)

1 participant