Browse Source
- Fixed bug #35106 (nested foreach fails when array variable has a reference).
- Fixed bug #35106 (nested foreach fails when array variable has a reference).
- Fixed bug #36214 (__get method works properly only when conditional operator is used). - Fixed bug #39449 (Overloaded array properties do not work correctly). - Fixed bug #39990 (Cannot "foreach" over overloaded properties).experimental/5.2-WITH_DRCP
16 changed files with 231 additions and 37 deletions
-
7NEWS
-
14Zend/tests/bug35106.phpt
-
52Zend/tests/bug36214.phpt
-
3Zend/tests/bug38146.phpt
-
40Zend/tests/bug39449.phpt
-
17Zend/tests/bug39990.phpt
-
50Zend/zend_compile.c
-
5Zend/zend_compile.h
-
3Zend/zend_execute.c
-
6Zend/zend_execute.h
-
31Zend/zend_hash.c
-
8Zend/zend_hash.h
-
16Zend/zend_language_parser.y
-
3Zend/zend_object_handlers.c
-
5Zend/zend_vm_def.h
-
8Zend/zend_vm_execute.h
@ -0,0 +1,14 @@ |
|||
--TEST-- |
|||
Bug #35106 (nested foreach fails when array variable has a reference) |
|||
--FILE-- |
|||
<?php |
|||
$a=array("1","2"); |
|||
$b=&$a; |
|||
foreach($a as $i){ |
|||
echo $i; |
|||
foreach($a as $p); |
|||
} |
|||
echo "\n"; |
|||
?> |
|||
--EXPECT-- |
|||
12 |
|||
@ -0,0 +1,52 @@ |
|||
--TEST-- |
|||
Bug #36214 (__get method works properly only when conditional operator is used) |
|||
--FILE-- |
|||
<?php |
|||
class context { |
|||
public $stack = array(); |
|||
|
|||
public function __set($name,$var) { |
|||
$this->stack[$name] = $var;return; |
|||
} |
|||
|
|||
public function &__get($name) { |
|||
return $this->stack[$name]; |
|||
} |
|||
} |
|||
|
|||
$ctx = new context; |
|||
$ctx->comment_preview = array(); |
|||
$ctx->comment_preview[0] = 1; |
|||
$ctx->comment_preview[1] = 2; |
|||
var_dump($ctx->comment_preview); |
|||
|
|||
$comment_preview = array(); |
|||
$comment_preview[0] = 1; |
|||
$comment_preview[1] = 2; |
|||
$ctx->comment_preview = $comment_preview; |
|||
var_dump($ctx->comment_preview); |
|||
|
|||
$ctx->comment_preview = new ArrayObject(); |
|||
$ctx->comment_preview[0] = 1; |
|||
$ctx->comment_preview[1] = 2; |
|||
var_dump($ctx->comment_preview); |
|||
?> |
|||
--EXPECT-- |
|||
array(2) { |
|||
[0]=> |
|||
int(1) |
|||
[1]=> |
|||
int(2) |
|||
} |
|||
array(2) { |
|||
[0]=> |
|||
int(1) |
|||
[1]=> |
|||
int(2) |
|||
} |
|||
object(ArrayObject)#2 (2) { |
|||
[0]=> |
|||
int(1) |
|||
[1]=> |
|||
int(2) |
|||
} |
|||
@ -0,0 +1,40 @@ |
|||
--TEST-- |
|||
Bug #39449 (Overloaded array properties do not work correctly) |
|||
--FILE-- |
|||
<?php |
|||
class A { |
|||
private $keys = array(); |
|||
public function & __get($val) { |
|||
return $this->keys[$val]; |
|||
} |
|||
public function __set($k, $v) { |
|||
$this->keys[$k] = $v; |
|||
} |
|||
} |
|||
|
|||
$a =new A(); |
|||
$a->arr = array('a','b','c'); |
|||
|
|||
$b = &$a->arr; |
|||
$b[]= 'd'; |
|||
|
|||
foreach ($a->arr as $k => $v) { |
|||
echo "$k => $v\n"; |
|||
} |
|||
|
|||
$a->arr[]='d'; |
|||
|
|||
foreach ($a->arr as $k => $v) { |
|||
echo "$k => $v\n"; |
|||
} |
|||
?> |
|||
--EXPECT-- |
|||
0 => a |
|||
1 => b |
|||
2 => c |
|||
3 => d |
|||
0 => a |
|||
1 => b |
|||
2 => c |
|||
3 => d |
|||
4 => d |
|||
@ -0,0 +1,17 @@ |
|||
--TEST-- |
|||
Bug #39990 (Cannot "foreach" over overloaded properties) |
|||
--FILE-- |
|||
<?php |
|||
class Foo { |
|||
public function __get($name) { |
|||
return array('Hello', 'World'); |
|||
} |
|||
} |
|||
|
|||
$obj=new Foo(); |
|||
foreach($obj->arr as $value) |
|||
echo "$value\n"; |
|||
?> |
|||
--EXPECT-- |
|||
Hello |
|||
World |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue