Skip to content

Commit d2fb6c8

Browse files
committed
Fix use not being highlighted (#159)
1 parent 33b8b2c commit d2fb6c8

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

src/Languages/Php/Injections/PhpFunctionParametersInjection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
public function getPattern(): string
1818
{
19-
return '(function|fn)[\s\w]*\((?<match>(.|\n)*?)({|\)[\s]*({|;|:|=>))';
19+
return '(function|fn)[\s\w]*\((?<match>(.|\n)*?)(use|{|\)[\s]*({|;|:|=>))';
2020
}
2121

2222
public function parseContent(string $content, Highlighter $highlighter): string

tests/Languages/Php/PhpLanguageTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ public function info(
138138
</span>) {}'],
139139
['public static function new(mixed ...$params): self;', '<span class="hl-keyword">public</span> <span class="hl-keyword">static</span> <span class="hl-keyword">function</span> <span class="hl-property">new</span>(<span class="hl-injection"><span class="hl-type">mixed</span> ...$params</span>): <span class="hl-type">self</span>;'],
140140
['return $this->createOrModify(namespace\push($this->value, $value));', '<span class="hl-keyword">return</span> <span class="hl-variable">$this</span>-&gt;<span class="hl-property">createOrModify</span>(<span class="hl-keyword">namespace</span>\<span class="hl-property">push</span>(<span class="hl-variable">$this</span>-&gt;<span class="hl-property">value</span>, <span class="hl-variable">$value</span>));'],
141+
['function () use ($request) {', '<span class="hl-keyword">function</span> (<span class="hl-injection">) </span><span class="hl-keyword">use</span> (<span class="hl-variable">$request</span>) {'],
141142
];
142143
}
143144
}

tests/targets/test.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
```php
2-
return $this->createOrModify(namespace\push($this->value, $value));
2+
function () use ($request) {
33
```

0 commit comments

Comments
 (0)