Skip to content

Commit

Permalink
[FEATURE] Upgrade php version, changes typo3 testing framework and up…
Browse files Browse the repository at this point in the history
…dated code-style tools version (#83)

* switch typo3 testing framework, set php version to 8.3

* chore: fix some tests and codestyles for php83

* chore: fix pipeline

* chore: fix pipeline unittest.xml

* chore: fix pipeline tests without coverage

* changing unittest.xml location

* renamed BaseTest to BaseTestCase

---------

Co-authored-by: thomas.layh <[email protected]>
  • Loading branch information
AndreAOE and tlayh authored Apr 3, 2024
1 parent 0821fcb commit 8591528
Show file tree
Hide file tree
Showing 45 changed files with 621 additions and 763 deletions.
89 changes: 35 additions & 54 deletions .code-quality/ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,70 +2,51 @@

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 Rector\Naming\Rector\ClassMethod\RenameParamToMatchTypeRector;
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,
RenameParamToMatchTypeRector::class => null,

])
->withSpacing(OPTION::INDENTATION_SPACES, "\n");
60 changes: 60 additions & 0 deletions .code-quality/ecs_old.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

declare(strict_types=1);

use PhpCsFixer\Fixer\ClassNotation\ClassAttributesSeparationFixer;
use PhpCsFixer\Fixer\Import\OrderedImportsFixer;
use PhpCsFixer\Fixer\Operator\NotOperatorWithSuccessorSpaceFixer;
use PhpCsFixer\Fixer\Phpdoc\GeneralPhpdocAnnotationRemoveFixer;
use PhpCsFixer\Fixer\Phpdoc\NoSuperfluousPhpdocTagsFixer;
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 Symplify\CodingStandard\Fixer\ArrayNotation\ArrayListItemNewlineFixer;
use Symplify\CodingStandard\Fixer\ArrayNotation\ArrayOpenerAndCloserNewlineFixer;
use Symplify\EasyCodingStandard\Config\ECSConfig;
use Symplify\CodingStandard\Fixer\LineLength\LineLengthFixer;
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;

return ECSConfig::configure()
->withPaths([
__DIR__ . '/../Classes',
__DIR__ . '/ecs.php',
])
->withSets([
SetList::COMMON,
SetList::CLEAN_CODE,
SetList::PSR_12,
SetList::SYMPLIFY,
])
->withConfiguredRule(
LineLengthFixer::class,
[
LineLengthFixer::LINE_LENGTH => 140,
LineLengthFixer::INLINE_SHORT_LINES => false,
]
)
->withSkip([
// Default Skips
Symplify\CodingStandard\Fixer\LineLength\LineLengthFixer::class => [
__DIR__ . '/ecs.php',
],
ArrayListItemNewlineFixer::class => null,
ArrayOpenerAndCloserNewlineFixer::class => null,
ClassAttributesSeparationFixer::class => null,
GeneralPhpdocAnnotationRemoveFixer::class => null,
OrderedImportsFixer::class => null,
NotOperatorWithSuccessorSpaceFixer::class => null,
ExplicitStringVariableFixer::class => null,
ArrayIndentationFixer::class => null,

// @todo for next upgrade
NoSuperfluousPhpdocTagsFixer::class => null,

// @todo strict php
DeclareStrictTypesFixer::class => null,
StrictComparisonFixer::class => null,
StrictParamFixer::class => null,
]);
62 changes: 33 additions & 29 deletions .code-quality/phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,62 +1,66 @@
parameters:
ignoreErrors:
-
message: "#^(.*)has no return typehint specified\\.$#"
path: ../
-
message: "#^Access to an undefined property Luracast\\\\Restler\\\\Restler\\:\\:\\$_authClasses\\.$#"
count: 1
path: ../Classes/System/RestApi/RestApiRequest.php

-
message: "#^Access to an undefined property Luracast\\\\Restler\\\\Restler\\:\\:\\$_authClasses\\.$#"
count: 2
path: ../Classes/System/RestApi/RestApiRequestScope.php

-
message: "#^Method Aoe\\\\Restler\\\\System\\\\RestApi\\\\RestApiRequestScope\\:\\:getOriginalRestApiRequest\\(\\) should return Luracast\\\\Restler\\\\Restler but returns Luracast\\\\Restler\\\\Scope\\.$#"
count: 1
path: ../Classes/System/RestApi/RestApiRequestScope.php

-
message: "#^Method Aoe\\\\Restler\\\\System\\\\Restler\\\\Builder\\:\\:getCache\\(\\) should return TYPO3\\\\CMS\\\\Core\\\\Cache\\\\Backend\\\\SimpleFileBackend but returns TYPO3\\\\CMS\\\\Core\\\\Cache\\\\Backend\\\\BackendInterface\\.$#"
count: 1
path: ../Classes/System/Restler/Builder.php

-
message: "#^Cognitive complexity for \"Aoe\\\\Restler\\\\System\\\\Restler\\\\Format\\\\HalJsonFormat\\:\\:decode\\(\\)\" is 9, keep it under 8$#"
message: "#^Strict comparison using \\=\\=\\= between bool and null will always evaluate to false\\.$#"
count: 1
path: ../Classes/System/Restler/Format/HalJsonFormat.php

-
message: "#^Cognitive complexity for \"Aoe\\\\Restler\\\\System\\\\Restler\\\\Format\\\\HalJsonFormat\\:\\:encode\\(\\)\" is 17, keep it under 8$#"
message: "#^Method Aoe\\\\Restler\\\\System\\\\TYPO3\\\\Cache\\:\\:getCacheEntry\\(\\) has no return type specified\\.$#"
count: 1
path: ../Classes/System/Restler/Format/HalJsonFormat.php

path: ../Classes/System/TYPO3/Cache.php
-
message: "#^Cognitive complexity for \"Aoe\\\\Restler\\\\System\\\\Restler\\\\Format\\\\HalJsonFormat\\:\\:formatJson\\(\\)\" is 14, keep it under 8$#"
message: "#^Method Aoe\\\\Restler\\\\System\\\\Restler\\\\RestlerExtended\\:\\:handle\\(\\) has no return type specified\\.$#"
count: 1
path: ../Classes/System/Restler/Format/HalJsonFormat.php

path: ../Classes/System/Restler/RestlerExtended.php
-
message: "#^Method Aoe\\\\Restler\\\\System\\\\Restler\\\\RestlerExtended\\:\\:postCall\\(\\) has no return type specified\\.$#"
count: 1
path: ../Classes/System/Restler/RestlerExtended.php
-
message: "#^Dead catch \\- Error is never thrown in the try block\\.$#"
count: 1
path: ../Classes/System/Restler/Builder.php
-
message: "#^Anonymous variable in a `\\$request\\-\\>getAttribute\\('site'\\)\\-\\>\\.\\.\\.\\(\\)` method call can lead to false dead methods\\. Make sure the variable type is known$#"
count: 1
path: ../Classes/System/Dispatcher.php
-
message: "#^Cognitive complexity for \"Aoe\\\\Restler\\\\System\\\\Restler\\\\RestlerExtended\\:\\:getPath\\(\\)\" is 9, keep it under 8$#"
message: "#^Anonymous variable in a `\\$request\\-\\>getAttribute\\('site'\\)\\-\\>getBase\\(\\)\\-\\>\\.\\.\\.\\(\\)` method call can lead to false dead methods\\. Make sure the variable type is known$#"
count: 1
path: ../Classes/System/Dispatcher.php
-
message: "#^Anonymous variable in a `\\$this\\-\\>request\\-\\>getAttribute\\('site'\\)\\-\\>\\.\\.\\.\\(\\)` method call can lead to false dead methods\\. Make sure the variable type is known$#"
count: 1
path: ../Classes/System/Restler/RestlerExtended.php

-
message: "#^Cognitive complexity for \"Aoe\\\\Restler\\\\System\\\\Restler\\\\RestlerExtended\\:\\:handleRequestByTypo3Cache\\(\\)\" is 13, keep it under 8$#"
message: "#^Anonymous variable in a `\\$this\\-\\>request\\-\\>getAttribute\\('site'\\)\\-\\>getBase\\(\\)\\-\\>\\.\\.\\.\\(\\)` method call can lead to false dead methods\\. Make sure the variable type is known$#"
count: 1
path: ../Classes/System/Restler/RestlerExtended.php

-
message: "#^Cognitive complexity for \"Aoe\\\\Restler\\\\System\\\\Restler\\\\Routes\\:\\:containsUrl\\(\\)\" is 16, keep it under 8$#"
message: "#^Method Aoe\\\\Restler\\\\System\\\\RestApi\\\\RestApiRequest\\:\\:composeHeaders\\(\\) has no return type specified\\.$#"
count: 1
path: ../Classes/System/Restler/Routes.php
path: ../Classes/System/RestApi/RestApiRequest.php
-
message: "#^Strict comparison using \\=\\=\\= between bool and null will always evaluate to false\\.$#"
message: "#^Method Aoe\\\\Restler\\\\System\\\\RestApi\\\\RestApiRequest\\:\\:postCall\\(\\) has no return type specified\\.$#"
count: 1
path: ../Classes/System/Restler/Format/HalJsonFormat.php
path: ../Classes/System/RestApi/RestApiRequest.php
-
message: "#^Cognitive complexity for \"Aoe\\\\Restler\\\\System\\\\Restler\\\\Builder\\:\\:addApiClassesByGlobalArray\\(\\)\" is 9, keep it under 8$#"
message: "#^Property Aoe\\\\Restler\\\\System\\\\RestApi\\\\RestApiRequestScope\\:\\:\\$originalRestApiRequest \\(Luracast\\\\Restler\\\\Scope\\) on left side of \\?\\? is not nullable\\.$#"
count: 1
path: ../Classes/System/Restler/Builder.php
path: ../Classes/System/RestApi/RestApiRequestScope.php
-
message: "#^Comparison operation \"\\>\" between int\\<1, max\\> and 0 is always true\\.$#"
count: 1
path: ../Classes/System/Restler/Format/HalJsonFormat.php
17 changes: 2 additions & 15 deletions .code-quality/phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
includes:
- 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
- ../.Build/vendor/symplify/phpstan-rules/config/services/services.neon

parameters:
level: 6
Expand All @@ -17,17 +15,6 @@ parameters:
checkAlwaysTrueStrictComparison: 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 Down
Loading

0 comments on commit 8591528

Please sign in to comment.