1--TEST-- 2Reflection Bug #81611 (ArgumentCountError when getting default value from ReflectionParameter with new) 3--FILE-- 4<?php 5 6class Bar 7{ 8} 9 10class Foo extends Bar 11{ 12 public function doFoo(object $test = new self()): object 13 { 14 return $test; 15 } 16 17 public function doBar(object $test = new parent()): object 18 { 19 return $test; 20 } 21} 22 23$ref = new \ReflectionClass(Foo::class); 24 25foreach (['doFoo', 'doBar'] as $method) { 26 $params = $ref->getMethod($method)->getParameters(); 27 28 foreach ($params as $param) { 29 echo "isDefaultValueAvailable:\n"; 30 var_dump($param->isDefaultValueAvailable()); 31 32 echo "isDefaultValueConstant:\n"; 33 var_dump($param->isDefaultValueConstant()); 34 35 echo "getDefaultValueConstantName:\n"; 36 var_dump($param->getDefaultValueConstantName()); 37 38 echo "getDefaultValue:\n"; 39 var_dump($param->getDefaultValue()); 40 41 echo "\n"; 42 } 43} 44?> 45--EXPECT-- 46isDefaultValueAvailable: 47bool(true) 48isDefaultValueConstant: 49bool(false) 50getDefaultValueConstantName: 51NULL 52getDefaultValue: 53object(Foo)#2 (0) { 54} 55 56isDefaultValueAvailable: 57bool(true) 58isDefaultValueConstant: 59bool(false) 60getDefaultValueConstantName: 61NULL 62getDefaultValue: 63object(Bar)#3 (0) { 64} 65