I have code two classes
class old{
function query(){
#do some actions ...
}
function advancedQuery(){
#some actions and then
$this->query();
}
}
and
class awesome extends old{
function query(){
parent::query();
$fromClassOld = false; # this variable must be changed if method is called from class 'OLD'
if( $fromClassOld ){
echo 'foo ';
}else{
echo 'bar ';
}
}
}
then some usage like this
$awesome = new awesome();
$awesome->query(); # should return 'bar'
$awesome->advancedQuery(); # should return 'foo'
You can check code here http://goo.gl/Gq63Wk
I want that variable $fromClassOld to be changed if method query() is called from class 'old'.
Class old cant be modified.
I found hack by using debug_backtrace() and checking variable debug_backtrace()[0]['file'], but I am preaty sure this could be solved in better way.