Coding-standard: Error generated in AnnotationTypeHelper

Created on 11 Jun 2019  路  8Comments  路  Source: slevomat/coding-standard

The following error is generated when a docblock with typehint of kind @var array{serialize:string|bool|null} is encountered.

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 1 | ERROR | An error occurred during processing; checking has been aborted. The error message was: Undefined property: PHPStan\PhpDocParser\Ast\Type\ArrayShapeNode::$name in
   |       | .../vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/AnnotationTypeHelper.php on line 167
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Bug

Most helpful comment

Welcome.

I see the milestone has been set to 5.1.0 for this issue. Shouldn't the fix go into next bugfix/patch release for 5.0?

All 8 comments

Changing the line in question from

        return $typeNode instanceof ThisTypeNode
            ? (string) $typeNode
            : $typeNode->name;

to just

        return (string) $typeNode;

prevents the error from being generated.

All TypeNode classes do have the __toString() method.

Or maybe additional changes are required further up the call chain to account for the support for array shapes recently added to the phpdoc parser https://github.com/phpstan/phpdoc-parser/releases/tag/0.3.5.

Welcome.

I see the milestone has been set to 5.1.0 for this issue. Shouldn't the fix go into next bugfix/patch release for 5.0?

Any ETA on when this fix will be released? It's causing our CakePHP builds to fail :slightly_smiling_face:.

@kukulich Update of the deps doesn't solve the problem.

$ composer show phpstan/phpdoc-parser | grep version
versions : * 0.3.5
$ vendor/bin/phpcs --standard=phpcs.xml.dist --ignore=./Migrations/* ./src

FILE: src/[redacted]
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 1 | ERROR | An error occurred during processing; checking has been
   |       | aborted. The error message was: Undefined property:
   |       | PHPStan\PhpDocParser\Ast\Type\ArrayShapeNode::$name in
   |       | /[redacted]/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/AnnotationTypeHelper.php
   |       | on line 167
----------------------------------------------------------------------

Time: 4.72 secs; Memory: 6MB

This problem is caused solely by using array shapes (e.g. @return array{bool, bool}).

:disappointed:

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

donatj picture donatj  路  3Comments

lptn picture lptn  路  4Comments

aiphee picture aiphee  路  4Comments

alcaeus picture alcaeus  路  6Comments

Stadly picture Stadly  路  6Comments