1--TEST-- 2get_object_vars(): visibility from static methods (target object passed as arg) 3--FILE-- 4<?php 5Class A { 6 private $hiddenPriv = 'A::hiddenPriv'; 7 8 public static function test($b) { 9 echo __METHOD__ . "\n"; 10 var_dump(get_object_vars($b)); 11 } 12} 13 14Class B extends A { 15 private $hiddenPriv = 'B::hiddenPriv'; 16 private $priv = 'B::priv'; 17 protected $prot = 'B::prot'; 18 public $pub = 'B::pub'; 19 20 public static function test($b) { 21 echo __METHOD__ . "\n"; 22 var_dump(get_object_vars($b)); 23 } 24} 25 26Class C extends B { 27 private $hiddenPriv = 'C::hiddenPriv'; 28 29 public static function test($b) { 30 echo __METHOD__ . "\n"; 31 var_dump(get_object_vars($b)); 32 } 33} 34 35Class X { 36 public static function test($b) { 37 echo __METHOD__ . "\n"; 38 var_dump(get_object_vars($b)); 39 } 40} 41 42 43$b = new B; 44echo "\n---( Global scope: )---\n"; 45var_dump(get_object_vars($b)); 46echo "\n---( Declaring class: )---\n"; 47B::test($b); 48echo "\n---( Subclass: )---\n"; 49C::test($b); 50echo "\n---( Superclass: )---\n"; 51A::test($b); 52echo "\n---( Unrelated class: )---\n"; 53X::test($b); 54?> 55--EXPECT-- 56---( Global scope: )--- 57array(1) { 58 ["pub"]=> 59 string(6) "B::pub" 60} 61 62---( Declaring class: )--- 63B::test 64array(4) { 65 ["hiddenPriv"]=> 66 string(13) "B::hiddenPriv" 67 ["priv"]=> 68 string(7) "B::priv" 69 ["prot"]=> 70 string(7) "B::prot" 71 ["pub"]=> 72 string(6) "B::pub" 73} 74 75---( Subclass: )--- 76C::test 77array(2) { 78 ["prot"]=> 79 string(7) "B::prot" 80 ["pub"]=> 81 string(6) "B::pub" 82} 83 84---( Superclass: )--- 85A::test 86array(3) { 87 ["hiddenPriv"]=> 88 string(13) "A::hiddenPriv" 89 ["prot"]=> 90 string(7) "B::prot" 91 ["pub"]=> 92 string(6) "B::pub" 93} 94 95---( Unrelated class: )--- 96X::test 97array(1) { 98 ["pub"]=> 99 string(6) "B::pub" 100} 101