Skip to content

Report overwritten variable when the original one is never used #13472

Closed

Description

@mvorisek

Feature request

repro: https://phpstan.org/r/a1506fc1-66bf-4c8e-94ba-c76bbf4f9fa2

This feature request is motivated by code like:

$config = $m->loadConfig('dev');
$config = $m->loadConfig('prod');

which is currently undetected even on the highest level, but the code does not make sense and only consumes CPU resources.

On line 12 I would expect PHPStan to emit an error.

Activity

  1. ondrejmirtes commented on Sep 9, 2025

    @ondrejmirtes
    Member

    Duplicate of #12789

  2. github-actions commented on Oct 11, 2025

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

  3. locked as resolved and limited conversation to collaborators on Oct 11, 2025
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