Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 9efbbb6

Browse files
Andreas Frömerondrejmirtes
Andreas Frömer
authored andcommitted
Add possibility for leading comma
1 parent ba7df7e commit 9efbbb6

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

‎src/Parser/TypeParser.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ public function parseGeneric(TokenIterator $tokens, Ast\Type\IdentifierTypeNode
167167
$tokens->consumeTokenType(Lexer::TOKEN_OPEN_ANGLE_BRACKET);
168168
$tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL);
169169
$genericTypes = [$this->parse($tokens)];
170+
$tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL);
170171

171172
while ($tokens->tryConsumeTokenType(Lexer::TOKEN_COMMA)) {
172173
$tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL);

‎tests/PHPStan/Parser/PhpDocParserTest.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3078,6 +3078,54 @@ public function provideRealWorldExampleData(): \Iterator
30783078
),
30793079
]),
30803080
];
3081+
3082+
// yield [
3083+
// 'multiline generic types - trailing comma',
3084+
// '/**' . PHP_EOL .
3085+
// ' * @implements Foo<' . PHP_EOL .
3086+
// ' * A,' . PHP_EOL .
3087+
// ' * >' . PHP_EOL .
3088+
// ' */',
3089+
// new PhpDocNode([
3090+
// new PhpDocTagNode(
3091+
// '@implements',
3092+
// new ImplementsTagValueNode(
3093+
// new GenericTypeNode(
3094+
// new IdentifierTypeNode('Foo'),
3095+
// [
3096+
// new IdentifierTypeNode('A'),
3097+
// ]
3098+
// ),
3099+
// ''
3100+
// )
3101+
// ),
3102+
// ]),
3103+
// ];
3104+
3105+
yield [
3106+
'multiline generic types - leading comma',
3107+
'/**' . PHP_EOL .
3108+
' * @implements Foo<' . PHP_EOL .
3109+
' * A' . PHP_EOL .
3110+
' * , B' . PHP_EOL .
3111+
' * >' . PHP_EOL .
3112+
' */',
3113+
new PhpDocNode([
3114+
new PhpDocTagNode(
3115+
'@implements',
3116+
new ImplementsTagValueNode(
3117+
new GenericTypeNode(
3118+
new IdentifierTypeNode('Foo'),
3119+
[
3120+
new IdentifierTypeNode('A'),
3121+
new IdentifierTypeNode('B'),
3122+
]
3123+
),
3124+
''
3125+
)
3126+
),
3127+
]),
3128+
];
30813129
}
30823130

30833131
public function dataParseTagValue(): array

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /