I would like to know, while using method chaining in PHP, if a last chained method, can possibly return its parent.
Here is an example.
class foo
{
function a(){
return $this;
}
function b()
{
return $this;
}
function c()
{
return $this;
}
}
echo (new foo)->c()->a(); // c
In the above example, you can see, that a()
is to output 'c'
. I can/have done this using arguments, or static properties, but I am thinking if it can be done another way, specially using Reflections
which I happen to know so little about.