Skip to content

Commit

Permalink
Trait and enum
Browse files Browse the repository at this point in the history
  • Loading branch information
brendt committed Mar 20, 2024
1 parent 6e8c59c commit b3cd587
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/Languages/Php/Patterns/ClassNamePattern.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,20 @@

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

#[PatternTest(input: 'class Foo {}', output: 'Foo')]
#[PatternTest(input: 'interface Foo {}', output: 'Foo')]
#[PatternTest(input: 'trait Foo {}', output: 'Foo')]
#[PatternTest(input: 'enum Foo {}', output: 'Foo')]
final readonly class ClassNamePattern implements Pattern
{
use IsPattern;

public function getPattern(): string
{
return '(class|interface) (?<match>[\w]+)';
return '(class|interface|trait|enum) (?<match>[\w]+)';
}

public function getTokenType(): TokenType
Expand Down
2 changes: 1 addition & 1 deletion src/Languages/Php/Patterns/GroupedTypePattern.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#[PatternTest(input: 'null|(Foo|Bar) $bar', output: '(Foo|Bar)')]
#[PatternTest(input: 'null|(?Bar) $bar', output: '(?Bar)')]
//#[PatternTest(input: 'while (true)', output: null)]
// TODO: this rule is broken and disabled
// TODO: this pattern is broken and disabled
final readonly class GroupedTypePattern implements Pattern
{
use IsPattern;
Expand Down
5 changes: 4 additions & 1 deletion tests/test.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
```php
while (true) {
trait Test {
abstract public function test(int $input): int;
}

```

0 comments on commit b3cd587

Please sign in to comment.