When working with types in any language there is a couple of scenarios that can occur. Allow properties to be typed using multiple different types where the property must match at least one of the types.
PHP has been already supporting the first scenario in form of https://www.amitmerchant.com/union-types-php/ since PHP 8.0 where you can type the properties using multiple types like so. class Number { private int|float $number; public function setNumber(int|float $number): void { $this->number = $number; } public function getNumber(): int|float { return $this->number; }}
Currently, only class types (interfaces and class names) are supported by intersection types due to some of the edge cases.