mirror of
https://github.com/danog/psalm.git
synced 2024-12-05 13:10:49 +01:00
36 lines
656 B
Markdown
36 lines
656 B
Markdown
|
# 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);
|
||
|
|
||
|
```
|