Skip to content
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

[HttpKernel] Fixed the nullable support for php 7.1 and below #19784

Closed
wants to merge 2 commits into from
Closed

[HttpKernel] Fixed the nullable support for php 7.1 and below #19784

wants to merge 2 commits into from

Conversation

linaori
Copy link
Contributor

@linaori linaori commented Aug 30, 2016

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

}

/**
* {@inheritdoc}
*/
public function resolve(Request $request, ArgumentMetadata $argument)
{
if ($argument->isNullable()) {
Copy link
Member

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();?

@nicolas-grekas
Copy link
Member

IMHO, if we can remove the deprecation, go for 3.1, otherwise, master.

@linaori
Copy link
Contributor Author

linaori commented Aug 30, 2016

@nicolas-grekas alright, re-opening against the master, I can't avoid the argument it seems

@linaori linaori closed this Aug 30, 2016
@linaori
Copy link
Contributor Author

linaori commented Aug 31, 2016

Reopened after removing BC break of #19785

public function __construct()
{
$this->supportsVariadic = method_exists('\ReflectionParameter', 'isVariadic');
$this->supportsParameterType = method_exists('\ReflectionParameter', 'getType');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for leading \

@fabpot
Copy link
Member

fabpot commented Aug 31, 2016

Isn't it something that also needs to fixed on 2.7?

@linaori
Copy link
Contributor Author

linaori commented Aug 31, 2016

@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

@fabpot
Copy link
Member

fabpot commented Aug 31, 2016

@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.

@linaori
Copy link
Contributor Author

linaori commented Aug 31, 2016

@fabpot sounds like a plan, I'll get it ready when I have some extra time

@fabpot
Copy link
Member

fabpot commented Aug 31, 2016

Thank you.

@fabpot
Copy link
Member

fabpot commented Sep 7, 2016

👍

fabpot added a commit that referenced this pull request Sep 14, 2016
…, 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
symfony-splitter pushed a commit to symfony/http-kernel that referenced this pull request Sep 14, 2016
…, 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
@fabpot
Copy link
Member

fabpot commented Sep 14, 2016

Thank you @iltar.

fabpot added a commit that referenced this pull request Sep 14, 2016
…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
@fabpot fabpot closed this Sep 14, 2016
@fabpot fabpot mentioned this pull request Oct 3, 2016
fabpot added a commit that referenced this pull request Oct 4, 2016
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
@linaori linaori deleted the fix/nullable-arguments branch February 8, 2019 13:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants