1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-15 02:47:02 +01:00
psalm/docs/running_psalm/issues/NamedArgumentNotAllowed.md
AndrolGenhald de5a031088
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.
2021-03-22 19:58:22 -04:00

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);
```