nette/application

Invalid type in Nette\Application\Request->isMethod(...)

SendiMyrkr opened this issue · 1 comments

Version: 3.0.4

Bug Description

In class Nette\Application\Request can be property method string or null, but null cannot be used in strcasecmp. https://github.com/nette/application/blob/master/src/Application/Request.php#L192

Steps To Reproduce

Set Error presenter and visit some missing page (404), then you will get error message:
strcasecmp() expects parameter 1 to be string, null given

Expected Behavior

Not invoking error "strcasecmp() expects parameter 1 to be string, null given"

Possible Solution

Probably replace line above by following code?

return strcasecmp($this->method ?? '', $method) === 0;

Or this one?

return $this->method ? strcasecmp($this->method, $method) === 0 : false;
dg commented

fixed