Closed JoyceBabu closed 4 years ago
This assignment is done to provide type-safety. By wrapping it in a closure, you'll know as soon as it is invoked if the $serverRequestErrorResponseGenerator
returns anything other than a ResponseInterface
— as the code consuming that callable requires that return type.
Basically, it's a way for us to guarantee type safety without requiring an interface to provide the signature.
Just a note here, I've removed that dedicated callable in v2 and added it to the __construct
psalm annotation.
When using psalm in upstream projects, this will lead to a static-code-analysis error rather than a runtime error.
Is the closure required here? Can't
$serverRequestErrorResponseGenerator
be assigned directly to$this->serverRequestErrorResponseGenerator
?https://github.com/laminas/laminas-httphandlerrunner/blob/e3d1b45283cf741de84a11661743143a98f1f899/src/RequestHandlerRunner.php#L77-L80