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