Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Standards.php

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

Standards

Namespace

PHP_CodeSniffer\Util

Code

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;
}
RSS feed
Powered by Drupal