File tree Expand file tree Collapse file tree
rules-tests/CodingStyle/Rector/Namespace_/ImportFullyQualifiedNamesRector/Fixture
src/BetterPhpDocParser/PhpDocNodeVisitor Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Rector \Tests \CodingStyle \Rector \Namespace_ \ImportFullyQualifiedNamesRector \Fixture ;
4+
5+ /**
6+ * @method static \Rector\Tests\CodingStyle\Rector\Namespace_\ImportFullyQualifiedNamesRector\Source\NormalParamClass disable(string|array ...$classes)
7+ */
8+ class ImportMethodWithFirstParamUnion
9+ {
10+ }
11+
12+ ?>
13+ -----
14+ <?php
15+
16+ namespace Rector \Tests \CodingStyle \Rector \Namespace_ \ImportFullyQualifiedNamesRector \Fixture ;
17+
18+ use Rector \Tests \CodingStyle \Rector \Namespace_ \ImportFullyQualifiedNamesRector \Source \NormalParamClass ;
19+
20+ /**
21+ * @method static NormalParamClass disable(string|array ...$classes)
22+ */
23+ class ImportMethodWithFirstParamUnion
24+ {
25+ }
26+
27+ ?>
Original file line number Diff line number Diff line change @@ -58,13 +58,13 @@ public function enterNode(Node $node): ?Node
5858 private function isWrappedInCurlyBrackets (BetterTokenIterator $ betterTokenProvider , StartAndEnd $ startAndEnd ): bool
5959 {
6060 $ previousPosition = $ startAndEnd ->getStart () - 1 ;
61+ $ nextPosition = $ startAndEnd ->getEnd () + 1 ;
6162
62- if ($ betterTokenProvider ->isTokenTypeOnPosition (Lexer::TOKEN_OPEN_PARENTHESES , $ previousPosition )) {
63- return true ;
64- }
65-
66- // there is no + 1, as end is right at the next token
67- return $ betterTokenProvider ->isTokenTypeOnPosition (Lexer::TOKEN_CLOSE_PARENTHESES , $ startAndEnd ->getEnd ());
63+ // A union is wrapped only when BOTH parens flank it. Either alone may be unrelated —
64+ // e.g. an `@method`'s parameter-list `(` before a first-position union, or the matching
65+ // `)` after a last-position union — neither belongs to the union type itself.
66+ return $ betterTokenProvider ->isTokenTypeOnPosition (Lexer::TOKEN_OPEN_PARENTHESES , $ previousPosition )
67+ && $ betterTokenProvider ->isTokenTypeOnPosition (Lexer::TOKEN_CLOSE_PARENTHESES , $ nextPosition );
6868 }
6969
7070 private function resolveStartAndEnd (UnionTypeNode $ unionTypeNode ): ?StartAndEnd
You can’t perform that action at this time.
0 commit comments