Should the type for parameter $redirection not be array|null? Also, consider making the array more specific, something like array<String>, or String[].
This check looks for @param annotations where the type inferred by our
type inference engine differs from the declared type.
It makes a suggestion as to what type it considers more descriptive. In addition it
looks for parameters that have the generic type array and suggests a stricter type
like array<String>.
Most often this is a case of a parameter that can be null in addition to
its declared types.
Loading history...
30
*/
31
public function __construct($message = 'This action is unauthorized.', $redirection = null, array $inputs = null)
It seems like $inputs can be null. However, the property $inputs is declared as array. Maybe change the type of the property to array|null or add a type check?
Our type inference engine has found an assignment of a scalar value (like a
string, an integer or null) to a property which is an array.
Either this assignment is in error or the assigned type should be added
to the documentation/type hint for that property.
To type hint that a parameter can be either an array or null, you can set
a type hint of array and a default value of null. The PHP interpreter will
then accept both an array or null for that parameter.
It seems like $redirection can also be of type array. However, the property $redirection is declared as type string. Maybe add an additional type check?
Our type inference engine has found a suspicous assignment of a value to a property.
This check raises an issue when a value that can be of a mixed type is assigned to
a property that is type hinted more strictly.
For example, imagine you have a variable $accountId that can either hold an
Id object or false (if there is no account id yet). Your code now assigns that
value to the id property of an instance of the Account class. This class
holds a proper account, so the id value must no longer be false.
Either this assignment is in error or a type check should be added for that assignment.
classId{public$id;publicfunction__construct($id){$this->id=$id;}}classAccount{/** @var Id $id */public$id;}$account_id=false;if(starsAreRight()){$account_id=newId(42);}$account=newAccount();if($accountinstanceofId){$account->id=$account_id;}
This check looks for
@param
annotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive. In addition it looks for parameters that have the generic type
array
and suggests a stricter type likearray<String>
.Most often this is a case of a parameter that can be null in addition to its declared types.