Skip to content

[RFC] Deprecate is_a() and is_subclass_of() with string when not allowed - #23236

Merged
DanielEScherzer merged 1 commit into
php:masterfrom
DanielEScherzer:allow-string-false
Aug 31, 2026
Merged

[RFC] Deprecate is_a() and is_subclass_of() with string when not allowed#23236
DanielEScherzer merged 1 commit into
php:masterfrom
DanielEScherzer:allow-string-false

Conversation

@DanielEScherzer

Copy link
Copy Markdown
Member

For is_a() and is_subclass_of(), emit deprecation warnings when calling with a string as the first argument but with $allow_string being false. The two functions share implementation code and so are updated together.

https://wiki.php.net/rfc/deprecations_php_8_6

Comment thread Zend/zend_builtin_functions.c Outdated
Comment thread Zend/zend_builtin_functions.c Outdated
Comment on lines +718 to +728
zend_string *function_name = get_active_function_or_method_name();
zend_error(
E_DEPRECATED,
"Calling %pS() with a string when $allow_string is false",
function_name
);
zend_string_release(function_name);
if (UNEXPECTED(EG(exception))) {
RETURN_THROWS();
}
RETURN_FALSE;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can determine this using the only_subclass parameter and just have a const char*.

Might also make sense as a follow-up to mark is_a_impl zend_always_inline so the compiler actually inlines the implementation for the two functions.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switched to using only_subclass to check

…allowed

For `is_a()` and `is_subclass_of()`, emit deprecation warnings when calling
with a string as the first argument but with `$allow_string` being false. The
two functions share implementation code and so are updated together.

https://wiki.php.net/rfc/deprecations_php_8_6
@DanielEScherzer
DanielEScherzer merged commit 4923c60 into php:master Aug 31, 2026
18 checks passed
@DanielEScherzer
DanielEScherzer deleted the allow-string-false branch August 31, 2026 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment