new_object_array()

From: Date: Sun, 25 Apr 2004 17:02:40 +0000
Subject: new_object_array()
Groups: php.internals 
Request: Send a blank email to internals+get-9554@lists.php.net to get a copy of this message
Hi all, Referring to call_user_func_array() I would like to suggest a new function: new_object_array(). I'm working on a php5 application framework and I would like to implement something I call an unified factory. The problem is that I don't know how many parameters to expect. Here's an example how it's meant to work: <?PHP class Kernel { public function __call($functionName, $functionParameters) { $className = substr($functionName, 3); // code omitted here ... // check for real $className ... return new_object_array($className, $functionParameters); } public function newObject() { $functionParameters = func_get_args(); $className = array_shift($functionParameters); // code omitted here ... // check for real $className ... return new_object_array($className, $functionParameters); } } $Kernel = Kernel::getInstance(); $DbManager = $Kernel->getDbManager('param1', 'param2'); // 1st possibility to get new object $XmlParser = $Kernel->newObject('XmlParser', 'param1', 'param2'); // 2nd possibility to get new object ?> I have written an implementation of new_object_array(); <-- see attachment Perhaps some things need to be rewritten ;) I would be happy if you would consider to include this function in the standard distribution of php. Yours sincerly, Julian Reich

« previous php.internals (#9554) next »