note 111312 added to function.get-called-class
| From: | luc at s dot illi dot be | Date: | Tue, 05 Feb 2013 15:09:32 +0000 |
| Subject: | note 111312 added to function.get-called-class | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-193532@lists.php.net to get a copy of this message | ||
get_called_class() in closure-scopes:
<?PHP
ABSTRACT CLASS Base
{
protected static $stub = ['baz'];
//final public function boot()
static public function boot()
{
print __METHOD__.'-> '.get_called_class().PHP_EOL;
array_walk(static::$stub, function()
{
print __METHOD__.'-> '.get_called_class().PHP_EOL;
});
}
public function __construct()
{
self::boot();
print __METHOD__.'-> '.get_called_class().PHP_EOL;
array_walk(static::$stub, function()
{
print __METHOD__.'-> '.get_called_class().PHP_EOL;
});
}
}
CLASS Sub EXTENDS Base
{
}
// static boot
Base::boot(); print PHP_EOL;
// Base::boot -> Base
// Base::{closure} -> Base
Sub::boot(); print PHP_EOL;
// Base::boot -> Sub
// Base::{closure} -> Base
new sub;
// Base::boot -> Sub
// Base::{closure} -> Base
// Base->__construct -> Sub
// Base->{closure} -> Sub
// instance boot
new sub;
// Base->boot -> Sub
// Base->{closure} -> Sub
// Base->__construct -> Sub
// Base->{closure} -> Sub
?>
----
Server IP: 69.147.83.199
Probable Submitter: 88.153.57.110
----
Manual Page -- http://php.net/manual/en/function.get-called-class.php
Edit -- https://master.php.net/note/edit/111312
Del: integrated -- https://master.php.net/note/delete/111312/integrated
Del: useless -- https://master.php.net/note/delete/111312/useless
Del: bad code -- https://master.php.net/note/delete/111312/bad+code
Del: spam -- https://master.php.net/note/delete/111312/spam
Del: non-english -- https://master.php.net/note/delete/111312/non-english
Del: in docs -- https://master.php.net/note/delete/111312/in+docs
Del: other reasons-- https://master.php.net/note/delete/111312
Reject -- https://master.php.net/note/reject/111312
Search -- https://master.php.net/manage/user-notes.php