010.phpt 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. --TEST--
  2. get_parent_class() tests
  3. --FILE--
  4. <?php
  5. interface i {
  6. function test();
  7. }
  8. class foo implements i {
  9. function test() {
  10. var_dump(get_parent_class());
  11. }
  12. }
  13. class bar extends foo {
  14. function test_bar() {
  15. var_dump(get_parent_class());
  16. }
  17. }
  18. $bar = new bar;
  19. $foo = new foo;
  20. $foo->test();
  21. $bar->test();
  22. $bar->test_bar();
  23. var_dump(get_parent_class($bar));
  24. var_dump(get_parent_class($foo));
  25. var_dump(get_parent_class("bar"));
  26. var_dump(get_parent_class("foo"));
  27. var_dump(get_parent_class("i"));
  28. try {
  29. get_parent_class("");
  30. } catch (TypeError $exception) {
  31. echo $exception->getMessage() . "\n";
  32. }
  33. try {
  34. get_parent_class("[[[[");
  35. } catch (TypeError $exception) {
  36. echo $exception->getMessage() . "\n";
  37. }
  38. try {
  39. get_parent_class(" ");
  40. } catch (TypeError $exception) {
  41. echo $exception->getMessage() . "\n";
  42. }
  43. var_dump(get_parent_class(new stdclass));
  44. try {
  45. get_parent_class(array());
  46. } catch (TypeError $exception) {
  47. echo $exception->getMessage() . "\n";
  48. }
  49. try {
  50. get_parent_class(1);
  51. } catch (TypeError $exception) {
  52. echo $exception->getMessage() . "\n";
  53. }
  54. echo "Done\n";
  55. ?>
  56. --EXPECT--
  57. bool(false)
  58. bool(false)
  59. string(3) "foo"
  60. string(3) "foo"
  61. bool(false)
  62. string(3) "foo"
  63. bool(false)
  64. bool(false)
  65. get_parent_class(): Argument #1 ($object_or_class) must be an object or a valid class name, string given
  66. get_parent_class(): Argument #1 ($object_or_class) must be an object or a valid class name, string given
  67. get_parent_class(): Argument #1 ($object_or_class) must be an object or a valid class name, string given
  68. bool(false)
  69. get_parent_class(): Argument #1 ($object_or_class) must be an object or a valid class name, array given
  70. get_parent_class(): Argument #1 ($object_or_class) must be an object or a valid class name, int given
  71. Done