rfc:deprecations_php_8_7

PHP RFC: Deprecations for PHP 8.7

  • Date: 2026-08-12
  • Authors:
  • Status: Draft
  • Discussion thread: Not started yet
  • Voting thread: tbd

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

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 a call to is_object.

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 a call to is_object.

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.

rfc/deprecations_php_8_7.txt · Last modified: by daniels