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:
parent
f22f5e38f1
commit
6d8e8ba5e2
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user