1--TEST-- 2get_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 11Class 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 20Class 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 32Class 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 41Class 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; 50echo "\n---( Global scope: )---\n"; 51var_dump(get_object_vars($b)); 52echo "\n---( Declaring class: )---\n"; 53B::test($b); 54echo "\n---( Subclass: )---\n"; 55C::test($b); 56echo "\n---( Superclass: )---\n"; 57A::test($b); 58echo "\n---( Unrelated class: )---\n"; 59X::test($b); 60?> 61--EXPECTF-- 62---( Global scope: )--- 63array(1) { 64 ["pub"]=> 65 string(6) "B::pub" 66} 67 68---( Declaring class: )--- 69B::test 70array(4) { 71 ["hiddenPriv"]=> 72 string(13) "B::hiddenPriv" 73 ["priv"]=> 74 string(7) "B::priv" 75 ["prot"]=> 76 string(7) "B::prot" 77 ["pub"]=> 78 string(6) "B::pub" 79} 80 81---( Subclass: )--- 82C::test 83array(2) { 84 ["prot"]=> 85 string(7) "B::prot" 86 ["pub"]=> 87 string(6) "B::pub" 88} 89 90---( Superclass: )--- 91A::test 92array(3) { 93 ["prot"]=> 94 string(7) "B::prot" 95 ["pub"]=> 96 string(6) "B::pub" 97 ["hiddenPriv"]=> 98 string(13) "A::hiddenPriv" 99} 100 101---( Unrelated class: )--- 102X::test 103array(1) { 104 ["pub"]=> 105 string(6) "B::pub" 106} 107