1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-15 02:47:02 +01:00
psalm/docs/running_psalm/issues/InvalidArgument.md
2020-03-21 15:33:40 -04:00

41 lines
634 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# InvalidArgument
Emitted when a supplied function/method argument is incompatible with the method signature or docblock one.
```php
<?php
class A {}
function foo(A $a) : void {}
/**
* @param string $s
*/
function callFoo($s) : void {
foo($s);
}
```
## Why its bad
Calling functions with incorrect values will cause a fatal error at runtime.
## How to fix
Sometimes this message can just be the result of an incorrect docblock.
You can fix by correcting the docblock, or converting to a function signature:
```php
<?php
class A {}
function foo(A $a) : void {}
function callFoo(A $a) : void {
foo($a);
}
```