Просмотр исходного кода

Remove non-default Config/Finder classes

Dariusz Ruminski 9 лет назад
Родитель
Сommit
0ba1846925

+ 0 - 16
README.rst

@@ -705,22 +705,6 @@ Choose from the list of available fixers:
                         the end of blank lines.
 
 
-The ``--config`` option customizes the files to analyse, based
-on some well-known directory structures:
-
-.. code-block:: bash
-
-    # For the Symfony 2.3+ branch
-    php php-cs-fixer.phar fix /path/to/sf23 --config=sf23
-
-Choose from the list of available configurations:
-
-* **default** A default configuration
-
-* **magento** The configuration for a Magento application
-
-* **sf23**    The configuration for the Symfony 2.3+ branch
-
 The ``--dry-run`` option displays the files that need to be
 fixed but without actually modifying them:
 

+ 1 - 3
src/Config.php

@@ -11,8 +11,6 @@
 
 namespace Symfony\CS;
 
-use Symfony\CS\Finder\DefaultFinder;
-
 /**
  * @author Fabien Potencier <fabien@symfony.com>
  * @author Katsuhiro Ogawa <ko.fivestar@gmail.com>
@@ -38,7 +36,7 @@ class Config implements ConfigInterface
     {
         $this->name = $name;
         $this->description = $description;
-        $this->finder = new DefaultFinder();
+        $this->finder = new Finder();
     }
 
     public static function create()

+ 0 - 37
src/Config/Config.php

@@ -1,37 +0,0 @@
-<?php
-
-/*
- * This file is part of the PHP CS utility.
- *
- * (c) Fabien Potencier <fabien@symfony.com>
- *
- * This source file is subject to the MIT license that is bundled
- * with this source code in the file LICENSE.
- */
-
-namespace Symfony\CS\Config;
-
-use Symfony\CS\Config as BaseConfig;
-
-/**
- * @author Fabien Potencier <fabien@symfony.com>
- * @author Katsuhiro Ogawa <ko.fivestar@gmail.com>
- *
- * @deprecated
- */
-class Config extends BaseConfig
-{
-    public function __construct()
-    {
-        @trigger_error(
-            sprintf(
-                'The "%s" class is deprecated. You should stop using it, as it will soon be removed in 2.0 version. Use "%s" instead.',
-                __CLASS__,
-                'Symfony\CS\Config'
-            ),
-            E_USER_DEPRECATED
-        );
-
-        parent::__construct();
-    }
-}

+ 0 - 48
src/Config/MagentoConfig.php

@@ -1,48 +0,0 @@
-<?php
-
-/*
- * This file is part of the PHP CS utility.
- *
- * (c) Fabien Potencier <fabien@symfony.com>
- *
- * This source file is subject to the MIT license that is bundled
- * with this source code in the file LICENSE.
- */
-
-namespace Symfony\CS\Config;
-
-use Symfony\CS\Finder\MagentoFinder;
-
-/**
- * @author Myke Hines <myke@webhines.com>
- *
- * @deprecated
- */
-class MagentoConfig extends Config
-{
-    public function __construct()
-    {
-        @trigger_error(
-            sprintf(
-                'The "%s" class is deprecated. You should stop using it, as it will soon be removed in 2.0 version. Use "%s" instead.',
-                __CLASS__,
-                'Symfony\CS\Config'
-            ),
-            E_USER_DEPRECATED
-        );
-
-        parent::__construct();
-
-        $this->finder = new MagentoFinder();
-    }
-
-    public function getName()
-    {
-        return 'magento';
-    }
-
-    public function getDescription()
-    {
-        return 'The configuration for a Magento application';
-    }
-}

+ 0 - 48
src/Config/Symfony23Config.php

@@ -1,48 +0,0 @@
-<?php
-
-/*
- * This file is part of the PHP CS utility.
- *
- * (c) Fabien Potencier <fabien@symfony.com>
- *
- * This source file is subject to the MIT license that is bundled
- * with this source code in the file LICENSE.
- */
-
-namespace Symfony\CS\Config;
-
-use Symfony\CS\Finder\Symfony23Finder;
-
-/**
- * @author Fabien Potencier <fabien@symfony.com>
- *
- * @deprecated
- */
-class Symfony23Config extends Config
-{
-    public function __construct()
-    {
-        @trigger_error(
-            sprintf(
-                'The "%s" class is deprecated. You should stop using it, as it will soon be removed in 2.0 version. Use "%s" instead.',
-                __CLASS__,
-                'Symfony\CS\Config'
-            ),
-            E_USER_DEPRECATED
-        );
-
-        parent::__construct();
-
-        $this->finder = new Symfony23Finder();
-    }
-
-    public function getName()
-    {
-        return 'sf23';
-    }
-
-    public function getDescription()
-    {
-        return 'The configuration for the Symfony 2.3+ branch';
-    }
-}

