Re: Deprecated partially supported callables: should is_callable() throwa deprecation notice ?
| From: | Rowan Tommins | Date: | Wed, 20 Apr 2022 10:42:56 +0000 |
| Subject: | Re: Deprecated partially supported callables: should is_callable() throwa deprecation notice ? | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-117549@lists.php.net to get a copy of this message | ||
On 20/04/2022 08:33, Claude Pache wrote:
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, writingYes, and crucially, you can write strpos('x', (string)120) if *that* was what was meant, and in both cases you're clarifying the code and not just working around the notice. What's more, the change can be made directly where the deprecation notice is raised. I agree with Christian that the callable parameter case should raise a deprecation notice - because it will become an error, there is no ambiguity about the right fix. The situation with is_callable is a bit less clear, because it depends on how the function is actually being used. If a false return is eventually equivalent to some kind of error, then the behaviour would ideally match callable parameters. In other examples, though, false is actually a valid state, so it's not clear what a user should change to avoid the deprecation notice. You make a very important claim in your bug report:strpos('x', chr(120))instead ofstrpos('x', 120)will work fine in both 7.4 and 8.0 (in case it is really what was meant).
However, in real world, is_callable() is almost never given totally arbitrary stuffMy concern is that we have no way of knowing whether this is true, and whether there will always be a clear action for users who see the deprecation notice.
As I think that it is a serious oversight of the RFC, I have open: https://github.com/php/php-src/issues/8401As a side-note, the bug tracker probably gets *less* attention than this list, so raising as a bug half-way through a discussion probably doesn't achieve much other than duplicating comments. Regards, -- Rowan Tommins [IMSoP]