Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork5.3k
Improving extracting type from constructor#10969
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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
javiereguiluz commentedFeb 7, 2019
@LS05 thanks for your contribution! However, it seems that this is more complicated than it looks. First, this option is configurable. Maybe we should mention that? And if possible, know why this is configurable (maybe it' too slow?) Second, the |
LS05 commentedFeb 7, 2019
@javiereguiluz Oh, my bad! Did it early this morning :) |
LS05 commentedFeb 7, 2019
I think that is configurable because of this recursive call Can this take some time for long subclass relationships? |
LS05 commentedFeb 18, 2019 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Besides me being blind about a private method 😄 I'm running a script on the CLI to understand how the Here the example script: And I get the following output: Am I using the It gives me my desired output: |
mantis commentedFeb 23, 2019
@javiereguiluz@LS05 - hi guys, just saw this on slack and thought i'd take a look - I think this might be a symfony bug - in property-info\Extractor\ReflectionExtractor.php, there is a line that reads: $context['enable_constructor_extraction'] ?? $this->enableConstructorExtraction && I think this might have been meant to read: ($context['enable_constructor_extraction'] ?? $this->enableConstructorExtraction) && |
If passing context to getTypes, it checks value of $context['enable_constructor_extraction'] for true/false or the constructor value of enableConstructorExtraction and should then populate fromConstructor if necessary. The missing brackets around the first part of this check mean that fromConstructor is only applied if context is not set.This fixes the issuse described at [symfony/symfony-docs#10969](symfony/symfony-docs#10969)
If passing context to getTypes, it checks value of $context['enable_constructor_extraction'] for true/false or the constructor value of enableConstructorExtraction and should then populate fromConstructor if necessary. The missing brackets around the first part of this check mean that fromConstructor is only applied if context is not set.This fixes the issuse described at [symfony/symfony-docs#10969](symfony/symfony-docs#10969)
If passing context to getTypes, it checks value of $context['enable_constructor_extraction'] for true/false or the constructor value of enableConstructorExtraction and should then populate fromConstructor if necessary. The missing brackets around the first part of this check mean that fromConstructor is only applied if context is not set.This fixes the issuse described at [symfony/symfony-docs#10969](symfony/symfony-docs#10969)
LS05 commentedFeb 25, 2019
@mantis Thanks! I had that error too, but I thought I was calling the class the wrong way :) @javiereguiluz Could it be that is configurable because in the constructor is possible to set |
If passing context to getTypes, it checks value of $context['enable_constructor_extraction'] for true/false or the constructor value of enableConstructorExtraction and should then populate fromConstructor if necessary. The missing brackets around the first part of this check mean that fromConstructor is only applied if context is not set.This fixes the issuse described at [symfony/symfony-docs#10969](symfony/symfony-docs#10969)
… passing context to getTypes (mantis, OskarStark)This PR was merged into the 4.2 branch.Discussion----------[PropertyInfo] Fix undefined variable fromConstructor when passing context to getTypes| Q | A| ------------- | ---| Branch? | 4.1, 4.2, master| Bug fix? | yes| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets |symfony/symfony-docs#10969| License | MIT| Doc PR |If passing context to getTypes, it checks value of $context['enable_constructor_extraction'] for true/false or the constructor value of enableConstructorExtraction and should then populate fromConstructor if necessary. The missing brackets around the first part of this check mean that fromConstructor is only applied if context is not set.This fixes the issue described at [symfony/symfony-docs#10969](symfony/symfony-docs#10969)Commits-------8e401af Allow 3rd argument to be null04dc692 Remove whitespace (tab on blank line)a0aa15a Update src/Symfony/Component/PropertyInfo/Tests/Extractor/ReflectionExtractorTest.phpc2986d5 Update src/Symfony/Component/PropertyInfo/Tests/Extractor/ReflectionExtractorTest.php42995c8 Update src/Symfony/Component/PropertyInfo/Tests/Extractor/ReflectionExtractorTest.php2d88298 Update src/Symfony/Component/PropertyInfo/Tests/Extractor/ReflectionExtractorTest.phpe43a3bc Update ReflectionExtractorTest.php2c91c75 Update ReflectionExtractorTest.php5acc85c Update ReflectionExtractorTest.phpd0a2dc0 Update ReflectionExtractorTest.phpbe8d14a Fix undefined variable fromConstructor when passing context to getTypes
… passing context to getTypes (mantis)This PR was merged into the 4.2 branch.Discussion----------[PropertyInfo] Fix undefined variable fromConstructor when passing context to getTypes| Q | A| ------------- | ---| Branch? | 4.1, 4.2, master| Bug fix? | yes| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets |symfony/symfony-docs#10969| License | MIT| Doc PR |If passing context to getTypes, it checks value of $context['enable_constructor_extraction'] for true/false or the constructor value of enableConstructorExtraction and should then populate fromConstructor if necessary. The missing brackets around the first part of this check mean that fromConstructor is only applied if context is not set.This fixes the issue described at [symfony/symfony-docs#10969](symfony/symfony-docs#10969)Commits-------7e4abee Fix undefined variable fromConstructor when passing context to getTypes
If passing context to getTypes, it checks value of $context['enable_constructor_extraction'] for true/false or the constructor value of enableConstructorExtraction and should then populate fromConstructor if necessary. The missing brackets around the first part of this check mean that fromConstructor is only applied if context is not set.This fixes the issuse described at [symfony/symfony-docs#10969](symfony/symfony-docs#10969)
LS05 commentedMar 15, 2019 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I have read the discussion insymfony/symfony#25605 Plus,@javiereguiluz after your commentsymfony/symfony#25605 (comment) there's a "Load More" button but if I click it, I get a 403. So I can't read further comments/explanations 😅 |
HeahDude left a comment
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.
ping@dunglas, would you have a look at this one? Thanks!
| $reflectionExtractor->isWritable($class, $property); | ||
| // Initializable information | ||
| // Initializable information. |
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.
Can be reverted
| // Initializable information. | ||
| $reflectionExtractor->isInitializable($class, $property); | ||
| // Constructor type information. |
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.
The dot can also be removed here
wouterj commentedOct 3, 2020
Hi@LS05! Thanks for creating the issue and providing value information + bug fixes around this topic! Seems like the bug you where describing is now fixed. After reading the original PR, I think this option is opt-in as it might create wrong type information (the argument name in the constructor doesn't have to be equal to the property name in the object - although that might be an edge-case imho). Are you by any chance able to update this PR with all new information you gathered? (so creating a working example and maybe showing both ways of enabling this option?) |
No description provided.