Skip to content

Commit

Permalink
switch typo3 testing framework, set php version to 8.3
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreAOE committed Mar 19, 2024
1 parent 0821fcb commit 75a7fad
Show file tree
Hide file tree
Showing 43 changed files with 547 additions and 674 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,
]);
170 changes: 36 additions & 134 deletions .code-quality/rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,142 +2,44 @@

declare(strict_types=1);

use Rector\Arguments\Rector\ClassMethod\ArgumentAdderRector;
use Rector\Arguments\Rector\FuncCall\FunctionArgumentDefaultValueReplacerRector;
use Rector\CodeQuality\Rector\Equal\UseIdenticalOverEqualWithSameTypeRector;
use Rector\CodeQuality\Rector\Identical\FlipTypeControlToUseExclusiveTypeRector;
use Rector\CodeQuality\Rector\If_\SimplifyIfReturnBoolRector;
use Rector\CodeQuality\Rector\Isset_\IssetOnPropertyObjectToPropertyExistsRector;
use Rector\CodeQualityStrict\Rector\If_\MoveOutMethodCallInsideIfConditionRector;
use Rector\CodingStyle\Rector\ClassMethod\RemoveDoubleUnderscoreInMethodNameRector;
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\Php73\Rector\FuncCall\JsonThrowOnErrorRector;
use Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector;
use Rector\Php74\Rector\LNumber\AddLiteralSeparatorToNumberRector;
use Rector\PHPUnit\CodeQuality\Rector\Class_\YieldDataProviderRector;
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\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,
ReturnTypeDeclarationRector::class => [
__DIR__ . '/../Classes/System/Restler/Builder.php',
],
SimplifyIfReturnBoolRector::class => [
__DIR__ . '/../Classes/System/TYPO3/Cache.php',
],
RemoveDeadInstanceOfRector::class => [
__DIR__ . '/../Classes/System/Restler/Builder.php',
__DIR__ . '/../Classes/System/RestApi/RestApiRequest.php'
],
ClosureToArrowFunctionRector::class => [
__DIR__ . '/../Classes/System/Restler/Builder.php'
],
FunctionArgumentDefaultValueReplacerRector::class => [
__DIR__ . '/../Classes/System/RestApi/RestApiRequest.php'
],
JsonThrowOnErrorRector::class => [
__DIR__ . '/../Classes/System/RestApi/RestApiRequest.php',
__DIR__ . '/../Classes/System/RestApi/RestApiJsonFormat.php',
__DIR__ . '/../Classes/System/Restler/Format/HalJsonFormat.php'
],
RemoveDoubleUnderscoreInMethodNameRector::class => [
__DIR__ . '/../Classes/Controller/FeUserAuthenticationController.php',
__DIR__ . '/../Classes/Controller/ExplorerAuthenticationController.php',
__DIR__ . '/../Classes/Controller/BeUserAuthenticationController.php'
],
// We can't fix this, because our code must support PHP v7.x
Rector\Php80\Rector\Catch_\RemoveUnusedVariableInCatchRector::class => [
__DIR__ . '/../Classes/System/Restler/RestlerExtended.php',
],
// We can't fix this, because our code must support PHP v7.x
Rector\CodingStyle\Rector\Catch_\CatchExceptionNameMatchingTypeRector::class => [
__DIR__ . '/../Classes/System/Restler/RestlerExtended.php',
],
]
);

$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,
YieldDataProviderRector::class,
])
->withAutoloadPaths([__DIR__ . '/../Classes'])
->registerService(RemoveUnusedPrivatePropertyRector::class);
10 changes: 5 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,16 @@ jobs:
run: find . -name \*.php ! -path "./.Build/*" ! -path "./scripts/*" ! -path "./typo3_src/*" | parallel --gnu php -d display_errors=stderr -l {} > /dev/null \;

- name: Unit Tests without coverage
if: matrix.typo3 != '^11.5' || matrix.php != '7.4'
if: matrix.typo3 != '^11.5' || matrix.php != '8.3'
run: |
export "UNIT_XML"=.Build/vendor/nimut/testing-framework/res/Configuration/UnitTests.xml
export "UNIT_XML"=..Build/vendor/typo3/testing-framework/Resources/Core/Build/UnitTests.xml
.Build/bin/phpunit --colors -c $UNIT_XML Tests/Unit
- name: Unit Tests with coverage
if: matrix.typo3 == '^11.5' && matrix.php == '7.4'
if: matrix.typo3 == '^11.5' && matrix.php == '8.3'
run: |
export "UNIT_XML"=.Build/vendor/nimut/testing-framework/res/Configuration/UnitTests.xml
.Build/bin/phpunit --whitelist Classes --coverage-clover=unittest-coverage.clover --colors -c $UNIT_XML Tests/Unit/
export "UNIT_XML"=.Build/vendor/typo3/testing-framework/Resources/Core/Build/UnitTests.xml
.Build/bin/phpunit --coverage-filter Classes --coverage-clover=unittest-coverage.clover --colors -c $UNIT_XML Tests/Unit/
- name: Upload coverage results to Scrutinizer
if: matrix.typo3 == '^11.5' && matrix.php == '7.4'
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

# Build folder
.Build
Build/testing-docker/.env

# PHP Dependencies + Dev
/composer.lock
Expand Down
3 changes: 0 additions & 3 deletions Classes/Configuration/ExtensionConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@
use TYPO3\CMS\Core\SingletonInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
* @package Restler
*/
class ExtensionConfiguration implements SingletonInterface
{
/**
Expand Down
7 changes: 2 additions & 5 deletions Classes/Controller/ExplorerAuthenticationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,8 @@ public function __construct()
// phpcs:ignore
public function __isAllowed()
{
if ($this->restler->apiMethodInfo->className !== Explorer::class) {
// this controller is not responsible for the authentication
return false;
}
return true;
// this controller is not responsible for the authentication
return $this->restler->apiMethodInfo->className === Explorer::class;
}

/**
Expand Down
Loading

0 comments on commit 75a7fad

Please sign in to comment.