Skip to content

Commit

Permalink
Attribute fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
brendt committed Mar 20, 2024
1 parent 78b70f7 commit 6e66b2a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 44 deletions.
6 changes: 3 additions & 3 deletions src/Languages/Php/Patterns/AttributePattern.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
use Tempest\Highlight\PatternTest;
use Tempest\Highlight\Tokens\TokenType;

#[
PatternTest(input: '#[Foo(prop: hi)]', output: '#[Foo(prop: hi)]'),
PatternTest(
#[PatternTest(input: '#[Foo(prop: hi)]', output: '#[Foo(prop: hi)]')]
#[PatternTest(input: '#[\\AllowDynamicProperties]', output: '#[\\AllowDynamicProperties]')]
#[PatternTest(
input:
'#[Foo(
prop: hi,
Expand Down
14 changes: 13 additions & 1 deletion src/Languages/Php/Patterns/AttributeTypePattern.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,27 @@

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

#[PatternTest(input: '#[Foo(prop: hi)]', output: 'Foo')]
#[PatternTest(input: '#[\Foo(prop: hi)]', output: '\Foo')]
#[PatternTest(
input: '#[Foo(
uri: "/books/create",
"/books/create",
),
Bar(uri: "/books/create"),
Baz,
]',
output: ['Foo', 'Bar', 'Baz'])]
final readonly class AttributeTypePattern implements Pattern
{
use IsPattern;

public function getPattern(): string
{
return '/(^[\s]*|\#\[)(?<match>[A-Z][\w]+)/m';
return '/(^[\s]*|\#\[)(?<match>[\\\\]*[A-Z][\w\\\\]+)/m';
}

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

This file was deleted.

5 changes: 1 addition & 4 deletions tests/test.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
```php
enum Foo: string
{
case Pending = 'hi';
}
#[\AllowDynamicProperties]
```

0 comments on commit 6e66b2a

Please sign in to comment.