Skip to content

Compatibility issue with Symfony 7.2.1: Symfony\Component\TypeInfo\Type::union(): Return value must be of type ... error #59223

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

Closed
scorpion3dd opened this issue Dec 16, 2024 · 3 comments

Comments

@scorpion3dd
Copy link

Symfony version(s) affected

7.2.1

Description

After upgrading Symfony to version 7.2.1, my project stopped working with the following error:
Symfony\Component\TypeInfo\Type::union(): Return value must be of type Symfony\Component\TypeInfo\Type\UnionType, Symfony\Component\TypeInfo\Type\BuiltinType returned

The issue seems to be related to changes introduced in Symfony 7.2, specifically in the redesigned TypeInfo component, as explained in this blog post: New in Symfony 7.2: Redesigned TypeInfo Component.

How to reproduce

Steps to Reproduce:

Use Symfony 7.2.1.
Open any application page.
Expected Behavior:
The application page should be processed normally without any errors.

Actual Behavior:
The error mentioned above is thrown, and the application fails to start.
http://prntscr.com/Q8XV-Y0k2tzy

Steps Taken:
Updated all dependencies to their latest versions.
Cleared the Symfony cache (php bin/console cache:clear).
Verified that the error disappears when downgrading Symfony to version 7.2.1.

Please let me know if further details or logs are needed.

Possible Solution

No response

Additional Context

No response

@xabbuh
Copy link
Member

xabbuh commented Dec 16, 2024

Can you confirm that in your source code you use something like mixed|null to describe type information?

@scorpion3dd
Copy link
Author

I searched the project and actually found this line mixed|null :
http://prntscr.com/wht0YfMTRyJy
when this line is there - there is an error
when I deleted this line, the error disappeared and the page opens without errors

@mtarld
Copy link
Contributor

mtarld commented Dec 20, 2024

I think this PR might fix the issue 🙂

xabbuh added a commit that referenced this issue Dec 27, 2024
This PR was merged into the 7.2 branch.

Discussion
----------

[TypeInfo] Fix PHPDoc resolving of union with mixed

| Q             | A
| ------------- | ---
| Branch?       | 7.2
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Issues        | Fix #59258, Fix #59223
| License       | MIT

Resolve "invalid" union PHPDoc with `mixed` standalone type as `mixed` type.

Commits
-------

cc8670d [TypeInfo] Fix PHPDoc resolving of union with mixed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants