2020-03-19 17:32:49 +01:00
|
|
|
|
# InvalidArgument
|
|
|
|
|
|
|
|
|
|
Emitted when a supplied function/method argument is incompatible with the method signature or docblock one.
|
|
|
|
|
|
|
|
|
|
```php
|
2020-03-21 00:13:46 +01:00
|
|
|
|
<?php
|
|
|
|
|
|
2020-03-19 17:32:49 +01:00
|
|
|
|
class A {}
|
2020-03-21 20:33:40 +01:00
|
|
|
|
|
|
|
|
|
function foo(A $a) : void {}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param string $s
|
|
|
|
|
*/
|
|
|
|
|
function callFoo($s) : void {
|
|
|
|
|
foo($s);
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Why it’s 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 {}
|
|
|
|
|
|
2020-03-19 17:32:49 +01:00
|
|
|
|
function foo(A $a) : void {}
|
2020-03-21 20:33:40 +01:00
|
|
|
|
|
|
|
|
|
function callFoo(A $a) : void {
|
|
|
|
|
foo($a);
|
|
|
|
|
}
|
2020-03-19 17:32:49 +01:00
|
|
|
|
```
|