Skip to content

Add PHP 8 Union Types Support for function Parameters #34263

Open
@karyna-t

Description

@karyna-t

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 $arg) { ...

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):

These 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 parameters. It should properly generate code and so on.

Actual result (*)

Right now Magento can't handle union types introduced in php 8.

Related issues:

#34264
#34265

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Ready for Grooming

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions