Skip to content

Commit

Permalink
Update packages, ecs, rector
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Tepper committed Mar 5, 2024
1 parent d20800a commit fa6e58c
Show file tree
Hide file tree
Showing 21 changed files with 812 additions and 357 deletions.
86 changes: 32 additions & 54 deletions .code-quality/ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,70 +2,48 @@

declare(strict_types=1);

use PhpCsFixer\Fixer\ClassNotation\ClassAttributesSeparationFixer;
use PhpCsFixer\Fixer\Import\OrderedImportsFixer;
use PhpCsFixer\Fixer\FunctionNotation\FunctionTypehintSpaceFixer;
use PhpCsFixer\Fixer\Operator\NotOperatorWithSuccessorSpaceFixer;
use PhpCsFixer\Fixer\Phpdoc\NoSuperfluousPhpdocTagsFixer;
use PhpCsFixer\Fixer\Phpdoc\GeneralPhpdocAnnotationRemoveFixer;
use PhpCsFixer\Fixer\Strict\DeclareStrictTypesFixer;
use PhpCsFixer\Fixer\Strict\StrictComparisonFixer;
use PhpCsFixer\Fixer\Strict\StrictParamFixer;
use PhpCsFixer\Fixer\StringNotation\ExplicitStringVariableFixer;
use PhpCsFixer\Fixer\Whitespace\ArrayIndentationFixer;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\CodingStandard\Fixer\ArrayNotation\ArrayListItemNewlineFixer;
use Symplify\CodingStandard\Fixer\ArrayNotation\ArrayOpenerAndCloserNewlineFixer;
use Symplify\CodingStandard\Fixer\LineLength\DocBlockLineLengthFixer;
use Symplify\CodingStandard\Fixer\LineLength\LineLengthFixer;
use Symplify\EasyCodingStandard\Config\ECSConfig;
use Symplify\EasyCodingStandard\ValueObject\Option;
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;

return static function (ContainerConfigurator $containerConfigurator): void {
$parameters = $containerConfigurator->parameters();
$parameters->set(
Option::PATHS,
return ECSConfig::configure()
->withPaths([
__DIR__ . '/../Classes',
__DIR__ . '/../Tests',
__DIR__ . '/ecs.php',
])
->withSets([
SetList::PSR_12,
SetList::COMMON,
SetList::SYMPLIFY,
SetList::CLEAN_CODE,
])
->withConfiguredRule(
LineLengthFixer::class,
[
__DIR__ . '/../Classes',
__DIR__ . '/ecs.php',
]
);

$containerConfigurator->import(SetList::COMMON);
$containerConfigurator->import(SetList::CLEAN_CODE);
$containerConfigurator->import(SetList::PSR_12);
$containerConfigurator->import(SetList::SYMPLIFY);

$containerConfigurator->services()
->set(LineLengthFixer::class)
->call('configure', [[
LineLengthFixer::LINE_LENGTH => 140,
LineLengthFixer::INLINE_SHORT_LINES => false,
]]);

// Skip Rules and Sniffer
$parameters->set(
Option::SKIP,
[
// Default Skips
Symplify\CodingStandard\Fixer\LineLength\LineLengthFixer::class => [
__DIR__ . '/ecs.php',
],
ArrayListItemNewlineFixer::class => null,
ArrayOpenerAndCloserNewlineFixer::class => null,
ClassAttributesSeparationFixer::class => null,
OrderedImportsFixer::class => null,
NotOperatorWithSuccessorSpaceFixer::class => null,
ExplicitStringVariableFixer::class => null,
ArrayIndentationFixer::class => null,
DocBlockLineLengthFixer::class => null,
'\SlevomatCodingStandard\Sniffs\Whitespaces\DuplicateSpacesSniff.DuplicateSpaces' => null,
'\SlevomatCodingStandard\Sniffs\Namespaces\ReferenceUsedNamesOnlySniff.PartialUse' => null,

// @todo for next upgrade
NoSuperfluousPhpdocTagsFixer::class => null,
// @todo strict php
DeclareStrictTypesFixer::class => null,
StrictComparisonFixer::class => null,
StrictParamFixer::class => null,
]
);
};
)
->withSkip([
NotOperatorWithSuccessorSpaceFixer::class => null,
DocBlockLineLengthFixer::class => null,
ArrayListItemNewlineFixer::class => null,
ArrayOpenerAndCloserNewlineFixer::class => null,
FunctionTypehintSpaceFixer::class => [
__DIR__ . '/../Tests/Unit/TYPO3/AdditionalResponseHeadersTest.php',
__DIR__ . '/../Classes/TYPO3/Hooks/ClearCacheMenuHook.php',
__DIR__ . '/../Classes/TYPO3/Configuration/ExtensionConfiguration.php',
],
DeclareStrictTypesFixer::class => null,
GeneralPhpdocAnnotationRemoveFixer::class => null,
])
->withSpacing(OPTION::INDENTATION_SPACES, "\n");
82 changes: 1 addition & 81 deletions .code-quality/phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,82 +1,2 @@
parameters:
ignoreErrors:
-
message: "#^Call to an undefined method object\\:\\:getQueryBuilderForTable\\(\\)\\.$#"
count: 1
path: ../Classes/Domain/Repository/FootnoteRepository.php

