Skip to content

Commit ab24c39

Browse files
committed
Add support for PHP shell-style comments
1 parent 4f274a2 commit ab24c39

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/Languages/Php/Patterns/SinglelineCommentPattern.php

Lines changed: 1 addition & 1 deletion
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

Lines changed: 18 additions & 0 deletions
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)