PHP 8.2: What to Expect

PHP 8.2 is expected to release in November this year, with the most recent stable version being PHP 8.1.5. While it’s still early, there has been mixed reception about the update.

However, knowing what to expect can help you prepare for the latest PHP version. By learning about the new features and the ones being deprecated, you can understand how the update may affect development. This knowledge can also help you get ready for the eventual release.

In this post, we’ll recap the most recent PHP versions. Then we’ll cover what’s new in PHP 8.2 and discuss the release schedule. Let’s jump in!

An Overview of PHP Versions

PHP is the primary programming language of WordPress. It plays a vital role in converting data from your database into HTML web pages for your site’s visitors.

As a website owner or developer, you’re likely already familiar with the importance of keeping your WordPress core, themes, and plugins updated. However, it’s also critical to keep your PHP up to date.

Currently, WordPress recommends using at least PHP 7.4. Older versions no longer receive active support for security updates and bug fixes. Therefore, upgrading to the latest stable version of PHP can result in better site security, enhanced performance, and higher levels of support (we emphasize stable because WordPress isn’t fully PHP 8.0 compatible just yet, so approach updates with caution).

PHP 7.4 introduced typed properties, an underscore numeric separator, and various improvements. Since then, there have been a couple more iterations of PHP released.

PHP 8.0, released in November 2020, brought a handful of essential features. In addition to syntax and performance enhancements, the release included:

  • Named parameters
  • Match syntax
  • Union types
  • Constructor Property Promotion
  • JIT (which affects how PHP executes source code)

A year later came PHP 8.1, the latest major PHP version. This update includes significant features, such as:

  • Intersection types
  • Readonly properties
  • Enums
  • Fibers
  • Never return type

Staying on top of the latest versions of PHP can help boost the performance and security of your website. However, it’s important to know which changes to expect before upgrading. If you’re interested in testing the current state of PHP 8.2, you can do so via GitHub.


What’s New in PHP 8.2

PHP 8.2 is expected to be released by the end of 2022. Here is the current release schedule, with General Availability (GA) programmed for November 24, 2022:

    • June 9: Alpha 1
    • June 23: Alpha 2
    • July 7: Alpha 3
    • July 19: Feature freeze
    • July 21: Beta 1
    • August 4: Beta 2
    • August 18: Beta 3
    • September 1: Release candidate 1
  • September 15: Release candidate 2
  • September 29: Release candidate 3
  • October 13: Release candidate 4
  • October 27: Release candidate 5
  • November 10: Release candidate 6
  • November 24: GA

According to the official documentation on the PHP website, there should be a handful of new features and deprecated functions. Let’s take a look at what to expect!

New memory_reset_peak_usage Function

PHP 8.2 will include a new function called memory_reset_peak_usage. It will reset the peak memory usage returned by the memory_get_peak_usage function.

This function will be helpful for cases that involve invoking an action several times and recording the peak memory usage of each iteration. Developers will be able to use this new feature to reset the peak memory usage at any given point during the lifetime of the request.

Get Content Delivered Straight to Your Inbox

Subscribe to our blog and receive great content just like this delivered straight to your inbox.

Readonly Classes

Introduced in PHP 8.1, readonly properties will be expanded in PHP 8.2 to add syntactic sugar so that all class properties are readonly at once:

readonly class Post
public function __construct(
public string $title,
public Author $author,
public string $body,
public DateTime $publishedAt,
) {}

This will prevent dynamic properties from being added to classes.

Null and False Standalone Types

In PHP 8.2, the return type of false will be available as a standalone type rather than strictly a union type for when an error occurs, which is already possible:

function alwaysFalse(): false
return false;

The same is true for the null type. For example, as a standalone type, unlike before, NullPost::getAuthor()will be able to only return null.

Deprecate Dynamic Properties

Dynamic properties will be deprecated in PHP 8.2, resulting in an ErrorException by PHP 9.0. These properties are set on an object:

class Post
public string $title;
// …

Dynamic properties allow flexibility when creating classes (e.g., value objects) without a strict class declaration. Their deprecation will likely be an issue for developers who rely on dynamic properties because it will push them more toward static analysis. For this reason, some developers are apprehensive about this change with PHP 8.2.

