Skip to content

Instantly share code, notes, and snippets.

@soxofaan
Last active December 24, 2015 14:09
Show Gist options
  • Save soxofaan/6810355 to your computer and use it in GitHub Desktop.
Save soxofaan/6810355 to your computer and use it in GitHub Desktop.
Some weird PHP magic going on here
<?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
@soxofaan
Copy link
Author

soxofaan commented Oct 3, 2013

Filed a PHP bug report: https://bugs.php.net/bug.php?id=65828

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment