Skip to content

Return from declare() block is ignored #9309

Closed

Description

@hocker1

Bug report

PHPStan seems to ignore code inside declare() { ... } blocks.

Code snippet that reproduces the problem

https://phpstan.org/r/626c6650-affc-4827-92ff-9f245ca2eb12

Expected output

I expected PHPStan to report that the code is ok. Instead, it reports that the return statement is missing, which is not true, there is return statement inside the declare() block.

Activity

  1. added this to the Easy fixes milestone on May 13, 2023
  2. ondrejmirtes commented on May 13, 2023

    @ondrejmirtes
    Member
  3. phpstan-bot commented on Oct 30, 2023

    @phpstan-bot
    Collaborator

    @hocker1 After the latest push in 1.11.x, PHPStan now reports different result with your code snippet:

    @@ @@
    -4: Function a() should return int but return statement is missing.
    +No errors
  4. mad-briller commented on Oct 31, 2023

    @mad-briller
    Contributor

    @ondrejmirtes this is fixed now

  5. ondrejmirtes commented on Oct 31, 2023

    @ondrejmirtes
    Member

    @mad-briller If you want to do the God's work, please send regression tests for these fixed issues: #5266, #9309, #9394, #6922. Thank you.

  6. added a commit that references this issue on Nov 2, 2023
  7. mad-briller commented on Nov 6, 2023

    @mad-briller
    Contributor

    sorry @ondrejmirtes i've been away from pc for a few days and you beat me to it

  8. github-actions commented on Dec 8, 2023

    @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.

  9. locked as resolved and limited conversation to collaborators on Dec 8, 2023
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

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions