Skip to content

$GLOBALS in function leaves variable unassigned #303

Closed

Description

@bookworm109

I'm trying to set up a debugging function using $GLOBALS, and phptools is saying the variable I assign a value with is unassigned. The variable works fine, and I had to trick phptools into preventing it from giving me an error.

This shows the variable $xValue as unassigned.
unassigned

I trick phptools with an assignment that never happens.

tricked

Activity

  1. jakubmisek commented on Mar 6, 2023

    @jakubmisek
    Member

    Thank you @bookworm109 for reporting the issue!

    We'll fix that.

    FYI I would suggest another quick workaround for now:

    /** @var string $xValue */
    $sType = gettype($xValue);
    ...
  2. self-assigned this
    on Mar 6, 2023
  3. jakubmisek commented on Mar 16, 2023

    @jakubmisek
    Member

    Fixed in the next pre-release, thank you!


    Hint: to improve the editor type inferring, you can take advantage of PHPDoc:

    /** @var string $xValue */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions