-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Support for PHP 7.1 nullables #19771
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
Comments
Right now the builds are being tested on 7.1 so it's at least backwards compatible for now. I'll see if I can add a test-case for 7.1. |
There is probably some work to do in the PropertyInfo component to support this new feature. |
I could have a look at it but that's a bit beyond my expertise ^^ |
IIUC, it doesn't change the reflection API and |
Previously it would return true if the signature had |
…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 is an excerpt from the #19677.
The upcoming PHP 7.1 will add support for nullable types. So the function declarations in php 7.1 won't need a default null parameter e.g
\StdClass $foo = null
but could be written as?\StdClass $fool
.I'm assuming that there are a lot of argument resolvers e.g controller argument resolver, DI, .. inside a Symfony which would complain or throw an exception on new declaration. The new version will be released around the symfony 3.2 release so this would fit nicely together.
The text was updated successfully, but these errors were encountered: