Skip to content

Commit

Permalink
Bump PHPStan, ECS and Symplify to 10.2 + make use of brand new ECSCon…
Browse files Browse the repository at this point in the history
…fig (#2076)
  • Loading branch information
TomasVotruba committed Apr 14, 2022
1 parent 86647cc commit d7590ea
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 83 deletions.
2 changes: 1 addition & 1 deletion build/target-repository/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
],
"require": {
"php": "^7.2|^8.0",
"phpstan/phpstan": "^1.5"
"phpstan/phpstan": "^1.5.5"
},
"autoload": {
"files": [
Expand Down
42 changes: 21 additions & 21 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
"nette/utils": "^3.2.7",
"nikic/php-parser": "^4.13.2",
"ondram/ci-detector": "^4.1",
"phpstan/phpdoc-parser": "^1.2",
"phpstan/phpstan": "^1.5",
"phpstan/phpdoc-parser": "^1.4.4",
"phpstan/phpstan": "^1.5.5",
"phpstan/phpstan-phpunit": "^1.0",
"psr/log": "^2.0",
"react/child-process": "^0.6.4",
Expand All @@ -47,16 +47,16 @@
"symfony/process": "^6.0",
"symfony/string": "^6.0",
"symfony/yaml": "^6.0",
"symplify/astral": "^10.1",
"symplify/autowire-array-parameter": "^10.1",
"symplify/composer-json-manipulator": "^10.1",
"symplify/easy-parallel": "^10.1",
"symplify/package-builder": "^10.1",
"symplify/rule-doc-generator-contracts": "^10.1",
"symplify/skipper": "^10.1",
"symplify/smart-file-system": "^10.1",
"symplify/symplify-kernel": "^10.1",
"symplify/vendor-patches": "^10.1",
"symplify/astral": "^10.2",
"symplify/autowire-array-parameter": "^10.2",
"symplify/composer-json-manipulator": "^10.2",
"symplify/easy-parallel": "^10.2",
"symplify/package-builder": "^10.2",
"symplify/rule-doc-generator-contracts": "^10.2",
"symplify/skipper": "^10.2",
"symplify/smart-file-system": "^10.2",
"symplify/symplify-kernel": "^10.2",
"symplify/vendor-patches": "^10.2",
"tracy/tracy": "^2.9",
"webmozart/assert": "^1.10"
},
Expand All @@ -72,14 +72,14 @@
"phpunit/phpunit": "^9.5",
"rector/phpstan-rules": "^0.4.21",
"spatie/enum": "^3.12",
"symplify/coding-standard": "^10.1",
"symplify/easy-ci": "^10.1",
"symplify/easy-coding-standard": "^10.1",
"symplify/easy-testing": "^10.1",
"symplify/monorepo-builder": "^10.1",
"symplify/phpstan-extensions": "^10.1",
"symplify/phpstan-rules": "^10.1",
"symplify/rule-doc-generator": "^10.1",
"symplify/coding-standard": "^10.2",
"symplify/easy-ci": "^10.2",
"symplify/easy-coding-standard": "^10.2",
"symplify/easy-testing": "^10.2",
"symplify/monorepo-builder": "^10.2",
"symplify/phpstan-extensions": "^10.2",
"symplify/phpstan-rules": "^10.2",
"symplify/rule-doc-generator": "^10.2",
"timeweb/phpstan-enum": "dev-22-upgrade-phpstan-to-1.0"
},
"replace": {
Expand Down Expand Up @@ -138,7 +138,7 @@
"vendor/bin/ecs check --fix --ansi",
"vendor/bin/ecs check-markdown README.md --fix --ansi"
],
"phpstan": "php -dmemory_limit=1G vendor/bin/phpstan analyse --ansi --error-format symplify",
"phpstan": "vendor/bin/phpstan analyse --ansi --error-format symplify --memory-limit 2G",
"phpstan-config": "vendor/bin/phpstan analyse config --ansi --error-format symplify",
"docs": [
"vendor/bin/rule-doc-generator generate packages rules --output-file build/rector_rules_overview.md --ansi --categorize --configure-method",
Expand Down
63 changes: 26 additions & 37 deletions ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,20 @@

declare(strict_types=1);

use PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\AssignmentInConditionSniff;
use PhpCsFixer\Fixer\FunctionNotation\FunctionTypehintSpaceFixer;
use PhpCsFixer\Fixer\Phpdoc\GeneralPhpdocAnnotationRemoveFixer;
use PhpCsFixer\Fixer\Phpdoc\NoSuperfluousPhpdocTagsFixer;
use PhpCsFixer\Fixer\Phpdoc\PhpdocTypesFixer;
use PhpCsFixer\Fixer\PhpUnit\PhpUnitStrictFixer;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\CodingStandard\Fixer\LineLength\DocBlockLineLengthFixer;
use Symplify\EasyCodingStandard\ValueObject\Option;
use Symplify\EasyCodingStandard\Config\ECSConfig;
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;

return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
return static function (ECSConfig $ecsConfig): void {
$ecsConfig->sets([SetList::PSR_12, SetList::SYMPLIFY, SetList::COMMON, SetList::CLEAN_CODE]);

$services->set(NoSuperfluousPhpdocTagsFixer::class)
->call('configure', [[
'allow_mixed' => true,
]]);

$services->set(GeneralPhpdocAnnotationRemoveFixer::class)
->call('configure', [[
'annotations' => [
'throw',
'throws',
'author',
'authors',
'package',
'group',
'required',
'phpstan-ignore-line',
'phpstan-ignore-next-line',
],
]]);

$parameters = $containerConfigurator->parameters();

$parameters->set(Option::PATHS, [
$ecsConfig->paths([
__DIR__ . '/bin',
__DIR__ . '/src',
__DIR__ . '/packages',
Expand All @@ -53,7 +31,25 @@
__DIR__ . '/scoper.php',
]);

$parameters->set(Option::SKIP, [
$ecsConfig->ruleWithConfiguration(NoSuperfluousPhpdocTagsFixer::class, [
'allow_mixed' => true,
]);

$ecsConfig->ruleWithConfiguration(GeneralPhpdocAnnotationRemoveFixer::class, [
'annotations' => [
'throw',
'throws',
'author',
'authors',
'package',
'group',
'required',
'phpstan-ignore-line',
'phpstan-ignore-next-line',
],
]);

$ecsConfig->skip([
'*/Source/*',
'*/Fixture/*',
'*/Expected/*',
Expand All @@ -73,14 +69,7 @@
__DIR__ . '/src/DependencyInjection/Loader/Configurator/RectorServiceConfigurator.php',
__DIR__ . '/rules/Php70/EregToPcreTransformer.php',
],
]);

// import SetList here in the end of ecs. is on purpose
// to avoid overridden by existing Skip Option in current config
$containerConfigurator->import(SetList::PSR_12);
$containerConfigurator->import(SetList::SYMPLIFY);
$containerConfigurator->import(SetList::COMMON);
$containerConfigurator->import(SetList::CLEAN_CODE);

$parameters->set(Option::LINE_ENDING, "\n");
AssignmentInConditionSniff::class . '.FoundInWhileCondition',
]);
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@
namespace Rector\Tests\CodingStyle\Rector\Property\InlineSimplePropertyAnnotationRector;

use Rector\CodingStyle\Rector\Property\InlineSimplePropertyAnnotationRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Rector\Config\RectorConfig;

return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$rectorServiceConfigurator = $services->set(InlineSimplePropertyAnnotationRector::class);
/** @phpstan-ignore-next-line */
$rectorServiceConfigurator->configure(['custom-var']);
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->ruleWithConfiguration(InlineSimplePropertyAnnotationRector::class, ['custom-var']);
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
namespace Rector\Tests\CodingStyle\Rector\Property\InlineSimplePropertyAnnotationRector;

use Rector\CodingStyle\Rector\Property\InlineSimplePropertyAnnotationRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Rector\Config\RectorConfig;

return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(InlineSimplePropertyAnnotationRector::class);
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->rule(InlineSimplePropertyAnnotationRector::class);
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@

namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ParamAnnotationIncorrectNullableRector;

use Rector\Config\RectorConfig;
use Rector\TypeDeclaration\Rector\ClassMethod\ParamAnnotationIncorrectNullableRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(ParamAnnotationIncorrectNullableRector::class);
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->rule(ParamAnnotationIncorrectNullableRector::class);
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,14 @@

declare(strict_types=1);

use Rector\Core\Configuration\Option;
use Rector\Config\RectorConfig;
use Rector\Core\ValueObject\PhpVersionFeature;
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(TypedPropertyFromAssignsRector::class)
->configure([
TypedPropertyFromAssignsRector::INLINE_PUBLIC => true,
]);
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->ruleWithConfiguration(TypedPropertyFromAssignsRector::class, [
TypedPropertyFromAssignsRector::INLINE_PUBLIC => true,
]);

$parameters = $containerConfigurator->parameters();
$parameters->set(Option::PHP_VERSION_FEATURES, PhpVersionFeature::INTERSECTION_TYPES);
$rectorConfig->phpVersion(PhpVersionFeature::INTERSECTION_TYPES);
};

0 comments on commit d7590ea

Please sign in to comment.