class TypeCheckSimple extends AbstractTypeCheck implements TypeCheckInterface
8
{
9
/**
10
* @param string|string[] $type
11
* @param bool $isNullable
12
*/
13
73
public function __construct($type, bool $isNullable = false)
14
{
15
73
$this->getTypesHelper($type);
16
17
73
$this->isNullable = $isNullable;
18
73
}
19
20
/**
21
* @param string $expectedTypes
22
* @param mixed $value
23
* @param string $type
24
*
25
* @return \TypeError
26
*/
27
22
public function throwException($expectedTypes, $value, $type): \Throwable
28
{
29
22
throw new \TypeError("Invalid type: expected to be of type {{$expectedTypes}}, instead got value `" . \print_r($value, true) . "` with type {{$type}}.");
The call to TypeError::__construct() has too many arguments starting with "Invalid type: expected ...` with type {{$type}}.".
This check compares calls to functions or methods with their respective definitions.
If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the
check may pick up the wrong definition and report false positives. One codebase
where this has been known to happen is Wordpress.
In this case you can add the @ignorePhpDoc
annotation to the duplicate definition and it will be ignored.
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignorePhpDoc annotation to the duplicate definition and it will be ignored.