However, classes using __get and __set will still support dynamic properties, as will objects of stdClass.

Alternatively, developers can use the new #[AllowDynamicProperties]attribute, declared in the global namespace, on classes to those properties:

class User() {}
$user = new User();
$user->foo = 'bar';

While it’s not recommended, another option is to disable deprecation warnings.

New /n Modifier

PHP 8.2 will include support for the /n (no capture) modifier to the preg_* function family. When used, any groups with()meta-characters won’t capture apart from captured groups that are named. Essentially, the result is the same as marking each group as non-capturing.

The reasoning behind this change is that the modifier simplifies complex regular expressions for multiple groups. Rather than marketing every group as non-capturing, developers can mark all groups as non-capturing. Then, they can select and name specific groups that need to capture.

Redact Parameters in Back Traces

Many developers use services that track stack traces and production errors from codebases. These services can notify users if and when something goes wrong. For instance, tracing call stacks is helpful when debugging an application.

However, sometimes stack traces can have sensitive information, such as usernames and passwords. PHP 8.2 will include a #[SensitiveParameter] attribute that will prevent this information from being included in stack traces when things go wrong:

function test(
#[\SensitiveParameter] $bar,
) {
throw new Exception('Error');
test('foo', 'bar', 'baz');

PHP 8.2 will use the sensitive parameters to redact private information from stack traces, making them more secure. These parameters ensure that the data won’t end up in error logs. Note that this attribute will only be available to use on parameters.

Deprecate ${} String Interpolation

There are multiple ways to embed variables in strings with PHP. However, PHP 8.2 will deprecate two methods. The first is using ${} in strings:

"Hello ${world}";

The second is using ${} (variable variables):

"Hello ${(world)}";

This likely won’t be a significant issue for developers as the two most popular string interpolation methods will still work.

Deprecate Partially Supported Callables

Another deprecated change will be with partially supported callables. There are multiple ways to create a callable in PHP. It can be called either with or without parameters with the $callable() syntax, the user_call_func(/a_array), or using a function with a callback.

The deprecated callable patterns include the following:

$callable = "self::method";
$callable = "parent::method";
$callable = "static::method";
$callable = ["self", "method"];
$callable = ["parent", "method"];
$callable = ["static", "method"];
$callable = ["MyClass", "MyParentClass::myMethod"];
$callable = [new MyClass(), "MyOtherClass::myMethod"];

Starting from PHP 8.2, calling any of the above will result in the following deprecation notice:

class Test {
public static function myMethod(): void {
echo "Called";

public static function call(): void {

$callable = Test::call();
// "Called";

However, passing these callables to the is_callable function or using them with the callable parameter types won’t generate the deprecation message. To prevent the deprecation notice, developers can instead convert parent, self, and static keywords in callable code to their respective class names using the::class magic method.

Part of the reason behind the change is to allow callables to be used for typed properties. It makes them less context-dependent.

MySQLi Can No Longer Be Compiled With libmysql

In the past, PHP has supported two libraries for connecting MySQL databases: mysqlnd and libmysql. As of PHP 5.4, the former has been the default library. However, it’s been possible to compile MySQLi through extensions.

Beginning with PHP 8.2, compiling a MySQLi extension with libmysql won’t be supported. Attempting to do so will result in a configuration error:

./configure --with-mysqli=FOO

Linking mysqli against external library is no longer supported

This won’t likely cause any significant errors for developers. However, the two biggest features supported by libmysql that aren’t available with mysqlnd are supported for automatic reconnecting and authentication through LDAP and SASL.

Keep Your WordPress PHP Version Up to Date

As a developer, it’s essential to test your code against upcoming versions of PHP. In this case, developers should begin testing their code against PHP 8.2 as soon as possible to ensure your code doesn’t break users’ sites when they update.

The Perfect Development Environment

We offer budget-friendly Shared Hosting services with robust features and resources to help you create the perfect website. Plans start at $1.99/mo.

shared hosting

We will be happy to hear your thoughts

Leave a reply

some deals vip
Enable registration in settings - general
Compare items
  • Total (0)
Shopping cart