mirror of
https://github.com/php/php-src.git
synced 2024-10-18 06:52:34 +00:00
53 lines
912 B
Plaintext
53 lines
912 B
Plaintext
|
--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)
|
||
|
}
|