phpstan/phpstan-nette

False positive on 0.12.15?

dakorpar opened this issue · 8 comments

image
see here:
https://github.com/contributte/datagrid/pull/957/checks?check_run_id=2015573206

code:
image

I don't think this should be noted as error here...

Yeah, this is an interesting side-effect of this change... you can get rid of the error by also having @param positive-int|0 $offset above the method. You can also use @phpstan-param if you don't want to confuse IDE etc.

I'm gonna keep it open so we can decide if the stub change was a mistake or not... /cc @lulco

lulco commented

Yes, that’s exactly kind of errors which should be found by that change. You don’t have any check if offset / limit is positive integer or zero. So the application will fail at this point. I understand it could be annoying (like almost all errors found by phpstan :)) but imho it is good to handle it another way like crashing app.

@ondrejmirtes feel free to remove it, if it is not compatible with the base ideas of phpstan

@lulco then again we're going to far and nette code returns int here so it fails...
image

I guess we could add @return positive-int|0 to paginator methods as well.

@ondrejmirtes @lulco any ETA on this?

If you send a PR that adds a stub for those Paginator methods, I’ll release it right away.

@ondrejmirtes PR is there

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.