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, 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).


Yes, 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:

> However, in real world, is_callable() is almost never given totally arbitrary stuff

My 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/8401

As 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]

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to