Intersection types in PHP 8.1

· Amit Merchant · Nov. 28, 2021, 7:41 a.m.
Summary
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. Allow properties to be typed using multiple different types where the property must match all of the types. PHP has been already supporting the first scenario in form of union types since PHP 8.0 where you can type the properties using multiple types like so. class Number { private int|flo...
AUTHOR