Skip to content

False positive on phpantom(undefined_variable) #78

@HeySora

Description

@HeySora

PHPantom version

0.7.0

Installation method

Pre-built binary from GitHub Releases

Operating system

macOS aarch64 (Apple Silicon)

Editor

Sublime Text

Bug description

In this specific scenario:

  • You're inside a function
  • You have a foreach loop whose value is a reference value

phpantom will claim that your value variable is undefined.

Image

Steps to reproduce

  1. Create a file with the following content:
<?php

function test()
{
    $values = [1, 2, 3];
    foreach ($values as &$value) {
        $value = 4;
    }
}
  1. Expected: No error, valid code
  2. Actual: $value is underlined in red.

.phpantom.toml

no config file

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