bug81611.phpt 1.2 KB

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