rfc:spl-namespace
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
rfc:spl-namespace [2008/07/21 15:18] – unicity problem in autoloading methods baptiste750 | rfc:spl-namespace [2008/07/22 08:41] – baptiste750 | ||
---|---|---|---|
Line 23: | Line 23: | ||
=== Use with spl_autoload === | === Use with spl_autoload === | ||
- | After a '' | + | After a '' |
<code php> | <code php> | ||
Line 31: | Line 31: | ||
</ | </ | ||
- | But '' | + | But '' |
So, taking the example above, if MyClass.php contains: | So, taking the example above, if MyClass.php contains: | ||
Line 56: | Line 56: | ||
=== Use with spl_autoload_register === | === Use with spl_autoload_register === | ||
- | The behaviour is the same, except that, just before executing the callback function, the parser changes directory to the physical path of the namespace. | + | The behaviour is the same, except that, just before executing the callback function, the parser |
<code php> | <code php> | ||
Line 70: | Line 70: | ||
* The namespacing system becomes more consistent. It does no longer belong to the class (or the interface) to define its full qualifying name. It belongs to the element that requires it to assign its final position in the namespace. | * The namespacing system becomes more consistent. It does no longer belong to the class (or the interface) to define its full qualifying name. It belongs to the element that requires it to assign its final position in the namespace. | ||
- | |||
- | * Now that a namespace points to a clear and unique location, importing a namespace is unambiguous, | ||
- | |||
- | <code php> | ||
- | use Foo1:: | ||
- | use Foo3; | ||
- | (..) | ||
- | $a = MyClass(); | ||
- | </ | ||
- | |||
- | The parser will look up in its autoloaded classes for a '' | ||
- | |||
- | If only one MyClass on the three is found, it is used. | ||
- | If two or the three MyClass are found, a fatal error is raised (other scenario: the first '' | ||
* It becomes possible to namespace old existing code without even modifying it. No need to add a '' | * It becomes possible to namespace old existing code without even modifying it. No need to add a '' | ||
Line 90: | Line 76: | ||
==== Drawbacks | ==== Drawbacks | ||
- | * If an autoload method, for a given class that it receives in parameter, includes a different file according to the value of a global variable, there' | + | * If an autoloader, for a given classname, includes a different file depending on the value of a global variable, there' |
* ... | * ... |
rfc/spl-namespace.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1