Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PhanUndeclaredThis when newThis assigned to closure #4848

Open
toddmazierski opened this issue Apr 2, 2024 · 1 comment
Open

PhanUndeclaredThis when newThis assigned to closure #4848

toddmazierski opened this issue Apr 2, 2024 · 1 comment

Comments

@toddmazierski
Copy link

Hello. I'd like to report what I understand to be a false positive in Phan. It occurs when a newThis is assigned to a Closure. The message from Phan is PhanUndeclaredThis Variable $this is undeclared. Thank you.

Example

<?php

class NewThis
{
    public $foo = 'bar';
}

$newThis = new NewThis();

$closure = function () {
    return $this->foo; // PhanUndeclaredThis Variable $this is undeclared
};

var_dump(
    $closure->call($newThis) // prints "bar"
);

Example in Phan Demo

@MatmaRex
Copy link

MatmaRex commented Apr 4, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants