Skip to content

Commit e6a0fe0

Browse files
authored
Add a better description to PossiblyInvalidArgument
1 parent 4079b53 commit e6a0fe0

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

docs/running_psalm/issues/InvalidArgument.md

+30-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,35 @@ Emitted when a supplied function/method argument is incompatible with the method
66
<?php
77

88
class A {}
9+
10+
function foo(A $a) : void {}
11+
12+
/**
13+
* @param string $s
14+
*/
15+
function callFoo($s) : void {
16+
foo($s);
17+
}
18+
```
19+
20+
## Why it’s bad
21+
22+
Calling functions with incorrect values will cause a fatal error at runtime.
23+
24+
## How to fix
25+
26+
Sometimes this message can just be the result of an incorrect docblock.
27+
28+
You can fix by correcting the docblock, or converting to a function signature:
29+
30+
```php
31+
<?php
32+
33+
class A {}
34+
935
function foo(A $a) : void {}
10-
foo("hello");
36+
37+
function callFoo(A $a) : void {
38+
foo($a);
39+
}
1140
```

0 commit comments

Comments
 (0)