PHP 8.4 Enhancements, Updates, and Removals

NewsPHP 8.4 Enhancements, Updates, and Removals

Upcoming PHP 8.4 Release: Essential Information for Developers

As the release date for PHP 8.4 approaches, development teams worldwide are preparing for the potential upgrade. This new version promises a variety of exciting features along with some important deprecations, which necessitates a thorough evaluation of how these changes might affect existing applications. This article aims to provide a comprehensive overview of PHP 8.4, highlighting its release schedule, new features, deprecations, and migration considerations.

PHP 8.4 Release Date Overview

PHP 8.4 is currently in active development and has reached the feature freeze stage, marking the point where no new features will be added, and the focus will shift to refining the release candidates. The PHP internals team has approved all proposals for feature additions and changes.

Release Cycle Changes

Earlier this year, a Request for Comments (RFC) was passed to update the PHP release cycle. The new policy delays the start of the release cycle by a month and reduces the number of release candidates from six to four. This decision was made to allow more time for feature discussions and because the last two release candidates historically saw few, if any, changes.

Additionally, the lifecycle of PHP releases has been extended. Instead of ending on the release anniversary, the end-of-life (EOL) date is now December 31. Starting with PHP 8.1, each release will receive two years of active support (including security and bug fixes) and two years of security-only support, totaling just over four years.

PHP 8.4 Release Date

The general availability release of PHP 8.4 is scheduled for November 21, 2024.

PHP 8.4 Release Date Timeline

