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

Breadcrumb

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

function Runner::checkRequirements

Exits if the minimum requirements of PHP_CodeSniffer are not met.

Return value

void

Throws

\PHP_CodeSniffer\Exceptions\DeepExitException If the requirements are not met.

2 calls to Runner::checkRequirements()
Runner::runPHPCBF in vendor/squizlabs/php_codesniffer/src/Runner.php
Run the PHPCBF script.
Runner::runPHPCS in vendor/squizlabs/php_codesniffer/src/Runner.php
Run the PHPCS script.

File

vendor/squizlabs/php_codesniffer/src/Runner.php, line 254

Class

Runner

Namespace

PHP_CodeSniffer

Code

public function checkRequirements() {
    // Check the PHP version.
    if (PHP_VERSION_ID < 50400) {
        $error = 'ERROR: PHP_CodeSniffer requires PHP version 5.4.0 or greater.' . PHP_EOL;
        throw new DeepExitException($error, 3);
    }
    $requiredExtensions = [
        'tokenizer',
        'xmlwriter',
        'SimpleXML',
    ];
    $missingExtensions = [];
    foreach ($requiredExtensions as $extension) {
        if (extension_loaded($extension) === false) {
            $missingExtensions[] = $extension;
        }
    }
    if (empty($missingExtensions) === false) {
        $last = array_pop($requiredExtensions);
        $required = implode(', ', $requiredExtensions);
        $required .= ' and ' . $last;
        if (count($missingExtensions) === 1) {
            $missing = $missingExtensions[0];
        }
        else {
            $last = array_pop($missingExtensions);
            $missing = implode(', ', $missingExtensions);
            $missing .= ' and ' . $last;
        }
        $error = 'ERROR: PHP_CodeSniffer requires the %s extensions to be enabled. Please enable %s.' . PHP_EOL;
        $error = sprintf($error, $required, $missing);
        throw new DeepExitException($error, 3);
    }
}
RSS feed
Powered by Drupal