From 377307996d90a482d87dab8178ba81a29e13dd79 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Fri, 17 Aug 2007 17:12:28 +0000 Subject: [PATCH] Added examples --- README.namespaces | 81 +++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 67 insertions(+), 14 deletions(-) diff --git a/README.namespaces b/README.namespaces index de71880e33..bb15d62b4d 100755 --- a/README.namespaces +++ b/README.namespaces @@ -4,12 +4,12 @@ Design Main assumption of the model is that the problem that we are to solve is the problem of the very long class names in PHP libraries. We would not attempt to take autoloader's job or create packaging model - only make names -manageable. +manageable. -Namespaces are defined the following way: +Namespaces are defined the following way: -Zend/DB/Connection.php: - -Namespace definition does the following: +Namespace definition does the following: All class and function names inside are automatically prefixed with namespace name. Inside namespace, local name always takes precedence over -global name. It is possible to use the same namespace in several PHP files. +global name. Several files may be included into the same namespace. The namespace declaration statement must be the very first statement in -file. +file. The only exception is "declare" statement that can be used before. Every class and function from namespace can be referred to by the full name -- e.g. Zend::DB::Connection or Zend::DB::connect - at any time. +- e.g. Zend::DB::Connection or Zend::DB::connect - at any time. -Namespace or class name can be imported: +Namespace or class name can be imported: - + + + + + + + +The worst case if class name conflicts with namespace name + TODO ==== * Rename namespaces to packages? +* Support for namespace constants? + +* support for "import ns::*"? + +* performance problems + + - calls to internal functions in namespaces are slower, because PHP first + lools for such function in current namespace + + - calls to static methods are slower, because PHP first tries to look + for corresponding function in namespace + * Extend the Reflection API * Add ReflectionPackage class @@ -120,4 +173,4 @@ TODO + getFunctions() + getFiles() - * Add getNamespace() methods to ReflectionClass and ReflectionFunction + * Add getNamespace() methods to ReflectionClass and ReflectionFunction -- 2.40.0