On 21/04/2023 12:11, Deleu wrote:
- PHP looks up \Foo\strlen. It's not on the Symbols table. Trigger autoload for it. - Autoload does NOT find a definition, register in the Symbols table that \Foo\strlen is undefined. - PHP looks up \strlen. It's not on the Symbols table, trigger autoload for it. - Autoload finds a definition, registers in the Symbols table and executes \strlen.


Yep, that's pretty much what's currently being proposed. The devil is in the detail of how to implement the "register that \Foo\strlen is undefined" part. In the current implementation, there's some unfortunate side effects.


I can imagine one would argue that caching every native function with a huge amount of namespace with a "undefined" definition could take up some memory space, but wouldn't that just encourage the PHP Community, PHP IDEs and static analysers to promote top-level file `use function \strlen`


Indeed, although bear in mind that the impact would be immediate on all existing code bases. Saying "all your code will be slower / use more memory in PHP 8.3 until you run this tool" is not the greatest message, so we still want to minimise that impact.

(As an aside, I'd personally much rather type \ in front of functions than maintain a long "use function" list in every file, even with the aid of tools; but apparently I'm in a minority on that.)


Regards,

--
Rowan Tommins
[IMSoP]

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

Reply via email to