You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
Dmitry Stogov 0f2247ae94 Fixed bug #44414 (Incomplete reporting about abstract methods) 18 years ago
TSRM MFH: fix TSRM mutex return value inconsitencies (patch by Scott MacVicar) 18 years ago
Zend Fixed bug #44414 (Incomplete reporting about abstract methods) 18 years ago
build - Updated bundled shtool to 2.0.6 and added "platform" command in it. 19 years ago
ext Fixed bug #44394 (Last two bytes missing from output) 18 years ago
main MFH: fix segfault - error_string may be NULL, in this case we have to follow the old behavior 18 years ago
netware MFH: Bump copyright year, 2 of 2. 18 years ago
pear fix #39300 (make install fails if wget is not available) 19 years ago
sapi Adding itk again to non-threaded MPMs. Sorry for the confusion 18 years ago
scripts Fixing typo arg->arglist at line 195. Thanks Chris J! 18 years ago
tests - Ok to fail on OSX, adjusted bug, patch from scoates 18 years ago
win32 - add PHP_PHP_BUILD\bin to the path in PATH_PROG (option set with --with-php-builds=[PATH] the zip.zip contains all we need (except re2c! ) 18 years ago
.gdbinit Fix macros after GC patch. 18 years ago
CODING_STANDARDS - MFH 18 years ago
CREDITS Let's pretend this is up-to-date now 24 years ago
ChangeLog ChangeLog update 21 years ago
ChangeLog.1999.gz * separated and compressed changelogs from 1999 and 2000 25 years ago
ChangeLog.2000.gz * separated and compressed changelogs from 1999 and 2000 25 years ago
ChangeLog.2001.gz * archive the 2001 changelog 24 years ago
ChangeLog.2002.gz rotate changelog 23 years ago
ChangeLog.2003.gz - Compress 2003 changelog 22 years ago
ChangeLog.2004.gz - Compressed 2004 Changelog 21 years ago
EXTENSIONS MFH 18 years ago
INSTALL update install instructions (auto-generated from phpdoc XML sources) 19 years ago
LICENSE Update license to 3.01 20 years ago
Makefile.frag - Allow build without flex/bison installed (fixes builddir != srcdir build 19 years ago
Makefile.gcov remove --show-details from lcov's genhtml, as currently we don't separate the coverage data per test, making this option useless 19 years ago
Makefile.global - MFH Allow zend_extensions to be build inside ext and tested with 'make test' 18 years ago
NEWS Fixed bug #44414 (Incomplete reporting about abstract methods) 18 years ago
README.CVS-RULES - MFH 18 years ago
README.EXTENSIONS * zend_module_entry change: apino, debug and zts are moved first, 24 years ago
README.EXT_SKEL ok, re-adding this mostly un-maintained awk/sed/sh nightmare for now ... 23 years ago
README.MAILINGLIST_RULES MFH 18 years ago
README.PARAMETER_PARSING_API MFH 18 years ago
README.PHP4-TO-PHP5-THIN-CHANGES new incompatibilities. maybe someone from the doc group will update the 22 years ago
README.QNX PHP 4.0 27 years ago
README.RELEASE_PROCESS MFH 18 years ago
README.SELF-CONTAINED-EXTENSIONS Improve the wording in this paragraph. 23 years ago
README.STREAMS Added notes about locking functions. 23 years ago
README.SUBMITTING_PATCH Typos found by Petras Kudaras. 22 years ago
README.TESTING typo 22 years ago
README.TESTING2 many new enhancements to run-tests that allow for testing cgi and other 23 years ago
README.UNIX-BUILD-SYSTEM Update documentation for PHP 5. 23 years ago
README.UPDATE_5_2 update xmlwriter_write_dtd_entity parameters 19 years ago
README.WIN32-BUILD-SYSTEM Now that it has matured somewhat, don't discourage questions about it 22 years ago
README.Zeus - Change from PHP5 -> PHP 5 22 years ago
README.input_filter Pierre requested an update to this. I don't think it makes sense to 19 years ago
README.namespaces T_IMPORT -> T_USE 18 years ago
TODO Removed completed TODO items 19 years ago
TODO-5.1 Slated for PHP 6 20 years ago
TODO-PHP5 Update TODO: filter extension was added 19 years ago
UPGRADING typofix 19 years ago
acconfig.h.in Wipe out acconfig.h.in and rewrite some checks to use PHP_ARG_ENABLE. 26 years ago
acinclude.m4 - MFH Allow zend_extensions to be build inside ext and tested with 'make test' 18 years ago
buildconf MFH: - Made build system less major version dependant to ease MFB/MFH 19 years ago
buildconf.bat - MFH: pass parameters to buildconf.bat over to buildconf.js (#43281) 18 years ago
config.guess - Update bundled libtool to 1.5.20 20 years ago
config.sub - Update bundled libtool to 1.5.20 20 years ago
configure.in MFH: Fix Darwin 9/Mac OS X 10.5 build problems, or at least patch them 18 years ago
cvsclean Renaming cvsclean target; IRIX make seems to ignore .PHONY 22 years ago
cvsclean.bat "Real" cvsclean, works as the unix version does 22 years ago
footer consistent with the used style 23 years ago
genfiles MFH 20 years ago
header Update copyright 18 years ago
ltmain.sh - Update bundled libtool to 1.5.20 20 years ago
makedist Download pear phar file when making a distribution package 20 years ago
makerpm - Change from PHP5 -> PHP 5 22 years ago
php.gif fix logo (proper spacing between the letters) 20 years ago
php.ini-dist MFH 18 years ago
php.ini-recommended MFH 18 years ago
php5.spec.in - Renamed all *php4* files to *php5*, changed all php4/PHP4 to php5/PHP5 22 years ago
run-tests.php Using new magic constant __DIR__ in run-tests.php 18 years ago
server-tests-config.php - MFH Fix filename 20 years ago
server-tests.php Update copyright 18 years ago
snapshot Integration of -ng changes. Changes: 26 years ago
stamp-h.in # Fix ColorResolve bogosity 26 years ago
stub.c Add newline. Recent GCC snapshots segfault, if the input file is completely 25 years ago

README.namespaces

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.

Namespaces are defined the following way:

Zend/DB/Connection.php:
<?php
namespace Zend::DB;

class Connection {
}

function connect() {
}
?>

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. Several files may be using the same namespace.
The namespace declaration statement must be the very first statement in
the file. The only exception is "declare" statement that can be used before.

Every class and function in a namespace can be referred to by the full name
- e.g. Zend::DB::Connection or Zend::DB::connect - at any time.

<?php
require 'Zend/Db/Connection.php';
$x = new Zend::DB::Connection;
Zend::DB::connect();
?>

Namespace or class name can be imported:

<?php
require 'Zend/Db/Connection.php';
use Zend::DB;
use Zend::DB::Connection as DbConnection;

$x = new Zend::DB::Connection();
$y = new DB::connection();
$z = new DbConnection();
DB::connect();
?>

The use statement only defines name aliasing. It may create name alias for
namespace or class. The simple form of statement "use A::B::C::D;" is
equivalent to "use A::B::C::D as D;". The use statement can be used at any
time in the global scope (not inside function/class) and takes effect from
the point of definition down to the end of file. It is recommended however to
place the use statements at the beginning of the file. The use statements have
effect only on the file where they appear.

The special "empty" namespace (:: prefix) is useful as explicit global
namespace qualification. All class and function names started from ::
interpreted as global.

<?php
namespace A::B::C;

$con = ::mysql_connect(...);
?>

A special constant __NAMESPACE__ contains the name of the current namespace.
It can be used to construct fully-qualified names to pass them as callbacks.

<?php
namespace A::B::C;

function foo() {
}

set_error_handler(__NAMESPACE__ . "::foo");
?>

In global namespace __NAMESPACE__ constant has the value of empty string.

Names inside namespace are resolved according to the following rules:

1) all qualified names are translated during compilation according to
current import rules. So if we have "use A::B::C" and then "C::D::e()"
it is translated to "A::B::C::D::e()".
2) unqualified class names translated during compilation according to
current import rules. So if we have "use A::B::C" and then "new C()" it
is translated to "new A::B::C()".
3) inside namespace, calls to unqualified functions that are defined in
current namespace (and are known at the time the call is parsed) are
interpreted as calls to these namespace functions.
4) inside namespace, calls to unqualified functions that are not defined
in current namespace are resolved at run-time. The call to function foo()
inside namespace (A::B) first tries to find and call function from current
namespace A::B::foo() and if it doesn't exist PHP tries to call internal
function foo(). Note that using foo() inside namespace you can call only
internal PHP functions, however using ::foo() you are able to call any
function from the global namespace.
5) unqualified class names are resolved at run-time. E.q. "new Exception()"
first tries to use (and autoload) class from current namespace and in case
of failure uses internal PHP class. Note that using "new A" in namespace
you can only create class from this namespace or internal PHP class, however
using "new ::A" you are able to create any class from the global namespace.
6) Calls to qualified functions are resolved at run-time. Call to
A::B::foo() first tries to call function foo() from namespace A::B, then
it tries to find class A::B (__autoload() it if necessary) and call its
static method foo()
7) qualified class names are interpreted as class from corresponding
namespace. So "new A::B::C()" refers to class C from namespace A::B.

