Skip to content

Commit

Permalink
Fix for promoted property hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
brendt committed Aug 27, 2024
1 parent 7901d5f commit 6ff070c
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 17 deletions.
4 changes: 4 additions & 0 deletions UPGRADING.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.9.0

- Fix for promoted property hooks (#110)

## 2.8.2

- Add Inspired GitHub theme (#139)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

public function getPattern(): string
{
return '(function|fn)[\s\w]*\((?<match>(.|\n)*?)\)[\s]*({|;|:|=>)';
return '(function|fn)[\s\w]*\((?<match>(.|\n)*?)({|\)[\s]*({|;|:|=>))';
}

public function parseContent(string $content, Highlighter $highlighter): string
Expand Down
2 changes: 1 addition & 1 deletion test-server.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

require_once __DIR__ . '/vendor/autoload.php';

passthru("php -S localhost:8080 -t tests/");
passthru("php -S localhost:8000 -t tests/");
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ public function show(
?Foo $post,
Bar $bar
)) => $bar,
public function __construct(
public string $username { set => strtolower($value); }
) {}
TXT;

$expectedOutput = <<<'TXT'
Expand Down Expand Up @@ -105,6 +109,10 @@ public function show(
<span class="hl-type">?Foo</span> $post,
<span class="hl-type">Bar</span> $bar
)</span>) =&gt; <span class="hl-variable">$bar</span>,
<span class="hl-keyword">public</span> <span class="hl-keyword">function</span> <span class="hl-property">__construct</span>(<span class="hl-injection">
<span class="hl-keyword">public</span> <span class="hl-type">string</span> <span class="hl-property">$username</span> </span>{ <span class="hl-keyword">set</span> =&gt; <span class="hl-property">strtolower</span>(<span class="hl-variable">$value</span>); }
) {}
TXT;

$highlighter = new Highlighter();
Expand Down
4 changes: 4 additions & 0 deletions tests/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@
align-items: center;
/*height: 100vh;*/
}

.hl-injection {
/*background-color: #f0000044;*/
}
</style>
<?php if ($stylesheet): ?>
<link rel="stylesheet" href="<?php echo $stylesheet; ?>">
Expand Down
18 changes: 3 additions & 15 deletions tests/targets/test.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
```php
/**
* This function will do some things
*
* @template T
* @param class-string<T> $className the class' name
* @param int $id
* @return T|null
*
* That's about all
*/

/**
* @template T
* @return T|null
*/
public function __construct(
public string $username { set => strtolower($value); }
) {}
```

0 comments on commit 6ff070c

Please sign in to comment.