Skip to content
#externals
← All RFCs
Draft

Deprecations for PHP 8.7

by Daniel ScherzerAndrey AndreevArnaud Le BlancJuliette Reinders Folmer
Contents
  1. Introduction
  2. Proposals
  3. Example Deprecation
  4. Deprecate is_a() with $object_or_class not being a string or object
  5. Deprecate is_subclass_of() with $object_or_class not being a string or object
  6. Deprecate the b prefix for binary strings
  7. Deprecate $algo integer values for password_hash(), password_needs_rehash()
  8. Deprecate 'snefru' hash alias for 'snefru256'
  9. Deprecate hash_pbkdf2() $options array
  10. Deprecate Session Upload Progress
  11. Deprecate class_uses()
  12. Deprecate class_implements()

Introduction

The RFC proposes to deprecate the listed functionality in PHP 8.7 and remove it in PHP 9 (except where otherwise noted).

The following list provides a short overview of the functionality targeted for deprecation, while more detailed explanation is provided in the Proposal section:

  • Deprecate is_a() with $object_or_class not being a string or object
  • Deprecate is_subclass_of() with $object_or_class not being a string or object
  • Deprecate the b prefix for binary strings
  • Deprecate $algo integer values for password_hash(), password_needs_rehash().
  • Deprecate 'snefru' hash alias for 'snefru256'.
  • Deprecate hash_pbkdf2() $options array.
  • Deprecate Session Upload Progress.
  • Deprecate class_uses()
  • Deprecate class_implements()

Proposals

Each feature proposed for deprecation is voted separately and requires a 2/3 majority. All votes refer to deprecation in PHP 8.7 and removal in PHP 9 (except where otherwise noted).

Example Deprecation

Description

Deprecate is_a() with $object_or_class not being a string or object

is_a() is used to check if an object or class name is an instance of some other named class/interface. The first parameter can be either an object to check, or the name of a class. It can also be something other than a string or object, in which case the function will always return false. I.e. code like is_a(5, "int") or is_a(true, "bool") will always return false.

Given that is_a() always returns false when the first parameter is something other than a string or object, we propose to deprecate providing non-string non-object parameters. If the type of a parameter is not known, the is_a() call can be preceded with calls to is_object() and is_string().

If accepted, calling is_a() with non-string non-object parameters will emit a deprecation similar to the following:

Deprecated: Calling is_a() with $object_or_class of type %s is deprecated.

Deprecate is_subclass_of() with $object_or_class not being a string or object

is_subclass_of() is used to check if an object or class name is an instance of a subclass of some other named class, or an instance of an interface. It works similarly to is_a(), except when an object's class is the exact same as the class to check. Like is_a(), the first parameter can be either an object to check, or the name of a class. It can also be something other than a string or object, in which case the function will always return false. I.e. code like is_subclass_of(5, "int") or is_subclass_of(true, "bool") will always return false.

Given that is_subclass_of() always returns false when the first parameter is something other than a string or object, we propose to deprecate providing non-string non-object parameters. If the type of a parameter is not known, the is_subclass_of() call can be preceded with calls to is_object() and is_string().

Unlike is_a(), is_subclass_of() also semantically makes no sense for non objects (or string class names) because there is no subclassing concept for non-objects.

If accepted, calling is_subclass_of() with non-string non-object parameters will emit a deprecation similar to the following:

Deprecated: Calling is_subclass_of() with $object_or_class of type %s is deprecated.

Deprecate the b prefix for binary strings

Background

The b-prefix for binary strings, along with the (binary) cast, was introduced twenty years ago in PHP 5.2.1 for forward compatibility with PHP 6, which was never released.

The (binary) type cast has since been deprecated in PHP 8.5.0.

From the very introduction until now, the b-prefix has never had any effect and b-prefixed text strings behave exactly the same as text strings without the b-prefix.

A previous RFC to deprecate this syntax for PHP 7.2 was rejected with 19 votes for and 13 votes against the proposal. Based on responses in the mailinglist at the time, the predominant line of thinking to vote against the proposal was along the lines of “we may want it to actually do something in the future”.

In the ten years since, it doesn't appear that such an occasion has come up though. Additionally, the current behaviour is “has no effect”. If the b-prefix would start to cause a new behaviour in the future, this would be a breaking change, so even if the syntax would be (re-)used, a deprecation period to make people aware of the current behaviour and that this behaviour could change in the future would be appropriate.

Other reasons to deprecate the b-prefix are:

  • Reducing cognitive load for the C-developers which need to take this syntax into account when working on applicable parts of the PHP Core codebase.
  • Reduced learning curve for PHP developers, which - based on anecdotal evidence - most (75%) have little to no awareness this syntax even exists, let alone what it does.

Proposal

With all this in mind, we are proposing to deprecate the b-prefix for text strings at compile time with the following deprecation message:

Deprecated: Usage of the 'b'-prefix for text string is deprecated as it never had any effect. It can be safely removed.

Code tokenized via token_get_all() will explicitly be excluded from throwing the deprecation.

Impact

In the discussion about the proposal from 2017, a number of people also brought up that they estimated that the deprecation would be high impact for existing code.

To validate/reject that claim, I've done a scan of the top 10.000 packages on Packagist (977.714 files per October 7th 2026) to find any usages of b-prefixed text string and found only 2 usages, both in the src/Response/CSVResponse.php file from the contributte/application--v0.6.2 application (and 2 duplicates of those in ublaboo/datagrid--v7.2.0).

While this doesn't negate that there may be an impact in private/proprietary projects, this analysis does give a tentative indication that it's unlikely for the syntax to be widely used.

Mitigation

This deprecation can be mitigated in affected codebases by removing the b-prefix from the text string.

If the RFC passes, an auto-fixer to apply this change will be made available via the external PHPCompatibility standard for PHP_CodeSniffer. Other tooling may also offer auto-fixers.

Deprecate $algo integer values for password_hash(), password_needs_rehash()

Currently, password_hash() and password_needs_rehash() accept integers in the second parameter, $algo as the following aliases:

0 = PASSWORD_DEFAULT
1 = PASSWORD_BCRYPT
2 = PASSWORD_ARGON2I
3 = PASSWORD_ARGON2ID

This is a backwards-compatibility measure added in PHP 7.4, when the PASSWORD_* algorithm constants became strings. RFC: Password Hashing Registry was (at least initially) meant to immediately deprecate integer value use, but the deprecation notice was never implemented.

The integer aliases have long over-served their purpose by now, and go against the registry design since they're hard-coded into ext/standard/password.c.

If accepted, calling password_hash() and/or password_needs_rehash() with integer $algo will emit warnings like:

Deprecated: Calling password_hash() with argument 2 ($algo) of type int is deprecated. Deprecated: Calling password_needs_rehash() with argument 2 ($algo) of type int is deprecated.

Deprecate 'snefru' hash alias for 'snefru256'

Snefru is a legacy hash function that has 128-bit and 256-bit output variants. PHP has only ever supported the 256-bit version and first named it just "snefru" back when it was introduced in PHP 5.1, while "snefru256" was added with the Mhash compatibility layer shortly after. Today, "snefru" is effectively an alias for "snefru256" and it is the only such alias in ext/hash.

However unlikely it is for Snefru to be used today, the alias is ambiguous and naturally mistaken for the Snefru128 variant. A deprecation notice may also help uncover forgotten uses of Snefru and induce long-overdue transitions away from it.

If accepted, calling any function from ext/hash with "snefru" as the algorithm will emit a notice similar to:

Deprecated: Use of 'snefru' algorithm alias is deprecated; use 'snefru256' instead.

Deprecate hash_pbkdf2() $options array

As of PHP 8.1, hash_pbkdf2() has a 7th parameter, array $options = [], which does nothing as it was added for MurmurHash3 and XXHash. Both of those are non-cryptographic hashes and therefore unusable with PBKDF2. Furthermore, PBKDF2 is entirely bound to the HMAC construct and already has discrete parameters for everything that should be customizable about it, so even theoretical future use isn't plausible. The parameter seems to have been added by mistake while other ext/hash functions were being modified.

If accepted, calling hash_pbkdf2() with the 7th parameter set to any value will emit a notice similar to:

Deprecated: Use of $options array with hash_pbkdf2() is deprecated.

Deprecate Session Upload Progress

The Session Upload Progress feature was introduced at a time when uploading a small file was slow and there was no way to give progress feedback to the user, but nowadays there are simpler ways to achieve this on the client side. The feature is also ineffective when the POST body is buffered before being forwarded to PHP, which is usually the case in FastCGI setups.

Moreover, the feature has been the cause of multiple security issues recently. It has been disabled by default since versions 8.2.36, 8.3.37, 8.4.28, 8.5.13, and 8.6.0.

If accepted, setting session.upload_progress.enabled to a truthy value will emit a notice similar to:

Deprecated: Setting session.upload_progress.enabled to On is deprecated.

Deprecate class_uses()

This function returns an associative array of the trait names used by a class. Since 2008, the Reflection extension has always been available, and using that extension should be preferred over this function. Use ReflectionClass::getTraitNames() instead.

If having the names as array keys is important, array_combine() can convert the indexed array to an associative one. If avoiding autoloading is important, the call can be guarded with a class_exists() check.

If accepted, calling the function will emit the following deprecation

Deprecated: Function class_uses() is deprecated since 8.7, use ReflectionClass::getTraitNames() instead.

Deprecate class_implements()

This function returns an associative array of the interface names implemented by a class (including by its parents). Since 2008, the Reflection extension has always been available, and using that extension should be preferred over this function. Use ReflectionClass::getInterfaceNames() instead.

If having the names as array keys is important, array_combine() can convert the indexed array to an associative one. If avoiding autoloading is important, the call can be guarded with a class_exists() check.

If accepted, calling the function will emit the following deprecation

Deprecated: Function class_implements() is deprecated since 8.7, use ReflectionClass::getInterfaceNames() instead.