Skip to content

Commit 0679847

Browse files
committed
Fix for variadic types
1 parent 1b4fc5c commit 0679847

File tree

3 files changed

+4
-11
lines changed

3 files changed

+4
-11
lines changed

UPGRADING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- Fix for static property types (#129)
66
- Fix for attribute in promoted property (#133)
77
- Fix for comments in function argument lists (#134)
8+
- Fix for variadic types (#140)
89

910
## 2.8.2
1011

src/Languages/Php/Patterns/TypeForVariablePattern.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@
1515
#[PatternTest(input: 'Foo|Bar|null $bar', output: 'Foo|Bar|null')]
1616
#[PatternTest(input: '(Foo&Bar)|null $bar', output: '(Foo&Bar)|null')]
1717
#[PatternTest(input: 'string|\Stringable $bar', output: 'string|\Stringable')]
18+
#[PatternTest(input: 'Foo ...$params', output: 'Foo')]
1819
final readonly class TypeForVariablePattern implements Pattern
1920
{
2021
use IsPattern;
2122

2223
public function getPattern(): string
2324
{
24-
return '(?<match>[\w\&\(\)\|\\\\\?]+)\s+\\$';
25+
return '(?<match>[\w\&\(\)\|\\\\\?]+)\s+(\.*)\\$';
2526
}
2627

2728
public function getTokenType(): TokenTypeEnum

tests/targets/test.md

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
11
```php
2-
public function __construct(
3-
// Allow a union on a special "missing relation" type:
4-
public Relation|Author $author,
5-
6-
// Making the relation nullable would be an option as well:
7-
/** @var Chapter[] $chapters */
8-
/**
9-
* hello */
10-
public ?array $chapters,
11-
) {}
2+
public function update(Foo ...$params): self;
123
```

0 commit comments

Comments
 (0)