Skip to content

Strict Rules: Foreach overwrites $queryString with its value variable. #9940

Closed
phpstan/phpstan-strict-rules
#333

Description

@staabm

Bug report

I wonder whether the error is expected., because the variable beeing reported "just exists within the previous loop"..?

Code snippet that reproduces the problem

https://phpstan.org/r/c0893b06-7315-4853-a6c7-935f6877b1d5

Expected output

no error?

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

No response

Activity

  1. staabm commented on Sep 29, 2023

    @staabm
    ContributorAuthor
  2. ondrejmirtes commented on Sep 29, 2023

    @ondrejmirtes
    Member

    It might be hard to work around this one. Thanks to "conditional type expressions" in Scope PHPStan knows that $queryString for sure exists when $queryStrings is not empty.

    But with polluteScopeWithAlwaysIterableForeach: false it shouldn't use this deduction.

  3. lulco commented on Oct 23, 2023

    @lulco
  4. github-actions commented on Oct 13, 2026

    @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 Oct 13, 2026
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

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions