function DiscouragedFunctionsRule::processNode
File
-
vendor/
mglaman/ phpstan-drupal/ src/ Rules/ Drupal/ Coder/ DiscouragedFunctionsRule.php, line 25
Class
- DiscouragedFunctionsRule
- Based on Drupal_Sniffs_Functions_DiscouragedFunctionsSniff.
Namespace
mglaman\PHPStanDrupal\Rules\Drupal\CoderCode
public function processNode(Node $node, Scope $scope) : array {
if (!$node->name instanceof Node\Name) {
return [];
}
$name = strtolower((string) $node->name);
$discouragedFunctions = [
// Devel module debugging functions.
'dargs',
'dcp',
'dd',
'dfb',
'dfbt',
'dpm',
'dpq',
'dpr',
'dprint_r',
'drupal_debug',
'dsm',
'dvm',
'dvr',
'kdevel_print_object',
'kpr',
'kprint_r',
'sdpm',
// Functions which are not available on all
// PHP builds.
'fnmatch',
// Functions which are a security risk.
'eval',
];
if (in_array($name, $discouragedFunctions, true)) {
return [
sprintf('Calls to function %s should not exist.', $name),
];
}
return [];
}