-
message: "#^Cannot call method fetchAllAssociative\\(\\) on Doctrine\\\\DBAL\\\\ForwardCompatibility\\\\Result\\|int\\|string\\.$#"
count: 1
path: ../Classes/Domain/Repository/FootnoteRepository.php

-
message: "#^Method AOE\\\\HappyFeet\\\\Domain\\\\Repository\\\\FootnoteRepository\\:\\:getFootnoteByUid\\(\\) should return AOE\\\\HappyFeet\\\\Domain\\\\Model\\\\Footnote\\|null but returns object\\|null\\.$#"
count: 1
path: ../Classes/Domain/Repository/FootnoteRepository.php

-
message: "#^Method AOE\\\\HappyFeet\\\\Service\\\\FCEFootnoteService\\:\\:getCObj\\(\\) should return TYPO3\\\\CMS\\\\Frontend\\\\ContentObject\\\\ContentObjectRenderer but returns TYPO3\\\\CMS\\\\Frontend\\\\ContentObject\\\\ContentObjectRenderer\\|null\\.$#"
count: 1
path: ../Classes/Service/FCEFootnoteService.php

-
message: "#^Call to an undefined method object\\:\\:setTemplatePathAndFilename\\(\\)\\.$#"
count: 1
path: ../Classes/Service/RenderingService.php

-
message: "#^Method AOE\\\\HappyFeet\\\\Service\\\\RenderingService\\:\\:createView\\(\\) should return TYPO3\\\\CMS\\\\Fluid\\\\View\\\\StandaloneView but returns object\\.$#"
count: 1
path: ../Classes/Service/RenderingService.php

-
message: "#^Method AOE\\\\HappyFeet\\\\Service\\\\RenderingService\\:\\:getContentObjectRenderer\\(\\) should return TYPO3\\\\CMS\\\\Frontend\\\\ContentObject\\\\ContentObjectRenderer but returns object\\.$#"
count: 1
path: ../Classes/Service/RenderingService.php

-
message: "#^Parameter \\#1 \\$richText of method AOE\\\\HappyFeet\\\\Service\\\\RenderingService\\:\\:renderRichText\\(\\) expects string, string\\|null given\\.$#"
count: 1
path: ../Classes/Service/RenderingService.php

-
message: "#^Property AOE\\\\HappyFeet\\\\Service\\\\RenderingService\\:\\:\\$contentObjectRenderer \\(TYPO3\\\\CMS\\\\Frontend\\\\ContentObject\\\\ContentObjectRenderer\\|null\\) does not accept object\\.$#"
count: 1
path: ../Classes/Service/RenderingService.php

-
message: "#^Cannot call method renderFootnotes\\(\\) on AOE\\\\HappyFeet\\\\Service\\\\RenderingService\\|null\\.$#"
count: 1
path: ../Classes/Typo3/Hook/LinkRenderer.php

