cakephp / app

CakePHP application template
366 stars 390 forks source link

Fix missing return type check in ErrorController.php #998

Closed umer936 closed 3 months ago

umer936 commented 3 months ago

Fixes:

( ! ) Fatal error: Declaration of App\Controller\ErrorController::beforeFilter(Cake\Event\EventInterface $event) must be compatible with App\Controller\AppController::beforeFilter(Cake\Event\EventInterface $event): void in /web/hpca/src/Controller/ErrorController.php on line 44

dereuromark commented 3 months ago

Is that fatal saying twice the same exact line? Weird

But either way, this is actually the correct the way it was so far.

The code does not contain the beforeFilter() https://github.com/cakephp/app/blob/5.x/src/Controller/AppController.php And the error controller defines it without actual type as @return \Cake\Http\Response|null|void

You added that type yourself, and as per documentation it can return (and in some cases must) Response, e.g. for redirects. So the typehint \Cake\Http\Response|null|void documented is correct. It would be the actual type \Cake\Http\Response|null if you always return something, that's a choice you can make on your project level.

The changes proposed as such can not be adapted/merged here.

ADmad commented 3 months ago

Closing for reasons stated above.