|
@@ -264,6 +264,7 @@ $bar;',
|
|
['<?php /* @var User $bar */ list($bar) = a();'],
|
|
['<?php /* @var User $bar */ list($bar) = a();'],
|
|
['<?php /* Before anonymous function */ $fn = fn($x) => $x + 1;'],
|
|
['<?php /* Before anonymous function */ $fn = fn($x) => $x + 1;'],
|
|
['<?php /* Before anonymous function */ fn($x) => $x + 1;'],
|
|
['<?php /* Before anonymous function */ fn($x) => $x + 1;'],
|
|
|
|
+ ['<?php /* @var int $x */ [$x] = [2];'],
|
|
];
|
|
];
|
|
}
|
|
}
|
|
|
|
|
|
@@ -291,25 +292,10 @@ $bar;',
|
|
|
|
|
|
static::bar();',
|
|
static::bar();',
|
|
],
|
|
],
|
|
|
|
+ ['<?php /* @var int $a */ [$b] = [2];'],
|
|
];
|
|
];
|
|
}
|
|
}
|
|
|
|
|
|
- public function testPhpdocCandidate71(): void
|
|
|
|
- {
|
|
|
|
- $tokens = Tokens::fromCode('<?php /* @var int $x */ [$x] = [2];');
|
|
|
|
- $analyzer = new CommentsAnalyzer();
|
|
|
|
-
|
|
|
|
- self::assertTrue($analyzer->isHeaderComment($tokens, 1));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public function testNotPhpdocCandidate71(): void
|
|
|
|
- {
|
|
|
|
- $tokens = Tokens::fromCode('<?php /* @var int $a */ [$b] = [2];');
|
|
|
|
- $analyzer = new CommentsAnalyzer();
|
|
|
|
-
|
|
|
|
- self::assertFalse($analyzer->isBeforeStructuralElement($tokens, 1));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* @dataProvider providePhpdocCandidatePhp80Cases
|
|
* @dataProvider providePhpdocCandidatePhp80Cases
|
|
*
|
|
*
|
|
@@ -384,4 +370,41 @@ Class MyAnnotation3 {}'],
|
|
'<?php /* Before enum */ enum Foo {}',
|
|
'<?php /* Before enum */ enum Foo {}',
|
|
];
|
|
];
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @dataProvider provideNotPhpdocCandidatePhp811Cases
|
|
|
|
+ *
|
|
|
|
+ * @requires PHP 8.1
|
|
|
|
+ */
|
|
|
|
+ public function testNotPhpdocCandidatePhp81(string $code): void
|
|
|
|
+ {
|
|
|
|
+ $tokens = Tokens::fromCode($code);
|
|
|
|
+ $index = $tokens->getNextTokenOfKind(0, [[T_COMMENT], [T_DOC_COMMENT]]);
|
|
|
|
+ $analyzer = new CommentsAnalyzer();
|
|
|
|
+
|
|
|
|
+ self::assertFalse($analyzer->isBeforeStructuralElement($tokens, $index));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static function provideNotPhpdocCandidatePhp811Cases(): iterable
|
|
|
|
+ {
|
|
|
|
+ yield 'enum and switch' => [
|
|
|
|
+ '<?php
|
|
|
|
+ enum E {}
|
|
|
|
+ switch ($x) {
|
|
|
|
+ /* */
|
|
|
|
+ case 1: return 2;
|
|
|
|
+ }
|
|
|
|
+ ',
|
|
|
|
+ ];
|
|
|
|
+
|
|
|
|
+ yield 'switch and enum' => [
|
|
|
|
+ '<?php
|
|
|
|
+ switch ($x) {
|
|
|
|
+ /* */
|
|
|
|
+ case 1: return 2;
|
|
|
|
+ }
|
|
|
|
+ enum E {}
|
|
|
|
+ ',
|
|
|
|
+ ];
|
|
|
|
+ }
|
|
}
|
|
}
|