Company
Date Published
Author
Gary Hockin
Word count
1099
Language
English
Hacker News points
None

Summary

PHP 7.4 has introduced several notable features, including typed properties, which provide a way to set the types of properties in classes, improving type checking and detecting bugs. Arrow functions offer a more concise alternative to traditional anonymous functions, particularly useful in callbacks. Limited return type covariance and argument type contravariance allow for more flexible method overloading, making it easier for library authors to extend their code. Unpacking inside arrays enables clean replacement of `array_merge` calls with a single expression. The numeric literal separator allows underscores to be used in numerical values for improved readability. Finally, allowing exceptions from `__toString()` fixes a long-standing issue with magic methods throwing fatal errors. Overall, PHP 7.4 is a mixed bag with one standout feature that significantly improves type checking and debugging.