-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[PropertyInfo] Fix undefined variable fromConstructor when passing context to getTypes #30361
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Hi, thanks. Could you add a test case please? |
@nicolas-grekas you asked the one question that I hoped you wouldn't ask - anyway, I've added my first attempt at using phpunit ;) |
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.
except this small change, I think you made it with the unit test @mantis 👍 congrats
src/Symfony/Component/PropertyInfo/Tests/Extractor/ReflectionExtractorTest.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/PropertyInfo/Tests/Extractor/ReflectionExtractorTest.php
Outdated
Show resolved
Hide resolved
@@ -111,7 +111,7 @@ public function getTypes($class, $property, array $context = []) | |||
} | |||
|
|||
if ( | |||
$context['enable_constructor_extraction'] ?? $this->enableConstructorExtraction && | |||
($context['enable_constructor_extraction'] ?? $this->enableConstructorExtraction) && |
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.
are you sure your tests only pass if you add these brackets? 🤔
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.
without the brackets:
- Symfony\Component\PropertyInfo\Tests\Extractor\ReflectionExtractorTest::testExtractTypeConstructor with data set #0 ('Symfony\Component\PropertyInf...1Dummy', 'string', array(Symfony\Component\PropertyInfo\Type Object (...)))
Undefined variable: fromConstructor
if I knock up a quick script, returning true for $a, the bellows returns null / 1:
$a = $b = $c = 1;
if( $a ?? $b && $d = $c ) {
var_dump($d);
}
if( ($a ?? $b) && $d = $c ) {
var_dump($d);
}
returns null / 1
Thanks ;) I made the mistake of just doing this change through github's editor - hence the multiple formatting commits. But equally 'easier' if you don't have everything checked out. In terms of the failing travis/appveyor builds, i'd used changes to the test fixtures that went in with 4.2 - and applied the fix to 4.1 branch. I'll leave you guys to decide what if anything you want to do there ;) |
src/Symfony/Component/PropertyInfo/Tests/Extractor/ReflectionExtractorTest.php
Show resolved
Hide resolved
You can check the maintained versions on the roadmap |
The issue was introduced in December 2017 by symfony/property-info@e168420#diff-818203fea9c55d86a0556b0d436126df That's been tagged as 4.1.0beta1 -> 4.2.3 |
Yes then |
src/Symfony/Component/PropertyInfo/Tests/Extractor/ReflectionExtractorTest.php
Outdated
Show resolved
Hide resolved
@mantis Can you fix the tests and change the target to 4.2? |
@fabpot - when i tried to change the target to 4.2, it started to want to pull in changes to the changelog,, and I got confused... IIRC, I think the test failures were only due to the target not being 4.2 |
First you should rebase your feature branch against 4.2 and push This should work |
@mantis I can do it for you if you want. |
@OskarStark @fabpot - I forced it - the tests were failing from adding in one of oskar's review comments. Current patch set passes as above, so I guess over to you guys ;) |
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)
Thank you @mantis. |
… 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 null 04dc692 Remove whitespace (tab on blank line) a0aa15a Update src/Symfony/Component/PropertyInfo/Tests/Extractor/ReflectionExtractorTest.php c2986d5 Update src/Symfony/Component/PropertyInfo/Tests/Extractor/ReflectionExtractorTest.php 42995c8 Update src/Symfony/Component/PropertyInfo/Tests/Extractor/ReflectionExtractorTest.php 2d88298 Update src/Symfony/Component/PropertyInfo/Tests/Extractor/ReflectionExtractorTest.php e43a3bc Update ReflectionExtractorTest.php 2c91c75 Update ReflectionExtractorTest.php 5acc85c Update ReflectionExtractorTest.php d0a2dc0 Update ReflectionExtractorTest.php be8d14a 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 issue described at symfony/symfony-docs#10969