z7zmey / php-parser

PHP parser written in Go

Home Page:https://php-parser.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NamespaceResolver does not resolve PHP 7.4 typed properties

tylerchr opened this issue · comments

PHP 7.4 introduced typed class properties which are parsed correctly by php-parser. However, the NamespaceResolver doesn't account for these and fails to include them in its ResolvedNames property.

We found this after seeing some odd behavior in a custom checker for "unused use statements, which would erroneously report Bar as unused in code like this:

<?php

use Foo\Bar;

class MyClass
{
	public Bar $instance;
}

I submitted PR #112 with my fix for this issue, though I'm not familiar enough with the internals of php-parser to know if I got it exactly right.