Skip to content

calling a function in a loop causes invalid types when shadowing variables #90

@Bleksak

Description

@Bleksak

PHPantom version

phpantom_lsp 0.7.0-44-g728f760

Installation method

Built from source

Operating system

Linux x86_64

Editor

Neovim

Bug description

the correct type of the first $s assignment is string, not string[]

Steps to reproduce

  1. file:
<?php

/** @var list<array{foo: string}> */
$foo = [
    ['foo' => 'asdf qwer']
];

foreach($foo as $bar) {
    $s = $bar['foo'];
    $s = explode(" ", $s);
}
  1. the first $s shows type as string[] which is incorrect

Error output or panic trace


.phpantom.toml

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions