function Standards::isInstalledStandard
Determine if a standard is installed.
Coding standards are directories located in the CodeSniffer/Standards directory. Valid coding standards include a ruleset.xml file.
Parameters
string $standard The name of the coding standard.:
Return value
boolean
See also
getInstalledStandards()
1 call to Standards::isInstalledStandard()
- Runner::init in vendor/
squizlabs/ php_codesniffer/ src/ Runner.php - Init the rulesets and other high-level settings.
File
-
vendor/
squizlabs/ php_codesniffer/ src/ Util/ Standards.php, line 234
Class
Namespace
PHP_CodeSniffer\UtilCode
public static function isInstalledStandard($standard) {
$path = self::getInstalledStandardPath($standard);
if ($path !== null && strpos($path, 'ruleset.xml') !== false) {
return true;
}
else {
// This could be a custom standard, installed outside our
// standards directory.
$standard = Common::realPath($standard);
if ($standard === false) {
return false;
}
// Might be an actual ruleset file itUtil.
// If it has an XML extension, let's at least try it.
if (is_file($standard) === true && (substr(strtolower($standard), -4) === '.xml' || substr(strtolower($standard), -9) === '.xml.dist')) {
return true;
}
// If it is a directory with a ruleset.xml file in it,
// it is a standard.
$ruleset = rtrim($standard, ' /\\') . DIRECTORY_SEPARATOR . 'ruleset.xml';
if (is_file($ruleset) === true) {
return true;
}
}
//end if
return false;
}