note 114106 added to language.oop5.autoload
| From: | norwood at computer dot org | Date: | Sat, 11 Jan 2014 16:12:43 +0000 |
| Subject: | note 114106 added to language.oop5.autoload | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-198205@lists.php.net to get a copy of this message | ||
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.
----
Server IP: 64.71.164.2
Probable Submitter: 107.200.173.164
----
Manual Page -- http://php.net/manual/en/language.oop5.autoload.php
Edit -- https://master.php.net/note/edit/114106
Del: integrated -- https://master.php.net/note/delete/114106/integrated
Del: useless -- https://master.php.net/note/delete/114106/useless
Del: bad code -- https://master.php.net/note/delete/114106/bad+code
Del: spam -- https://master.php.net/note/delete/114106/spam
Del: non-english -- https://master.php.net/note/delete/114106/non-english
Del: in docs -- https://master.php.net/note/delete/114106/in+docs
Del: other reasons-- https://master.php.net/note/delete/114106
Reject -- https://master.php.net/note/reject/114106
Search -- https://master.php.net/manage/user-notes.php