File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / Zend / tests / bug36214.phpt
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue Feb 21 23:47:52 2012 UTC (13 years, 1 month ago) by misho
Branches: php, MAIN
CVS tags: v5_4_3elwix, v5_4_29p0, v5_4_29, v5_4_20p0, v5_4_20, v5_4_17p0, v5_4_17, v5_3_10, HEAD
php

    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>