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

1.1       misho       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>