An early look at PHP 9.0's new features and changes
Introduction
PHP is an open-source project. Knowing what new features and changes are planned for the next version only takes a minute of research. For instance, this page lists all the accepted RFCs for different versions of PHP.
That being said, despite PHP 9.0 being planned, no work have been started yet and we have to dig deeper.
When will PHP 9.0 be released?
For now, the release date of PHP 9.0 hasn’t been announced yet. This version is still far in the future. We could get PHP 8.5 and 8.6 before 9.0 is even considered. Who knows?
How to install and test PHP 9.0?
To this day, no work has been started on PHP 9.0, so you won’t even be able to pull the latest code and compile it yourself.
New features and changes planned for PHP 9.0
PHP 9.0 throws an exception on unserialization errors
This RFC, Improve unserialize() error handling, which has been partially implemented in PHP 8.3, upgrades unserialization errors from E_NOTICE
to E_WARNING
.
In PHP 9.0, these will be upgraded to an UnserializationFailedException
.
This will allow developers to stop using a custom error handler and get a behavior more consistent with other parts of the language.
// PHP 8.3: "Warning: unserialize(): Error at offset 0 of 3 bytes" // PHP 9.0: "Uncaught UnserializationFailedException: unserialize(): Error at offset 0 of 3 bytes" unserialize("foo");
Deprecated features from earlier PHP versions will be removed
Features that have been deprecated in PHP 8.1, 8.2, 8.3, and 8.4 (learn more about PHP 8.4) will finally removed in PHP 9.0. This will translate to breaking changes for developers who ignored the warnings. 😅
Here’s a list of RFCs containing all the deprecated features:
- PHP RFC: Deprecations for PHP 8.1
- PHP RFC: Deprecations for PHP 8.2
- PHP RFC: Deprecations for PHP 8.3
- PHP RFC: Deprecations for PHP 8.4
Some warnings will become errors in PHP 9.0
In order to make PHP more reliable, warnings for undefined variables and properties will now become errors.
For instance, the following code will not run anymore in PHP 9.0:
// PHP 8.x: "Warning: Undefined variable $foo" // PHP 9.0: "Fatal error: Uncaught Error: Undefined variable '$foo'" echo $foo;
Also, from what I understand, these changes with variables and properties will make the maintainers’ lives easier, which is good for everyone!
I let you check out the RFCs for more details:
What would you expect from PHP 9? PHP 8 seems quite mature already. I think they are yet collecting breaking ideas for PHP 9.
I'm open to big changes! Some people might not, though. It's really hard to see where it's going for now, unfortunately.