Last active
December 24, 2015 14:09
-
-
Save soxofaan/6810355 to your computer and use it in GitHub Desktop.
Some weird PHP magic going on here
This file contains 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 | |
class A | |
{ | |
public function whoami() { return 'A'; } | |
public function __call($method, array $args) | |
{ | |
return 'A::__call::' . $method; | |
} | |
} | |
class BB extends A | |
{ | |
public function whoami() { return 'BB'; } | |
public function getX() | |
{ | |
return 'BB::getX (FYI: parent is ' . parent::whoami(). ') -> ' . parent::getX() ; | |
} | |
} | |
class CCC extends BB | |
{ | |
public function whoami() { return 'CCC'; } | |
public function __call($method, array $args) | |
{ | |
return 'CCC::__call::' . $method . ' -> ' . parent::__call($method, $args); | |
} | |
} | |
$c = new CCC(); | |
echo $c->getX() . "\n"; | |
////////////////////////////////////// | |
// Output (on PHP 5.3.26 (cli)): | |
// | |
// BB::getX (FYI: parent is A) -> CCC::__call::getX -> A::__call::getX |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Filed a PHP bug report: https://bugs.php.net/bug.php?id=65828