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

Breadcrumb

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

function Config::__construct

Same name in this branch
  1. 11.1.x vendor/composer/composer/src/Composer/Config.php \Composer\Config::__construct()
  2. 11.1.x composer/Plugin/VendorHardening/Config.php \Drupal\Composer\Plugin\VendorHardening\Config::__construct()
  3. 11.1.x core/lib/Drupal/Core/Config/Config.php \Drupal\Core\Config\Config::__construct()
  4. 11.1.x core/modules/migrate/src/Plugin/migrate/destination/Config.php \Drupal\migrate\Plugin\migrate\destination\Config::__construct()

Creates a Config object and populates it with command line values.

Parameters

array $cliArgs An array of values gathered from CLI args.:

bool $dieOnUnknownArg Whether or not to kill the process when an: unknown command line arg is found.

Return value

void

File

vendor/squizlabs/php_codesniffer/src/Config.php, line 373

Class

Config
Stores the configuration used to run PHPCS and PHPCBF.

Namespace

PHP_CodeSniffer

Code

public function __construct(array $cliArgs = [], $dieOnUnknownArg = true) {
    if (defined('PHP_CODESNIFFER_IN_TESTS') === true) {
        // Let everything through during testing so that we can
        // make use of PHPUnit command line arguments as well.
        $this->dieOnUnknownArg = false;
    }
    else {
        $this->dieOnUnknownArg = $dieOnUnknownArg;
    }
    if (empty($cliArgs) === true) {
        $cliArgs = $_SERVER['argv'];
        array_shift($cliArgs);
    }
    $this->restoreDefaults();
    $this->setCommandLineValues($cliArgs);
    if (isset(self::$overriddenDefaults['standards']) === false) {
        // They did not supply a standard to use.
        // Look for a default ruleset in the current directory or higher.
        $currentDir = getcwd();
        $defaultFiles = [
            '.phpcs.xml',
            'phpcs.xml',
            '.phpcs.xml.dist',
            'phpcs.xml.dist',
        ];
        do {
            foreach ($defaultFiles as $defaultFilename) {
                $default = $currentDir . DIRECTORY_SEPARATOR . $defaultFilename;
                if (is_file($default) === true) {
                    $this->standards = [
                        $default,
                    ];
                    break 2;
                }
            }
            $lastDir = $currentDir;
            $currentDir = dirname($currentDir);
        } while ($currentDir !== '.' && $currentDir !== $lastDir && Common::isReadable($currentDir) === true);
    }
    
    //end if
    if (defined('STDIN') === false || stripos(PHP_OS, 'WIN') === 0) {
        return;
    }
    $handle = fopen('php://stdin', 'r');
    // Check for content on STDIN.
    if ($this->stdin === true || Common::isStdinATTY() === false && feof($handle) === false) {
        $readStreams = [
            $handle,
        ];
        $writeSteams = null;
        $fileContents = '';
        while (is_resource($handle) === true && feof($handle) === false) {
            // Set a timeout of 200ms.
            if (stream_select($readStreams, $writeSteams, $writeSteams, 0, 200000) === 0) {
                break;
            }
            $fileContents .= fgets($handle);
        }
        if (trim($fileContents) !== '') {
            $this->stdin = true;
            $this->stdinContent = $fileContents;
            self::$overriddenDefaults['stdin'] = true;
            self::$overriddenDefaults['stdinContent'] = true;
        }
    }
    
    //end if
    fclose($handle);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal