-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpKernel] Fixed the nullable support for php 7.1 and below #19784
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
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function resolve(Request $request, ArgumentMetadata $argument) | ||
{ | ||
if ($argument->isNullable()) { |
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.
yield $argument->isNullable() ? null : $argument->getDefaultValue();
?
IMHO, if we can remove the deprecation, go for 3.1, otherwise, master. |
@nicolas-grekas alright, re-opening against the master, I can't avoid the argument it seems |
Reopened after removing BC break of #19785 |
public function __construct() | ||
{ | ||
$this->supportsVariadic = method_exists('\ReflectionParameter', 'isVariadic'); | ||
$this->supportsParameterType = method_exists('\ReflectionParameter', 'getType'); |
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.
no need for leading \
Isn't it something that also needs to fixed on 2.7? |
@fabpot in the controller resolver, yes. Probably in the argument resolver as well (but would like to do that in another patch) Once it's fixed in here, I can probably backport a similar solution |
@iltar If possible, I would prefer to have the 2.7 patch so that we can merge it first, merge 2.7 into 2.8 then 3.1, and merge this PR immediately to resolve conflicts. |
@fabpot sounds like a plan, I'll get it ready when I have some extra time |
Thank you. |
👍 |
…, 3.0) (iltar) This PR was merged into the 2.7 branch. Discussion ---------- Fixed the nullable support for php 7.1 and below (2.7, 2.8, 3.0) | Q | A | ------------- | --- | Branch? | 2.7, 2.8, 3.0 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #19784 (comment) | License | MIT | Doc PR | ~ Fixes the nullable support for 2.7, 2.8 and 3.0, can probably be partially merged into 3.1 but not 100% sure. /ping @fabpot Commits ------- 9c48756 Fixed the nullable support for php 7.1 and below
…, 3.0) (iltar) This PR was merged into the 2.7 branch. Discussion ---------- Fixed the nullable support for php 7.1 and below (2.7, 2.8, 3.0) | Q | A | ------------- | --- | Branch? | 2.7, 2.8, 3.0 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | symfony/symfony#19784 (comment) | License | MIT | Doc PR | ~ Fixes the nullable support for 2.7, 2.8 and 3.0, can probably be partially merged into 3.1 but not 100% sure. /ping @fabpot Commits ------- 9c48756 Fixed the nullable support for php 7.1 and below
Thank you @iltar. |
…low (iltar) This PR was squashed before being merged into the 3.1 branch (closes #19784). Discussion ---------- [HttpKernel] Fixed the nullable support for php 7.1 and below | Q | A | ------------- | --- | Branch? | 3.1 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #19771 | License | MIT | Doc PR | ~ This PR gives support for for the new php 7.1 and will only work in beta3 or higher. I've had to backport the support to 3.1 because I consider this a bug that it won't work, even though 3.1 won't be supported for much longer. ~~The deprecation I've added in the `ArgumentMetadata` should not be triggered as all framework cases create it with the argument. Just for developers who for some reason implemented this manually, I've added the deprecation.~~ ~~*If needed, I can re-open this against 3.2 and leave 3.1 "broken"*~~ On 7.1 lower than beta3 this will happen but shouldn't affect any higher versions (I hope). ``` There was 1 failure: 1) Symfony\Component\HttpKernel\Tests\ControllerMetadata\ArgumentMetadataFactoryTest::testNullableTypesSignature Failed asserting that two arrays are equal. --- Expected +++ Actual @@ @@ Array ( 0 => Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata Object (...) 1 => Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata Object ( 'name' => 'bar' - 'type' => 'stdClass' + 'type' => 'Symfony\Component\HttpKernel\Tests\Fixtures\Controller\stdClass' 'isVariadic' => false 'hasDefaultValue' => false 'defaultValue' => null 'isNullable' => true ) 2 => Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata Object (...) ) /home/ivanderberg/projects/symfony/src/Symfony/Component/HttpKernel/Tests/ControllerMetadata/ArgumentMetadataFactoryTest.php:123 ``` Commits ------- 4a1ab6d [HttpKernel] Fixed the nullable support for php 7.1 and below
This PR was merged into the 3.1 branch. Discussion ---------- [HttpKernel] Fix nullable types handling | Q | A | ------------- | --- | Branch? | 3.1 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #19784 | License | MIT | Doc PR | - Commits ------- 0884518 [HttpKernel] Fix nullable types handling
This PR gives support for for the new php 7.1 and will only work in beta3 or higher. I've had to backport the support to 3.1 because I consider this a bug that it won't work, even though 3.1 won't be supported for much longer.
The deprecation I've added in theArgumentMetadata
should not be triggered as all framework cases create it with the argument. Just for developers who for some reason implemented this manually, I've added the deprecation.If needed, I can re-open this against 3.2 and leave 3.1 "broken"On 7.1 lower than beta3 this will happen but shouldn't affect any higher versions (I hope).