123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- declare(strict_types=1);
- /*
- * This file is part of PHP CS Fixer.
- *
- * (c) Fabien Potencier <fabien@symfony.com>
- * Dariusz Rumiński <dariusz.ruminski@gmail.com>
- *
- * This source file is subject to the MIT license that is bundled
- * with this source code in the file LICENSE.
- */
- $header = <<<'EOF'
- This file is part of PHP CS Fixer.
- (c) Fabien Potencier <fabien@symfony.com>
- Dariusz Rumiński <dariusz.ruminski@gmail.com>
- This source file is subject to the MIT license that is bundled
- with this source code in the file LICENSE.
- EOF;
- $finder = PhpCsFixer\Finder::create()
- ->ignoreDotFiles(false)
- ->ignoreVCSIgnored(true)
- ->exclude('tests/Fixtures')
- ->in(__DIR__)
- ->append([
- __DIR__.'/dev-tools/doc.php',
- // __DIR__.'/php-cs-fixer', disabled, as we want to be able to run bootstrap file even on lower PHP version, to show nice message
- ])
- ;
- $config = new PhpCsFixer\Config();
- $config
- ->setRiskyAllowed(true)
- ->setRules([
- '@PHP74Migration' => true,
- '@PHP74Migration:risky' => true,
- '@PHPUnit100Migration:risky' => true,
- '@PhpCsFixer' => true,
- '@PhpCsFixer:risky' => true,
- 'general_phpdoc_annotation_remove' => ['annotations' => ['expectedDeprecation']], // one should use PHPUnit built-in method instead
- 'header_comment' => ['header' => $header],
- 'heredoc_indentation' => false, // TODO switch on when # of PR's is lower
- 'modernize_strpos' => true, // needs PHP 8+ or polyfill
- 'no_useless_concat_operator' => false, // TODO switch back on when the `src/Console/Application.php` no longer needs the concat
- 'use_arrow_functions' => false, // TODO switch on when # of PR's is lower
- ])
- ->setFinder($finder)
- ;
- // special handling of fabbot.io service if it's using too old PHP CS Fixer version
- if (false !== getenv('FABBOT_IO')) {
- try {
- PhpCsFixer\FixerFactory::create()
- ->registerBuiltInFixers()
- ->registerCustomFixers($config->getCustomFixers())
- ->useRuleSet(new PhpCsFixer\RuleSet($config->getRules()))
- ;
- } catch (PhpCsFixer\ConfigurationException\InvalidConfigurationException $e) {
- $config->setRules([]);
- } catch (UnexpectedValueException $e) {
- $config->setRules([]);
- } catch (InvalidArgumentException $e) {
- $config->setRules([]);
- }
- }
- return $config;
|