PHP 8.4 follows a condensed timeline compared to previous versions. At the time of writing, it has progressed through the Beta Release phase and is on track for Release Candidate 1. Here are the key dates:

  • July 4, 2024: Alpha Release 1
  • July 18, 2024: Alpha Release 2
  • August 1, 2024: Alpha Release 3 (Skipped)
  • August 1, 2024: Alpha Release 4
  • August 13, 2024: Feature Freeze
  • August 15, 2024: Beta Release 1 (Skipped)
  • August 15, 2024: Beta Release 2 (Skipped)
  • August 15, 2024: Beta Release 3
  • August 29, 2024: Beta Release 4
  • September 12, 2024: Beta Release 5
  • September 26, 2024: Release Candidate 1
  • October 10, 2024: Release Candidate 2
  • October 24, 2024: Release Candidate 3
  • November 7, 2024: Release Candidate 4
  • November 21, 2024: General Availability Release

    Stay up-to-date with the latest PHP versions through this guide.

    PHP 8.4 Features

    PHP 8.4 introduces several new features aimed at simplifying PHP usage and addressing common developer challenges. Below are some of the most notable features:

    Property Hooks

    Property Hooks provide a robust way to work with PHP class properties. This feature allows properties to define one or more hooks, such as "get" and "set," which let developers perform specific logic when a property is accessed or modified. This is particularly useful for reducing boilerplate code associated with getters and setters.

    For example, consider the following code:

    php<br /> class User {<br /> private bool $isModified = false;<br /> <br /> public function __construct(private string $first, private string $last) {}<br /> <br /> public string $fullName<br /> get => $this->first . " " . $this->last;<br /> set {<br /> [$this->first, $this->last] = explode(' ', $value, 2);<br /> $this->isModified = true;<br /> }<br /> }<br />

    In this example, the $fullName property defines both "get" and "set" hooks. When retrieving the value, it concatenates the $first and $last properties. When setting the value, it splits the string into two segments and updates the internal properties accordingly.

    Asymmetric Visibility

    Asymmetric Visibility allows different visibility levels for different operations on a property. For instance, you can allow public read access to a property while restricting write access to internal use only:

    php<br /> public private(set) string $bar = "baz";<br />

    This feature works well with Property Hooks and enables more powerful data structures using objects.

    New Array Find Functions

    PHP 8.4 introduces new array functions to simplify value searches within arrays:

  • array_find
  • array_find_key
  • array_any
  • array_all

    Each function accepts two arguments: the array to operate on and a callback to invoke for each item. If the callback returns "true," the search stops immediately, except for array_all(), which returns true only if all items validate against the callback.

    MyClass()->method() Without Parentheses

    PHP 8.4 allows instantiating a class and immediately accessing a method or property without requiring parentheses:

    php<br /> $request = new Request()->withMethod('GET')->withUri('/hello-world');<br />

    JIT Changes

    The Just-In-Time (JIT) compiler for PHP has been improved to simplify maintenance and introduce new features. These changes are designed to be non-breaking for users and should make the internal Zend Engine more manageable for developers.

    HTML5 Support

    PHP 8.4 introduces comprehensive support for HTML5, adopting a more capable HTML5 parsing library. New opt-in DOM classes in a new PHP namespace differentiate these from existing XML-oriented DOM classes, offering better support for developers working with HTML.

    Additional New PHP 8.4 Features

    Other notable features in PHP 8.4 include:

  • $_POST and $_FILES now support additional HTTP verbs.
  • Multibyte trim functions: mb_trim(), mb_ltrim(), and mb_rtrim().
  • New, clearer rounding modes for the round() function.
  • Driver-specific PDO subclasses for accessing driver-specific features.
  • Improved callbacks for DOM and XSL, allowing closures, first-class callables, and instance methods.
  • Addition of Lazy Object support for generating ghost objects, proxies, and more.

    For a complete list of features, visit the list of PHP 8.4 accepted RFCs.

    PHP 8.4 Deprecations

    Alongside new features, PHP 8.4 introduces several deprecations, including implicit nullable types and the deprecation of GET/POST sessions.

    Implicit Nullable Types

    Previously, nullable types could be declared implicitly by setting a default value of "null":

    php<br /> function foo(T1 $a, T2 $b = null, T3 $c)<br />

    With PHP 8.4, this implicit declaration is deprecated. Developers must now explicitly declare nullable types or use a union type that includes "null":

    php<br /> function bar(T1 $a, ?T2 $b = null, T3 $c)<br /> function test(T1 $a, T2|null $b = null, T3 $c)<br />

    Deprecation of GET/POST Sessions

    PHP has allowed tracking user state via GET and POST parameters, but this is no longer recommended. Starting in PHP 8.4, settings that enable this behavior (session.use_only_cookies and session.use_trans_sid) will raise deprecation warnings. These settings will be removed in PHP 9.

    Other Deprecations

    Other deprecations include those captured in a single RFC to cover functionality flagged in recent years. For more details, visit the PHP 8.4 deprecations RFC.

    Considerations for Upgrading or Migrating to PHP 8.4

    It’s generally advisable to wait for at least one bugfix release before adopting any new feature release. This allows time for static analysis tools and ecosystem QA tooling to adapt, helping identify potential issues.

    Before upgrading, review the approved RFCs and the general list of deprecations to understand how changes may affect your code. Utilize static analysis tools and consider using tools like Rector to assist with the migration.

    Final Thoughts

    For those planning to upgrade to PHP 8.4, it may be beneficial to engage with a third-party consultant or organization like Zend by Perforce. Zend provides long-term support for EOL PHP versions and offers professional services to assist with PHP management.

    Make Our PHP Experts Your Experts

    Zend’s PHP Long Term Support and Migration Services are designed to help you maximize your PHP applications. Learn more about their support options and migration services here and here.

    For additional resources, visit the PHP resource guide.

    By staying informed about the latest PHP developments and leveraging available resources, you can ensure a smooth transition to PHP 8.4 and take full advantage of its new features and improvements.

For more Information, Refer to this article.

Neil S
Neil S
Neil is a highly qualified Technical Writer with an M.Sc(IT) degree and an impressive range of IT and Support certifications including MCSE, CCNA, ACA(Adobe Certified Associates), and PG Dip (IT). With over 10 years of hands-on experience as an IT support engineer across Windows, Mac, iOS, and Linux Server platforms, Neil possesses the expertise to create comprehensive and user-friendly documentation that simplifies complex technical concepts for a wide audience.
Watch & Subscribe Our YouTube Channel
YouTube Subscribe Button

Latest From Hawkdive

You May like these Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.