switch config.yaml to config.php

This commit is contained in:
TomasVotruba 2020-07-16 13:07:08 +02:00
parent c20dc14b26
commit f8c50ee885
11 changed files with 221 additions and 159 deletions

45
config/config.php Normal file
View File

@ -0,0 +1,45 @@
<?php
declare(strict_types=1);
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
return static function (ContainerConfigurator $containerConfigurator): void {
$containerConfigurator->import(__DIR__ . '/../packages/**/config/config.*');
$containerConfigurator->import(__DIR__ . '/../rules/**/config/config.*');
$containerConfigurator->import(__DIR__ . '/services.php');
$containerConfigurator->import(__DIR__ . '/parameters/parameter_name_guard.php');
$containerConfigurator->import(__DIR__ . '/../utils/**/config/config.yaml', null, true);
$parameters = $containerConfigurator->parameters();
$parameters->set('paths', []);
$parameters->set('file_extensions', ['php']);
$parameters->set('exclude_paths', []);
$parameters->set('exclude_rectors', []);
$parameters->set('autoload_paths', []);
$parameters->set('rector_recipe', []);
$parameters->set('project_type', 'proprietary');
$parameters->set('nested_chain_method_call_limit', 30);
$parameters->set('auto_import_names', false);
$parameters->set('import_short_classes', true);
$parameters->set('import_doc_blocks', true);
$parameters->set('php_version_features', null);
$parameters->set('safe_types', false);
};

View File

@ -1,41 +0,0 @@
imports:
- { resource: '../packages/**/config/config.*' }
- { resource: '../rules/**/config/config.*' }
- { resource: 'services.yaml' }
- { resource: 'parameters/parameter_name_guard.yaml' }
# only in local repository
# ignore errors, because utils are not part of composer package nor rector.phar
- { resource: '../utils/**/config/config.yaml', ignore_errors: true }
parameters:
# processed paths
paths: []
file_extensions:
- 'php'
# exclude
exclude_paths: []
exclude_rectors: []
autoload_paths: []
rector_recipe: []
# this helps to separate opened 3rd party code vs private code approach (e.g. use of public constants)
project_type: "proprietary" # or "open-source"
# lower for performance; higher to prevent bugs with fluent interfaces like https://github.com/rectorphp/rector/issues/1646, or https://github.com/rectorphp/rector/issues/2444
nested_chain_method_call_limit: 30
# importing FQN names; false disables "import_short_classes" and "import_doc_blocks" options bellow
auto_import_names: false
# e.g. import \DateTime
import_short_classes: true
# e.g. /** @var \Some\ClassHere */
import_doc_blocks: true
# what PHP version is used for features, composer.json version, then local PHP version is used by default
php_version_features: null
# false = use types from docblocks; true = only from PHP types, e.g. for typed properties
safe_types: false

View File

@ -0,0 +1,61 @@
<?php
declare(strict_types=1);
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
return static function (ContainerConfigurator $containerConfigurator): void {
$parameters = $containerConfigurator->parameters();
$parameters->set('correct_to_typos', [
'exclude_paths' => [
'exclude',
'excluded',
'exclude_path',
'excluded_path',
'exclude_dir',
'excluded_dir',
'exclude_dirs',
'excluded_dirs',
'exclude_file',
'excluded_file',
'exclude_files',
'excluded_files',
'ignore_path',
'ignored_path',
'ignore_paths',
'ignored_paths',
'ignore_dir',
'ignored_dir',
'ignore_dirs',
'ignored_dirs',
'ignore_file',
'ignored_file',
'ignore_files',
'ignored_files',
'skip_path',
'skip_paths',
'skip_dir',
'skip_dirs',
'skip_file',
'skip_files',
],
'exclude_rectors' => [
'exclude_rector',
'excluded_rector',
'excluded_rectors',
'skip_rector',
'skip_rectors',
],
'autoload_paths' => ['#(autolaod|autoload|include|bootstrap)((ed)?_(path(s)?|dir(s)?|file(s)?))?#'],
'auto_import_names' => [
'auto_imort_names',
'auto_import_name',
'auto_imports_names',
'auto_imports_name',
'auto_names',
'import_name(space)?(s)?',
],
'paths' => ['path', 'source'], ]
);
};

View File

