Duplicate Type

../_images/duplicate_type.png

Union types check for duplicate types, so array|array is not possible, nor if a class is aliased with a use expression: on the other hand, it is valid with a class alias, created with class_alias().

The last case is the union type that actually hides the type: here, iterable includes array, so PHP complains about a duplicate, which is not visible at first sight.

Note that intersectional types also check for duplicate types.

See Also

PHP Error Messages

PHP Features