1.2.252. Could Be Callable¶
Mark arguments and return types that can be set to
callable
.
The analysis also reports properties that could be ‘callable’, although PHP doesn’t allow that configuration. Note that properties cannot be callable. It reports a compilation error.
<?php
// Accept a callable as input
function foo($b) {
// Returns value as return
return $b();
}
?>
See also Callbacks / callables.
1.2.252.1. Suggestions¶
Add callable typehint to arguments or returntypes.
1.2.252.2. Specs¶
Short name |
Typehints/CouldBeCallable |
Rulesets |
|
Exakat since |
2.1.2 |
PHP Version |
All |
Severity |
Major |
Time To Fix |
Quick (30 mins) |
Precision |
High |
Features |
callback, callable |
Available in |