Announcing Blackfire Support for PHP 8.4

By Thomas di Luccio, on Dec 11, 2024

We’re thrilled to announce that Blackfire now fully supports PHP 8.4. With this update, you can leverage Blackfire’s continuous observability capabilities to monitor, profile, and optimize applications running on PHP 8.4 seamlessly. We strongly recommend upgrading your Blackfire Probe to the latest version to fully take advantage of these enhancements.

What’s New in PHP 8.4?

PHP 8.4 introduces several new features and improvements designed to make development smoother and more efficient. Let’s highlight some of the standout features:

1. Property hooks

PHP 8.4 introduces property hooks, a versatile feature designed to minimize the need for extensive getters and setters. Properties can have their own custom get and set hooks.

These hooks are optional; you can implement either or both for any given property. For instance, a property with only a get hook functions as a virtual property, providing flexible and dynamic data handling options:

class DeepThought
{
    public string $question {
    	set (string $question) {
           $this->question = HGG::superTokenizer($question);
    	}
    
	public int $answer {
    	    get => 42;
	}
    }
}

2. Asymmetric visibility

Asymmetric visibility allows different access levels for getters and setters, giving you more control over property accessibility. To simplify the syntax for this common use case, PHP 8.4 introduces a shorthand:

class BlogPost {
    private(set) Author $author;
}

Additionally, you can define properties with protected write access:

class BlogPost {
    public protected(set) Author $author;
}

This syntax also extends to promoted properties in constructors:

public function __construct(
    private(set) Author $author
) {}

Asymmetric visibility provides finer control over how properties are accessed and modified, making your classes more robust and expressive

new without parentheses

PHP 8.4 introduces another long-awaited feature reducing code size and driving readability up with  shorthand for invoking methods without parentheses:

class Foo {
    public function bar() {
        return "Hello world!";
    }
}

echo new Foo()->bar; // Finally valid

Many new other features are available. Among them, the time-savings array functions array_find(), array_find_key(), array_any(), and array_all(), as well as the #[\Deprecated] attribute helping keep your codebase tidy and readable.

Upgrade to PHP 8.4 today

If you haven’t upgraded to PHP 8.4 yet, now is the perfect time to do so. Check out our upgrade procedure to install the Blackfire PHP 8.4 Probe.

To better observability and beyond

Thomas di Luccio

Thomas is a Developer Relations Engineer at Platform.sh for Blackfire.io. He likes nothing more than understanding the users' needs and helping them find practical and empowering solutions. He’ll support you as a day-to-day user.