phan icon indicating copy to clipboard operation
phan copied to clipboard

Type 'static' not interpreted as expected

Open mdeweerd opened this issue 1 year ago • 2 comments

public $oldcopy is declared of static time in the base class. Yet this results in the following notification:

PhanTypeMismatchProperty Assigning (clone($object)) of type \User to property but \User->oldcopy is static

Test case:

class User {
    /**
     * @var static Global User
     */
    public $userlink;
}


class Users {
    /**
     * @var User
     */
    public $local_user;

    public function testfunc() {
        $u = new User();
        $this->local_user->userlink = clone $this->local_user;
        print "Class of clone is ".get_class($this->local_user->userlink).PHP_EOL;
    }
}


$users = new Users();
$users->local_user = new User();

$users->testfunc();

Phan 5.4.5 php-ast version 1.0.16 PHP version used to run Phan: 8.1.13

mdeweerd avatar Oct 10 '24 20:10 mdeweerd

I think I have a fix for this: https://github.com/reviewdog/reviewdog/pull/1975

dallonf avatar Nov 25 '24 17:11 dallonf

IIRC, even if reviewdog support it, GitHub code suggestion doesn't support inserting EOF with the error message same as you posted in the top of this issue.

```suggestion
end of file
```

reviewdog will generate the above suggestion regardless of the existence of EOF newline and GitHub says it's invalid because there are no changes.

```suggestion
end of file

```

We could think of inserting new blank line at the end alternatively like the above, but it's obviously different suggestion and unintended behabior.

haya14busa avatar Feb 04 '25 07:02 haya14busa

I think this issue is resolved.

I confirm reviewdog makes EOF new line code suggestion. Image https://github.com/mongolyy/reviewdog-action-biome/pull/69#discussion_r2348623163

Thank you!!

mongolyy avatar Sep 15 '25 11:09 mongolyy