@ -1,54 +0,0 @@
# see https://github.com/symplify/parameter-name-guard
parameters:
correct_to_typos:
# keep "exclude_" explicit, to get typos to the correct key
exclude_paths:
- 'exclude'
- 'excluded'
- 'exclude_path'
- 'excluded_path'
- 'exclude_dir'
- 'excluded_dir'
- 'exclude_dirs'
- 'excluded_dirs'
- 'exclude_file'
- 'excluded_file'
- 'exclude_files'
- 'excluded_files'
- 'ignore_path'
- 'ignored_path'
- 'ignore_paths'
- 'ignored_paths'
- 'ignore_dir'
- 'ignored_dir'
- 'ignore_dirs'
- 'ignored_dirs'
- 'ignore_file'
- 'ignored_file'
- 'ignore_files'
- 'ignored_files'
- 'skip_path'
- 'skip_paths'
- 'skip_dir'
- 'skip_dirs'
- 'skip_file'
- 'skip_files'
exclude_rectors:
- 'exclude_rector'
- 'excluded_rector'
- 'excluded_rectors'
- 'skip_rector'
- 'skip_rectors'
autoload_paths:
# https://regex101.com/r/aXEZYk/1
- '#(autolaod|autoload|include|bootstrap)((ed)?_(path(s)?|dir(s)?|file(s)?))?#'
auto_import_names:
- 'auto_imort_names'
- 'auto_import_name'
- 'auto_imports_names'
- 'auto_imports_name'
- 'auto_names'
- 'import_name(space)?(s)?'
paths:
- path
- source

89
config/services.php Normal file
View File

@ -0,0 +1,89 @@
<?php
declare(strict_types=1);
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
use OndraM\CiDetector\CiDetector;
use PhpParser\BuilderFactory;
use PhpParser\Lexer;
use PhpParser\NodeFinder;
use PhpParser\NodeVisitor\CloningVisitor;
use PhpParser\Parser;
use PhpParser\ParserFactory;
use Rector\Core\Configuration\MinimalVersionChecker;
use Rector\Core\Console\Application;
use Rector\Core\EventDispatcher\AutowiredEventDispatcher;
use Rector\Core\PhpParser\Parser\LexerFactory;
use Rector\Core\PhpParser\Parser\NikicPhpParserFactory;
use Symfony\Component\Console\Application as SymfonyApplication;
use Symfony\Component\Console\Descriptor\TextDescriptor;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Filesystem\Filesystem;
use Symplify\PackageBuilder\Parameter\ParameterProvider;
use Symplify\PackageBuilder\Reflection\PrivatesAccessor;
use Symplify\PackageBuilder\Reflection\PrivatesCaller;
use Symplify\PackageBuilder\Strings\StringFormatConverter;
use Symplify\SmartFileSystem\FileSystemFilter;
use Symplify\SmartFileSystem\Finder\FinderSanitizer;
return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->defaults()
->public()
->autowire();
$services->load('Rector\Core\\', __DIR__ . '/../src')
->exclude([
__DIR__ . '/../src/Rector/**/*Rector.php',
__DIR__ . '/../src/Testing/PHPUnit/*',
__DIR__ . '/../src/RectorDefinition/*',
__DIR__ . '/../src/Exception/*',
__DIR__ . '/../src/DependencyInjection/CompilerPass/*',
__DIR__ . '/../src/DependencyInjection/Loader/*',
__DIR__ . '/../src/PhpParser/Builder/*',
__DIR__ . '/../src/HttpKernel/*',
__DIR__ . '/../src/ValueObject/*',
__DIR__ . '/../src/Configuration/MinimalVersionChecker/*',
]);
$services->set(MinimalVersionChecker::class)
->autowire(false);
$services->alias(SymfonyApplication::class, Application::class);
$services->set(TextDescriptor::class);
$services->set(ParserFactory::class);
$services->set(BuilderFactory::class);
$services->set(CloningVisitor::class);
$services->set(NodeFinder::class);
$services->set(Parser::class)
->factory([ref(NikicPhpParserFactory::class), 'create']);
$services->set(Lexer::class)
->factory([ref(LexerFactory::class), 'create']);
$services->set(Filesystem::class);
$services->set(PrivatesAccessor::class);
$services->set(FinderSanitizer::class);
$services->set(FileSystemFilter::class);
$services->set(ParameterProvider::class);
$services->set(PrivatesCaller::class);
$services->set(StringFormatConverter::class);
$services->set(CiDetector::class);
$services->alias(EventDispatcherInterface::class, AutowiredEventDispatcher::class);
};

View File

@ -1,54 +0,0 @@
services:
_defaults:
public: true
autowire: true
Rector\Core\:
resource: '../src'
exclude:
- '../src/Rector/**/*Rector.php'
- '../src/Testing/PHPUnit/*'
- '../src/RectorDefinition/*'
- '../src/Exception/*'
- '../src/DependencyInjection/CompilerPass/*'
- '../src/DependencyInjection/Loader/*'
- '../src/PhpParser/Builder/*'
- '../src/HttpKernel/*'
- '../src/ValueObject/*'
- '../src/Configuration/MinimalVersionChecker'
- '../src/Configuration/MinimalVersionChecker/*'
Rector\Core\Configuration\MinimalVersionChecker:
autowire: false
Symfony\Component\Console\Application:
alias: 'Rector\Core\Console\Application'
Symfony\Component\Console\Descriptor\TextDescriptor: null
# PhpParser - Parser
PhpParser\ParserFactory: null
PhpParser\BuilderFactory: null
PhpParser\NodeVisitor\CloningVisitor:
PhpParser\NodeFinder: null
PhpParser\Parser:
factory: ['@Rector\Core\PhpParser\Parser\NikicPhpParserFactory', 'create']
PhpParser\Lexer:
factory: ['@Rector\Core\PhpParser\Parser\LexerFactory', 'create']
# value resolver
Symfony\Component\Filesystem\Filesystem: null
Symplify\PackageBuilder\Reflection\PrivatesAccessor: null
Symplify\SmartFileSystem\Finder\FinderSanitizer: null
Symplify\SmartFileSystem\FileSystemFilter: null
Symplify\PackageBuilder\Parameter\ParameterProvider: null
Symplify\PackageBuilder\Reflection\PrivatesCaller: null
Symplify\PackageBuilder\Strings\StringFormatConverter: null
OndraM\CiDetector\CiDetector: null
Symfony\Component\EventDispatcher\EventDispatcherInterface: '@Rector\Core\EventDispatcher\AutowiredEventDispatcher'

View File

@ -3,11 +3,10 @@ services:
SlevomatCodingStandard\Sniffs\Whitespaces\DuplicateSpacesSniff: null
PhpCsFixer\Fixer\Phpdoc\GeneralPhpdocAnnotationRemoveFixer:
annotations:
- 'throws'
- 'author'
- 'package'
- 'group'
calls:
- ['configure', [{'annotations': ['throws', 'author', 'package', 'group']}]]
Symplify\CodingStandard\Fixer\LineLength\LineLengthFixer: null
parameters:
paths:
@ -18,6 +17,7 @@ parameters:
- "tests"
- "utils"
- "compiler"
- "config"
sets:
- "psr12"
@ -27,7 +27,7 @@ parameters:
- "common"
- "clean-code"
exclude_files:
exclude_paths:
# tests files
- '*/Source/*'
- '*/Fixture/*'

View File

@ -18,5 +18,8 @@ return static function (ContainerConfigurator $containerConfigurator): void {
$services->load('Rector\Doctrine\\', __DIR__ . '/../src')
->exclude([__DIR__ . '/../src/Rector/**/*Rector.php']);
$services->alias(DoctrineEntityAndRepositoryMapperInterface::class, DefaultDoctrineEntityAndRepositoryMapper::class);
$services->alias(
DoctrineEntityAndRepositoryMapperInterface::class,
DefaultDoctrineEntityAndRepositoryMapper::class
);
};

View File

@ -12,5 +12,11 @@ return static function (ContainerConfigurator $containerConfigurator): void {
->autowire();
$services->load('Rector\Php70\\', __DIR__ . '/../src')
->exclude([__DIR__ . '/../src/Rector/**/*Rector.php', __DIR__ . '/../src/Exception/*', __DIR__ . '/../src/ValueObject/*']);
->exclude(
[
__DIR__ . '/../src/Rector/**/*Rector.php',
__DIR__ . '/../src/Exception/*',
__DIR__ . '/../src/ValueObject/*',
]
);
};

View File

@ -16,5 +16,12 @@ return static function (ContainerConfigurator $containerConfigurator): void {
->autowire();
$services->load('Rector\Symfony\\', __DIR__ . '/../src')
->exclude([__DIR__ . '/../src/Rector/**/*Rector.php', __DIR__ . '/../src/Exception/*', __DIR__ . '/../src/ValueObject/*', __DIR__ . '/../src/PhpDocParser/Ast/PhpDoc/*']);
->exclude(
[
__DIR__ . '/../src/Rector/**/*Rector.php',
__DIR__ . '/../src/Exception/*',
__DIR__ . '/../src/ValueObject/*',
__DIR__ . '/../src/PhpDocParser/Ast/PhpDoc/*',
]
);
};

View File

@ -60,7 +60,7 @@ final class RectorKernel extends Kernel implements ExtraConfigAwareKernelInterfa
public function registerContainerConfiguration(LoaderInterface $loader): void
{
$loader->load(__DIR__ . '/../../config/config.yaml');
$loader->load(__DIR__ . '/../../config/config.php');
foreach ($this->configs as $config) {
$loader->load($config);