From:             msa at xtivate dot de
Operating system: ubuntu
PHP version:      5.2.11
PHP Bug Type:     Class/Object related
Bug description:  get_class_vars with protected members inconsistent

Description:
------------
get_class_vars return is inconsistent.
from inside the class it returnes the protected members as well as the
public.
from outside the class it returns only the public.

until php 5.2.10 it only returned the public, not the non-public.
(as is it specified in the documentation that it only returns the
public...)


so... now it does not only return the non-public when called from inside
the actual class, but is inconsistent with the output  that one gets
calling outside of the class.

this is a _major issiue_ in terms of scoping/inheritance/consitency.


please change it back to the way it was before because that was 
a) consistent 
and
b) in accordance with the spec ( "only public" )




Reproduce code:
---------------
abstract class Vader{
        protected $vaders_protected_var;
}

class Luke extends Vader {
        public $lukes_public_var;       
        final function ShowVars(){
                echo "<br> inside Luke:<br>";
                print_r(get_class_vars(get_class($this)));
        }
}

$luke = new Luke();

$luke->ShowVars();

echo "<br> outside luke:<br>";
print_r( get_class_vars("Luke") );


Expected result:
----------------
inside Luke:
Array ( [lukes_public_var] => )
outside luke:
Array ( [lukes_public_var] => ) 

Actual result:
--------------
inside Luke:
Array ( [lukes_public_var] => [vaders_protected_var] => )
outside luke:
Array ( [lukes_public_var] => ) 

-- 
Edit bug report at http://bugs.php.net/?id=50275&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=50275&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=50275&r=trysnapshot53
Try a snapshot (PHP 6.0):            
http://bugs.php.net/fix.php?id=50275&r=trysnapshot60
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=50275&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=50275&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=50275&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=50275&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=50275&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=50275&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=50275&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=50275&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=50275&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=50275&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=50275&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=50275&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=50275&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=50275&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=50275&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=50275&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=50275&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=50275&r=mysqlcfg

Reply via email to