On Mon, 10 Apr 2023 at 20:12, Anton Smirnov <sand...@sandfox.me> wrote:
> Hello George, > > I'm not sure I'm 100% correct but I think that this RFC still allows to > call different functions for the same code, just not in the same run. > > Consider this pseudocode: > > //- funcs.php > > namespace My; > > function myfunc(...) { ... } > function array_map(...) { ... } > > //- code1.php > > namespace My; > > myfunc(1); // autoload triggered > // bonus points if it's a different file or some obscure method > array_map(strlen(...), []); // My\array_map > > //- code2.php > > namespace My; > > // no prior autoload > array_map(strlen(...), []); // global array_map > No, array_map will trigger the autoloader (actually strlen() will trigger it once first) and the autoloader should then load the array_map function from the My namespace. However, if the autoloader does not correctly load the My\array_map() function then it will be bound to the global function. I can add some test cases for that if needed. > And if I understand the current order of execution correctly, here is a > more extreme example: > > //- moreextreme.php > > namespace My; > > if (some_random()) { > array_map('My\myfunc', []); // global array_map > } else { > array_map(myfunc(...), []); // My\array_map > } > > -- > Anton > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php > >