5
5
* For full license information, please view the LICENSE file that was distributed with this source code.
6
6
*/
7
7
8
- declare (strict_types=1 );
9
-
10
8
namespace PhpCollective \Sniffs \Commenting ;
11
9
12
10
use PHP_CodeSniffer \Files \File ;
@@ -102,6 +100,9 @@ public function process(File $phpcsFile, $docCommentOpenPointer): void
102
100
}
103
101
104
102
$ parsedDocComment = DocCommentHelper::parseDocComment ($ phpcsFile , $ docCommentOpenPointer );
103
+ if ($ parsedDocComment === null ) {
104
+ continue ;
105
+ }
105
106
106
107
/** @var list<\PHPStan\PhpDocParser\Ast\Type\UnionTypeNode> $unionTypeNodes */
107
108
$ unionTypeNodes = AnnotationHelper::getAnnotationNodesByType ($ annotation ->getNode (), UnionTypeNode::class);
@@ -194,6 +195,7 @@ protected function isGenericObjectCollection(Annotation $annotation): bool
194
195
*/
195
196
protected function fixGenericObjectCollection (File $ phpcsFile , Annotation $ annotation ): void
196
197
{
198
+ //@phpstan-ignore-next-line
197
199
$ typeNode = AnnotationHelper::getAnnotationTypes ($ annotation )[0 ];
198
200
199
201
$ genericType = null ;
@@ -215,6 +217,7 @@ protected function fixGenericObjectCollection(File $phpcsFile, Annotation $annot
215
217
continue ;
216
218
}
217
219
220
+ //@phpstan-ignore-next-line
218
221
if ($ this ->isArrayTypeNode ($ type )) {
219
222
if ($ arrayType !== null ) {
220
223
return ;
@@ -236,7 +239,7 @@ protected function fixGenericObjectCollection(File $phpcsFile, Annotation $annot
236
239
$ fix = $ phpcsFile ->addFixableError (
237
240
sprintf (
238
241
'Usage of old type hint syntax for generic in `%s` is disallowed, use generic type hint syntax instead. ' ,
239
- AnnotationTypeHelper::export ($ typeNode ),
242
+ AnnotationTypeHelper::print ($ typeNode ),
240
243
),
241
244
$ annotation ->getStartPointer (),
242
245
static ::CODE_DISALLOWED_ARRAY_TYPE_HINT_SYNTAX . 'Union ' ,
@@ -256,6 +259,7 @@ protected function fixGenericObjectCollection(File $phpcsFile, Annotation $annot
256
259
257
260
$ fixedType = implode ('| ' , $ unionTypes );
258
261
262
+ //@phpstan-ignore-next-line
259
263
$ content = $ annotation ->getContent () ?? '' ;
260
264
$ spacePosition = strpos ($ content , ' ' );
261
265
if ($ spacePosition !== false ) {
0 commit comments