[PHP-BUG] Bug #52591 [NEW]: possibility of calling protected static methods in not inherited classes
From: Operating system: any PHP version: 5.2.14 Package: Scripting Engine problem Bug Type: Bug Bug description:possibility of calling protected static methods in not inherited classes 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 bug report at http://bugs.php.net/bug.php?id=52591edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=52591r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=52591r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=52591r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=52591r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=52591r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=52591r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=52591r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=52591r=needscript Try newer version: http://bugs.php.net/fix.php?id=52591r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=52591r=support Expected behavior: http://bugs.php.net/fix.php?id=52591r=notwrong Not enough info: http://bugs.php.net/fix.php?id=52591r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=52591r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=52591r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=52591r=php4 Daylight Savings:http://bugs.php.net/fix.php?id=52591r=dst IIS Stability: http://bugs.php.net/fix.php?id=52591r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=52591r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=52591r=float No Zend Extensions: http://bugs.php.net/fix.php?id=52591r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=52591r=mysqlcfg
Bug #52591 [Bgs]: possibility of calling protected static methods in not inherited classes
Edit report at http://bugs.php.net/bug.php?id=52591edit=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=52591edit=1