Annotation of embedaddon/php/Zend/tests/bug36214.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Bug #36214 (__get method works properly only when conditional operator is used)
                      3: --SKIPIF--
                      4: <?php if (!extension_loaded("spl")) die("skip SPL is no available"); ?>
                      5: --FILE--
                      6: <?php
                      7: class context {
                      8:   public $stack = array();
                      9: 
                     10:   public function __set($name,$var) {
                     11:     $this->stack[$name] = $var;return;
                     12:   }
                     13: 
                     14:   public function &__get($name) {
                     15:     return $this->stack[$name];
                     16:   }
                     17: }
                     18: 
                     19: $ctx = new context;
                     20: $ctx->comment_preview = array();
                     21: $ctx->comment_preview[0] = 1;
                     22: $ctx->comment_preview[1] = 2;
                     23: var_dump($ctx->comment_preview);
                     24: 
                     25: $comment_preview = array();
                     26: $comment_preview[0] = 1;
                     27: $comment_preview[1] = 2;
                     28: $ctx->comment_preview = $comment_preview;
                     29: var_dump($ctx->comment_preview);
                     30: 
                     31: $ctx->comment_preview = new ArrayObject();
                     32: $ctx->comment_preview[0] = 1;
                     33: $ctx->comment_preview[1] = 2;
                     34: var_dump($ctx->comment_preview);
                     35: ?>
                     36: --EXPECTF--
                     37: array(2) {
                     38:   [0]=>
                     39:   int(1)
                     40:   [1]=>
                     41:   int(2)
                     42: }
                     43: array(2) {
                     44:   [0]=>
                     45:   int(1)
                     46:   [1]=>
                     47:   int(2)
                     48: }
                     49: object(ArrayObject)#%d (1) {
                     50:   ["storage":"ArrayObject":private]=>
                     51:   array(2) {
                     52:     [0]=>
                     53:     int(1)
                     54:     [1]=>
                     55:     int(2)
                     56:   }
                     57: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>