Examples
--------
<?php
namespace A;
foo(); // first tries to call "foo" defined in namespace "A"
// then calls internal function "foo"
::foo(); // calls function "foo" defined in global scope
?>

<?php
namespace A;
new B(); // first tries to create object of class "B" defined in namespace "A"
// then creates object of internal class "B"
new ::B(); // creates object of class "B" defined in global scope
?>

<?php
namespace A;
new A(); // first tries to create object of class "A" from namespace "A" (A::A)
// then creates object of internal class "A"
?>

<?php
namespace A;
B::foo(); // first tries to call function "foo" from namespace "A::B"
// then calls method "foo" of internal class "B"
::B::foo(); // first tries to call function "foo" from namespace "B"
// then calls method "foo" of class "B" from global scope
?>

The worst case if class name conflicts with namespace name
<?php
namespace A;
A::foo(); // first tries to call function "foo" from namespace "A::A"
// then tries to call method "foo" of class "A" from namespace "A"
// then tries to call function "foo" from namespace "A"
// then calls method "foo" of internal class "A"
::A::foo(); // first tries to call function "foo" from namespace "A"
// then calls method "foo" of class "A" from global scope
?>

TODO
====

* Support for namespace constants?

* performance problems
- calls to internal functions in namespaces are slower, because PHP first
looks 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 ReflectionNamespace class
+ getName()
+ getClasses()
+ getFunctions()
+ getFiles()
* Add getNamespace() methods to ReflectionClass and ReflectionFunction

* Rename namespaces to packages?