+ 0 - 48
src/Console/Command/FixCommand.php

@@ -89,7 +89,6 @@ final class FixCommand extends Command
         $this->eventDispatcher = new EventDispatcher();
 
         $this->fixer = $fixer ?: new Fixer();
-        $this->fixer->registerBuiltInConfigs();
 
         $this->errorsManager = $this->fixer->getErrorsManager();
         $this->stopwatch = $this->fixer->getStopwatch();
@@ -108,7 +107,6 @@ final class FixCommand extends Command
                 array(
                     new InputArgument('path', InputArgument::OPTIONAL, 'The path', null),
                     new InputOption('allow-risky', '', InputOption::VALUE_REQUIRED, 'Are risky fixers allowed (can be yes or no)', null),
-                    new InputOption('config', '', InputOption::VALUE_REQUIRED, 'The configuration name', null),
                     new InputOption('config-file', '', InputOption::VALUE_OPTIONAL, 'The path to a .php_cs file ', null),
                     new InputOption('dry-run', '', InputOption::VALUE_NONE, 'Only shows which files would have been modified'),
                     new InputOption('rules', '', InputOption::VALUE_REQUIRED, 'The rules', null),
@@ -166,15 +164,6 @@ Choose from the list of available fixers:
 
 {$this->getFixersHelp()}
 
-The <comment>--config</comment> option customizes the files to analyse, based
-on some well-known directory structures:
-
-    <comment># For the Symfony 2.3+ branch</comment>
-    <info>php %command.full_name% /path/to/sf23 --config=sf23</info>
-
-Choose from the list of available configurations:
-
-{$this->getConfigsHelp()}
 The <comment>--dry-run</comment> option displays the files that need to be
 fixed but without actually modifying them:
 
@@ -324,7 +313,6 @@ EOF
             ->setFixer($this->fixer)
             ->setOptions(array(
                 'allow-risky' => $input->getOption('allow-risky'),
-                'config' => $input->getOption('config'),
                 'config-file' => $input->getOption('config-file'),
                 'dry-run' => $input->getOption('dry-run'),
                 'rules' => $input->getOption('rules'),
@@ -642,40 +630,4 @@ EOF
 
         return $help;
     }
-
-    protected function getConfigsHelp()
-    {
-        $help = '';
-        $maxName = 0;
-
-        $configs = $this->fixer->getConfigs();
-
-        usort(
-            $configs,
-            function (ConfigInterface $a, ConfigInterface $b) {
-                return strcmp($a->getName(), $b->getName());
-            }
-        );
-
-        foreach ($configs as $config) {
-            if (strlen($config->getName()) > $maxName) {
-                $maxName = strlen($config->getName());
-            }
-        }
-
-        $count = count($this->fixer->getConfigs()) - 1;
-        foreach ($configs as $i => $config) {
-            $chunks = explode("\n", wordwrap($config->getDescription(), 72 - $maxName, "\n"));
-            $help .= sprintf(" * <comment>%s</comment>%s %s\n", $config->getName(), str_repeat(' ', $maxName - strlen($config->getName())), array_shift($chunks));
-            while ($c = array_shift($chunks)) {
-                $help .= str_repeat(' ', $maxName + 4).$c."\n";
-            }
-
-            if ($count !== $i) {
-                $help .= "\n";
-            }
-        }
-
-        return $help;
-    }
 }

+ 0 - 17
src/Console/ConfigurationResolver.php

@@ -91,7 +91,6 @@ final class ConfigurationResolver
      */
     private $options = array(
         'allow-risky' => null,
-        'config' => null,
         'config-file' => null,
         'dry-run' => null,
         'format' => 'txt',
@@ -377,22 +376,6 @@ final class ConfigurationResolver
      */
     private function resolveConfig()
     {
-        $configOption = $this->options['config'];
-
-        if ($configOption) {
-            foreach ($this->fixer->getConfigs() as $c) {
-                if ($c->getName() === $configOption) {
-                    $this->config = $c;
-
-                    return;
-                }
-            }
-
-            if (null === $this->config) {
-                throw new InvalidConfigurationException(sprintf('The configuration "%s" is not defined.', $configOption));
-            }
-        }
-
         foreach ($this->computeConfigFiles() as $configFile) {
             if (!file_exists($configFile)) {
                 continue;

+ 0 - 41
src/Finder/DefaultFinder.php

@@ -1,41 +0,0 @@
-<?php
-
-/*
- * This file is part of the PHP CS utility.
- *
- * (c) Fabien Potencier <fabien@symfony.com>
- *
- * This source file is subject to the MIT license that is bundled
- * with this source code in the file LICENSE.
- */
-
-namespace Symfony\CS\Finder;
-
-use Symfony\CS\Finder as BaseFinder;
-
-/**
- * @author Fabien Potencier <fabien@symfony.com>
- *
- * @deprecated
- */
-class DefaultFinder extends BaseFinder
-{
-    public function __construct()
-    {
-        @trigger_error(
-            sprintf(
-                'The "%s" class is deprecated. You should stop using it, as it will soon be removed in 2.0 version. Use "%s" instead.',
-                __CLASS__,
-                'Symfony\CS\Finder'
-            ),
-            E_USER_DEPRECATED
-        );
-
-        parent::__construct();
-
-        $this
-            ->name('*.xml')
-            ->name('*.yml')
-        ;
-    }
-}

+ 0 - 81
src/Finder/MagentoFinder.php

@@ -1,81 +0,0 @@
-<?php
-
-/*
- * This file is part of the PHP CS utility.
- *
- * (c) Fabien Potencier <fabien@symfony.com>
- *
- * This source file is subject to the MIT license that is bundled
- * with this source code in the file LICENSE.
- */
-
-namespace Symfony\CS\Finder;
-
-/**
- * @author Myke Hines <myke@webhines.com>
- *
- * @deprecated
- */
-class MagentoFinder extends DefaultFinder
-{
-    public function __construct()
-    {
-        @trigger_error(
-            sprintf(
-                'The "%s" class is deprecated. You should stop using it, as it will soon be removed in 2.0 version. Use "%s" instead.',
-                __CLASS__,
-                'Symfony\CS\Finder'
-            ),
-            E_USER_DEPRECATED
-        );
-
-        parent::__construct();
-
-        $this
-            ->name('*.php')
-            ->name('*.phtml')
-            ->exclude(
-                array(
-                    'lib',
-                    'shell',
-                    'app/Mage.php',
-                    'app/code/core',
-                    'app/code/community',
-                    'app/design/frontend/default',
-                    'app/design/frontend/enterprise/default',
-                    'app/design/frontend/base',
-                    'app/design/adminhtml/default',
-                )
-            )
-        ;
-    }
-
-    public function setDir($dir)
-    {
-        $this->in($this->getDirs($dir));
-    }
-
-    /**
-     * Gets the directories that needs to be scanned for files to validate.
-     *
-     * @param string $dir
-     *
-     * @return array
-     */
-    protected function getDirs($dir)
-    {
-        return array($dir);
-    }
-
-    /**
-     * Excludes files because modifying them would break.
-     *
-     * This is mainly useful for fixtures in unit tests.
-     *
-     * @return array
-     */
-    protected function getFilesToExclude()
-    {
-        return array();
-    }
-}

+ 0 - 51
src/Finder/Symfony23Finder.php

@@ -1,51 +0,0 @@
-<?php
-
-/*
- * This file is part of the PHP CS utility.
- *
- * (c) Fabien Potencier <fabien@symfony.com>
- *
- * This source file is subject to the MIT license that is bundled
- * with this source code in the file LICENSE.
- */
-
-namespace Symfony\CS\Finder;
-
-/**
- * @author Fabien Potencier <fabien@symfony.com>
- *
- * @deprecated
- */
-class Symfony23Finder extends DefaultFinder
-{
-    public function __construct()
-    {
-        @trigger_error(
-            sprintf(
-                'The "%s" class is deprecated. You should stop using it, as it will soon be removed in 2.0 version. Use "%s" instead.',
-                __CLASS__,
-                'Symfony\CS\Finder'
-            ),
-            E_USER_DEPRECATED
-        );
-
-        parent::__construct();
-    }
-
-    protected function getDirs($dir)
-    {
-        return array($dir.'/src');
-    }
-
-    protected function getFilesToExclude()
-    {
-        return array(
-            'Symfony/Component/Console/Tests/Fixtures/application_1.xml',
-            'Symfony/Component/Console/Tests/Fixtures/application_2.xml',
-            'Symfony/Component/Console/Tests/Helper/TableHelperTest.php',
-            'Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services1.yml',
-            'Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services8.yml',
-            'Symfony/Component/Yaml/Tests/Fixtures/sfTests.yml',
-        );
-    }
-}

Некоторые файлы не были показаны из-за большого количества измененных файлов