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 public $object; 16 17 public function __construct() { 18 $this->object = new test_props; 19 } 20 21 public function getArray() { 22 return $this->array; 23 } 24 25 public function getString() { 26 return $this->string; 27 } 28 29 public function case1() { 30 foreach ($this->array as $foo) { 31 echo $foo; 32 } 33 } 34 35 public function case2() { 36 foreach ($this->foobar as $foo); 37 } 38 39 public function case3() { 40 foreach ($this->string as $foo); 41 } 42 43 public function case4() { 44 foreach ($this->getArray() as $foo); 45 } 46 47 public function case5() { 48 foreach ($this->getString() as $foo); 49 } 50 51 public function case6() { 52 foreach ($this->object as $foo) { 53 echo $foo; 54 } 55 } 56} 57$test = new test(); 58$test->case1(); 59$test->case2(); 60$test->case3(); 61$test->case4(); 62$test->case5(); 63$test->case6(); 64echo "\n"; 65echo "===DONE==="; 66?> 67--EXPECTF-- 68123 69Warning: Undefined property: test::$foobar in %s on line %d 70 71Warning: foreach() argument must be of type array|object, null given in %s on line %d 72 73Warning: foreach() argument must be of type array|object, string given in %s on line %d 74 75Warning: foreach() argument must be of type array|object, string given in %s on line %d 76123 77===DONE=== 78