Language: reject self/parent/static::method in free functions (#32227) - #32242
Merged
Merged
Conversation
Zend zend_ensure_valid_class_fetch_type() is a compile-time fatal when a named free function uses self/parent/static::method (or ::class) with no class scope. File-level and closures still compile — they inherit or rebind at runtime. Co-authored-by: Cursor <cursoragent@cursor.com>
…ile fatals (#32227) Co-authored-by: Cursor <cursoragent@cursor.com>
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
self::/parent::/static::method calls (andstatic::class) inside a named free function are now a compile-time fatal matching Zendzend_ensure_valid_class_fetch_type().Zend/zend_compile.c—Cannot use "%s" when no class scope is active. PHP implementation:lib/Compiler.php(rejectPseudoClassFetchOutsideKnownClassScope) + existingPseudoClassTypeHintCompileCheck::messageFor().zend_is_scope_known(): they inherit include/eval scope or can be rebound). No newruntime/*.clogic.Test plan
accepted)./script/phpunit.sh --filter PseudoClassCallNoScope32227./script/phpunit.sh --filter PseudoClassStaticCallCompileFatalTestphp script/bootstrap-inventory.php --check→OK 7590/7590(Docker regen; no gen-0 restamp)Verification
Same Zend substring + rc=255 for
maintainer_gap_self_call_no_scope.php,maintainer_gap_parent_call_no_scope.php, andphp bin/jit.phpon the static repro.Did not run full
make test-harnessornorth-star5-verify --strict.Made with Cursor