1.2.1225. Too Many Native Calls¶
Avoid stuffing too many PHP native call inside another functioncall.
For readability reasons, or, more often, for edge case handling, it is recommended to avoid nesting too many PHP native calls.
This analysis reports any situation where more than 3 PHP native calls are nested.
<?php
// Too many nested functions
$cleanArray = array_unique(array_keys(array_count_values(array_column($source, 'x'))));
// Avoid warning when source is empty
$extract = array_column($source, 'x');
if (empty($extract)) {
$cleanArray = array();
} else {
$cleanArray = array_unique(array_keys(array_count_values($extract)));
}
// This is not readable, although it is short.
// It may easily get out of hand.
echo chr(80), chr(72), chr(80), chr(32), ' is great!';
?>
Name |
Default |
Type |
Description |
nativeCallCounts |
3 |
integer |
Number of native calls found inside another call. |
1.2.1225.1. Connex PHP features¶
1.2.1225.1.1. Suggestions¶
Reduce the number of native calls
Split the method into smaller methods
1.2.1225.1.2. Specs¶
Short name |
Php/TooManyNativeCalls |
Rulesets |
|
Exakat since |
1.1.10 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Precision |
Very high |
Examples |
|
Available in |