note 78059 added to language.oop5.overloading
| From: | lokrain at gmail dot com | Date: | Wed, 26 Sep 2007 09:05:21 +0000 |
| Subject: | note 78059 added to language.oop5.overloading | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-130794@lists.php.net to get a copy of this message | ||
Let us look at the following example:
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
----
Server IP: 62.237.7.3
Probable Submitter: 193.142.0.1
----
Manual Page -- http://www.php.net/manual/en/language.oop5.overloading.php
Edit -- https://master.php.net/note/edit/78059
Del: integrated -- https://master.php.net/note/delete/78059/integrated
Del: useless -- https://master.php.net/note/delete/78059/useless
Del: bad code -- https://master.php.net/note/delete/78059/bad+code
Del: spam -- https://master.php.net/note/delete/78059/spam
Del: non-english -- https://master.php.net/note/delete/78059/non-english
Del: in docs -- https://master.php.net/note/delete/78059/in+docs
Del: other reasons-- https://master.php.net/note/delete/78059
Reject -- https://master.php.net/note/reject/78059
Search -- https://master.php.net/manage/user-notes.php