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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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

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: Mon Sep 16 19:01:28 2024 UTC