- $address = $customer->getAddress();
- $country = $address ? $address->getCountry() : null;
+ $country = $customer->getAddress()?->getCountry();
Constructor property promotion :-
Union types :-
Given the dynamically typed nature of PHP, there are lots of cases where union types can be useful. Union types are a collection of two or more types which indicate that either one of those can be used.
public function foo(Foo|Bar $input): int|float;
Source :- https://www.youtube.com/watch?v=F-AWT88vsyM
I hope everyone enjoys.
Top comments (0)