-
message: "#^Parameter \\#1 \\$string of function trim expects string, string\\|null given\\.$#"
count: 1
path: ../Classes/Typo3/Hook/LinkRenderer.php

-
message: "#^Property AOE\\\\HappyFeet\\\\Typo3\\\\Hook\\\\LinkRenderer\\:\\:\\$renderingService \\(AOE\\\\HappyFeet\\\\Service\\\\RenderingService\\|null\\) does not accept object\\.$#"
count: 1
path: ../Classes/Typo3/Hook/LinkRenderer.php

-
message: "#^Call to an undefined method TYPO3Fluid\\\\Fluid\\\\View\\\\ViewInterface\\:\\:setTemplate\\(\\)\\.$#"
count: 1
path: ../Classes/Typo3/Hook/LinkWizzard.php

-
message: "#^Call to an undefined method object\\:\\:asString\\(\\)\\.$#"
count: 1
path: ../Classes/Typo3/Hook/LinkWizzard.php

-
message: "#^Call to an undefined method object\\:\\:displayRecordsForPage\\(\\)\\.$#"
count: 1
path: ../Classes/Typo3/Hook/LinkWizzard.php

-
message: "#^Offset 'selector' does not exist on array\\|string\\.$#"
count: 1
path: ../Classes/Typo3/Hook/LinkWizzard.php

ignoreErrors: []
22 changes: 4 additions & 18 deletions .code-quality/phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
includes:
- ../.Build/vendor/symplify/phpstan-rules/config/services/services.neon
- phpstan-baseline.neon
- ../.Build/vendor/symplify/phpstan-rules/packages/cognitive-complexity/config/cognitive-complexity-rules.neon

rules:
- Symplify\PHPStanRules\Rules\NoDefaultExceptionRule
- ../.Build/vendor/symplify/phpstan-rules/config/code-complexity-rules.neon

parameters:
level: max
level: 6
paths:
- "../Classes/"

Expand All @@ -15,17 +13,6 @@ parameters:
checkGenericClassInNonGenericObjectType: false

services:
- class: Symplify\Astral\Naming\SimpleNameResolver
- class: Symplify\PHPStanRules\CognitiveComplexity\AstCognitiveComplexityAnalyzer
- class: Symplify\PHPStanRules\CognitiveComplexity\NodeTraverser\ComplexityNodeTraverserFactory
- class: Symplify\PHPStanRules\CognitiveComplexity\DataCollector\CognitiveComplexityDataCollector
- class: Symplify\PHPStanRules\CognitiveComplexity\NodeVisitor\NestingNodeVisitor
- class: Symplify\PHPStanRules\CognitiveComplexity\NodeVisitor\ComplexityNodeVisitor
- class: Symplify\PHPStanRules\CognitiveComplexity\NodeAnalyzer\ComplexityAffectingNodeFinder
- class: Symplify\PackageBuilder\Php\TypeChecker
- class: Symplify\PackageBuilder\Matcher\ArrayStringAndFnMatcher
- class: Symplify\PHPStanRules\TypeAnalyzer\ObjectTypeAnalyzer
- class: Symplify\PHPStanRules\TypeAnalyzer\TypeUnwrapper
-
class: Symplify\PHPStanRules\Rules\ForbiddenFuncCallRule
tags: [phpstan.rules.rule]
Expand All @@ -35,5 +22,4 @@ services:
- dd
- die
- dump
- compact
- var_dump
- compact
154 changes: 34 additions & 120 deletions .code-quality/rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,128 +2,42 @@

declare(strict_types=1);

