Created
March 18, 2014 15:33
-
-
Save bwg/9622479 to your computer and use it in GitHub Desktop.
how does Bar call test() on Foo if its defined as protected?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
abstract class Base { | |
protected static function test() { | |
echo get_called_class()."\n"; | |
} | |
} | |
class Foo extends Base { | |
protected static function test2(){ | |
echo get_called_class()."\n"; | |
} | |
} | |
class Bar extends Base { | |
public static function fooTest() { | |
echo Foo::test()."\n"; | |
} | |
public static function fooTest2() { | |
echo Foo::test2()."\n"; | |
} | |
} | |
Bar::fooTest(); // Foo | |
Bar::fooTest2(); // Fatal call to protected method Foo::test2() from context 'Bar' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment