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 14:21] – baptiste750 | rfc:spl-namespace [2008/07/21 15:23] – baptiste750 | ||
---|---|---|---|
Line 10: | Line 10: | ||
==== Introduction ==== | ==== Introduction ==== | ||
- | '' | + | The present RFC suggests a new namespacing system, based on the association |
- | + | ||
- | The default association being: Class Foo -> Foo.php | + | |
- | + | ||
- | Why not implementing a similar association between namespaces and physical paths? | + | |
- | The present RFC suggests a new namespacing system, based on that association. | + | |
==== A new instruction: | ==== A new instruction: | ||
- | '' | + | '' |
<code php> | <code php> | ||
- | spl_namespace(' | + | spl_namespace (' |
- | spl_namespace(' | + | spl_namespace (' |
</ | </ | ||
=== Use with spl_autoload === | === Use with spl_autoload === | ||
- | After a '' | + | After a '' |
<code php> | <code php> | ||
spl_namespace(' | spl_namespace(' | ||
... | ... | ||
- | spl_autoload(' | + | spl_autoload(' |
</ | </ | ||
- | But '' | + | But '' |
So, taking the example above, if MyClass.php contains: | So, taking the example above, if MyClass.php contains: | ||
Line 61: | Line 56: | ||
=== Use with spl_autoload_register === | === Use with spl_autoload_register === | ||
- | TODO | + | The behaviour is the same, except that, just before executing the callback function, the parser changes directory to the physical path of the namespace. |
+ | |||
+ | <code php> | ||
+ | spl_namespace(" | ||
+ | (...) | ||
+ | spl_autoload_register(array(" | ||
+ | // When Foo1:: | ||
+ | </ | ||
+ | |||
+ | In the example above, every class succesfully autoloaded by '' | ||
==== Benefits ==== | ==== Benefits ==== | ||
Line 86: | Line 90: | ||
==== Drawbacks | ==== Drawbacks | ||
- | * ... | + | * 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