From:             pascal dot parietti at fh-aargau dot ch
Operating system: Linux, 2.6.11
PHP version:      5.0.4
PHP Bug Type:     Class/Object related
Bug description:  Access to protected functions from static function in base 
class

Description:
------------
A static function in the base class (A) can execute a protected function
in a derived class (B).

If the same function is called from outside of class A the PHP Fatal error
occurs as excepted.

The error also occurs with the CVS Snapshot php5-STABLE-200507211237
compiled with ./configure && make

Reproduce code:
---------------
<?php
class A {
        public static function test()   {
                $a = new B();
                $a->test2(); # why does this work?
        }
}
class B extends A {
        protected function test2()      {
                echo "B: test2 \n";
        }
}

A::test();

$b = new B();

# call a protected function -> PHP Fatal error as excepted:
$b->test2(); 
?>


Expected result:
----------------
PHP Fatal error:  Call to protected method B::test2() on line  5


-- 
Edit bug report at http://bugs.php.net/?id=33806&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=33806&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=33806&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=33806&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=33806&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=33806&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=33806&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=33806&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=33806&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=33806&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=33806&r=notwrong
Not enough info:             
http://bugs.php.net/fix.php?id=33806&r=notenoughinfo
Submitted twice:             
http://bugs.php.net/fix.php?id=33806&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=33806&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=33806&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=33806&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=33806&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=33806&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=33806&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=33806&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=33806&r=mysqlcfg

Reply via email to