Fix builtin class string instantiation#11860
Open
HenkPoley wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 26d8a6a. Configure here.
26d8a6a to
557147c
Compare
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.

Fixes #11491
Replaces #11502 with a narrower fix.
Since 3.4.0 @ 99e6cd8 (2019-06-03) Psalm can crash when a string literal containing a built-in/runtime class name is used for dynamic instantiation:
This PR keeps the fix at the point where the behavior is needed: dynamic instantiation analysis in NewAnalyzer.
Before validating the classlike for
new $class_name, Psalm now ensures reflected storage exists when all of these are true:The runtime existence checks use
*_exists(..., false), so this does not trigger autoloading while analyzing arbitrary values.Tests
Added coverage in ClassLikeStringTest for instantiating
\AssertionErrorthrough a string variable withallow_string_standin_for_classis enabled.