Re: Not autoloading functions
| From: | Rowan Collins | Date: | Fri, 27 Jan 2017 13:30:33 +0000 |
| Subject: | Re: Not autoloading functions | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-97985@lists.php.net to get a copy of this message | ||
On 27 January 2017 09:23:38 GMT+00:00, Wes <netmo.php@gmail.com> wrote:
>An alternative (which I haven't properly developed yet). Thoughts?
>\A\B\someFunction();
>// prints:
>// LOADING A\n
>// LOADING AB\n
As I understand it, PHP namespaces aren't really hierarchies, they just have a hierarchical
naming scheme; so namespace \A is not actually being referenced here.
>\A\B\someFunction();
>// tries no autoload, because both namespaces A and A\B were
>// attempted to be loaded already.
>// in other words, autoload is attempted only once
>// for any given namespace
The tricky case that stalled the discussion of https://wiki.php.net/rfc/function_autoloading
is using unqualified function names: if you're already inside the same namespace as the
function, or alias it with "use function". I'm not sure how this mechanism would work
for those cases.
Finally, suggestions of a single include per namespace haven't been universally popular in
previous threads, because some projects genuinely prefer each function in its own file (think plugin
functions for Smarty / Wordpress / etc).
It's an idea worth exploring though, IMO.
Regards,
--
Rowan Collins
[IMSoP]