use Rector\Arguments\Rector\ClassMethod\ArgumentAdderRector;
use Rector\CodeQuality\Rector\Array_\CallableThisArrayToAnonymousFunctionRector;
use Rector\CodeQuality\Rector\Equal\UseIdenticalOverEqualWithSameTypeRector;
use Rector\CodeQuality\Rector\Identical\FlipTypeControlToUseExclusiveTypeRector;
use Rector\CodeQuality\Rector\Isset_\IssetOnPropertyObjectToPropertyExistsRector;
use Rector\CodeQualityStrict\Rector\If_\MoveOutMethodCallInsideIfConditionRector;
use Rector\CodingStyle\Rector\ClassMethod\ReturnArrayClassMethodToYieldRector;
use Rector\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector;
use Rector\CodingStyle\Rector\Encapsed\WrapEncapsedVariableInCurlyBracesRector;
use Rector\CodingStyle\Rector\FuncCall\ConsistentPregDelimiterRector;
use Rector\CodingStyle\Rector\PostInc\PostIncDecToPreIncDecRector;
use Rector\CodingStyle\Rector\Property\AddFalseDefaultToBoolPropertyRector;
use Rector\Core\Configuration\Option;
use Rector\DeadCode\Rector\Cast\RecastingRemovalRector;
use Rector\DeadCode\Rector\ClassMethod\RemoveDelegatingParentCallRector;
use Rector\DeadCode\Rector\If_\RemoveDeadInstanceOfRector;
use Rector\Config\RectorConfig;
use Rector\DeadCode\Rector\Property\RemoveUnusedPrivatePropertyRector;
use Rector\Defluent\Rector\Return_\ReturnFluentChainMethodCallToNormalMethodCallRector;
use Rector\EarlyReturn\Rector\If_\ChangeAndIfToEarlyReturnRector;
use Rector\EarlyReturn\Rector\If_\ChangeOrIfReturnToEarlyReturnRector;
use Rector\EarlyReturn\Rector\Return_\ReturnBinaryAndToEarlyReturnRector;
use Rector\Naming\Rector\ClassMethod\RenameVariableToMatchNewTypeRector;
use Rector\Naming\Rector\Foreach_\RenameForeachValueVariableToMatchMethodCallReturnTypeRector;
use Rector\Naming\Rector\Property\MakeBoolPropertyRespectIsHasWasMethodNamingRector;
use Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector;
use Rector\Php74\Rector\LNumber\AddLiteralSeparatorToNumberRector;
use Rector\Set\ValueObject\SetList;
use Rector\PHPUnit\Set\PHPUnitSetList;
use Rector\Privatization\Rector\Class_\ChangeReadOnlyVariableWithDefaultValueToConstantRector;
use Rector\Privatization\Rector\Class_\FinalizeClassesWithoutChildrenRector;
use Rector\Privatization\Rector\Class_\RepeatedLiteralToClassConstantRector;
use Rector\Privatization\Rector\MethodCall\PrivatizeLocalGetterToPropertyRector;
use Rector\Privatization\Rector\Property\PrivatizeLocalPropertyToPrivatePropertyRector;
use Rector\Set\ValueObject\SetList;
use Rector\TypeDeclaration\Rector\ClassMethod\AddArrayParamDocTypeRector;
use Rector\TypeDeclaration\Rector\ClassMethod\AddArrayReturnDocTypeRector;
use Rector\TypeDeclaration\Rector\FunctionLike\ParamTypeDeclarationRector;
use Rector\TypeDeclaration\Rector\FunctionLike\ReturnTypeDeclarationRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return static function (ContainerConfigurator $containerConfigurator): void {

$containerConfigurator->import(SetList::CODE_QUALITY);
$containerConfigurator->import(SetList::CODE_QUALITY_STRICT);
$containerConfigurator->import(SetList::CODING_STYLE);
$containerConfigurator->import(SetList::DEAD_CODE);
$containerConfigurator->import(SetList::EARLY_RETURN);
$containerConfigurator->import(SetList::PRIVATIZATION);
$containerConfigurator->import(SetList::TYPE_DECLARATION);
$containerConfigurator->import(SetList::PSR_4);
$containerConfigurator->import(SetList::MYSQL_TO_MYSQLI);
$containerConfigurator->import(SetList::TYPE_DECLARATION_STRICT);
$containerConfigurator->import(SetList::UNWRAP_COMPAT);

$containerConfigurator->import(SetList::PHP_72);
$containerConfigurator->import(SetList::PHP_73);
$containerConfigurator->import(SetList::PHP_74);
$containerConfigurator->import(SetList::PHP_80);

$containerConfigurator->import(PHPUnitSetList::PHPUNIT_CODE_QUALITY);

$parameters = $containerConfigurator->parameters();
$parameters->set(
Option::PATHS,
[
__DIR__ . '/../Classes',
__DIR__ . '/rector.php',
]
);

$parameters->set(Option::AUTO_IMPORT_NAMES, false);
$parameters->set(Option::AUTOLOAD_PATHS, [__DIR__ . '/../Classes']);
$parameters->set(
Option::SKIP,
[
RecastingRemovalRector::class,
ConsistentPregDelimiterRector::class,
PostIncDecToPreIncDecRector::class,
FinalizeClassesWithoutChildrenRector::class,
ChangeOrIfReturnToEarlyReturnRector::class,
ChangeAndIfToEarlyReturnRector::class,
ReturnBinaryAndToEarlyReturnRector::class,
MakeBoolPropertyRespectIsHasWasMethodNamingRector::class,
MoveOutMethodCallInsideIfConditionRector::class,
ReturnArrayClassMethodToYieldRector::class,
AddArrayParamDocTypeRector::class,
AddArrayReturnDocTypeRector::class,
ReturnFluentChainMethodCallToNormalMethodCallRector::class,
IssetOnPropertyObjectToPropertyExistsRector::class,
FlipTypeControlToUseExclusiveTypeRector::class,
RepeatedLiteralToClassConstantRector::class,
RenameVariableToMatchNewTypeRector::class,
AddLiteralSeparatorToNumberRector::class,
RenameForeachValueVariableToMatchMethodCallReturnTypeRector::class,
ChangeReadOnlyVariableWithDefaultValueToConstantRector::class,
PrivatizeLocalPropertyToPrivatePropertyRector::class,
RemoveDelegatingParentCallRector::class,
RemoveUnusedPrivatePropertyRector::class => [
__DIR__ . '/../Classes/Typo3/Hook/LinkWizzard.php',
],
RemoveDeadInstanceOfRector::class => [
__DIR__ . '/../Classes/Service/RenderingService.php',
__DIR__ . '/../Classes/Domain/Repository/FootnoteRepository.php',
],
PrivatizeLocalGetterToPropertyRector::class => [
__DIR__ . '/../Classes/Service/FCEFootnoteService.php',
],
CallableThisArrayToAnonymousFunctionRector::class => [
__DIR__ . '/../Classes/Domain/Repository/FootnoteRepository.php',
],

// @todo strict php
ArgumentAdderRector::class,
ParamTypeDeclarationRector::class,
ReturnTypeDeclarationRector::class,
RemoveExtraParametersRector::class,
EncapsedStringsToSprintfRector::class,
AddFalseDefaultToBoolPropertyRector::class,
WrapEncapsedVariableInCurlyBracesRector::class,
UseIdenticalOverEqualWithSameTypeRector::class,
]
);

$services = $containerConfigurator->services();
$services->set(RemoveUnusedPrivatePropertyRector::class);
};
use Rector\TypeDeclaration\Rector\ClassMethod\AddMethodCallBasedStrictParamTypeRector;
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictSetUpRector;

return RectorConfig::configure()
->withPaths([
__DIR__ . '/../Classes',
__DIR__ . '/../Tests',
__DIR__ . '/rector.php',
])
->withPhpSets(
true
)
->withSets([
SetList::CODE_QUALITY,
SetList::STRICT_BOOLEANS,
SetList::CODING_STYLE,
SetList::DEAD_CODE,
SetList::EARLY_RETURN,
SetList::PRIVATIZATION,
SetList::TYPE_DECLARATION,
SetList::INSTANCEOF,
PHPUnitSetList::PHPUNIT_CODE_QUALITY
])
->withSkip([
FinalizeClassesWithoutChildrenRector::class,
ChangeAndIfToEarlyReturnRector::class,
TypedPropertyFromStrictSetUpRector::class,
AddMethodCallBasedStrictParamTypeRector::class,
FlipTypeControlToUseExclusiveTypeRector::class,
])
->withAutoloadPaths([__DIR__ . '/../Classes'])
->registerService(RemoveUnusedPrivatePropertyRector::class);
Loading

0 comments on commit fa6e58c

Please sign in to comment.