Skip to content

Commit

Permalink
implements, extends
Browse files Browse the repository at this point in the history
  • Loading branch information
brendt committed Mar 20, 2024
1 parent 1ee03d6 commit 6f86073
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 28 deletions.
4 changes: 3 additions & 1 deletion src/Languages/Php/Patterns/ExtendsPattern.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@

use Tempest\Highlight\IsPattern;
use Tempest\Highlight\Pattern;
use Tempest\Highlight\PatternTest;
use Tempest\Highlight\Tokens\TokenType;

#[PatternTest(input: 'extends Foo', output: 'Foo')]
final readonly class ExtendsPattern implements Pattern
{
use IsPattern;

public function getPattern(): string
{
return 'extends\s(?<match>.*)';
return 'extends\s(?<match>[\w]+)';
}

public function getTokenType(): TokenType
Expand Down
5 changes: 4 additions & 1 deletion src/Languages/Php/Patterns/ImplementsPattern.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,18 @@

use Tempest\Highlight\IsPattern;
use Tempest\Highlight\Pattern;
use Tempest\Highlight\PatternTest;
use Tempest\Highlight\Tokens\TokenType;

#[PatternTest(input: 'implements Foo', output: ' Foo')]
#[PatternTest(input: 'implements Foo, Bar', output: ' Foo, Bar')]
final readonly class ImplementsPattern implements Pattern
{
use IsPattern;

public function getPattern(): string
{
return 'implements\s(?<match>[\w]+)';
return 'implements(?<match>[\s\,\w]+)';
}

public function getTokenType(): TokenType
Expand Down
23 changes: 0 additions & 23 deletions tests/Languages/Php/Patterns/ImplementsPatternTest.php

This file was deleted.

1 change: 1 addition & 0 deletions tests/Languages/Php/PhpLanguageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public static function data(): array
['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> = [];'],
['$concrete instanceof Closure', '$concrete <span class="hl-keyword">instanceof</span> <span class="hl-type">Closure</span>'],
['extends Foo implements ArrayAccess, ContainerContract', '<span class="hl-keyword">extends</span> <span class="hl-type">Foo</span> <span class="hl-keyword">implements</span><span class="hl-type"> ArrayAccess, ContainerContract</span>'],
[
"// We'll
Expand Down
2 changes: 1 addition & 1 deletion tests/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

$markdown = new MarkdownConverter($environment);

$contents = $markdown->convert(file_get_contents(__DIR__ . '/test-big.md'))->getContent();
$contents = $markdown->convert(file_get_contents(__DIR__ . '/test.md'))->getContent();

?>

Expand Down
6 changes: 4 additions & 2 deletions tests/test.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
```php
$abstract;
$class
extends Foo implements ArrayAccess, ContainerContract
{

}
```

0 comments on commit 6f86073

Please sign in to comment.