Skip to content

Commit 325fc64

Browse files
committed
Fix skipped new lines
1 parent 37a3efb commit 325fc64

File tree

2 files changed

+86
-13
lines changed

2 files changed

+86
-13
lines changed

src/Parser/PhpDocParser.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,6 @@ private function parseText(TokenIterator $tokens): Ast\PhpDoc\PhpDocTextNode
8080
// to be combined.
8181
$tokens->pushSavePoint();
8282
$tokens->next();
83-
if ($tokens->currentTokenType() === Lexer::TOKEN_PHPDOC_EOL) {
84-
$tokens->next();
85-
}
8683
if ($tokens->currentTokenType() !== Lexer::TOKEN_IDENTIFIER) {
8784
$tokens->rollback();
8885
break;

tests/PHPStan/Parser/PhpDocParserTest.php

Lines changed: 86 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2265,6 +2265,32 @@ public function provideMultiLinePhpDocData(): array
22652265
];
22662266
}
22672267

2268+
public function providerDebug(): \Iterator
2269+
{
2270+
$sample = '/**
2271+
* Returns the schema for the field.
2272+
*
2273+
* This method is static because the field schema information is needed on
2274+
* creation of the field. FieldItemInterface objects instantiated at that
2275+
* time are not reliable as field settings might be missing.
2276+
*
2277+
* Computed fields having no schema should return an empty array.
2278+
*/';
2279+
yield [
2280+
'OK class line',
2281+
$sample,
2282+
new PhpDocNode([
2283+
new PhpDocTextNode('Returns the schema for the field.'),
2284+
new PhpDocTextNode(''),
2285+
new PhpDocTextNode('This method is static because the field schema information is needed on
2286+
creation of the field. FieldItemInterface objects instantiated at that
2287+
time are not reliable as field settings might be missing.'),
2288+
new PhpDocTextNode(''),
2289+
new PhpDocTextNode('Computed fields having no schema should return an empty array.'),
2290+
]),
2291+
];
2292+
}
2293+
22682294
public function provideRealWorldExampleData(): \Iterator
22692295
{
22702296
$sample = "/**
@@ -2305,20 +2331,17 @@ public function provideRealWorldExampleData(): \Iterator
23052331
* such as {taxonomy_term_data}.
23062332
*/";
23072333
yield [
2308-
'OK with two param and paragraph description',
2334+
'OK FieldItemInterface::schema',
23092335
$sample,
23102336
new PhpDocNode([
2311-
new PhpDocTextNode('Returns the schema for the field.
2312-
This method is static because the field schema information is needed on
2337+
new PhpDocTextNode('Returns the schema for the field.'),
2338+
new PhpDocTextNode(''),
2339+
new PhpDocTextNode('This method is static because the field schema information is needed on
23132340
creation of the field. FieldItemInterface objects instantiated at that
2314-
time are not reliable as field settings might be missing.
2315-
Computed fields having no schema should return an empty array.'),
2316-
// @todo the commented out items should be correct.
2317-
//new PhpDocTextNode('Returns the schema for the field.'),
2341+
time are not reliable as field settings might be missing.'),
2342+
new PhpDocTextNode(''),
2343+
new PhpDocTextNode('Computed fields having no schema should return an empty array.'),
23182344
new PhpDocTextNode(''),
2319-
//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.'),
2320-
//new PhpDocTextNode(''),
2321-
//new PhpDocTextNode('Computed fields having no schema should return an empty array.'),
23222345
new PhpDocTagNode(
23232346
'@param',
23242347
new ParamTagValueNode(
@@ -2362,6 +2385,59 @@ public function provideRealWorldExampleData(): \Iterator
23622385
such as {taxonomy_term_data}.'),
23632386
]),
23642387
];
2388+
2389+
$sample = '/**
2390+
* Parses a chunked request and return relevant information.
2391+
*
2392+
* This function must return an array containing the following
2393+
* keys and their corresponding values:
2394+
* - last: Wheter this is the last chunk of the uploaded file
2395+
* - uuid: A unique id which distinguishes two uploaded files
2396+
* This uuid must stay the same among the task of
2397+
* uploading a chunked file.
2398+
* - index: A numerical representation of the currently uploaded
2399+
* chunk. Must be higher that in the previous request.
2400+
* - orig: The original file name.
2401+
*
2402+
* @param Request $request - The request object
2403+
*
2404+
* @return array
2405+
*/';
2406+
yield [
2407+
'OK AbstractChunkedController::parseChunkedRequest',
2408+
$sample,
2409+
new PhpDocNode([
2410+
new PhpDocTextNode('Parses a chunked request and return relevant information.'),
2411+
new PhpDocTextNode(''),
2412+
new PhpDocTextNode('This function must return an array containing the following
2413+
keys and their corresponding values:'),
2414+
new PhpDocTextNode('- last: Wheter this is the last chunk of the uploaded file'),
2415+
new PhpDocTextNode('- uuid: A unique id which distinguishes two uploaded files
2416+
This uuid must stay the same among the task of
2417+
uploading a chunked file.'),
2418+
new PhpDocTextNode('- index: A numerical representation of the currently uploaded
2419+
chunk. Must be higher that in the previous request.'),
2420+
new PhpDocTextNode('- orig: The original file name.'),
2421+
new PhpDocTextNode(''),
2422+
new PhpDocTagNode(
2423+
'@param',
2424+
new ParamTagValueNode(
2425+
new IdentifierTypeNode('Request'),
2426+
false,
2427+
'$request',
2428+
'- The request object'
2429+
)
2430+
),
2431+
new PhpDocTextNode(''),
2432+
new PhpDocTagNode(
2433+
'@return',
2434+
new ReturnTagValueNode(
2435+
new IdentifierTypeNode('array'),
2436+
''
2437+
)
2438+
),
2439+
]),
2440+
];
23652441
}
23662442

23672443
}

0 commit comments

Comments
 (0)