note 85591 added to language.oop5.late-static-bindings

From: Date: Sun, 07 Sep 2008 16:01:41 +0000
Subject: note 85591 added to language.oop5.late-static-bindings
Groups: php.notes 
Request: Send a blank email to php-notes+get-144228@lists.php.net to get a copy of this message
I have been dying to see this issue resolved. I'm very much looking forward to the production release of PHP 5.3... In my case I have been trying to do the following: class A { function __construct() { echo "I was called by " . static::__CLASS__; } } class B extends A { function Foo() { echo "I am class " . __CLASS__; } } $b = new B; // Should echo "I was called by B" $b->Foo(); // Should echo "I am class B" At the moment I do the following workaround: class A { function __construct($child) { echo "I was called by " . $child; } } class B extends A { function __construct() { parent::__construct(__CLASS__); } function Foo() { echo "I am class " . __CLASS__; } } $b = new B; // Echos "I was called by B" $b->Foo(); // Echo "I am class B" As you can see, my current workaround has some overhead and is not as water-tight as the late static binding method. ---- Server IP: 92.48.100.16 Probable Submitter: 78.145.88.69 ---- Manual Page -- http://www.php.net/manual/en/language.oop5.late-static-bindings.php Edit -- https://master.php.net/note/edit/85591 Del: integrated -- https://master.php.net/note/delete/85591/integrated Del: useless -- https://master.php.net/note/delete/85591/useless Del: bad code -- https://master.php.net/note/delete/85591/bad+code Del: spam -- https://master.php.net/note/delete/85591/spam Del: non-english -- https://master.php.net/note/delete/85591/non-english Del: in docs -- https://master.php.net/note/delete/85591/in+docs Del: other reasons-- https://master.php.net/note/delete/85591 Reject -- https://master.php.net/note/reject/85591 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#144228) next »