bug38465.phpt 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. --TEST--
  2. Bug #38465 (ReflectionParameter fails on access to self::)
  3. --FILE--
  4. <?php
  5. class Baz {
  6. const B = 3;
  7. }
  8. class Foo {
  9. const X = 1;
  10. public function x($a = self::X, $b = Baz::B, $c = 99) {}
  11. }
  12. class Bar extends Foo {
  13. const Y = 2;
  14. public function y($a = self::Y, $b = Baz::B, $c = 99) {}
  15. }
  16. echo "From global scope:\n";
  17. $clazz = new ReflectionClass('Bar');
  18. foreach ($clazz->getMethods() as $method) {
  19. foreach ($method->getParameters() as $param) {
  20. if ($param->isDefaultValueAvailable()) {
  21. echo $method->getDeclaringClass()->getName(), '::', $method->getName(), '($', $param->getName(), ' = ', $param->getDefaultValue(), ")\n";
  22. }
  23. }
  24. }
  25. echo "\nFrom class context:\n";
  26. class Test {
  27. function __construct() {
  28. $clazz = new ReflectionClass('Bar');
  29. foreach ($clazz->getMethods() as $method) {
  30. foreach ($method->getParameters() as $param) {
  31. if ($param->isDefaultValueAvailable()) {
  32. echo $method->getDeclaringClass()->getName(), '::', $method->getName(), '($', $param->getName(), ' = ', $param->getDefaultValue(), ")\n";
  33. }
  34. }
  35. }
  36. }
  37. }
  38. new Test();
  39. ?>
  40. --EXPECT--
  41. From global scope:
  42. Bar::y($a = 2)
  43. Bar::y($b = 3)
  44. Bar::y($c = 99)
  45. Foo::x($a = 1)
  46. Foo::x($b = 3)
  47. Foo::x($c = 99)
  48. From class context:
  49. Bar::y($a = 2)
  50. Bar::y($b = 3)
  51. Bar::y($c = 99)
  52. Foo::x($a = 1)
  53. Foo::x($b = 3)
  54. Foo::x($c = 99)