Annotation of embedaddon/php/Zend/tests/dereference_001.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: Testing array dereference
        !             3: --FILE--
        !             4: <?php
        !             5: error_reporting(E_ALL);
        !             6: 
        !             7: function a() {
        !             8:        return array(1,array(5));
        !             9: }
        !            10: var_dump(a()[1][0]); // int(5)
        !            11: 
        !            12: function b() {
        !            13:        return array();
        !            14: }
        !            15: var_dump(b()[0]); // Notice: Undefined offset: 0 
        !            16: 
        !            17: class foo {
        !            18:        public $y = 1; 
        !            19:        
        !            20:        public function test() {
        !            21:                return array(array(array('foobar')));
        !            22:        }
        !            23: }
        !            24: 
        !            25: function c() {
        !            26:        return array(new foo);
        !            27: }
        !            28: var_dump(c()[0]->y); // int(1)
        !            29: 
        !            30: function d() {
        !            31:        $obj = new foo;
        !            32:        return $obj->test();
        !            33: }
        !            34: var_dump(d()[0][0][0][3]); // string(1) "b"
        !            35: 
        !            36: function e() {
        !            37:        $y = 'bar';
        !            38:        $x = array('a' => 'foo', 'b' => $y);
        !            39:        return $x;
        !            40: }
        !            41: var_dump(e()['b']); // string(3) "bar"
        !            42: 
        !            43: ?>
        !            44: --EXPECTF--
        !            45: int(5)
        !            46: 
        !            47: Notice: Undefined offset: 0 in %s on line %d
        !            48: NULL
        !            49: int(1)
        !            50: string(1) "b"
        !            51: string(3) "bar"

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