Reputation: 31919
When there is inheritance we can do this:
class Demo
{
public function doStuff(Form $form, Request $request)
{
parent::doStuff($form, $request);
}
}
Is there a way to inject these same parameter in a funciton that is not a parent, ie:
//...
MyRandomClass::doStuff($form, $request);
//...
If yes, what is the synthax?
Cheers
Upvotes: 1
Views: 90
Reputation: 25755
Is there a way to inject these same parameter in a funciton that is not a parent
do you mean to say, you want to pass the same parameter values inside of another function of the same name in some other class.
public function doStuff(Form $form, Request $request)
{
parent::doStuff($form, $request);
MyRandomClass::doStuff($form, $request);
}
above code will pass the parameter values to MyRandomClass::dostuff()
method too. remember that the method should be static otherwise it won't work.
Upvotes: 2
Reputation: 2556
MyRandomClass::doStuff($form, $request);
will just work (assuming MyRandomClass has been included/required in the context of this line) if the function doStuff() is defined as "public static".
Upvotes: 3