Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[PropertyInfo] Fix getting type from constructor of parent class inPhpStanExtractor#61752
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
+18 −4
Conversation
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
50e234d to44a8112ComparePhpStanExtractorsrc/Symfony/Component/PropertyInfo/Extractor/PhpStanExtractor.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
44a8112 to35e940eCompare35e940e to63532f5CompareMember
nicolas-grekas commentedSep 15, 2025
Thank you@wuchen90. |
| if (!$rawDocNode =$reflectionConstructor->getDocComment()) { | ||
| returnnull; | ||
| } | ||
| $class =$reflectionConstructor->class; |
Member
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I updated the code to simplify the implementation and remove repeated code.
Merged
nicolas-grekas added a commit that referenced this pull requestOct 6, 2025
…th templates (HypeMC)This PR was merged into the 7.3 branch.Discussion----------[PropertyInfo][TypeInfo] Fix resolving constructor type with templates| Q | A| ------------- | ---| Branch? | 7.3| Bug fix? | yes| New feature? | no| Deprecations? | no| Issues | -| License | MIT#61752 broke the resolution of templated types.Consider the following code:```php/** * `@template` T of object */abstract class ParentClass{ /** * `@param` list<T> $items */ public function __construct( public array $items, ) { }}/** * `@template` T of SomeClass * * `@extends` ParentClass<T> */class ChildClass extends ParentClass{}$serializer->deserialize($jsonPayload, ChildClass::class, 'json');```Before that PR, after deserialization, `$items` would correctly contain a list of `SomeClass` instances.Now it no longer works, `$items` is a list of associative arrays instead.Commits-------7ad51ea [PropertyInfo][TypeInfo] Fix resolving constructor type with templates
Sign up for freeto 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.
The PhpStanExtractor fails when we try to resolve the type of a constructor argument that is declared in parent class.
It is mainly because the TypeContextFactory doesn't get all the
usesof parent classes.