File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / Zend / tests / bug64417.phpt
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Mon Jul 22 01:32:17 2013 UTC (11 years, 8 months ago) by misho
Branches: php, MAIN
CVS tags: v5_4_29p0, v5_4_29, v5_4_20p0, v5_4_20, v5_4_17, HEAD
5.4.17

    1: --TEST--
    2: Bug #64417 (BC break: ArrayAccess::&offsetGet() in a trait causes fatal error)
    3: --FILE--
    4: <?php
    5: trait aa {
    6:     private $container = array();
    7:     public function offsetSet($offset, $value) {
    8:         if (is_null($offset)) {
    9:             $this->container[] = $value;
   10:         } else {
   11:             $this->container[$offset] = $value;
   12:         }
   13:     }
   14:     public function offsetExists($offset) {
   15:         return isset($this->container[$offset]);
   16:     }
   17:     public function offsetUnset($offset) {
   18:         unset($this->container[$offset]);
   19:     }
   20:     public function &offsetGet($offset) {
   21: 	$result = null;
   22:         if (isset($this->container[$offset])) {
   23:             $result = &$this->container[$offset];
   24:         }
   25:         return $result;
   26:     }
   27: }
   28: 
   29: class obj implements ArrayAccess {
   30:     use aa;
   31: }
   32: 
   33: $o = new obj;
   34: $o['x'] = 1;
   35: ++$o['x'];
   36: echo $o['x'], "\n";
   37: --EXPECT--
   38: 2
   39: 

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