cvs: ZendEngine2 / ZEND_CHANGES

From: Date: Mon, 20 Oct 2003 10:06:31 +0000
Subject: cvs: ZendEngine2 / ZEND_CHANGES
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-1923@lists.php.net to get a copy of this message
helly Mon Oct 20 06:06:31 2003 EDT Modified files: /ZendEngine2 ZEND_CHANGES Log: Update Index: ZendEngine2/ZEND_CHANGES diff -u ZendEngine2/ZEND_CHANGES:1.57 ZendEngine2/ZEND_CHANGES:1.58 --- ZendEngine2/ZEND_CHANGES:1.57 Sun Jun 29 05:40:23 2003 +++ ZendEngine2/ZEND_CHANGES Mon Oct 20 06:06:31 2003 @@ -125,7 +125,8 @@ $o->test(); ?> - Abstract classes cannot be instantiated. + Abstract classes cannot be instantiated and must not contain + abstract methods. Old code that has no user-defined classes or functions named 'abstract' should run without modifications. @@ -205,11 +206,11 @@ This syntax only applies to objects/classes, not built-in types. - * final. + * Final methods and classes. The Zend Engine 2.0 introduces the "final" keyword to declare final members and methods. Those cannot be overridden by - sub-classes. + sub-classes. Example: @@ -221,6 +222,23 @@ } ?> + It is furthermore possible to make a class final. Doing this + prevents a class from being specialized (it cannot be inherited + by another class). There's no need to declare the methods of + a final class themselves as final. + + Example: + + <?php + final class Foo { + // class definition + } + // the next line is impossible + // class Bork extends Foo {} + ?> + + Properties cannot be final. + Old code that has no user-defined classes or functions named 'final' should run without modifications. @@ -474,8 +492,7 @@ ShapeFactoryMethod('Square')->draw(); ?> - * Static member variables of static classes can now be - initialized. + * Static member variables of classes can now be initialized. Example: @@ -605,6 +622,86 @@ $a = $foo->test(1, '2', 3.4, true); var_dump($a); ?> + + * Iteration + + Objects may be iterated in an overloaded way when used with + foreach. The default behavior is to iterate over all properties. + + Example: + + <?php + class Foo { + var $x = 1; + var $y = 2; + } + + $obj = new Foo; + + foreach ($obj as $prp_name => $prop_value) { + // using the property + } + ?> + + TBD: Respect visibility: Show protected only when inside class + method and only otherwise public properties only. + + * __METHOD__ + + The pseudo constant __METHOD__ shows the current class and method + when used inside a method and the function when used outside of a + class. + + Example: + + <?php + class Foo { + function Show() { + echo __FILE__ . '(' . __LINE__ . ')' . __METHOD__; + } + } + ?> + + * __toString() + + The magic method __toString() allows to overload the object to + string conversion. + + Example: + + <?php + class Foo { + function __toString() { + return "What ever"; + } + + $obj = Foo; + + $str = (string) $obj; // call __toString() + ?> + + * Reflection + + Nearly all aspects of object oriented code can be reflected by + using the reflection API which is documented separatley: + http://sitten-polizei.de/php/reflection_api/docs/language.reflection.html + + Example: + + <?php + class Foo { + public $prop; + function Func($name) { + echo "Hello $name"; + } + + reflection_class::export('Foo'); + reflection_object::export(new Foo); + reflection_method::export('Foo', 'func'); + reflection_property::export('Foo', 'prop'); + reflection_extension::export('standard'); + ?> + Changes in the Zend Engine 1.0

« previous php.zend-engine.cvs (#1923) next »