mirror of
https://github.com/danog/phpdoc-parser.git
synced 2024-11-30 04:29:20 +01:00
Require whitespace before description with limited start tokens
This commit is contained in:
parent
b75949e747
commit
d579798d2f
@ -474,6 +474,10 @@ class PhpDocParser
|
||||
|
||||
$tokens->consumeTokenType(Lexer::TOKEN_OTHER); // will throw exception
|
||||
}
|
||||
|
||||
if (!$tokens->isCurrentTokenType(Lexer::TOKEN_PHPDOC_EOL) && !$tokens->isPrecededByHorizontalWhitespace()) {
|
||||
$tokens->consumeTokenType(Lexer::TOKEN_HORIZONTAL_WS); // will throw exception
|
||||
}
|
||||
}
|
||||
|
||||
return $this->parseText($tokens)->text;
|
||||
|
@ -1310,6 +1310,58 @@ class PhpDocParserTest extends TestCase
|
||||
),
|
||||
]),
|
||||
];
|
||||
|
||||
yield [
|
||||
'OK variadic callable',
|
||||
'/** @return \Closure(int ...$u, string): string */',
|
||||
new PhpDocNode([
|
||||
new PhpDocTagNode(
|
||||
'@return',
|
||||
new ReturnTagValueNode(
|
||||
new CallableTypeNode(
|
||||
new IdentifierTypeNode('\Closure'),
|
||||
[
|
||||
new CallableTypeParameterNode(
|
||||
new IdentifierTypeNode('int'),
|
||||
false,
|
||||
true,
|
||||
'$u',
|
||||
false
|
||||
),
|
||||
new CallableTypeParameterNode(
|
||||
new IdentifierTypeNode('string'),
|
||||
false,
|
||||
false,
|
||||
'',
|
||||
false
|
||||
),
|
||||
],
|
||||
new IdentifierTypeNode('string')
|
||||
),
|
||||
''
|
||||
)
|
||||
),
|
||||
]),
|
||||
];
|
||||
|
||||
yield [
|
||||
'invalid variadic callable',
|
||||
'/** @return \Closure(...int, string): string */',
|
||||
new PhpDocNode([
|
||||
new PhpDocTagNode(
|
||||
'@return',
|
||||
new InvalidTagValueNode(
|
||||
'\Closure(...int, string): string',
|
||||
new ParserException(
|
||||
'(',
|
||||
Lexer::TOKEN_OPEN_PARENTHESES,
|
||||
20,
|
||||
Lexer::TOKEN_HORIZONTAL_WS
|
||||
)
|
||||
)
|
||||
),
|
||||
]),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@ -2104,10 +2156,14 @@ class PhpDocParserTest extends TestCase
|
||||
new PhpDocNode([
|
||||
new PhpDocTagNode(
|
||||
'@var',
|
||||
new VarTagValueNode(
|
||||
new IdentifierTypeNode('callable'),
|
||||
'',
|
||||
'(int)'
|
||||
new InvalidTagValueNode(
|
||||
'callable(int)',
|
||||
new ParserException(
|
||||
'(',
|
||||
Lexer::TOKEN_OPEN_PARENTHESES,
|
||||
17,
|
||||
Lexer::TOKEN_HORIZONTAL_WS
|
||||
)
|
||||
)
|
||||
),
|
||||
]),
|
||||
@ -4076,14 +4132,14 @@ Finder::findFiles('*.php')
|
||||
new PhpDocNode([
|
||||
new PhpDocTagNode(
|
||||
'@return',
|
||||
new ReturnTagValueNode(
|
||||
new GenericTypeNode(
|
||||
new IdentifierTypeNode('Foo'),
|
||||
[
|
||||
new IdentifierTypeNode('strong'),
|
||||
]
|
||||
),
|
||||
'Important description'
|
||||
new InvalidTagValueNode(
|
||||
'Foo <strong>Important description',
|
||||
new ParserException(
|
||||
'Important',
|
||||
Lexer::TOKEN_IDENTIFIER,
|
||||
27,
|
||||
Lexer::TOKEN_HORIZONTAL_WS
|
||||
)
|
||||
)
|
||||
),
|
||||
]),
|
||||
|
Loading…
Reference in New Issue
Block a user