Skip to content

Commit 5a239a9

Browse files
authored
Merge pull request #172 from rojtjo/feature/php-shell-style-comments
Add support for PHP shell-style comments
2 parents 4f274a2 + ab24c39 commit 5a239a9

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/Languages/Php/Patterns/SinglelineCommentPattern.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
public function getPattern(): string
1616
{
17-
return '(?<match>\/\/(.)*)';
17+
return '(?<match>(?:\/\/|#[^\[])(.)*)';
1818
}
1919

2020
public function getTokenType(): TokenTypeEnum

tests/Languages/Php/Patterns/SinglelineDocCommentPatternTest.php

+18
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,23 @@ public function test_pattern()
1919
content: '$bar // foo',
2020
expected: '// foo',
2121
);
22+
23+
$this->assertMatches(
24+
pattern: new SinglelineCommentPattern(),
25+
content: '$bar # foo',
26+
expected: '# foo',
27+
);
28+
29+
$this->assertMatches(
30+
pattern: new SinglelineCommentPattern(),
31+
content: '$bar #[IncompleteAttribute',
32+
expected: null,
33+
);
34+
35+
$this->assertMatches(
36+
pattern: new SinglelineCommentPattern(),
37+
content: '$bar #[Attribute]',
38+
expected: null,
39+
);
2240
}
2341
}

0 commit comments

Comments
 (0)