Skip to content
This repository has been archived by the owner on Dec 3, 2023. It is now read-only.

Commit

Permalink
[EasyCodingStandard] allow local config (#198)
Browse files Browse the repository at this point in the history
* [EasyCodingStandard] allow local config

* fix description
  • Loading branch information
Tomáš Votruba committed Jun 27, 2017
1 parent f7b002a commit 153ff91
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
28 changes: 24 additions & 4 deletions packages/EasyCodingStandard/bin/easy-coding-standard.php
@@ -1,12 +1,13 @@
<?php declare(strict_types=1);

use Symfony\Component\Console\Application;
use Symfony\Component\Console\Input\ArgvInput;
use Symplify\EasyCodingStandard\DependencyInjection\ContainerFactory;

// performance boost
gc_disable();

// prefer local vendor over analyzed project (e.g. for "composer create-project symplify/easy-coding-standard")
// 0. Prefer local vendor over analyzed project (e.g. for "composer create-project symplify/easy-coding-standard")
$possibleAutoloadPaths = [
__DIR__ . '/../../..',
__DIR__ . '/../vendor',
Expand All @@ -21,10 +22,29 @@
}
}

// 1. build DI container
$container = (new ContainerFactory)->create();
// 1. Detect configuration
$input = new ArgvInput;
$configurationFile = null;
if ($input->hasParameterOption('--configuration') || $input->hasParameterOption('-c')) {
$filePath = getcwd() . '/' . $input->getParameterOption('-c');
if (file_exists($filePath)) {
$configurationFile = $filePath;
}

$filePath = getcwd() . '/' . $input->getParameterOption('--configuration');
if (file_exists($filePath)) {
$configurationFile = $filePath;
}
}

// 2. Build DI container
if ($configurationFile) {
$container = (new ContainerFactory)->createWithCustomConfig($configurationFile);
} else {
$container = (new ContainerFactory)->create();
}

// 2. Run Console Application
// 3. Run Console Application
/** @var Application $application */
$application = $container->get(Application::class);
$application->run();
Expand Up @@ -5,6 +5,7 @@
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symplify\EasyCodingStandard\Application\Application;
use Symplify\EasyCodingStandard\Application\Command\RunCommand;
Expand Down Expand Up @@ -60,6 +61,11 @@ protected function configure(): void
$this->addArgument('source', InputArgument::REQUIRED | InputArgument::IS_ARRAY, 'The path(s) to be checked.');
$this->addOption('fix', null, null, 'Fix found violations.');
$this->addOption('clear-cache', null, null, 'Clear cache for already checked files.');
$this->addOption(
'configuration',
'c',
InputOption::VALUE_REQUIRED,
'Path to config file.', getcwd() . '/easy-coding-standard.neon');
}

protected function execute(InputInterface $input, OutputInterface $output): int
Expand Down

0 comments on commit 153ff91

Please sign in to comment.