-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Refactor: Apply PHPStan rule "Short ternary operator is not allowed" to RouteCollection #7947
Refactor: Apply PHPStan rule "Short ternary operator is not allowed" to RouteCollection #7947
Conversation
system/Router/RouteCollection.php
Outdated
@@ -1699,7 +1700,9 @@ public function resetRoutes() | |||
*/ | |||
protected function loadRoutesOptions(?string $verb = null): array | |||
{ | |||
$verb = $verb ?: $this->getHTTPVerb(); | |||
if (null === $verb || $verb === '') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need $verb === ''
check?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because $verb
is a string
we also need to validade if its empty string to replace the validation $verb = $verb ?: $this->getHTTPVerb();
unless we check like this:
if (! $verb) {
$verb = $this->getHTTPVerb();
}
what do you sugest?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then, what if '0'
?
Probably we don't expect '0'
for $verb
.
I'm not sure what is correct. The question is just a question.
So if you believe you should check ''
, it is fine.
By the way, we do not use Yoda conditions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After another review of all uses of this method I think its reasonable to only validate the null
value.
I will fix the commit.
f6899f9
to
d736bcf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Apply PHPStan rule "Short ternary operator is not allowed" to RouteCollection
Checklist: