Skip to content

Instantly share code, notes, and snippets.

@soxofaan

soxofaan/entities.php

Last active Dec 24, 2015
Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner Author

@soxofaan 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
You can’t perform that action at this time.