1.2.253. Could Be Callable¶
This rule marks 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 is reported as a compilation error.
<?php
// Accept a callable as input
function foo($b) {
// Returns value as return
return $b();
}
?>
See also Callbacks / callables.
1.2.253.2. Connex PHP features¶
1.2.253.2.1. Suggestions¶
Add callable typehint to arguments or returntypes.
1.2.253.2.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 |
Available in |