bug27439.phpt 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. --TEST--
  2. Bug #27439 (foreach() with $this segfaults)
  3. --FILE--
  4. <?php
  5. class test_props {
  6. public $a = 1;
  7. public $b = 2;
  8. public $c = 3;
  9. }
  10. class test {
  11. public $array = array(1,2,3);
  12. public $string = "string";
  13. public function __construct() {
  14. $this->object = new test_props;
  15. }
  16. public function getArray() {
  17. return $this->array;
  18. }
  19. public function getString() {
  20. return $this->string;
  21. }
  22. public function case1() {
  23. foreach ($this->array as $foo) {
  24. echo $foo;
  25. }
  26. }
  27. public function case2() {
  28. foreach ($this->foobar as $foo);
  29. }
  30. public function case3() {
  31. foreach ($this->string as $foo);
  32. }
  33. public function case4() {
  34. foreach ($this->getArray() as $foo);
  35. }
  36. public function case5() {
  37. foreach ($this->getString() as $foo);
  38. }
  39. public function case6() {
  40. foreach ($this->object as $foo) {
  41. echo $foo;
  42. }
  43. }
  44. }
  45. $test = new test();
  46. $test->case1();
  47. $test->case2();
  48. $test->case3();
  49. $test->case4();
  50. $test->case5();
  51. $test->case6();
  52. echo "\n";
  53. echo "===DONE===";
  54. ?>
  55. --EXPECTF--
  56. 123
  57. Notice: Undefined property: test::$foobar in %s on line %d
  58. Warning: Invalid argument supplied for foreach() in %s on line %d
  59. Warning: Invalid argument supplied for foreach() in %s on line %d
  60. Warning: Invalid argument supplied for foreach() in %s on line %d
  61. 123
  62. ===DONE===