Skip to content

Commit

Permalink
Fix for functions called "new"
Browse files Browse the repository at this point in the history
  • Loading branch information
brendt committed Aug 27, 2024
1 parent 0679847 commit ca84b97
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- Fix for attribute in promoted property (#133)
- Fix for comments in function argument lists (#134)
- Fix for variadic types (#140)
- Fix for functions called "new" (#141)

## 2.8.2

Expand Down
2 changes: 1 addition & 1 deletion src/Languages/Php/PhpLanguage.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public function getPatterns(): array
new OperatorPattern('\|\|'),
new OperatorPattern('<=>'),
new OperatorPattern('\?'),
new FunctionNamePattern(),

// KEYWORDS
new KeywordPattern('null'),
Expand Down Expand Up @@ -190,7 +191,6 @@ public function getPatterns(): array
// PROPERTIES
new ClassPropertyPattern(),
new PropertyAccessPattern(),
new FunctionNamePattern(),
new NestedFunctionCallPattern(),
new FunctionCallPattern(),
new ConstantPropertyPattern(),
Expand Down
1 change: 1 addition & 0 deletions tests/Languages/Php/PhpLanguageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ public function info(
* hello */</span>
<span class="hl-keyword">public</span> <span class="hl-type">?array</span> <span class="hl-property">$chapters</span>,
</span>) {}'],
['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>;'],
];
}
}
4 changes: 2 additions & 2 deletions tests/targets/test.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
```php
public function update(Foo ...$params): self;
```
public static function new(mixed ...$params): self;
```

0 comments on commit ca84b97

Please sign in to comment.