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

1.1       misho       1: --TEST--
                      2: SPL: ArrayObject::setFlags basic usage with ArrayObject::ARRAY_AS_PROPS. Currently fails on php.net due to bug 45622. 
                      3: --FILE--
                      4: <?php
                      5: class C extends ArrayObject {
                      6:        public $p = 'object property';
                      7: }      
                      8: 
                      9: function access_p($ao) {
                     10:   // isset
                     11:   var_dump(isset($ao->p));
                     12:   // read
                     13:   var_dump($ao->p);
                     14:   // write  
                     15:   $ao->p = $ao->p . '.changed';
                     16:   var_dump($ao->p);
                     17: }
                     18: 
                     19: $ao = new C(array('p'=>'array element'));
                     20: $ao->setFlags(ArrayObject::ARRAY_AS_PROPS);
                     21: 
                     22: echo "\n--> Access the real property:\n";
                     23: access_p($ao);
                     24: 
                     25: echo "\n--> Remove the real property and access the array element:\n";
                     26: unset($ao->p);
                     27: access_p($ao);
                     28: 
                     29: echo "\n--> Remove the array element and try access again:\n";
                     30: unset($ao->p);
                     31: access_p($ao);
                     32: ?>
                     33: --EXPECTF--
                     34: --> Access the real property:
                     35: bool(true)
                     36: string(15) "object property"
                     37: string(23) "object property.changed"
                     38: 
                     39: --> Remove the real property and access the array element:
                     40: bool(true)
                     41: string(13) "array element"
                     42: string(21) "array element.changed"
                     43: 
                     44: --> Remove the array element and try access again:
                     45: bool(false)
                     46: 
1.1.1.2 ! misho      47: Notice: Undefined index: p in %s on line 10
1.1       misho      48: NULL
                     49: 
1.1.1.2 ! misho      50: Notice: Undefined index: p in %s on line 12
1.1       misho      51: string(8) ".changed"

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