Skip to content

Commit

Permalink
adding documentation about @no-named-arguments and allowNamedArgument…
Browse files Browse the repository at this point in the history
…Calls (#5654)
  • Loading branch information
orklah committed Apr 21, 2021
1 parent 39e61ae commit 0d524ec
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
13 changes: 13 additions & 0 deletions docs/annotating_code/supported_annotations.md
Expand Up @@ -538,6 +538,19 @@ class NormalClass {

Behaves the same way as `@psalm-require-extends`, but for interfaces.

### `@no-named-arguments`

This will prevent access to the function or method tagged with named parameters (by emitting a `NamedArgumentNotAllowed` issue).

Incidentally, it will change the inferred type for the following code:
```php
<?php
function a(int ...$a){
var_dump($a);
}
```
The type of `$a` is `array<array-key, int>` without `@no-named-arguments` but becomes `list<int>` with it, because it exclude the case where the offset would be a string with the name of the parameter

## Type Syntax

Psalm supports PHPDoc’s [type syntax](https://docs.phpdoc.org/latest/guide/guides/types.html), and also the [proposed PHPDoc PSR type syntax](https://github.com/php-fig/fig-standards/blob/master/proposed/phpdoc.md#appendix-a-types).
Expand Down
10 changes: 10 additions & 0 deletions docs/running_psalm/configuration.md
Expand Up @@ -314,6 +314,16 @@ When `true`, Psalm will run [Taint Analysis](../security_analysis/index.md) on y

When `false`, Psalm will not consider issue at lower level than `errorLevel` as `info` (they will be suppressed instead). This can be a big improvement in analysis time for big projects. However, this config will prevent Psalm to count or suggest fixes for suppressed issue

#### allowNamedArgumentCalls

```xml
<psalm
allowNamedArgumentCalls="[bool]"
>
```

When `false`, Psalm will not report `ParamNameMismatch` issues in your code anymore. This does not replace the use of individual `@no-named-arguments` to prevent external access to a library's method or to reduce the type to a `list` when using variadics

### Running Psalm

#### autoloader
Expand Down

0 comments on commit 0d524ec

Please sign in to comment.