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 63---( Global scope: )--- 64array(1) { 65 ["pub"]=> 66 string(6) "B::pub" 67} 68 69---( Declaring class: )--- 70B::test 71array(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: )--- 83C::test 84array(2) { 85 ["prot"]=> 86 string(7) "B::prot" 87 ["pub"]=> 88 string(6) "B::pub" 89} 90 91---( Superclass: )--- 92A::test 93array(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: )--- 103X::test 104array(1) { 105 ["pub"]=> 106 string(6) "B::pub" 107}