note 78059 deleted from language.oop5.overloading by levim

From: Date: Mon, 16 Nov 2015 02:09:39 +0000
Subject: note 78059 deleted from language.oop5.overloading by levim
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-204160@lists.php.net to get a copy of this message
Note Submitter: lokrain at gmail dot com ---- Let us look at the following example: <?php class objDriver { private $value; public function __construct() { $value = 1; } public function doSomething($parameterList) { //We make actions with the value } } class WantStaticCall { private static $objectList; private function __construct() public static function init() { self::$objectList = array(); } public static function register($alias) { self::$objectList[$alias] = new objDriver(); } public static function __call($method, $arguments) { $alias = $arguments[0]; array_shift($arguments); call_user_method($method, self::$objectList[$alias], $arguments); } } // The deal here is to use following code: WantStaticCall::register('logger'); WantStaticCall::doSomething('logger', $argumentList); // and we will make objDriver to call his doSomething function with arguments // $argumentList. This is not common pattern but very usefull in some cases. // The problem here is that __call() cannot be static, Is there a way to work it around ?>

« previous php.notes (#204160) next »