Re: new_object_array()
| From: | Timm Friebe | Date: | Sun, 25 Apr 2004 17:20:11 +0000 |
| Subject: | Re: new_object_array() | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-9555@lists.php.net to get a copy of this message | ||
On Sun, 2004-04-25 at 19:02, Julian Reich wrote:
> 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);
> }
How about:
return call_user_func_array(
array(new ReflectionClass($className), 'newInstance'),
$functionParameters
);
Untested but should work.
- Timm