php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #36141 Add ReflectionClass::newInstanceArgs($args)
Submitted: 2006-01-24 12:19 UTC Modified: 2006-01-25 23:04 UTC
From: sebastian@php.net Assigned: helly (profile)
Status: Closed Package: Feature/Change Request
PHP Version: 5.1.2 OS: *
Private report: No CVE-ID: None
 [2006-01-24 12:19 UTC] sebastian@php.net
Description:
------------
An equivalent to ReflectionMethod::invokeArgs() is missing for creating new instances of classes through the Reflection API where the class' constructor requires parameters.

I there propose ReflectionClass::newInstanceArgs($args) in addition to the existing ReflectionClass::newInstance() method.

Reproduce code:
---------------
<?php
class Sample
{
  public function __construct($a, $b)
  {
    print "$a, $b";
  }
}

$class  = new ReflectionClass('Sample');
$object = $class->newInstanceArgs(array(23, 42));
?>

Expected result:
----------------
23, 42


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-01-24 21:27 UTC] helly@php.net
Implemented in HEAD
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 00:01:35 2025 UTC