Method/Function Call Checks¶
This pass performs several call related checks.
1. Method Calls on Non-Objects¶
class A
{
private $b;
public function __construct(B $b = null)
{
$this->b = $b;
}
public function foo()
{
$this->b->bar(); // possible method call on null
}
}
2. Missing Argument on Function/Method Calls¶
Checks whether a function, or method call misses a required argument.
function foo($a) { }
foo(); // missing argument
3. Too Many Arguments on Function/Method Calls¶
Checks whether a function, or method call has too many arguments.
function foo() { }
foo($a); // foo() does not support this argument.
4. Argument Type Check¶
Checks whether an argument type can be passed to a function/method. Currently, two different levels are supported:
- Strict: The passed type must be a sub-type of the expected type.
- Lenient (default): In lenient mode, we make a few exceptions to the strict sub-type requirement. For example, we treat string, integer, and double types as interchangable. So, if a string is expected, an integer, or a double would also be acceptable.
Tip: If you have an existing code-base, lenient mode is most likely what you want. If
you start a new project, using strict type checking is recommended.