inheritance_005.phpt 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. --TEST--
  2. Check for inherited old-style constructor.
  3. --FILE--
  4. <?php
  5. class A
  6. {
  7. function A()
  8. {
  9. echo "In " . __METHOD__ . "\n";
  10. }
  11. }
  12. class B extends A
  13. {
  14. }
  15. class C extends B
  16. {
  17. }
  18. echo "About to construct new B: \n";
  19. $b = new B;
  20. echo "Is B::B() callable?\n";
  21. var_dump(is_callable(array($b, "B")));
  22. echo "Is B::A() callable?\n";
  23. var_dump(is_callable(array($b, "A")));
  24. echo "About to construct new C: \n";
  25. $c = new C;
  26. echo "Is C::A() callable?\n";
  27. var_dump(is_callable(array($c, "A")));
  28. echo "Is C::B() callable?\n";
  29. var_dump(is_callable(array($c, "B")));
  30. echo "Is C::C() callable?\n";
  31. var_dump(is_callable(array($c, "C")));
  32. ?>
  33. --EXPECTF--
  34. Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; A has a deprecated constructor in %s on line %d
  35. About to construct new B:
  36. In A::A
  37. Is B::B() callable?
  38. bool(false)
  39. Is B::A() callable?
  40. bool(true)
  41. About to construct new C:
  42. In A::A
  43. Is C::A() callable?
  44. bool(true)
  45. Is C::B() callable?
  46. bool(false)
  47. Is C::C() callable?
  48. bool(false)