Skip to content

Phpstan doesn't see code throwing Exception if couter go after his limit @var int<0, 20> #7783

Closed

Description

@Neila142

Bug report

Code snippet that reproduces the problem

https://phpstan.org/r/cc1c3857-c540-4158-9460-89ea6fe4ee84

Expected output

Expected phpstan to not find error

Did PHPStan help you today? Did it make you happy in any way?

Phpstan is very good and useful I love it!
Thanks for you're work here!!!
Have a lovely day

Activity

  1. Neila142 commented on Aug 15, 2022

    @Neila142
    Author

    For an additonal note, this code show no errors:

    https://phpstan.org/r/50d56438-1877-4e12-b073-74a29e4a447f

    Which is the same, just a little different placement of variables increments.
    It work but I found it less readable

  2. ezintz commented on Aug 22, 2022

    @ezintz

    I think the issue is not related to the counter. It feels like it can not find that methods are throwing exceptions. It seems to neither work inlined or as doc-block comment. Here an example: https://phpstan.org/r/d7399c17-547b-4203-866f-90149148e33b

    Throwing the exception directly works and PHPStan is happy.

    PHPStan was helpful today, yes. Because if this is behaviour, it currently does not make me happy (; But in general it does.

    Edit: Seems to be working if return type never is used. Thanks to @Mooeeezzzz!

  3. ondrejmirtes commented on Aug 22, 2022

    @ondrejmirtes
    Member

    Yes, see this: https://phpstan.org/user-guide/troubleshooting-types#what-phpstan-doesn%E2%80%99t-do

    This feature might help you in the future once it's released: phpstan/phpstan-src#1317

    never marks a function that ALWAYS throws the exception.

  4. github-actions commented on Sep 23, 2022

    @github-actions

    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.

  5. locked as resolved and limited conversation to collaborators on Sep 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions