Skip to content

[3.4] Fix support for PHP8 union types #37340

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

Merged
merged 1 commit into from
Jun 18, 2020

Conversation

nicolas-grekas
Copy link
Member

@nicolas-grekas nicolas-grekas commented Jun 18, 2020

Q A
Branch? 3.4
Bug fix? yes
New feature? no
Deprecations? no
Tickets -
License MIT
Doc PR -

This fixes fatal errors on PHP 8 once union types are used. Note that this doesn't provide support for union types, eg autowiring, serializer, etc will just skip them. If another behavior is desired, that'd be for the 5.x branch.

With PHP 8 coming, calling the getName() on the object returned by ReflectionParameter::getType() or ReflectionFunctionAbstract::getReturnType() might fail. The reason is that these might return a ReflectionUnionType now, which has no getName() method (same for `isBuiltin() btw.)

@nicolas-grekas nicolas-grekas merged commit cf66f03 into symfony:3.4 Jun 18, 2020
@nicolas-grekas nicolas-grekas deleted the union-type34 branch June 18, 2020 17:54
@derrabus
Copy link
Member

We need test cases for this, don't we?

@nicolas-grekas
Copy link
Member Author

We might, PR welcome :)

@derrabus
Copy link
Member

All right, on it. 🙈

nicolas-grekas added a commit that referenced this pull request Jun 18, 2020
This PR was merged into the 4.4 branch.

Discussion
----------

[4.4] Fix support for PHP8 union types

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

Same as #37340 for 4.4

Commits
-------

da68e66 Fix support for PHP8 union types
nicolas-grekas added a commit that referenced this pull request Jun 18, 2020
This PR was merged into the 5.1 branch.

Discussion
----------

[5.1] Fix support for PHP8 union types

| Q             | A
| ------------- | ---
| Branch?       | 5.1
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

Same as #37340 for 5.1

Commits
-------

dd1b617 Fix support for PHP8 union types
@derrabus
Copy link
Member

see #37346

nicolas-grekas added a commit that referenced this pull request Jun 18, 2020
This PR was merged into the 3.4 branch.

Discussion
----------

Added Unit tests for php 8 union types

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | N/A
| License       | MIT
| Doc PR        | N/A

The missing test cases for #37340.

Commits
-------

2ca8ecd Added Unit tests for php 8 union types.
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.

3 participants