-
Notifications
You must be signed in to change notification settings - Fork 665
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve @no-named-arguments support and variadics. (#5455)
* Improve @no-named-arguments support and variadics. Handling of argument unpacking and variadics still needs a pretty big makeover, but this is a good start. Fixes #5420 Improves #5453 (iterable works, array still causes issues) * Remove unneeded imports.
- Loading branch information
1 parent
0789745
commit de5a031
Showing
12 changed files
with
275 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# NamedArgumentNotAllowed | ||
|
||
Emitted when a named argument is used when calling a function with `@no-named-arguments`. | ||
|
||
```php | ||
<?php | ||
|
||
/** @no-named-arguments */ | ||
function foo(int $a, int $b): int { | ||
return $a + $b; | ||
} | ||
|
||
foo(a: 0, b: 1); | ||
|
||
``` | ||
|
||
## Why this is bad | ||
|
||
The `@no-named-arguments` annotation indicates that argument names may be changed in the future, and an update may break backwards compatibility with function calls using named arguments. | ||
|
||
## How to fix | ||
|
||
Avoid using named arguments for functions annotated with `@no-named-arguments`. | ||
|
||
```php | ||
<?php | ||
|
||
/** @no-named-arguments */ | ||
function foo(int $a, int $b): int { | ||
return $a + $b; | ||
} | ||
|
||
foo(0, 1); | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
namespace Psalm\Issue; | ||
|
||
class NamedArgumentNotAllowed extends ArgumentIssue | ||
{ | ||
public const ERROR_LEVEL = 7; | ||
public const SHORTCODE = 268; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.