Skip to content

Always assigned variable in conditional body branch should be substracted from mutually-exclusive context #12992

Closed

Description

@mvorisek

Feature request

repro: https://phpstan.org/r/3bb17546-a92b-4dcd-8e9b-f1d35a632bbf

In l14 body the l16 assignment can be substracted and thus there should be no error at l23.

Activity

  1. added this to the Dependent types milestone on May 13, 2025
  2. phpstan-bot commented on Sep 25, 2025

    @phpstan-bot
    Collaborator

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

    @@ @@
    -PHP 8.3 – 8.4 (1 error)
    -==========
    -
    -23: Variable $errorLogPrevious might not be defined.
    -
    -PHP 8.1 – 8.2 (2 errors)
    +PHP 8.1 – 8.4 (2 errors)
     ==========
     
     12: Offset 'uri' might not exist on array{timed_out: bool, blocked: bool, eof: bool, unread_bytes: int, stream_type: string, wrapper_type: string, wrapper_data: mixed, mode: string, ...}.
    Full report

    PHP 8.1 – 8.4 (2 errors)

    Line Error
    12 Offset 'uri' might not exist on array{timed_out: bool, blocked: bool, eof: bool, unread_bytes: int, stream_type: string, wrapper_type: string, wrapper_data: mixed, mode: string, ...}.
    23 Variable $errorLogPrevious might not be defined.

    PHP 8.0 (3 errors)

    Line Error
    12 Offset 'uri' might not exist on array{timed_out: bool, blocked: bool, eof: bool, unread_bytes: int, stream_type: string, wrapper_type: string, wrapper_data: mixed, mode: string, ...}.
    23 `Parameter #2 $value of function ini_set expects string, string
    23 Variable $errorLogPrevious might not be defined.

    PHP 7.2 – 7.4 (3 errors)

    Line Error
    12 Offset 'uri' might not exist on array{timed_out: bool, blocked: bool, eof: bool, unread_bytes: int, stream_type: string, wrapper_type: string, wrapper_data: mixed, mode: string, ...}.
    23 `Parameter #2 $newvalue of function ini_set expects string, string
    23 Variable $errorLogPrevious might not be defined.
  3. phpstan-bot commented on Mar 30, 2026

    @phpstan-bot
    Collaborator

    Closed via merging phpstan/phpstan-src#5056

  4. github-actions commented on May 1, 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 May 1, 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

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions