List Info

Thread: note 78059 added to language.oop5.overloading




note 78059 added to language.oop5.overloading
user name
2007-09-26 04:05:21
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  -- h
ttps://master.php.net/note/delete/78059/integrated
Del: useless     -- http
s://master.php.net/note/delete/78059/useless
Del: bad code    -- htt
ps://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     -- http
s://master.php.net/note/delete/78059/in+docs
Del: other reasons-- https://mast
er.php.net/note/delete/78059
Reject      -- https://mast
er.php.net/note/reject/78059
Search      -- https://
master.php.net/manage/user-notes.php

-- 
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php


[1]

about | contact  Other archives ( Real Estate discussion Medical topics )