.. _php-php80uniontypehint: .. _union-typehint: Union Typehint ++++++++++++++ Union typehints allows the specification of several typehint for the same argument or return value. Several typehints are specified at the same place as a single one. The different values are separated by a pipe character ``|``, like for exceptions Nullable is reported as union type. Mixed and iterable are not reported as a union type. Union types are a PHP 8.0 new feature. They are not compatible with PHP 7.4 and older. .. code-block:: php number = $number; } public function getNumber(): int|float { return $this->number; } } ?> See also `PHP RFC: Union Types 2.0 `_, `PHP 8 Union types `_ and `Type declarations `_. Related PHP errors ------------------- + `0 `_ Connex PHP features ------------------- + `typehint `_ + `intersection-type `_ Specs _____ +--------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Short name | Php/Php80UnionTypehint | +--------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Rulesets | :ref:`All `, :ref:`Appinfo `, :ref:`CE `, :ref:`Changed Behavior `, :ref:`CompatibilityPHP70 `, :ref:`CompatibilityPHP71 `, :ref:`CompatibilityPHP72 `, :ref:`CompatibilityPHP73 `, :ref:`CompatibilityPHP74 ` | +--------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Exakat since | 2.0.9 | +--------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | PHP Version | With PHP 8.0 and more recent | +--------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Severity | Minor | +--------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Time To Fix | Quick (30 mins) | +--------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Precision | Very high | +--------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Available in | `Entreprise Edition `_, `Community Edition `_, `Exakat Cloud `_ | +--------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+