doctrine / common

Doctrine Common
https://www.doctrine-project.org/projects/common.html
MIT License
5.79k stars 294 forks source link

Better PHP8 type handling #918

Closed adambalint-srg closed 3 years ago

adambalint-srg commented 3 years ago

I've found two type declaration related problems in proxy generator, when using it with PHP8.

First is the usage of static keyword, which should be "copied" to the proxy class, and also can be nullable. function setId(int $id): ?static This is supported in this pull request.

Second is a fix for union types of PHP8, because in case of nullable union types the '?' sign is nut supported. It should be used in this way: float|int|null But the proxy generator prepended the '?' to the null part of the union type: float|int|?null This problem has been fixed with an optional argument in case of recursive call of formatType function.

jellynoone commented 3 years ago

Can someone from the Doctrine team review the pull request? @beberlei @greg0ire

By now the author, myself and https://github.com/doctrine/orm/issues/8422 have found the issue being solved in this pull request.

beberlei commented 3 years ago

Does this target the 3.1.x branch for a specific reason? This is a bugfix for me and should target 3.0.x

Edit: Sorry, my mistake Github showed 3.0.3 as last release, but it was actually 3.1.0 already.