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
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
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.
Thank you for your report.
Fixed in https://github.com/slevomat/coding-standard/commit/896e52a167a1ebfe6d4a84835cf545181ba23796
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.
Most helpful comment
Welcome.
I see the milestone has been set to
5.1.0for this issue. Shouldn't the fix go into next bugfix/patch release for5.0?