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

Add more suggestions

This commit is contained in:
Matthew Brown 2020-03-16 09:42:17 -04:00 committed by GitHub
parent f22f5e38f1
commit 6d8e8ba5e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -35,6 +35,26 @@ function takesA(A $a) : void {
function takesB(B $b) : void {}
```
#### How to fix
You could add a typecheck before the call to `takesB`:
```php
function takesA(A $a) : void {
if ($a instanceof B) {
takesB($a);
}
}
```
Or, if you have control over the function signature of `takesA` you can change it to expect `B`:
```php
function takesA(B $a) : void {
takesB($a);
}
```
### AssignmentToVoid
Emitted when assigning from a function that returns `void`:
@ -44,6 +64,15 @@ function foo() : void {}
$a = foo();
```
### How to fix
You should just be able to remove the assignment:
```php
function foo() : void {}
foo();
```
### CircularReference
Emitted when a class references itself as one of its parents