Bug #74035 [Csd->Asn]: getNumberOfRequiredParameters wrong for ReflectionClass::newInstance

From: Date: Mon, 24 Apr 2017 11:19:17 +0000
Subject: Bug #74035 [Csd->Asn]: getNumberOfRequiredParameters wrong for ReflectionClass::newInstance
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-208737@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=74035&edit=1

 ID:                 74035
 User updated by:    fabien dot villepinte at gmail dot com
 Reported by:        fabien dot villepinte at gmail dot com
 Summary:            getNumberOfRequiredParameters wrong for
                     ReflectionClass::newInstance
-Status:             Closed
+Status:             Assigned
 Type:               Bug
 Package:            Reflection related
 PHP Version:        7.1.1
 Block user comment: N
 Private report:     N

 New Comment:

I reopen this issue since the fix has been rollbacked (see https://bugs.php.net/bug.php?id=74292 ).


Previous Comments:
------------------------------------------------------------------------
[2017-02-12 21:04:58] nikic@php.net

Automatic comment on behalf of nikita.ppv@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=eb1373e509a69a48e90e6dd4c2dda1348e19b776
Log: Revert "Fixed bug #74035"

------------------------------------------------------------------------
[2017-02-03 17:30:57] nikic@php.net

Automatic comment on behalf of andrew.nester.dev@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=9ffc6ca62f53431a4b32b30cdda8180142f47cdb
Log: Fixed bug #74035

------------------------------------------------------------------------
[2017-02-03 09:00:40] andrew dot nester dot dev at gmail dot com

Just added PR with fix for the issue.

------------------------------------------------------------------------
[2017-02-02 15:36:06] fabien dot villepinte at gmail dot com

Description:
------------
The method ReflectionFunctionAbstract::getNumberOfRequiredParameters returns 1 for the method
ReflectionClass::newInstance when it can be invoked with no parameter.

Furthermore I think the documentation should be updated because it is unclear if a parameter is
required or not :
http://php.net/manual/en/reflectionclass.newinstance.php

FYI, HHVM returns already the right result : https://3v4l.org/RPXQp

Test script:
---------------
<?php

$r = new ReflectionClass(ReflectionClass::class);
$m = $r->getMethod('newInstance');

echo $m->getNumberOfRequiredParameters(); // returns 1 instead of 0, KO



Expected result:
----------------
0

Actual result:
--------------
1


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=74035&edit=1


Thread (7 messages)

« previous php.bugs (#208737) next »