-
-
Notifications
You must be signed in to change notification settings - Fork 863
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
Class PHPDoc not parsed when there's an attribute above it #4633
Comments
Reported upstream: nikic/PHP-Parser#762 |
Don't hol your breath for this being solved, see: nikic/PHP-Parser#762 (comment) |
@oprypkhantc After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
15: Parameter $var of method ClassStub::__construct() has invalid typehint type T.
15: Property ClassStub::$var has unknown class T as its type.
-PHP 7.1 – 7.4 (1 error)
+PHP 7.1 – 7.4 (4 errors)
==========
-15: Promoted properties are supported only on PHP 8.0 and later.
+ 3: Attribute class Attribute does not exist.
+15: Parameter $var of method ClassStub::__construct() has invalid typehint type T.
+15: Promoted properties are supported only on PHP 8.0 and later.
+15: Property ClassStub::$var has unknown class T as its type. Full reportPHP 8.0 (2 errors)
PHP 7.1 – 7.4 (4 errors)
|
@oprypkhantc After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
PHP 7.1 – 7.4 (1 error)
==========
-15: Promoted properties are supported only on PHP 8.0 and later.
+-1: Internal error: Property $var was not found in reflection of class ClassStub.
+Run PHPStan with --debug option and post the stack trace to:
+https://github.com/phpstan/phpstan/issues/new?template=Bug_report.md Full reportPHP 8.0 (2 errors)
PHP 7.1 – 7.4 (1 error)
|
@oprypkhantc After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
PHP 8.0 (2 errors)
==========
-15: Parameter $var of method ClassStub::__construct() has invalid typehint type T.
+15: Parameter $var of method ClassStub::__construct() has invalid type T.
15: Property ClassStub::$var has unknown class T as its type.
-PHP 7.1 – 7.4 (1 error)
+PHP 7.1 – 7.4 (4 errors)
==========
-15: Promoted properties are supported only on PHP 8.0 and later.
+ 3: Attribute class Attribute does not exist.
+15: Parameter $var of method ClassStub::__construct() has invalid type T.
+15: Promoted properties are supported only on PHP 8.0 and later.
+15: Property ClassStub::$var has unknown class T as its type. Full reportPHP 8.0 (2 errors)
PHP 7.1 – 7.4 (4 errors)
|
@oprypkhantc After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
-PHP 8.0 (2 errors)
+PHP 8.0 (4 errors)
==========
-15: Parameter $var of method ClassStub::__construct() has invalid typehint type T.
+ 3: Class Attribute is not an Attribute class.
+ 6: Class AttributeStub is not an Attribute class.
+15: Parameter $var of method ClassStub::__construct() has invalid type T.
15: Property ClassStub::$var has unknown class T as its type.
-PHP 7.1 – 7.4 (1 error)
+PHP 7.1 – 7.4 (5 errors)
==========
-15: Promoted properties are supported only on PHP 8.0 and later.
+ 3: Attribute class Attribute does not exist.
+ 6: Class AttributeStub is not an Attribute class.
+15: Parameter $var of method ClassStub::__construct() has invalid type T.
+15: Promoted properties are supported only on PHP 8.0 and later.
+15: Property ClassStub::$var has unknown class T as its type. Full reportPHP 8.0 (4 errors)
PHP 7.1 – 7.4 (5 errors)
|
@oprypkhantc After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
PHP 8.0 (2 errors)
==========
-15: Parameter $var of method ClassStub::__construct() has invalid typehint type T.
15: Property ClassStub::$var has unknown class T as its type.
+15: Parameter $var of method ClassStub::__construct() has invalid type T.
-PHP 7.1 – 7.4 (1 error)
+PHP 7.1 – 7.4 (4 errors)
==========
-15: Promoted properties are supported only on PHP 8.0 and later.
+ 3: Attribute class Attribute does not exist.
+15: Promoted properties are supported only on PHP 8.0 and later.
+15: Property ClassStub::$var has unknown class T as its type.
+15: Parameter $var of method ClassStub::__construct() has invalid type T. Full reportPHP 8.0 (2 errors)
PHP 7.1 – 7.4 (4 errors)
|
@oprypkhantc After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
PHP 8.0 (2 errors)
==========
-15: Parameter $var of method ClassStub::__construct() has invalid typehint type T.
+15: Parameter $var of method ClassStub::__construct() has invalid type T.
15: Property ClassStub::$var has unknown class T as its type.
-PHP 7.1 – 7.4 (1 error)
+PHP 7.4 (3 errors)
==========
-15: Promoted properties are supported only on PHP 8.0 and later.
+15: Parameter $var of method ClassStub::__construct() has invalid type T.
+15: Promoted properties are supported only on PHP 8.0 and later.
+15: Property ClassStub::$var has unknown class T as its type.
+
+PHP 7.3 (4 errors)
+==========
+
+ 3: Attribute class Attribute does not exist.
+15: Parameter $var of method ClassStub::__construct() has invalid type T.
+15: Promoted properties are supported only on PHP 8.0 and later.
+15: Property ClassStub::$var has unknown class T as its type.
+
+PHP 7.1 – 7.2 (3 errors)
+==========
+
+15: Parameter $var of method ClassStub::__construct() has invalid type T.
+15: Promoted properties are supported only on PHP 8.0 and later.
+15: Property ClassStub::$var has unknown class T as its type. Full reportPHP 8.0 (2 errors)
PHP 7.4 (3 errors)
PHP 7.3 (4 errors)
PHP 7.1 – 7.2 (3 errors)
|
@oprypkhantc After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
PHP 8.0 (2 errors)
==========
-15: Parameter $var of method ClassStub::__construct() has invalid typehint type T.
+15: Parameter $var of method ClassStub::__construct() has invalid type T.
15: Property ClassStub::$var has unknown class T as its type.
-PHP 7.1 – 7.4 (1 error)
+PHP 7.1 – 7.4 (3 errors)
==========
-15: Promoted properties are supported only on PHP 8.0 and later.
+15: Parameter $var of method ClassStub::__construct() has invalid type T.
+15: Promoted properties are supported only on PHP 8.0 and later.
+15: Property ClassStub::$var has unknown class T as its type. Full reportPHP 8.0 (2 errors)
PHP 7.1 – 7.4 (3 errors)
|
Bug report
See the title. Moving the attribute below the PHPDoc fixes the problem and that's the usual way I would do it, but is strange either way.
Code snippet that reproduces the problem
https://phpstan.org/r/e933d057-a3d6-49b3-86c4-8b8be4090522
Expected output
Parse the PHPDoc correctly, as if the attribute was below it.
The text was updated successfully, but these errors were encountered: