Re: Deprecated partially supported callables: should is_callable() throwa deprecation notice ?

From: Date: Wed, 20 Apr 2022 07:33:17 +0000
Subject: Re: Deprecated partially supported callables: should is_callable() throwa deprecation notice ?
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-117548@lists.php.net to get a copy of this message
> Le 20 avr. 2022 à 00:22, Claude Pache <claude.pache@gmail.com> a écrit : > > > >> Le 19 avr. 2022 à 20:20, Andreas Hennings <andreas@dqxtech.net> a écrit : >> >> A deprecation warning on is_callable() would imply that in a future >> version of PHP that call will be illegal. > > No, in the case of is_callable(), the deprecation warning will > imply that, in a future version of PHP, the behaviour will change. There are precedents of > deprecation warning for changing behaviour: https://3v4l.org/Iqo4N > <https://3v4l.org/Iqo4N> > > —Claude Expanding my last message: Although we can technically use deprecation warning for anything reasonable (even without precedent), we should nevertheless be careful that it remains possible to write forward- and backward-compatible code without triggering that deprecation notice (and without resorting to the error suppression operator). For example, writing strpos('x', chr(120)) instead of strpos('x', 120) will work fine in both 7.4 and 8.0 (in case it is really what was meant). In the case of is_callable(), it is true that it should in theory accept arbitrary input without notice. However, in practice, the value that is_callable() receives is almost never totally arbitrary: for instance, when it is fed with a string beginning with "static::", that particular prefix is almost surely written somewhere verbatim in your code, and you must change your code in some way in order to keep the intended behaviour in 9.0. By contrast, we shouldn’t use any type of notice for password_verify(), because that function must be prepared to accept *really* arbitrary strings. —Claude

« previous php.internals (#117548) next »