> On 29 May 2017, at 04:23, Dan Ackroyd <
[email protected]> wrote:
>
> Hi,
>
> I'd like to introduce an RFC to cleanup the behaviour of callables and
> related functions in PHP.
>
>
https://wiki.php.net/rfc/consistent_callables
>
> Note, this RFC targets PHP 8, with soft deprecations in PHP 7.3 and
> deprecation notices in 7.last. This means there is a lot of time for
> reading and thinking about the RFC.
>
> One piece of feedback I've had from informal discussions is that the
> BC break for one part is too big even for a major release number. I'd
> like to get other people's opinion on the RFC before possibly
> modifying it.
>
> Additionally modifying the signature of is_callable() might not be the
> best path. Again, looking forward to getting the opinion of other
> people.
>
> cheers
> Dan
> Ack
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit:
http://www.php.net/unsub.php
>
Hi Dan,
While there *is* a difference, your resulting comments are reversed for the "call_user_func different from is_callable” section. The call_user_func invocation works properly, the direct invocation does not.
A *lot* of the things you’re highlighting as “errors” or “is_callable lied to us” are neither - they’re just a consequence of scope, and I think the wording should be changed, because “it lied” has very different meaning to “it’s response is not necessary applicable in a different scope”. If an astronaut on the moon says he weighs 11.5kg, but you are looking at his medical report on Earth and it says he weighs 69kg, would you call him a liar?
Regarding the big change you suggest, making protected/private methods return false unless a new third parameter is true in is_callable():
I think you need to make your intention a *lot* clearer under the "Private and protected functions no longer report as callable for is_callable” section. You make no mention of it being user controlled, simply “this will not work any more”, until the next section.
As for the actual change: I think for the sake of BC, and frankly logic, it would make *more* sense, to reverse your flag, so the default respects current behaviour, *but* it gives people who rely on is_callable() from another scope the ability to make sure they only get universally-callable values.
Lastly - you mention the need to use Reflection to create closures, but Closure::fromCallable exists, so perhaps you drafted this before that passed, and haven’t updated that part?
Cheers,
Stephen
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit:
http://www.php.net/unsub.php