Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inject the Config in the Runner constructor #3882

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 14 additions & 10 deletions src/Runner.php
Expand Up @@ -45,6 +45,20 @@ class Runner
*/
public $reporter = null;

/**
* @param \PHP_CodeSniffer\Config|null $config Config object
*/
public function __construct($config = null)
{
// Creating the Config object populates it with all required settings
// based on the CLI arguments provided to the script and any config
// values the user has set.
if ($config === null) {
$config = new Config();
}
$this->config = $config;
}//end __construct()


/**
* Run the PHPCS script.
Expand All @@ -63,11 +77,6 @@ public function runPHPCS()
define('PHP_CODESNIFFER_CBF', false);
}

// Creating the Config object populates it with all required settings
// based on the CLI arguments provided to the script and any config
// values the user has set.
$this->config = new Config();

// Init the run and load the rulesets to set additional config vars.
$this->init();

Expand Down Expand Up @@ -165,11 +174,6 @@ public function runPHPCBF()
Util\Timing::startTiming();
Runner::checkRequirements();

// Creating the Config object populates it with all required settings
// based on the CLI arguments provided to the script and any config
// values the user has set.
$this->config = new Config();

// When processing STDIN, we can't output anything to the screen
// or it will end up mixed in with the file output.
if ($this->config->stdin === true) {
Expand Down