Considering the following class :
class MyClass {
public function __construct($mailProvider) {
$this->mailProvider = $mailProvider;
echo get_class($mailProvider());
echo get_class($this->mailProvider());
}
}
And the following call :
$mailProvider = function () {
$mail = new PHPMailer(true);
return $mail;
};
$myClass = new MyClass($mailProvider);
I can't figure why the second echo would cause a call to an undefined function.
Anyone can figure it out ?