PHP 8.4: what’s coming in November 2024
Scheduled for release in November 2024, PHP 8.4 brings a wave of improvements varying from simplifying syntax to improving arrays and strings handling.
Here’s a glimpse into some of the key features to be released :
Method Chaining Without Parentheses (See https://wiki.php.net/rfc/new_without_parentheses)
Instantiating a class and immediately calling a method no longer requires wrapping the method call in parentheses.
// Before the RFC
(new Class())->method();
// After the RFC
new Class()->method();
Array Helper Functions (See https://wiki.php.net/rfc/generic-arrays)
New array helper functions like array_find
, array_find_key
, array_any
, and array_all
simplify common array operations.
// Locates the first element in an array that satisfies the provided callback function.
array_find($array, $callback)
// Finds the key of the first element that matches the callback condition.
array_find_key($array, $callback)
// Determines if any element in the array passes the callback check.
array_any($array, $callback)
// Checks if all elements in the array fulfill the callback criteria.
array_all($array, $callback)
Precise White space Removal (See https://wiki.php.net/rfc/working_with_substrings)
The mbstring
extension gains mb_trim
, mb_ltrim
, and mb_rtrim
functions, offering multibyte safe trimming of white space and other characters from strings.
Large XML Parsing Fix (See https://wiki.php.net/rfc/xml_option_parse_huge)
A recurring parsing issue with handling large XML documents using xml_parse
and xml_parse_into_struct
functions has been resolved.
Building on the large XML parsing fix, PHP 8.4 introduces a new parser option specifically designed for handling massive XML documents. This option provides more efficient memory allocation and processing for these extensive files.
Security Enhancements (See https://wiki.php.net/rfc/bcrypt_cost_2023)
By default, the bcrypt algorithm used for password hashing increases its cost factor from 10 to 12, This change strengthens password security by making it more computationally expensive to crack passwords.
Improved DOM extension support (https://wiki.php.net/rfc/domdocument_html5_parser)
This update enhances the DOM extension’s ability to parse and serialize HTML5, streamlining the process of working with modern web markup.
Gear up for a the November release. ✨