Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing return type check in ErrorController.php #998

Closed
wants to merge 2 commits into from
Closed

Fix missing return type check in ErrorController.php #998

wants to merge 2 commits into from

Conversation

umer936
Copy link
Contributor

@umer936 umer936 commented Mar 28, 2024

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

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
Copy link
Member

dereuromark commented Mar 28, 2024

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.

@dereuromark dereuromark added this to the 5.x milestone Mar 28, 2024
@ADmad
Copy link
Member

ADmad commented Mar 29, 2024

Closing for reasons stated above.

@ADmad ADmad closed this Mar 29, 2024
@umer936 umer936 deleted the patch-1 branch March 29, 2024 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants