Skip to content

Commit

Permalink
Fix static keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
brendt committed Mar 20, 2024
1 parent 129d8ac commit cb895f2
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Languages/Php/Patterns/KeywordPattern.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function caseInsensitive(): self

public function getPattern(): string
{
$pattern = "/\b(?<!\\$)(?<match>{$this->keyword})(\s|\()/";
$pattern = "/\b(?<!\\$)(?<match>{$this->keyword})(\:|\s|\()/";

if ($this->caseInsensitive) {
$pattern .= 'i';
Expand Down
2 changes: 1 addition & 1 deletion src/Tokens/GroupTokens.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
public function __invoke(array $tokens): array
{
// dump($tokens);
// dump($tokens);
// Sort tokens in the right order
usort($tokens, function (Token $a, Token $b) {
if ($a->start === $b->start) {
Expand Down
1 change: 1 addition & 0 deletions tests/Languages/Php/PhpLanguageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public static function data(): array
["public string|\Stringable \$message;", '<span class="hl-keyword">public</span> <span class="hl-type">string|\<span class="hl-type">Stringable</span></span> <span class="hl-property">$message</span>;'],
['for($x = 0; $x < 150; $x++) {', '<span class="hl-keyword">for</span>(<span class="hl-variable">$x</span> = 0; <span class="hl-variable">$x</span> &lt; 150; <span class="hl-variable">$x</span>++) {'],
["'namespace ';", "'<span class=\"hl-value\">namespace </span>';"],
["static::foo()", '<span class="hl-keyword">static</span>::<span class="hl-property">foo</span>()'],
['$class', '<span class="hl-variable">$class</span>'],
['protected $resolved = [];', '<span class="hl-keyword">protected</span> <span class="hl-property">$resolved</span> = [];'],
['protected Foo $resolved = [];', '<span class="hl-keyword">protected</span> <span class="hl-type">Foo</span> <span class="hl-property">$resolved</span> = [];'],
Expand Down
4 changes: 1 addition & 3 deletions tests/test.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
```php
$foo && $bar
$foo || $bar
$foo <=> $bar
static::$instance
```

0 comments on commit cb895f2

Please sign in to comment.