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

1.1       misho       1: --TEST--
                      2: get_object_vars(): visibility from 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 static function test($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 static function test($b) {
                     27:                echo __METHOD__ . "\n";         
                     28:                var_dump(get_object_vars($b));
                     29:        } 
                     30: }
                     31: 
                     32: Class C extends B {
                     33:        private $hiddenPriv = 'C::hiddenPriv';
                     34:        
                     35:        public static function test($b) {
                     36:                echo __METHOD__ . "\n";         
                     37:                var_dump(get_object_vars($b));
                     38:        } 
                     39: }
                     40: 
                     41: Class X {
                     42:        public static function test($b) {
                     43:                echo __METHOD__ . "\n";         
                     44:                var_dump(get_object_vars($b));
                     45:        } 
                     46: }
                     47: 
                     48: 
                     49: $b = new B;
                     50: echo "\n---( Global scope: )---\n";
                     51: var_dump(get_object_vars($b));
                     52: echo "\n---( Declaring class: )---\n";
                     53: B::test($b);
                     54: echo "\n---( Subclass: )---\n";
                     55: C::test($b);
                     56: echo "\n---( Superclass: )---\n";
                     57: A::test($b);
                     58: echo "\n---( Unrelated class: )---\n";
                     59: X::test($b);
                     60: ?>
                     61: --EXPECTF--
                     62: 
                     63: ---( Global scope: )---
                     64: array(1) {
                     65:   ["pub"]=>
                     66:   string(6) "B::pub"
                     67: }
                     68: 
                     69: ---( Declaring class: )---
                     70: B::test
                     71: array(4) {
                     72:   ["hiddenPriv"]=>
                     73:   string(13) "B::hiddenPriv"
                     74:   ["priv"]=>
                     75:   string(7) "B::priv"
                     76:   ["prot"]=>
                     77:   string(7) "B::prot"
                     78:   ["pub"]=>
                     79:   string(6) "B::pub"
                     80: }
                     81: 
                     82: ---( Subclass: )---
                     83: C::test
                     84: array(2) {
                     85:   ["prot"]=>
                     86:   string(7) "B::prot"
                     87:   ["pub"]=>
                     88:   string(6) "B::pub"
                     89: }
                     90: 
                     91: ---( Superclass: )---
                     92: A::test
                     93: array(3) {
                     94:   ["prot"]=>
                     95:   string(7) "B::prot"
                     96:   ["pub"]=>
                     97:   string(6) "B::pub"
                     98:   ["hiddenPriv"]=>
                     99:   string(13) "A::hiddenPriv"
                    100: }
                    101: 
                    102: ---( Unrelated class: )---
                    103: X::test
                    104: array(1) {
                    105:   ["pub"]=>
                    106:   string(6) "B::pub"
                    107: }

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