This check compares calls to functions or methods with their respective definitions.
If the call has less 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. Please note the @ignore annotation hint above.
Loading history...
26
$this->name = $name;
27
$this->value = $value;
28
}
29
30
/**
31
* 从 $_SERVER 变量获取
32
*
33
* @param array $server
34
* @return HeaderItem[] 头部数组
35
*/
36
public static function buildFromServer(array $server):array
In this branch, the function will implicitly return null which is incompatible with the type-hinted return array. Consider adding a return statement or allowing null as return value.
For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type.
Let?s take a look at an example:
interfaceReturnsInt{publicfunctionreturnsIntHinted():int;}classMyClassimplementsReturnsInt{publicfunctionreturnsIntHinted():int{if(foo()){return123;}// here: null is implicitly returned}}
Loading history...
45
}
46
47
/**
48
* 获取头部信息
49
*
50
* @param array $headers
51
* @return HeaderItem[]
52
*/
53
public static function build(array $headers):array
This check compares calls to functions or methods with their respective definitions. If the call has less 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. Please note the @ignore annotation hint above.