On Mon, Jan 23, 2023, at 10:08 AM, Robert Landers wrote:

> In my mind, Test::Func(...) should be treated the same as ['Test',
> 'Func'] or 'Test::Func' until it is called and if some fancy framework
> wants to do something special with the closure, it can do so. FWIW, I
> didn't even know this syntax checked anything until today. I can think
> of a number of cases where delaying the error to actual execution is
> beneficial.
>
> 1. Just because the method/object doesn't exist, doesn't mean it won't
> exist by the time it is called -- this is PHP after all.
> 2. I can have a file with 100 million of these things without
> triggering any autoloading.
> 3. PHPStorm currently doesn't trigger this syntax as an error.

This ship has long since sailed.  Test::func(...) produces a \Callable object, 
using the Closure::fromCallable() mechanism internally.  One important 
advantage (and why Nikita favored it over most other callable syntaxes) is that 
it respects scope visibility better than passing around a buncha strings.

Changing that at this point is a major API break that is not going to happen.

--Larry Garfield

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

Reply via email to