php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74035 getNumberOfRequiredParameters wrong for ReflectionClass::newInstance
Submitted: 2017-02-02 15:36 UTC Modified: 2019-02-10 16:33 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: fabien dot villepinte at gmail dot com Assigned: carusogabriel (profile)
Status: Closed Package: Reflection related
PHP Version: Next major version OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: fabien dot villepinte at gmail dot com
New email:
PHP Version: OS:

 

 [2017-02-02 15:36 UTC] 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

Patches

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-02-03 09:00 UTC] andrew dot nester dot dev at gmail dot com
Just added PR with fix for the issue.
 [2017-02-03 17:30 UTC] 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 17:30 UTC] nikic@php.net
-Status: Open +Status: Closed
 [2017-02-12 21:04 UTC] 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 &quot;Fixed bug #74035&quot;
 [2017-04-24 11:19 UTC] fabien dot villepinte at gmail dot com
-Status: Closed +Status: Assigned
 [2017-04-24 11:19 UTC] fabien dot villepinte at gmail dot com
I reopen this issue since the fix has been rollbacked (see https://bugs.php.net/bug.php?id=74292 ).
 [2017-10-24 06:06 UTC] kalle@php.net
-Status: Assigned +Status: Open
 [2018-09-21 05:35 UTC] carusogabriel@php.net
-PHP Version: 7.1.1 +PHP Version: Next major version -Assigned To: +Assigned To: carusogabriel
 [2018-09-21 05:35 UTC] carusogabriel@php.net
This is only taking place in our next major version, as discussed in https://github.com/php/php-src/pull/3443
 [2019-02-10 16:33 UTC] carusogabriel@php.net
-Status: Assigned +Status: Closed
 [2019-02-10 16:33 UTC] carusogabriel@php.net
This was fixed and will be available at PHP 8.0.

http://git.php.net/?p=php-src.git;a=commit;h=35db1ccdd
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 13:01:29 2024 UTC