Select Git revision
-
Marcel Behrmann authoredMarcel Behrmann authored
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
AbstractNewFeatureSniff.php 3.12 KiB
<?php
/**
* PHPCompatibility_AbstractNewFeatureSniff.
*
* @category PHP
* @package PHPCompatibility
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
*/
/**
* PPHPCompatibility_AbstractNewFeatureSniff.
*
* @category PHP
* @package PHPCompatibility
* @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
*/
abstract class PHPCompatibility_AbstractNewFeatureSniff extends PHPCompatibility_AbstractComplexVersionSniff
{
/**
* Determine whether an error/warning should be thrown for an item based on collected information.
*
* @param array $errorInfo Detail information about an item.
*
* @return bool
*/
protected function shouldThrowError(array $errorInfo)
{
return ($errorInfo['not_in_version'] !== '');
}
/**
* Retrieve the relevant detail (version) information for use in an error message.
*
* @param array $itemArray Version and other information about the item.
* @param array $itemInfo Base information about the item.
*
* @return array
*/
public function getErrorInfo(array $itemArray, array $itemInfo)
{
$errorInfo = array(
'not_in_version' => '',
'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.
*
* @return string
*/
protected function getErrorMsgTemplate()