The expression $this->actions of type Kunstmaan\AdminBundle\He...nPanelActionInterface[] is implicitly converted to a boolean; are you sure this is intended? If so, consider using empty($expr) instead to make it clear that you intend to check for an array without elements.
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an
empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using empty(..) or !empty(...) instead.
The expression $adaptors of type null|array<integer,objec...PanelAdaptorInterface>> is not guaranteed to be traversable. How about adding an additional type check?
There are different options of fixing this problem.
If you want to be on the safe side, you can add an additional type-check:
$collection=json_decode($data,true);if(!is_array($collection)){thrownew\RuntimeException('$collection must be an array.');}foreach($collectionas$item){/** ... */}
If you are sure that the expression is traversable, you might want to add a
doc comment cast to improve IDE auto-completion and static analysis:
It seems like array_merge($this->actio...getAdminPanelActions()) of type array is incompatible with the declared type array<integer,object<Kun...nPanelActionInterface>> of property $actions.
Our type inference engine has found an assignment to a property that is incompatible
with the declared type of that property.
Either this assignment is in error or the assigned type should be added
to the documentation/type hint for that property..
Should the return type not be null|AdminPanelAdaptorInterface[]?
This check compares the return type specified in the @return annotation of a function
or method doc comment with the types returned by the function and raises an issue if they
mismatch.
Loading history...
53
*/
54
1
private function getAdaptors()
55
{
56
1
if (!isset($this->sorted)) {
57
1
$this->sortAdaptors();
58
}
59
60
1
return $this->sorted;
61
}
62
63
/**
64
* Sorts the internal list of adaptors by priority.
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate
the same code in three or more different places, we strongly encourage you to
look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.
It seems like array_merge(...$this->adaptors) of type array is incompatible with the declared type array<integer,object<Kun...PanelAdaptorInterface>> of property $sorted.
Our type inference engine has found an assignment to a property that is incompatible
with the declared type of that property.
Either this assignment is in error or the assigned type should be added
to the documentation/type hint for that property..
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)
or! empty(...)
instead.