PHP 8.4 Released: Main Innovations and Performance Improvements
The developer community has been eagerly awaiting this moment — PHP 8.4 is officially released. This release represents a significant step forward for the language that continues to be the foundation for millions of websites and applications. In the new version, developers received long-awaited features, improved performance, and a number of changes that simplify writing code. Let's break down what exactly has changed.
Key Innovations of PHP 8.4
1. Property Hooks
One of the most discussed innovations — property hooks. Now you can define the logic for getting (get) and setting (set) property values directly in their declaration, without needing to write getters and setters separately. This makes code cleaner and reduces boilerplate code.
- Example:
public string $name { set => strtoupper($value); } - Simplifies implementation of computed properties.
- Improves readability and maintainability of classes.
2. Asymmetric Visibility
PHP 8.4 allows setting different access levels for reading and writing properties. For example, you can make a property public for reading but protected for writing. This is especially useful for creating strict APIs and data encapsulation.
- Syntax:
public private(set) string $title; - Improves data security.
- Reduces the need for using getters for access control.
3. Improvements in JIT Compilation
The JIT (Just-In-Time) compiler, first introduced in PHP 8.0, has received significant optimizations. In version 8.4, work with arrays and loops has been improved, providing a performance boost in resource-intensive tasks — from image processing to complex calculations.
- Speed increase in some benchmarks up to 15-20%.
- Better integration with opcache.
- Reduced memory consumption in long-running processes.
4. New Syntax for Creating Objects Without Parentheses
Now you can create objects without parentheses if the constructor does not require parameters. This makes code more concise.
- Was:
$obj = new MyClass(); - Now:
$obj = new MyClass; - Especially convenient in method chains:
$obj = new MyClass->method();
5. Improved Error Handling and New Attributes
New built-in attributes have been added, such as #[Deprecated], which allows explicitly marking deprecated methods and functions. This simplifies the process of refactoring and maintaining the codebase.
- Automatic warning when calling deprecated methods.
- Ability to specify an alternative in the error message.
- Better integration with IDEs and static analyzers.
What Does This Mean for Developers?
PHP 8.4 is not just a set of new features. It is a step towards a more modern, secure, and performant language. Property hooks and asymmetric visibility lower the entry barrier for beginners and increase flexibility