Named arguments
- Specify only required parameters, skipping optional ones.
- Arguments are order-independent and self-documented.
Attributes
![](https://cozmot.com/wp-content/uploads/2023/05/Attributes-Cozmot-inc.png)
Instead of PHPDoc annotations, you can now use structured metadata with PHP’s native syntax.
Constructor property promotion
![](https://cozmot.com/wp-content/uploads/2023/05/Constructor-property-promotion-cozmot-inc.png)
Less boilerplate code to define and initialize properties.
Union types
![](https://cozmot.com/wp-content/uploads/2023/05/Union-types-cozmot-inc.png)
Instead of PHPDoc annotations for a combination of types, you can use native union type declarations that are validated at runtime.
Match expression
![](https://cozmot.com/wp-content/uploads/2023/05/Match-expression-cozmot-inc.png)
- Match is an expression, meaning its result can be stored in a variable or returned.
- Match branches only support single-line expressions and do not need a break; statement.
- Match does strict comparisons.
Nullsafe operator
![](https://cozmot.com/wp-content/uploads/2023/05/Nullsafe-operator-cozmot-inc.png)
Saner string to number comparisons
![](https://cozmot.com/wp-content/uploads/2023/05/Saner-string-to-number-comparisons-cozmot-inc.png)
Consistent type errors for internal functions
![](https://cozmot.com/wp-content/uploads/2023/05/Consistent-type-errors-for-internal-functions-cozmot-inc.png)
Most of the internal functions now throw an Error exception if the validation of the parameters fails.
]]>