note 114106 deleted from language.oop5.autoload by crell
| From: | crell@php.net | Date: | Mon, 04 Apr 2022 16:10:03 +0000 |
| Subject: | note 114106 deleted from language.oop5.autoload by crell | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-218025@lists.php.net to get a copy of this message | ||
Note Submitter: norwood at computer dot org
----
Autoloaders & Namespaces: The effective namespace of an autoloaded file must match that of its
original reference; just finding and loading the file isn't enough. (I know, seems obvious
now, but...)
My namespaces may serve as hints to locations within the file system, and I tried to be cute:
If a class (file) wasn't found where it was expected, my autoloader also looked in an
alternate location. This worked fine, except that the alternate's own qualified namespace was
thus slightly different (reflecting where *it* lived). So although the desired class was ultimately
loaded (name and all), the original caller's reference remained unsatisfied because of the
namespace discrepancy (as it should, really), but it was subtle.
Of course, this scheme works fine within the same namespace (explicit or not).
And kudos to the autoload devs for anticipating what could have been an endless autoload loop.