Annotation of embedaddon/php/ext/spl/tests/arrayObject___construct_basic3.phpt, revision 1.1.1.2

1.1       misho       1: --TEST--
                      2: SPL: ArrayObject::__construct basic usage with ArrayObject::STD_PROP_LIST.
                      3: --FILE--
                      4: <?php
                      5: class C {
                      6:        public $prop = 'C::prop.orig';
                      7: }
                      8: 
                      9: class MyArrayObject extends ArrayObject {
                     10:        public $prop = 'MyArrayObject::prop.orig';
                     11: }      
                     12: 
                     13: echo "\n--> Access prop on instance of ArrayObject with ArrayObject::STD_PROP_LIST:\n";
                     14: $c = new C;
                     15: $ao = new ArrayObject($c, ArrayObject::STD_PROP_LIST);
                     16: testAccess($c, $ao);
                     17: 
                     18: echo "\n--> Access prop on instance of MyArrayObject with ArrayObject::STD_PROP_LIST:\n";
                     19: $c = new C;
                     20: $ao = new MyArrayObject($c, ArrayObject::STD_PROP_LIST);
                     21: testAccess($c, $ao);
                     22: 
                     23: function testAccess($c, $ao) {
                     24:        echo "  - Iteration:\n";
                     25:        foreach ($ao as $key=>$value) {
                     26:                echo "      $key=>$value\n";
                     27:        }
                     28: 
                     29:        echo "  - Read:\n";
                     30:        @var_dump($ao->prop, $ao['prop']);
                     31:        
                     32:        echo "  - Write:\n";
                     33:        $ao->prop = 'changed1';
                     34:        $ao['prop'] = 'changed2';
                     35:        var_dump($ao->prop, $ao['prop']);
                     36:        
                     37:        echo "  - Isset:\n";
                     38:        var_dump(isset($ao->prop), isset($ao['prop']));
                     39:        
                     40:        echo "  - Unset:\n";
                     41:        unset($ao->prop);
                     42:        unset($ao['prop']);
                     43:        var_dump($ao->prop, $ao['prop']);
                     44:        
                     45:        echo "  - After:\n";
                     46:        var_dump($ao, $c);
                     47: }
                     48: ?>
                     49: --EXPECTF--
                     50: --> Access prop on instance of ArrayObject with ArrayObject::STD_PROP_LIST:
                     51:   - Iteration:
                     52:       prop=>C::prop.orig
                     53:   - Read:
                     54: NULL
                     55: string(12) "C::prop.orig"
                     56:   - Write:
                     57: string(8) "changed1"
                     58: string(8) "changed2"
                     59:   - Isset:
                     60: bool(true)
                     61: bool(true)
                     62:   - Unset:
                     63: 
                     64: Notice: Undefined property: ArrayObject::$prop in %s on line 40
                     65: 
1.1.1.2 ! misho      66: Notice: Undefined index: prop in %s on line 40
1.1       misho      67: NULL
                     68: NULL
                     69:   - After:
                     70: object(ArrayObject)#2 (1) {
                     71:   ["storage":"ArrayObject":private]=>
                     72:   object(C)#1 (0) {
                     73:   }
                     74: }
                     75: object(C)#1 (0) {
                     76: }
                     77: 
                     78: --> Access prop on instance of MyArrayObject with ArrayObject::STD_PROP_LIST:
                     79:   - Iteration:
                     80:       prop=>C::prop.orig
                     81:   - Read:
                     82: string(24) "MyArrayObject::prop.orig"
                     83: string(12) "C::prop.orig"
                     84:   - Write:
                     85: string(8) "changed1"
                     86: string(8) "changed2"
                     87:   - Isset:
                     88: bool(true)
                     89: bool(true)
                     90:   - Unset:
                     91: 
                     92: Notice: Undefined property: MyArrayObject::$prop in %s on line 40
                     93: 
1.1.1.2 ! misho      94: Notice: Undefined index: prop in %s on line 40
1.1       misho      95: NULL
                     96: NULL
                     97:   - After:
                     98: object(MyArrayObject)#3 (1) {
                     99:   ["storage":"ArrayObject":private]=>
                    100:   object(C)#4 (0) {
                    101:   }
                    102: }
                    103: object(C)#4 (0) {
                    104: }

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