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

Bug: RouteCollection::getHTTPVerb() can return null #4435

Closed
MGatner opened this issue Mar 15, 2021 · 0 comments · Fixed by #4440
Closed

Bug: RouteCollection::getHTTPVerb() can return null #4435

MGatner opened this issue Mar 15, 2021 · 0 comments · Fixed by #4440
Labels
bug Verified issues on the current code behavior or pull requests that will fix them

Comments

@MGatner
Copy link
Member

MGatner commented Mar 15, 2021

Describe the bug
By default RouteCollection::$HTTPVerb is not set, nor does the constructor attempt to set it. This means that calling getHTTPVerb() on a "vanilla" instance will cause the following error:

TypeError: Return value of CodeIgniter\Router\RouteCollection::getHTTPVerb() must be of the type string, null returned

/var/www/project/vendor/codeigniter4/codeigniter4/system/Router/RouteCollection.php:552
/var/www/project/codeigniter4/system/Router/RouteCollection.php:496
/var/www/project/tests/feature/FeatureTest.php:13
/var/www/project/vendor/phpunit/phpunit/src/TextUI/Command.php:142
/var/www/project/vendor/phpunit/phpunit/src/TextUI/Command.php:95

To recreate simply call service('routes', false')->getHTTPVerb().

CodeIgniter 4 version
develop

Affected module(s)
RouteCollection

Expected behavior, and steps to reproduce if appropriate
I wonder if a RouteCollection even needs to know the "active verb"? Seems like it should always be requested externally. Router already provides it albeit, ironically, from RouteCollection itself:

$routes = $this->collection->getRoutes($this->collection->getHTTPVerb());

@MGatner MGatner added the bug Verified issues on the current code behavior or pull requests that will fix them label Mar 15, 2021
@MGatner MGatner changed the title Bug: RouteCollection Bug: RouteCollection::getHTTPVerb() can return null Mar 15, 2021
@MGatner MGatner mentioned this issue Mar 16, 2021
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant