function FunctionLengthSniff::process
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint *
Parameters
int $functionPointer:
Overrides Sniff::process
File
-
vendor/
slevomat/ coding-standard/ SlevomatCodingStandard/ Sniffs/ Functions/ FunctionLengthSniff.php, line 41
Class
Namespace
SlevomatCodingStandard\Sniffs\FunctionsCode
public function process(File $file, $functionPointer) : void {
$this->maxLinesLength = SniffSettingsHelper::normalizeInteger($this->maxLinesLength);
$flags = array_keys(array_filter([
FunctionHelper::LINE_INCLUDE_COMMENT => $this->includeComments,
FunctionHelper::LINE_INCLUDE_WHITESPACE => $this->includeWhitespace,
]));
$flags = array_reduce($flags, static function ($carry, $flag) : int {
return $carry | $flag;
}, 0);
$length = FunctionHelper::getFunctionLengthInLines($file, $functionPointer, $flags);
if ($length <= $this->maxLinesLength) {
return;
}
$errorMessage = sprintf('Your function is too long. Currently using %d lines. Can be up to %d lines.', $length, $this->maxLinesLength);
$file->addError($errorMessage, $functionPointer, self::CODE_FUNCTION_LENGTH);
}