Annotation of embedaddon/php/ext/standard/tests/class_object/get_object_vars_basic_002.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: get_object_vars(): visibility from non static methods (target object passed as arg)
                      3: --FILE--
                      4: <?php
                      5: /* Prototype  : proto array get_object_vars(object obj)
                      6:  * Description: Returns an array of object properties 
                      7:  * Source code: Zend/zend_builtin_functions.c
                      8:  * Alias to functions: 
                      9:  */
                     10: 
                     11: Class A {
                     12:        private $hiddenPriv = 'A::hiddenPriv';
                     13: 
                     14:        public function testA($b) {
                     15:                echo __METHOD__ . "\n"; 
                     16:                var_dump(get_object_vars($b));
                     17:        } 
                     18: }
                     19: 
                     20: Class B extends A {
                     21:        private $hiddenPriv = 'B::hiddenPriv';  
                     22:        private $priv = 'B::priv';
                     23:        protected $prot = 'B::prot';
                     24:        public $pub = 'B::pub';
                     25: 
                     26:        public function testB($b) {
                     27:                echo __METHOD__ . "\n";         
                     28:                var_dump(get_object_vars($b));
                     29:        } 
                     30: }
                     31: 
                     32: 
                     33: $b = new B;
                     34: echo "\n---( Declaring class: )---\n";
                     35: $b->testB($b);
                     36: echo "\n---( Superclass: )---\n";
                     37: $b->testA($b);
                     38: 
                     39: ?>
                     40: --EXPECTF--
                     41: 
                     42: ---( Declaring class: )---
                     43: B::testB
                     44: array(4) {
                     45:   ["hiddenPriv"]=>
                     46:   string(13) "B::hiddenPriv"
                     47:   ["priv"]=>
                     48:   string(7) "B::priv"
                     49:   ["prot"]=>
                     50:   string(7) "B::prot"
                     51:   ["pub"]=>
                     52:   string(6) "B::pub"
                     53: }
                     54: 
                     55: ---( Superclass: )---
                     56: A::testA
                     57: array(3) {
                     58:   ["prot"]=>
                     59:   string(7) "B::prot"
                     60:   ["pub"]=>
                     61:   string(6) "B::pub"
                     62:   ["hiddenPriv"]=>
                     63:   string(13) "A::hiddenPriv"
                     64: }

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