Skip to content

Commit

Permalink
Fix skipped new lines
Browse files Browse the repository at this point in the history
  • Loading branch information
mglaman authored and ondrejmirtes committed May 28, 2019
1 parent 13d62b8 commit ab518a5
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 14 deletions.
3 changes: 0 additions & 3 deletions src/Parser/PhpDocParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,6 @@ private function parseText(TokenIterator $tokens): Ast\PhpDoc\PhpDocTextNode
// to be combined.
$tokens->pushSavePoint();
$tokens->next();
if ($tokens->currentTokenType() === Lexer::TOKEN_PHPDOC_EOL) {
$tokens->next();
}
if ($tokens->currentTokenType() !== Lexer::TOKEN_IDENTIFIER) {
$tokens->rollback();
break;
Expand Down
98 changes: 87 additions & 11 deletions tests/PHPStan/Parser/PhpDocParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ protected function setUp(): void
* @dataProvider provideSingleLinePhpDocData
* @dataProvider provideMultiLinePhpDocData
* @dataProvider provideTemplateTagsData
* @dataProvider provideRealWorldExampleData
* @dataProvider provideRealWorldExampleData
* @param string $label
* @param string $input
* @param PhpDocNode $expectedPhpDocNode
Expand Down Expand Up @@ -2368,6 +2368,32 @@ public function provideTemplateTagsData(): \Iterator
];
}

public function providerDebug(): \Iterator
{
$sample = '/**
* Returns the schema for the field.
*
* This method is static because the field schema information is needed on
* creation of the field. FieldItemInterface objects instantiated at that
* time are not reliable as field settings might be missing.
*
* Computed fields having no schema should return an empty array.
*/';
yield [
'OK class line',
$sample,
new PhpDocNode([
new PhpDocTextNode('Returns the schema for the field.'),
new PhpDocTextNode(''),
new PhpDocTextNode('This method is static because the field schema information is needed on
creation of the field. FieldItemInterface objects instantiated at that
time are not reliable as field settings might be missing.'),
new PhpDocTextNode(''),
new PhpDocTextNode('Computed fields having no schema should return an empty array.'),
]),
];
}

public function provideRealWorldExampleData(): \Iterator
{
$sample = "/**
Expand Down Expand Up @@ -2408,20 +2434,17 @@ public function provideRealWorldExampleData(): \Iterator
* such as {taxonomy_term_data}.
*/";
yield [
'OK with two param and paragraph description',
'OK FieldItemInterface::schema',
$sample,
new PhpDocNode([
new PhpDocTextNode('Returns the schema for the field.
This method is static because the field schema information is needed on
new PhpDocTextNode('Returns the schema for the field.'),
new PhpDocTextNode(''),
new PhpDocTextNode('This method is static because the field schema information is needed on
creation of the field. FieldItemInterface objects instantiated at that
time are not reliable as field settings might be missing.
Computed fields having no schema should return an empty array.'),
// @todo the commented out items should be correct.
//new PhpDocTextNode('Returns the schema for the field.'),
time are not reliable as field settings might be missing.'),
new PhpDocTextNode(''),
new PhpDocTextNode('Computed fields having no schema should return an empty array.'),
new PhpDocTextNode(''),
//new PhpDocTextNode('This method is static because the field schema information is needed on creation of the field. FieldItemInterface objects instantiated at that time are not reliable as field settings might be missing.'),
//new PhpDocTextNode(''),
//new PhpDocTextNode('Computed fields having no schema should return an empty array.'),
new PhpDocTagNode(
'@param',
new ParamTagValueNode(
Expand Down Expand Up @@ -2465,6 +2488,59 @@ public function provideRealWorldExampleData(): \Iterator
such as {taxonomy_term_data}.'),
]),
];

$sample = '/**
* Parses a chunked request and return relevant information.
*
* This function must return an array containing the following
* keys and their corresponding values:
* - last: Wheter this is the last chunk of the uploaded file
* - uuid: A unique id which distinguishes two uploaded files
* This uuid must stay the same among the task of
* uploading a chunked file.
* - index: A numerical representation of the currently uploaded
* chunk. Must be higher that in the previous request.
* - orig: The original file name.
*
* @param Request $request - The request object
*
* @return array
*/';
yield [
'OK AbstractChunkedController::parseChunkedRequest',
$sample,
new PhpDocNode([
new PhpDocTextNode('Parses a chunked request and return relevant information.'),
new PhpDocTextNode(''),
new PhpDocTextNode('This function must return an array containing the following
keys and their corresponding values:'),
new PhpDocTextNode('- last: Wheter this is the last chunk of the uploaded file'),
new PhpDocTextNode('- uuid: A unique id which distinguishes two uploaded files
This uuid must stay the same among the task of
uploading a chunked file.'),
new PhpDocTextNode('- index: A numerical representation of the currently uploaded
chunk. Must be higher that in the previous request.'),
new PhpDocTextNode('- orig: The original file name.'),
new PhpDocTextNode(''),
new PhpDocTagNode(
'@param',
new ParamTagValueNode(
new IdentifierTypeNode('Request'),
false,
'$request',
'- The request object'
)
),
new PhpDocTextNode(''),
new PhpDocTagNode(
'@return',
new ReturnTagValueNode(
new IdentifierTypeNode('array'),
''
)
),
]),
];
}

}

0 comments on commit ab518a5

Please sign in to comment.