|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2021-11-12 03:27 UTC] camporter1 at gmail dot com
[2021-11-12 09:33 UTC] nikic@php.net
[2021-11-12 17:37 UTC] camporter1 at gmail dot com
[2021-11-12 22:51 UTC] camporter1 at gmail dot com
[2021-11-16 13:40 UTC] git@php.net
[2021-11-16 13:40 UTC] git@php.net
-Status: Open
+Status: Closed
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 03:00:02 2025 UTC |
Description: ------------ Trying to get a default value from ReflectionParameter when the default value contains "new" leads to "Uncaught ArgumentCountError: ReflectionParameter::__construct() expects exactly 2 arguments, 0 given" from an internal function. Test script: --------------- <?php // lint >= 8.1 namespace NewInInitializers; class Foo { public function doFoo( object $test = new self() ): object { return $test; } } class Bar extends Foo { } $ref = new \ReflectionClass(Foo::class); $params = $ref->getMethod('doFoo')->getParameters(); foreach ($params as $param) { var_dump($param->getDefaultValue()); } Expected result: ---------------- object(NewInInitializers\Foo)#1 (0) { } Actual result: -------------- Fatal error: Uncaught ArgumentCountError: ReflectionParameter::__construct() expects exactly 2 arguments, 0 given in /in/aJ2qI:25 Stack trace: #0 [internal function]: ReflectionParameter->__construct() #1 /in/aJ2qI(25): ReflectionParameter->getDefaultValue() #2 {main} thrown in /in/aJ2qI on line 25 Process exited with code 255.