'', 'error' => true, ); $versionArray = $this->getVersionArray($itemArray); if (empty($versionArray) === false) { foreach ($versionArray as $version => $present) { if ($errorInfo['not_in_version'] === '' && $present === false && $this->supportsBelow($version) === true ) { $errorInfo['not_in_version'] = $version; } } } return $errorInfo; } /** * Get the error message template for this sniff. * * @since 7.1.0 * * @return string */ protected function getErrorMsgTemplate() { return '%s is not present in PHP version %s or earlier'; } /** * Generates the error or warning for this item. * * @since 7.1.0 * * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned. * @param int $stackPtr The position of the relevant token in * the stack. * @param array $itemInfo Base information about the item. * @param array $errorInfo Array with detail (version) information * relevant to the item. * * @return void */ public function addError(File $phpcsFile, $stackPtr, array $itemInfo, array $errorInfo) { $itemName = $this->getItemName($itemInfo, $errorInfo); $error = $this->getErrorMsgTemplate(); $errorCode = $this->stringToErrorCode($itemName) . 'Found'; $data = array( $itemName, $errorInfo['not_in_version'], ); $error = $this->filterErrorMsg($error, $itemInfo, $errorInfo); $data = $this->filterErrorData($data, $itemInfo, $errorInfo); $this->addMessage($phpcsFile, $error, $stackPtr, $errorInfo['error'], $errorCode, $data); } }