From:             
Operating system: Mac OS X 10.6.2
PHP version:      5.3.3
Package:          Class/Object related
Bug Type:         Bug
Bug description:ReflectionClass::newInstanceArgs does not work for classes 
without constructors

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 bug report at http://bugs.php.net/bug.php?id=52854&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=52854&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=52854&r=trysnapshot53
Try a snapshot (trunk):              
http://bugs.php.net/fix.php?id=52854&r=trysnapshottrunk
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=52854&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=52854&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=52854&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=52854&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=52854&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=52854&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=52854&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=52854&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=52854&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=52854&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=52854&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=52854&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=52854&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=52854&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=52854&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=52854&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=52854&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=52854&r=mysqlcfg

Reply via email to