rfc:spl-namespace

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
rfc:spl-namespace [2008/07/21 15:25] baptiste750rfc:spl-namespace [2017/09/22 13:28] (current) – external edit 127.0.0.1
Line 2: Line 2:
   * Version: 1.0   * Version: 1.0
   * Date: 2008-07-19   * Date: 2008-07-19
-  * Author: Baptiste Autin <baptiste.autin.at.free.fr> +  * Author: Baptiste <fjas.at.free.fr> 
-  * Status: Under Discussion+  * Status: Abandonned
   * First Published at: http://wiki.php.net/rfc/spl-namespace   * First Published at: http://wiki.php.net/rfc/spl-namespace
   * Other formats ..   * Other formats ..
Line 23: Line 23:
 === Use with spl_autoload === === Use with spl_autoload ===
  
-After a ''spl_namespace($namespace, $path)'', all subsequent ''spl_autoload(...)'' that refer to $namespace will **change directory** to $path.+After a ''spl_namespace($namespace, $path)'', all subsequent ''spl_autoload(...)'' that refer to $namespace will include the class file by changing directory to $path.
  
 <code php> <code php>
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 changes directory to the physical path of the namespace.
  
 <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, and aliases are no longer needed: 
- 
-<code php> 
-use Foo1::Foo2::*; // or spl_use (?) 
-use Foo3; 
-(..) 
-$a = MyClass(); 
-</code> 
- 
-The parser will look up in its autoloaded classes for a ''Foo1::Foo2::MyClass'', for a ''Foo3::MyClass'' and then for a ''::MyClass'' (global namespace). 
- 
-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 ''MyClass'' found is taken, regardless of the rest). 
  
 * It becomes possible to namespace old existing code without even modifying it. No need to add a ''namespace'' at the beginning of every file. * It becomes possible to namespace old existing code without even modifying it. No need to add a ''namespace'' at the beginning of every file.
Line 92: Line 78:
   * If an autoloader, for a given classname, includes a different file depending on the value of a global variable, there's no longer unicity   * If an autoloader, for a given classname, includes a different file depending on the value of a global variable, there's no longer unicity
  
-  * ...+  * spl_autoload_register() will generally be present in the same file as the autoloader class, so changing directory is not really usefull, since we'll already be positionned in the correct directory.
  
 ==== Practical usage ==== ==== Practical usage ====
rfc/spl-namespace.1216653928.txt.gz · Last modified: 2017/09/22 13:28 (external edit)