You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 lines
1.5 KiB

  1. --TEST--
  2. ReflectionObject::getConstructor() - basic function test
  3. --FILE--
  4. <?php
  5. class NewCtor {
  6. function __construct() {}
  7. }
  8. class ExtendsNewCtor extends NewCtor {
  9. }
  10. class OldCtor {
  11. function OldCtor() {}
  12. }
  13. class ExtendsOldCtor extends OldCtor {
  14. }
  15. class X {
  16. function Y() {}
  17. }
  18. class Y extends X {
  19. }
  20. class OldAndNewCtor {
  21. function OldAndNewCtor() {}
  22. function __construct() {}
  23. }
  24. class NewAndOldCtor {
  25. function __construct() {}
  26. function NewAndOldCtor() {}
  27. }
  28. class B {
  29. function B() {}
  30. }
  31. class C extends B {
  32. function C() {}
  33. }
  34. class D1 extends C {
  35. function __construct() {}
  36. }
  37. class D2 extends C {
  38. }
  39. $classes = array('NewCtor', 'ExtendsNewCtor', 'OldCtor', 'ExtendsOldCtor',
  40. 'OldAndNewCtor', 'NewAndOldCtor', 'B', 'C', 'D1', 'D2', 'X', 'Y');
  41. foreach ($classes as $class) {
  42. $rc = new ReflectionObject(new $class);
  43. $rm = $rc->getConstructor();
  44. if ($rm != null) {
  45. echo "Constructor of $class: " . $rm->getName() . "\n";
  46. } else {
  47. echo "No constructor for $class\n";
  48. }
  49. }
  50. ?>
  51. --EXPECTF--
  52. Strict Standards: Redefining already defined constructor for class OldAndNewCtor in %s on line 26
  53. Strict Standards: %s for class NewAndOldCtor in %s on line 31
  54. Constructor of NewCtor: __construct
  55. Constructor of ExtendsNewCtor: __construct
  56. Constructor of OldCtor: OldCtor
  57. Constructor of ExtendsOldCtor: OldCtor
  58. Constructor of OldAndNewCtor: __construct
  59. Constructor of NewAndOldCtor: __construct
  60. Constructor of B: B
  61. Constructor of C: C
  62. Constructor of D1: __construct
  63. Constructor of D2: C
  64. No constructor for X
  65. No constructor for Y