php-src icon indicating copy to clipboard operation
php-src copied to clipboard

is_callable($deprecated_callable), etc., should throw a deprecation notice

Open claudepache opened this issue 4 years ago • 3 comments

Description

Deprecation of partially supported callables was accepted in RFC and implemented in #7446.

The callable type and the is_callable() function were wilfully exempted from the deprecation notice. While I can guess some of the reasoning behind this decision, real world code shows that this is problematic, and a bunch of code would silently break in 9.0.

See the links in https://externals.io/message/117342#117374 for some examples.

As additional example, I have found few instances of the following pattern in my own code base:

if (is_callable([ 'self', 'some_prefix_'.$foo ])) {
    self::{'some_prefix_'.$foo}(...$args);
}

Request: The callable type, the is_callable() function (and any other function that currently supports partially supported callables) should throw a deprecation notice whenever they encounter a “deprecated callable”.

claudepache avatar Apr 19 '22 15:04 claudepache

With the proposed change, we lose the possibility to feed is_callable() with arbitrary input without triggering a deprecation warning in PHP 8.x (x ≥ 3), save resorting to @.

However, in real world, is_callable() is almost never given totally arbitrary stuff (e.g., when the stuff includes the string "static", that string is usually hard-coded somewhere); so that it is not an issue in practice.

claudepache avatar Apr 20 '22 08:04 claudepache

@jrfnl made an RFC for this.

cmb69 avatar May 16 '22 12:05 cmb69

And that RFC has been accepted, and implemented in the meantime.

cmb69 avatar Aug 01 '22 17:08 cmb69