Description
In PHP 8, new Union types feature was introduced.
(see details https://wiki.php.net/rfc/union_types_v2)
e.g. it's possible to create a function with a signature like
function baz(): Foo|Bar|int { ...
were return type is a union.
Right now Magento will not work properly with such a feature. There are several places where we're using Parameter's Class (e.g. for code generation):
- https://github.com/magento/magento2/blob/platform-health/lib/internal/Magento/Framework/Async/Code/Generator/ProxyDeferredGenerator.php#L247
- https://github.com/magento/magento2/blob/platform-health/lib/internal/Magento/Framework/Interception/Code/Generator/Interceptor.php#L213
- https://github.com/magento/magento2/blob/platform-health/lib/internal/Magento/Framework/MessageQueue/Code/Generator/RemoteServiceGenerator.php#L158
- https://github.com/magento/magento2/blob/platform-health/lib/internal/Magento/Framework/ObjectManager/Code/Generator/Proxy.php#L288
- https://github.com/magento/magento2/blob/platform-health/lib/internal/Magento/Framework/ObjectManager/Code/Generator/Repository.php#L252
- https://github.com/magento/magento2/blob/platform-health/lib/internal/Magento/Framework/ObjectManager/Code/Generator/Repository.php#L726
- \Magento\Framework\Reflection\Test\Unit\TypeProcessorTest
(better to re-check other possible places)
Such places should be adjusted to work properly with union types.
The main reason for this adjustments it's because 3rd-party developers may develop some new extensions and declare them to support only php >= 8.0.
in such modules they may use this PHP8-feature.
Expected result (*)
Magento should not break when union types are used in the function return type. It should properly generate code and so on.
Actual result (*)
Right now Magento can't handle union types introduced in php 8.
Related issues:
Metadata
Metadata
Assignees
Labels
Type
Projects
Status