note 69834 deleted from language.oop5.paamayim-nekudotayim by felipe
| From: | felipe@php.net | Date: | Sat, 15 Dec 2007 02:06:10 +0000 |
| Subject: | note 69834 deleted from language.oop5.paamayim-nekudotayim by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-133519@lists.php.net to get a copy of this message | ||
Note Submitter: dexen at google dot me dot up
----
`
self'' and parent'' are valid arguments to the
`new'' operator. All the constructor stuff works as expected. Example:
<?php
class Foo {}
class Bar extends Foo {
static function test() {
return(
array(
new self,
new self(),
new parent( 'a', 1 ),
) );
}
}
print_r( Bar::test() ); ?>
Calling Bar::test() gives you nice list of three instances. ( i'm describing it there, as it
was a suprise to me. ) Maybe you can find it usefull, for example, in some generic ::__clone()
method that works across inheritance tree.