Bug #52854 [Asn->Csd]: ReflectionClass::newInstanceArgs does not work for classes without constructors
| From: | johannes@php.net | Date: | Sun, 21 Nov 2010 12:24:50 +0000 |
| Subject: | Bug #52854 [Asn->Csd]: ReflectionClass::newInstanceArgs does not work for classes without constructors | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-156262@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=52854&edit=1
ID: 52854
Updated by: johannes@php.net
Reported by: mail_ben_schmidt at yahoo dot com dot au
Summary: ReflectionClass::newInstanceArgs does not work for
classes without constructors
-Status: Assigned
+Status: Closed
Type: Bug
Package: Class/Object related
Operating System: Mac OS X 10.6.2
PHP Version: 5.3.3
Assigned To: johannes
Block user comment: N
Private report: N
New Comment:
Fixed for 5.3.4 and trunk.
Previous Comments:
------------------------------------------------------------------------
[2010-11-21 13:24:11] johannes@php.net
Automatic comment from SVN on behalf of johannes
Revision: http://svn.php.net/viewvc/?view=revision&revision=305605
Log: - Fix #52854 (ReflectionClass::newInstanceArgs does not work for
classes without constructors
------------------------------------------------------------------------
[2010-09-15 14:40:33] mail_ben_schmidt at yahoo dot com dot au
Description:
------------
ReflectionClass::newInstanceArgs does not work for classes without
constructors when passed an empty array.
This is a duplicate of bug #49376 which has been marked as bogus.
IMHO, it is not bogus, nor is it a documentation problem.
An empty array semantically means no arguments are to be passed. It is
like the distinction between new Test and new Test(). One has no
argument list, and one has an empty argument list, but both work.
Likewise newInstanceArgs(array()) should work equally to
newInstanceArgs(). It is also ridiculous to give an error which says
"you cannot pass any constructor arguments" when you are not, in fact,
attempting to pass any constructor arguments.
Test script:
---------------
class Test {
}
$c = new ReflectionClass('Test');
$t = new Test;
$t = new Test();
$t = $c->newInstance();
$t = $c->newInstanceArgs(array());
Expected result:
----------------
All four constructions should complete without error.
Actual result:
--------------
"ReflectionException: Class Test does not have a constructor, so you
cannot pass any constructor arguments." referring to the line where
newInstanceArgs is called.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=52854&edit=1