From: Sebastian Bergmann Date: Thu, 6 Mar 2003 16:30:21 +0000 (+0000) Subject: D some TBDs X-Git-Tag: RELEASE_0_5~587 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8f8a534c7a7d2524c8d8163a9d7d6eb2d3f14ccf;p=php D some TBDs --- diff --git a/Zend/ZEND_CHANGES b/Zend/ZEND_CHANGES index 0c2420afc7..0fc47364ee 100644 --- a/Zend/ZEND_CHANGES +++ b/Zend/ZEND_CHANGES @@ -69,7 +69,141 @@ Changes in the Zend Engine 2.0 class they are declared in, whereas private member variables can only be accessed by the class they belong to. - * Private and protected methods. (TBD) + * Private and protected methods. + + The Zend Engine 2.0 introduces private and protected methods. + + Example: + + aPrivateMethod(); + } + } + + class Bar extends Foo { + public function aPublicMethod() { + echo "Bar::aPublicMethod() called.\n"; + $this->aProtectedMethod(); + } + } + + $o = new Bar; + $o->aPublicMethod(); + ?> + + Old code that has no user-defined classes or functions named + 'public', 'protected' or 'private' should run without modifications. + + * Abstract Methods. + + The Zend Engine 2.0 introduces abstract methods. An abstract + method only declares the method's signature and does not + provide an implementation. + + Example: + + test(); + ?> + + A class containing abstract methods may be instantiated, but + calling its abstract methods will result in an error. + + Old code that has no user-defined classes or functions named + 'abstract' should run without modifications. + + * Interfaces. + + The Zend Engine 2.0 introduces interfaces. A class may implement + an arbitrary list of interfaces. + + Example: + + + + Old code that has no user-defined classes or functions named + 'interface' or 'implements' should run without modifications. + + * Class Type Hints. + + While remaining loosely typed the Zend Engine 2.0 introduces the + ability to use class type hints to declare the expected class of + objects that are passed as parameters to a method. + + Example: + + a($b); + $a->b($b); + ?> + + These class type hints are not checked upon compilation, as would + be the case in a typed language, but during runtime. + + This means that + + function foo(Class $object) { + // .. + } + + is equivalent to + + function foo(Class $object) { + if (!($object instanceof Class)) { + die('Argument 1 must be an instance of Class'); + } + } + + This syntax only applies to objects/classes, not built-in types. * Object Cloning. @@ -353,9 +487,25 @@ Changes in the Zend Engine 2.0 print foo::$my_static; ?> - * Static methods. (TBD) + * Static Methods. + + The Zend Engine 2.0 introduces the 'static' keyword to declare + a method static, thus callable from outside the object context. + + Example: - * Abstract methods. (TBD) + + + The pseudo variable $this is not available inside a method that + has been declared static. * instanceof (TBD) @@ -379,7 +529,22 @@ Changes in the Zend Engine 2.0 } ?> - * __autoload(). TBD. + * __autoload(). + + The __autoload() interceptor function will be automatically called + when an undeclared class is to be instantiated. The name of that + class will be passed to the __autoload() interceptor function as its + only argument. + + Example: + + * Method calls and property accesses can be overloaded by class methods __call(), __get() and __set().