1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

Add a better description to PossiblyInvalidArgument

This commit is contained in:
Matthew Brown 2020-03-21 15:33:40 -04:00 committed by GitHub
parent 4079b53b93
commit e6a0fe0973
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,6 +6,35 @@ Emitted when a supplied function/method argument is incompatible with the method
<?php
class A {}
function foo(A $a) : void {}
foo("hello");
/**
* @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);
}
```