Edit report at http://bugs.php.net/bug.php?id=52591&edit=1

 ID:                 52591
 User updated by:    v dot kholoshenko at gmail dot com
 Reported by:        v dot kholoshenko at gmail dot com
 Summary:            possibility of calling protected static methods in
                     not inherited classes
 Status:             Bogus
 Type:               Bug
 Package:            Scripting Engine problem
 Operating System:   any
 PHP Version:        5.2.14
 Block user comment: N

 New Comment:

ok, so why call_user_func doesn't works in such way?


Previous Comments:
------------------------------------------------------------------------
[2010-08-12 13:34:54] johan...@php.net

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

That is exactly what protected means.

------------------------------------------------------------------------
[2010-08-12 12:52:32] v dot kholoshenko at gmail dot com

Description:
------------
PHP allows to call protected static method in classes not inherited from
class, 

that defines this method. See test script. We have two classes inherited
from 

basic abstract class and we can call protected functions (defined
abstract) of 

first class from second. Note, call_user_func caused error (works as
expected).

Test script:
---------------
<?php

abstract class A {

        abstract protected static function test();

}



class B extends A {

        protected static function test()

        {

                return "abc";

        }

}



abstract class C extends A {

        public static function do1()

        {

                return B::test();// Expected "Fatal error: Call to protected
method..."

        }

}



echo C::do1(); // returns 'abc'

Expected result:
----------------
Fatal error: Call to protected method B::test() from context 'C'

Actual result:
--------------
abc


------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=52591&edit=1

Reply via email to