Skip to content

Commit ca84b97

Browse files
committed
Fix for functions called "new"
1 parent 0679847 commit ca84b97

File tree

4 files changed

+5
-3
lines changed

4 files changed

+5
-3
lines changed

UPGRADING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- Fix for attribute in promoted property (#133)
77
- Fix for comments in function argument lists (#134)
88
- Fix for variadic types (#140)
9+
- Fix for functions called "new" (#141)
910

1011
## 2.8.2
1112

src/Languages/Php/PhpLanguage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ public function getPatterns(): array
8484
new OperatorPattern('\|\|'),
8585
new OperatorPattern('<=>'),
8686
new OperatorPattern('\?'),
87+
new FunctionNamePattern(),
8788

8889
// KEYWORDS
8990
new KeywordPattern('null'),
@@ -190,7 +191,6 @@ public function getPatterns(): array
190191
// PROPERTIES
191192
new ClassPropertyPattern(),
192193
new PropertyAccessPattern(),
193-
new FunctionNamePattern(),
194194
new NestedFunctionCallPattern(),
195195
new FunctionCallPattern(),
196196
new ConstantPropertyPattern(),

tests/Languages/Php/PhpLanguageTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ public function info(
135135
* hello */</span>
136136
<span class="hl-keyword">public</span> <span class="hl-type">?array</span> <span class="hl-property">$chapters</span>,
137137
</span>) {}'],
138+
['public static function new(mixed ...$params): self;', '<span class="hl-keyword">public</span> <span class="hl-keyword">static</span> <span class="hl-keyword">function</span> <span class="hl-property">new</span>(<span class="hl-injection"><span class="hl-type">mixed</span> ...$params</span>): <span class="hl-type">self</span>;'],
138139
];
139140
}
140141
}

tests/targets/test.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
```php
2-
public function update(Foo ...$params): self;
3-
```
2+
public static function new(mixed ...$params): self;
3+
```

0 commit comments

Comments
 (0)