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
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: sebastian@php.net
New email:
PHP Version: OS:

 

 [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

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-01-24 21:27 UTC] helly@php.net
Implemented in HEAD
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Sep 08 01:01:28 2024 UTC