Skip to content

Commit

Permalink
Feature/php83 (#23)
Browse files Browse the repository at this point in the history
* chore: CD-306297 Added PHP 8.3 compatibility, updated code-styles and testing framework

* chore: CD-306297 Updated github actions unit test XML

* chore: CD-306297 Updated github actions for matrix tests
  • Loading branch information
sourcesoldier authored Mar 22, 2024
1 parent f55f1e9 commit c9c076a
Show file tree
Hide file tree
Showing 99 changed files with 632 additions and 535 deletions.
77 changes: 28 additions & 49 deletions .code-quality/ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,64 +2,43 @@

declare(strict_types=1);

use PhpCsFixer\Fixer\ClassNotation\ClassAttributesSeparationFixer;
use PhpCsFixer\Fixer\Import\OrderedImportsFixer;
use PhpCsFixer\Fixer\Operator\NotOperatorWithSuccessorSpaceFixer;
use PhpCsFixer\Fixer\Phpdoc\NoSuperfluousPhpdocTagsFixer;
use PhpCsFixer\Fixer\Strict\DeclareStrictTypesFixer;
use PhpCsFixer\Fixer\Strict\StrictComparisonFixer;
use PhpCsFixer\Fixer\Strict\StrictParamFixer;
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\ValueObject\Option;
use Symplify\EasyCodingStandard\Config\ECSConfig;
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::COMMON,
SetList::CLEAN_CODE,
SetList::PSR_12,
SetList::SYMPLIFY,
])
->withConfiguredRule(
LineLengthFixer::class,
[
__DIR__ . '/../Classes',
__DIR__ . '/../Tests',
__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
DocBlockLineLengthFixer::class => null,
NotOperatorWithSuccessorSpaceFixer::class => null,
OrderedImportsFixer::class => null,
ArrayListItemNewlineFixer::class => null,
ArrayIndentationFixer::class => null,
ArrayOpenerAndCloserNewlineFixer::class => null,
ClassAttributesSeparationFixer::class => null,

// @todo for next upgrade
NoSuperfluousPhpdocTagsFixer::class => null,
// @todo strict php
DeclareStrictTypesFixer::class => null,
StrictComparisonFixer::class => null,
StrictParamFixer::class => null,
]
);
};
)
->withSkip([
// Default Skips
NotOperatorWithSuccessorSpaceFixer::class => null,
DocBlockLineLengthFixer::class => null,
ArrayListItemNewlineFixer::class => null,
ArrayOpenerAndCloserNewlineFixer::class => null,

// @todo strict php
DeclareStrictTypesFixer::class => null,
StrictComparisonFixer::class => null,
StrictParamFixer::class => null,
]);
52 changes: 44 additions & 8 deletions .code-quality/phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
parameters:
ignoreErrors:
-
message: "#^Cognitive complexity for \"Aoe\\\\Asdis\\\\Content\\\\Scraper\\\\Extractor\\\\XmlTagAttribute\\:\\:getAttributeFromTag\\(\\)\" is 9, keep it under 8$#"
count: 1
path: ../Classes/Content/Scraper/Extractor/XmlTagAttribute.php
-
message: "#^Cognitive complexity for \"Aoe\\\\Asdis\\\\System\\\\Configuration\\\\TypoScriptConfiguration\\:\\:getSetting\\(\\)\" is 9, keep it under 8$#"
count: 1
path: ../Classes/System/Configuration/TypoScriptConfiguration.php
-
message: "#^Comparison operation \"\\<\" between int\\<1, max\\> and 1 is always false\\.$#"
count: 2
Expand All @@ -24,3 +16,47 @@ parameters:
message: "#^Call to an undefined static method TYPO3\\\\CMS\\\\Core\\\\Utility\\\\GeneralUtility\\:\\:sysLog\\(\\)\\.$#"
count: 1
path: ../Classes/System/Log/Logger.php
-
message: "#^Relative file path \"tslib/class\\.tslib_fe\\.php\" is not allowed, use absolute one with __DIR__$#"
count: 4
path: ../Classes/Backend/Utility/HookUtility.php
-
message: "#^Use value object over return of values$#"
count: 2
path: ../Classes/Content/Scraper/Css/Url.php
-
message: "#^Use value object over return of values$#"
count: 3
path: ../Classes/Content/Scraper/Extractor/XmlTagAttribute.php
-
message: "#^Anonymous variable in a `\\$GLOBALS\\['TYPO3_REQUEST'\\]\\-\\>\\.\\.\\.\\(\\)` method call can lead to false dead methods\\. Make sure the variable type is known$#"
count: 1
path: ../Classes/System/Configuration/TypoScriptConfiguration.php

-
message: "#^Anonymous variable in a `\\$site\\-\\>getBase\\(\\)\\-\\>\\.\\.\\.\\(\\)` method call can lead to false dead methods\\. Make sure the variable type is known$#"
count: 1
path: ../Classes/System/Configuration/TypoScriptConfiguration.php

-
message: "#^Anonymous variables in a \"\\$GLOBALS\\['TSFE'\\]\\-\\>\\.\\.\\.\" property fetch can lead to false dead property\\. Make sure the variable type is known$#"
count: 1
path: ../Classes/System/Configuration/TypoScriptConfiguration.php

-
message: "#^Anonymous variables in a \"\\$GLOBALS\\['TSFE'\\]\\-\\>tmpl\\-\\>\\.\\.\\.\" property fetch can lead to false dead property\\. Make sure the variable type is known$#"
count: 1
path: ../Classes/System/Configuration/TypoScriptConfiguration.php

-
message: "#^Anonymous variable in a `\\$GLOBALS\\['TSFE'\\]\\-\\>\\.\\.\\.\\(\\)` method call can lead to false dead methods\\. Make sure the variable type is known$#"
count: 2
path: ../Classes/Typo3/Hook/ContentPostProcAll.php
-
message: "#^Anonymous variable in a `\\$this\\[\\$found\\]\\-\\>\\.\\.\\.\\(\\)` method call can lead to false dead methods\\. Make sure the variable type is known$#"
count: 3
path: ../Classes/Domain/Model/Asset/Collection.php
-
message: "#^On passing a constant, the method should have an enum type\\. See https\\://phpstan\\.org/writing\\-php\\-code/phpdoc\\-types\\#literals\\-and\\-constants$#"
count: 1
path: ../Classes/Api/Url.php
19 changes: 3 additions & 16 deletions .code-quality/phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
includes:
- ../.Build/vendor/symplify/phpstan-rules/config/services/services.neon
- ../.Build/vendor/symplify/phpstan-rules/config/code-complexity-rules.neon
- phpstan-baseline.neon
- ../.Build/vendor/symplify/phpstan-rules/packages/cognitive-complexity/config/cognitive-complexity-rules.neon

rules:
- Symplify\PHPStanRules\Rules\NoDefaultExceptionRule

parameters:
level: 6
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 @@ -36,4 +23,4 @@ services:
- die
- dump
- compact
- var_dump
- var_dump
143 changes: 62 additions & 81 deletions .code-quality/rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,107 +3,88 @@
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\FuncCall\AddPregQuoteDelimiterRector;
use Rector\CodeQuality\Rector\Identical\FlipTypeControlToUseExclusiveTypeRector;
use Rector\CodeQuality\Rector\Isset_\IssetOnPropertyObjectToPropertyExistsRector;
use Rector\CodeQualityStrict\Rector\If_\MoveOutMethodCallInsideIfConditionRector;
use Rector\CodingStyle\Rector\Class_\AddArrayDefaultToArrayPropertyRector;
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\Config\RectorConfig;
use Rector\Core\Configuration\Option;
use Rector\DeadCode\Rector\Cast\RecastingRemovalRector;
use Rector\DeadCode\Rector\ClassMethod\RemoveDelegatingParentCallRector;
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\Php73\Rector\FuncCall\RegexDashEscapeRector;
use Rector\Php80\Rector\Catch_\RemoveUnusedVariableInCatchRector;
use Rector\Php80\Rector\Switch_\ChangeSwitchToMatchRector;
use Rector\PHPUnit\Rector\Class_\AddSeeTestAnnotationRector;
use Rector\Php74\Rector\LNumber\AddLiteralSeparatorToNumberRector;
use Rector\Php74\Rector\Property\TypedPropertyRector;
use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector;
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\ClassMethod\ChangeGlobalVariablesToPropertiesRector;
use Rector\Privatization\Rector\Property\ChangeReadOnlyPropertyWithDefaultValueToConstantRector;
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__ . '/../Tests',
__DIR__ . '/rector.php',
]
);

$parameters->set(Option::AUTO_IMPORT_NAMES, false);
$parameters->set(Option::AUTOLOAD_PATHS, [__DIR__ . '/../Classes']);
$parameters->set(
Option::SKIP,
[
// Default Skips
FinalizeClassesWithoutChildrenRector::class,
RepeatedLiteralToClassConstantRector::class,
RegexDashEscapeRector::class,
ConsistentPregDelimiterRector::class,
AddArrayReturnDocTypeRector::class,
RemoveDelegatingParentCallRector::class,
AddArrayParamDocTypeRector::class,
PostIncDecToPreIncDecRector::class,
ChangeOrIfReturnToEarlyReturnRector::class,
ChangeAndIfToEarlyReturnRector::class,

// Test Skips
ChangeReadOnlyVariableWithDefaultValueToConstantRector::class,
ChangeReadOnlyPropertyWithDefaultValueToConstantRector::class,
ChangeGlobalVariablesToPropertiesRector::class,

AddSeeTestAnnotationRector::class,
ChangeSwitchToMatchRector::class,
RemoveUnusedVariableInCatchRector::class,
AddPregQuoteDelimiterRector::class,

// @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);
};
return RectorConfig::configure()
->withPaths([
__DIR__ . '/../Classes',
__DIR__ . '/../Tests',
__DIR__ . '/rector.php'
])
->withPhpSets(
true
)
->withSets([
SetList::CODE_QUALITY,
SetList::CODING_STYLE,
SetList::DEAD_CODE,
SetList::EARLY_RETURN,
SetList::PRIVATIZATION,
SetList::TYPE_DECLARATION,
SetList::PHP_74,
SetList::PHP_80,
SetList::PHP_81,
SetList::PHP_82,
SetList::PHP_83,
PHPUnitSetList::PHPUNIT_CODE_QUALITY,
])
->withRules([
RemoveUnusedPrivatePropertyRector::class,
])
->withSkip([
RecastingRemovalRector::class,
PostIncDecToPreIncDecRector::class,
FinalizeClassesWithoutChildrenRector::class,
ChangeAndIfToEarlyReturnRector::class,
IssetOnPropertyObjectToPropertyExistsRector::class,
FlipTypeControlToUseExclusiveTypeRector::class,
RenameVariableToMatchNewTypeRector::class,
AddLiteralSeparatorToNumberRector::class,
RenameForeachValueVariableToMatchMethodCallReturnTypeRector::class,
ClassPropertyAssignToConstructorPromotionRector::class,
ArgumentAdderRector::class,
RemoveExtraParametersRector::class,
EncapsedStringsToSprintfRector::class,
WrapEncapsedVariableInCurlyBracesRector::class,
UseIdenticalOverEqualWithSameTypeRector::class,
])
->withAutoloadPaths([__DIR__ . '/../Classes'])
->withCache('.cache/rector/default')
->withImportNames(false);
Loading

0 comments on commit c9c076a

Please sign in to comment.