Skip to content

Commit 32908c8

Browse files
committed
Parse docs with line endings: LF, CR, CRLF
1 parent b30ae55 commit 32908c8

File tree

3 files changed

+39
-2
lines changed

3 files changed

+39
-2
lines changed

ReadMe.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,10 @@ The original implementation is in <https://github.com/jasny/phpdoc-parser>.
239239

240240
Features fixed and improved so far:
241241

242+
- Tags `@param` failed to handle multiline tags properly, now it's fixed
242243
- Typo `"summery"` to `"summary"`
243244
- Improper parsing summary in multiple lines
244245
- Added support for `@version` tag
245246
- `@method` interprets `static` properly
246-
- Tags `@param` failed to handle multiline tags properly
247247
- Fixed improper parsing of unclosed or improperly closed doc block
248+
- Previous parser failed parsing for line endings `CR` and `CRLF`, now it supports: `LF`, `CR`, `CRLF`.

src/PhpdocParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ private function summaryLinesAndTagList(string $docBlock): array
4141

4242
private function tagsAndLines(string $docBlock): array
4343
{
44-
$regex = Pattern::of('^
44+
$regex = Pattern::of('(*ANYCRLF)^
4545
\s*
4646
\*?
4747
(?:

test/Feature/Test.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,42 @@ public function shouldParseStandardExample()
6464
]);
6565
}
6666

67+
/**
68+
* @test
69+
*/
70+
public function shouldParseCrlf()
71+
{
72+
// given
73+
$crlfDoc = "/**\r\n * @deprecated\r\n */";
74+
// when, then
75+
$this->assertParses($crlfDoc, ['deprecated' => true,]);
76+
}
77+
78+
/**
79+
* @test
80+
*/
81+
public function shouldParseCr()
82+
{
83+
// given
84+
$crlfDoc = "/**\r * @deprecated\r */";
85+
// when, then
86+
$this->assertParses($crlfDoc, ['deprecated' => true,]);
87+
}
88+
89+
/**
90+
* @test
91+
*/
92+
public function shouldParseCrNewlines()
93+
{
94+
// given
95+
$crlfDoc = "/** summary\r*\r*description */";
96+
// when, then
97+
$this->assertParses($crlfDoc, [
98+
'summary' => 'summary',
99+
'description' => 'description',
100+
]);
101+
}
102+
67103
/**
68104
* @test
69105
* @dataProvider improperDocBlocks

0 commit comments

Comments
 (0)