From 7ec19f2b35d742968238c9401aaad3933cae2e60 Mon Sep 17 00:00:00 2001 From: Christian Krzeminski <49280056+aoekrz@users.noreply.github.com> Date: Tue, 16 Jul 2024 15:40:36 +0200 Subject: [PATCH] feat: TYPO3 v12 compatibility (#85) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: prepare for TYPO3_v12 * chore: prepare for TYPO3_v12 - update github actions * chore: prepare for TYPO3_v12 - update github actions - fix typo * chore: prepare for TYPO3_v12 - update github actions - fix path to phpunit * chore: v12 only * chore: v12 only, code-style * chore: code-style * docs: readme, year update * docs: more badges * chore: ecs config * chore: minor adjustment * chore: PHP 8.4 experimental * Revert "chore: PHP 8.4 experimental" This reverts commit 4ab6a71f1490b51a1b557890493b8d6406904c4a. * chore: fix javascript include * chore: cleanup the code --------- Co-authored-by: thomas.layh Co-authored-by: Jürgen Kußmann --- .code-quality/ecs.php | 11 ---- .code-quality/ecs_old.php | 60 ------------------- .code-quality/phpstan-baseline.neon | 28 +++------ .code-quality/phpstan.neon | 5 +- .code-quality/rector-8_0.php | 30 ---------- .code-quality/rector.php | 4 -- .github/workflows/tests.yml | 37 ++++-------- .scrutinizer.yml | 3 + .../Configuration/ExtensionConfiguration.php | 2 +- .../BeUserAuthenticationController.php | 10 ++-- .../ExplorerAuthenticationController.php | 2 +- .../FeUserAuthenticationController.php | 10 ++-- Classes/System/Dispatcher.php | 12 +++- Classes/System/RestApi/RestApiClient.php | 17 ++---- Classes/System/RestApi/RestApiJsonFormat.php | 6 +- Classes/System/RestApi/RestApiRequest.php | 16 ++--- .../RestApi/RestApiRequestException.php | 2 +- .../System/RestApi/RestApiRequestScope.php | 2 +- .../Restler/AbstractExceptionHandler.php | 10 +--- Classes/System/Restler/Builder.php | 42 +++---------- Classes/System/Restler/Configuration.php | 10 ++-- .../System/Restler/ConfigurationInterface.php | 2 +- .../System/Restler/Format/HalJsonFormat.php | 6 +- Classes/System/Restler/RestlerExtended.php | 26 ++++---- Classes/System/Restler/Routes.php | 2 +- Classes/System/RestlerBuilderAware.php | 10 ++-- Classes/System/TYPO3/Cache.php | 6 +- Classes/System/TYPO3/Loader.php | 50 ++++------------ Classes/System/TYPO3/MockRequestHandler.php | 2 +- Classes/System/TYPO3/RestlerEnhancer.php | 2 +- README.md | 16 +++-- Tests/Unit/BaseTestCase.php | 4 +- .../ExtensionConfigurationTest.php | 4 +- .../BeUserAuthenticationControllerTest.php | 2 +- .../ExplorerAuthenticationControllerTest.php | 2 +- .../FeUserAuthenticationControllerTest.php | 2 +- Tests/Unit/System/DispatcherTest.php | 2 +- .../Unit/System/RestApi/RestApiClientTest.php | 2 +- .../System/RestApi/RestApiRequestTest.php | 6 +- Tests/Unit/System/Restler/BuilderTest.php | 2 +- .../Unit/System/Restler/ConfigurationTest.php | 2 +- .../System/Restler/ExceptionHandlerTest.php | 2 +- .../Restler/Fixtures/ExceptionHandler.php | 2 +- .../Restler/Fixtures/InvalidConfiguration.php | 2 +- .../Restler/Fixtures/ValidConfiguration.php | 2 +- Tests/Unit/System/TYPO3/CacheTest.php | 2 +- Tests/phpunit.xml | 43 +++++++------ composer.json | 33 ++++------ ext_emconf.php | 4 +- ext_localconf.php | 4 +- 50 files changed, 176 insertions(+), 387 deletions(-) delete mode 100644 .code-quality/ecs_old.php delete mode 100644 .code-quality/rector-8_0.php diff --git a/.code-quality/ecs.php b/.code-quality/ecs.php index df1dc61..4f3246c 100644 --- a/.code-quality/ecs.php +++ b/.code-quality/ecs.php @@ -2,14 +2,11 @@ declare(strict_types=1); -use PhpCsFixer\Fixer\FunctionNotation\FunctionTypehintSpaceFixer; use PhpCsFixer\Fixer\Operator\NotOperatorWithSuccessorSpaceFixer; use PhpCsFixer\Fixer\Phpdoc\GeneralPhpdocAnnotationRemoveFixer; -use PhpCsFixer\Fixer\Strict\DeclareStrictTypesFixer; 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; @@ -36,17 +33,9 @@ ) ->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"); diff --git a/.code-quality/ecs_old.php b/.code-quality/ecs_old.php deleted file mode 100644 index cc92a28..0000000 --- a/.code-quality/ecs_old.php +++ /dev/null @@ -1,60 +0,0 @@ -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, - ]); diff --git a/.code-quality/phpstan-baseline.neon b/.code-quality/phpstan-baseline.neon index 522ab0b..085696e 100644 --- a/.code-quality/phpstan-baseline.neon +++ b/.code-quality/phpstan-baseline.neon @@ -28,26 +28,6 @@ parameters: 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: "#^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: "#^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: "#^Method Aoe\\\\Restler\\\\System\\\\RestApi\\\\RestApiRequest\\:\\:composeHeaders\\(\\) has no return type specified\\.$#" count: 1 @@ -64,3 +44,11 @@ parameters: message: "#^Comparison operation \"\\>\" between int\\<1, max\\> and 0 is always true\\.$#" count: 1 path: ../Classes/System/Restler/Format/HalJsonFormat.php + - + message: "#^Interface (.*) has only single implementer. Consider using the class directly as there is no point in using the interface.$#" + count: 1 + path: ../Classes/System/Restler/ConfigurationInterface.php + - + message: "#^Unable to resolve the template type T in call to method static method (.*)$#" + count: 2 + path: ../Classes/System/Restler/Builder.php diff --git a/.code-quality/phpstan.neon b/.code-quality/phpstan.neon index 8fef980..0bf371c 100644 --- a/.code-quality/phpstan.neon +++ b/.code-quality/phpstan.neon @@ -8,9 +8,10 @@ parameters: paths: - "../Classes/" + ignoreErrors: + - identifier: missingType.iterableValue + inferPrivatePropertyTypeFromConstructor: true - checkMissingIterableValueType: false - checkGenericClassInNonGenericObjectType: false checkAlwaysTrueCheckTypeFunctionCall: false checkAlwaysTrueStrictComparison: false diff --git a/.code-quality/rector-8_0.php b/.code-quality/rector-8_0.php deleted file mode 100644 index 623b419..0000000 --- a/.code-quality/rector-8_0.php +++ /dev/null @@ -1,30 +0,0 @@ -parameters(); - $parameters->set( - Option::PATHS, - [ - __DIR__ . '/../Classes', - __DIR__ . '/../Tests', - __DIR__ . '/rector.php', - __DIR__ . '/rector-8_0.php', - ] - ); - - $containerConfigurator->import(SetList::PHP_81); - - $parameters->set(Option::AUTO_IMPORT_NAMES, false); - $parameters->set(Option::AUTOLOAD_PATHS, [__DIR__ . '/../Classes']); - $parameters->set(Option::SKIP, []); - - $services = $containerConfigurator->services(); - $services->set(RemoveUnusedPrivatePropertyRector::class); -}; diff --git a/.code-quality/rector.php b/.code-quality/rector.php index 65d88dd..fc3ec26 100644 --- a/.code-quality/rector.php +++ b/.code-quality/rector.php @@ -5,12 +5,10 @@ use Rector\CodeQuality\Rector\Identical\FlipTypeControlToUseExclusiveTypeRector; use Rector\Config\RectorConfig; use Rector\DeadCode\Rector\Property\RemoveUnusedPrivatePropertyRector; -use Rector\EarlyReturn\Rector\If_\ChangeAndIfToEarlyReturnRector; use Rector\PHPUnit\CodeQuality\Rector\Class_\YieldDataProviderRector; use Rector\PHPUnit\CodeQuality\Rector\MethodCall\AssertEqualsToSameRector; use Rector\Set\ValueObject\SetList; use Rector\PHPUnit\Set\PHPUnitSetList; -use Rector\Privatization\Rector\Class_\FinalizeClassesWithoutChildrenRector; use Rector\TypeDeclaration\Rector\ClassMethod\AddMethodCallBasedStrictParamTypeRector; use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictSetUpRector; @@ -35,8 +33,6 @@ PHPUnitSetList::PHPUNIT_CODE_QUALITY ]) ->withSkip([ - FinalizeClassesWithoutChildrenRector::class, - ChangeAndIfToEarlyReturnRector::class, TypedPropertyFromStrictSetUpRector::class, AddMethodCallBasedStrictParamTypeRector::class, FlipTypeControlToUseExclusiveTypeRector::class, diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 14d5dbb..239416a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,18 +1,6 @@ name: Tests -on: - push: - branches: - - '**' - - '!TYPO3_V10' - - '!TYPO3V8' - - '!TYPO3V9' - pull_request: - branches: - - '**' - - '!TYPO3_V10' - - '!TYPO3V8' - - '!TYPO3V9' +on: [ push, pull_request ] jobs: build: @@ -22,13 +10,10 @@ jobs: strategy: fail-fast: false matrix: - typo3: [ ^11.5 ] - php: [ '7.4', '8.0', '8.1', '8.2', '8.3' ] + typo3: [ ^12.4 ] + php: [ '8.1', '8.2', '8.3' ] experimental: [false] - include: - - typo3: ^11.5 - php: '8.1' - experimental: true + continue-on-error: ${{ matrix.experimental }} @@ -55,9 +40,9 @@ jobs: - name: Validate composer.json and composer.lock run: composer validate - - name: Install dependencies with nimut/typo3-complete:${{ matrix.typo3 }} + - name: Install dependencies with typo3/cms-core:${{ matrix.typo3 }} run: | - composer require --dev nimut/typo3-complete:${{ matrix.typo3 }} --no-progress + composer require --dev typo3/cms-core:${{ matrix.typo3 }} --no-progress git checkout composer.json ln -nfs .Build/vendor/typo3/cms/typo3 typo3 @@ -65,19 +50,19 @@ 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 != '8.3' + if: matrix.typo3 != '^12.4' || matrix.php != '8.3' run: | - export "UNIT_XML"=.Build/vendor/typo3/testing-framework/Resources/Core/Build/UnitTests.xml + export "UNIT_XML"=Tests/phpunit.xml .Build/bin/phpunit --colors -c $UNIT_XML Tests/Unit - name: Unit Tests with coverage - if: matrix.typo3 == '^11.5' && matrix.php == '8.3' + if: matrix.typo3 == '^12.4' && matrix.php == '8.3' run: | - export "UNIT_XML"=.Build/vendor/typo3/testing-framework/Resources/Core/Build/UnitTests-v10.xml + export "UNIT_XML"=Tests/phpunit.xml .Build/bin/phpunit --coverage-filter Classes --coverage-clover=unittest-coverage.clover --colors -c $UNIT_XML Tests/Unit/ - name: Upload coverage results to Scrutinizer uses: sudo-bot/action-scrutinizer@latest - if: matrix.typo3 == '^11.5' && matrix.php == '8.3' + if: matrix.typo3 == '^12.4' && matrix.php == '8.3' with: cli-args: "--format=php-clover .Build/reports/php_all_tests/coverage_clover.xml --revision=${{ github.event.pull_request.head.sha || github.sha }}" diff --git a/.scrutinizer.yml b/.scrutinizer.yml index 212da43..1433157 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -1,6 +1,9 @@ build: nodes: analysis: + image: default-bionic + environment: + php: 8.3.0 tests: override: - php-scrutinizer-run diff --git a/Classes/Configuration/ExtensionConfiguration.php b/Classes/Configuration/ExtensionConfiguration.php index 2c6ca1e..519f811 100644 --- a/Classes/Configuration/ExtensionConfiguration.php +++ b/Classes/Configuration/ExtensionConfiguration.php @@ -5,7 +5,7 @@ /*************************************************************** * Copyright notice * - * (c) 2021 AOE GmbH + * (c) 2024 AOE GmbH * * All rights reserved * diff --git a/Classes/Controller/BeUserAuthenticationController.php b/Classes/Controller/BeUserAuthenticationController.php index 5b8cd70..fd1125a 100644 --- a/Classes/Controller/BeUserAuthenticationController.php +++ b/Classes/Controller/BeUserAuthenticationController.php @@ -5,7 +5,7 @@ /*************************************************************** * Copyright notice * - * (c) 2021 AOE GmbH + * (c) 2024 AOE GmbH * * All rights reserved * @@ -63,11 +63,9 @@ class BeUserAuthenticationController implements iAuthenticate */ public $restler; - private Loader $typo3Loader; - - public function __construct(Loader $typo3Loader) - { - $this->typo3Loader = $typo3Loader; + public function __construct( + private readonly Loader $typo3Loader + ) { $this->restler = Scope::get('Restler'); } diff --git a/Classes/Controller/ExplorerAuthenticationController.php b/Classes/Controller/ExplorerAuthenticationController.php index c7aa1f7..ac2e7d2 100644 --- a/Classes/Controller/ExplorerAuthenticationController.php +++ b/Classes/Controller/ExplorerAuthenticationController.php @@ -5,7 +5,7 @@ /*************************************************************** * Copyright notice * - * (c) 2021 AOE GmbH + * (c) 2024 AOE GmbH * * All rights reserved * diff --git a/Classes/Controller/FeUserAuthenticationController.php b/Classes/Controller/FeUserAuthenticationController.php index 61d1f7a..63f0dbb 100644 --- a/Classes/Controller/FeUserAuthenticationController.php +++ b/Classes/Controller/FeUserAuthenticationController.php @@ -5,7 +5,7 @@ /*************************************************************** * Copyright notice * - * (c) 2021 AOE GmbH + * (c) 2024 AOE GmbH * * All rights reserved * @@ -89,11 +89,9 @@ class FeUserAuthenticationController implements iAuthenticate */ public $restler; - private Loader $typo3Loader; - - public function __construct(Loader $typo3Loader) - { - $this->typo3Loader = $typo3Loader; + public function __construct( + private readonly Loader $typo3Loader + ) { $this->restler = Scope::get('Restler'); } diff --git a/Classes/System/Dispatcher.php b/Classes/System/Dispatcher.php index 4bd2fb0..6881a14 100644 --- a/Classes/System/Dispatcher.php +++ b/Classes/System/Dispatcher.php @@ -5,7 +5,7 @@ /*************************************************************** * Copyright notice * - * (c) 2015 AOE GmbH + * (c) 2024 AOE GmbH * * All rights reserved * @@ -83,7 +83,15 @@ protected function extractSiteUrl(ServerRequestInterface $request): string } if ($siteBasePath) { - return '/' . rtrim(preg_replace('%^' . preg_quote($siteBasePath, '%') . '%', '', $request->getUri()->getPath()), '/'); + return '/' . rtrim( + (string) preg_replace( + '%^' . preg_quote((string) $siteBasePath, '%') . '%', + '', + $request->getUri() + ->getPath() + ), + '/' + ); } return $request->getUri() diff --git a/Classes/System/RestApi/RestApiClient.php b/Classes/System/RestApi/RestApiClient.php index c8d0db4..ef95eba 100644 --- a/Classes/System/RestApi/RestApiClient.php +++ b/Classes/System/RestApi/RestApiClient.php @@ -5,7 +5,7 @@ /*************************************************************** * Copyright notice * - * (c) 2015 AOE GmbH + * (c) 2024 AOE GmbH * * All rights reserved * @@ -37,24 +37,15 @@ class RestApiClient implements SingletonInterface { - private Cache $typo3Cache; - - private ExtensionConfiguration $extensionConfiguration; - private bool $isExecutingRequest = false; private bool $isRequestPrepared = false; - private RestApiRequestScope $restApiRequestScope; - public function __construct( - ExtensionConfiguration $extensionConfiguration, - RestApiRequestScope $restApiRequestScope, - Cache $typo3Cache + private readonly ExtensionConfiguration $extensionConfiguration, + private readonly RestApiRequestScope $restApiRequestScope, + private readonly Cache $typo3Cache ) { - $this->extensionConfiguration = $extensionConfiguration; - $this->restApiRequestScope = $restApiRequestScope; - $this->typo3Cache = $typo3Cache; } public function isExecutingRequest(): bool diff --git a/Classes/System/RestApi/RestApiJsonFormat.php b/Classes/System/RestApi/RestApiJsonFormat.php index aab8538..0130e3c 100644 --- a/Classes/System/RestApi/RestApiJsonFormat.php +++ b/Classes/System/RestApi/RestApiJsonFormat.php @@ -5,7 +5,7 @@ /*************************************************************** * Copyright notice * - * (c) 2015 AOE GmbH + * (c) 2024 AOE GmbH * * All rights reserved * @@ -53,13 +53,13 @@ public function decode($data) } try { - $decoded = json_decode($data, false, 512, $options); + $decoded = json_decode((string) $data, false, 512, $options); $this->handleJsonError(); } catch (\RuntimeException $runtimeException) { throw new RestException('400', $runtimeException->getMessage()); } - if (strlen($data) && $decoded === null || $decoded === $data) { + if (strlen((string) $data) && $decoded === null || $decoded === $data) { throw new RestException('400', 'Error parsing JSON'); } diff --git a/Classes/System/RestApi/RestApiRequest.php b/Classes/System/RestApi/RestApiRequest.php index 02cecbb..d51ddcc 100644 --- a/Classes/System/RestApi/RestApiRequest.php +++ b/Classes/System/RestApi/RestApiRequest.php @@ -5,7 +5,7 @@ /*************************************************************** * Copyright notice * - * (c) 2015 AOE GmbH + * (c) 2024 AOE GmbH * * All rights reserved * @@ -88,10 +88,6 @@ class RestApiRequest extends Restler */ private string $restApiRequestMethod; - private RestApiRequestScope $restApiRequestScope; - - private Cache $typo3Cache; - /***************************************************************************************************************************/ /***************************************************************************************************************************/ /* Block of methods, which MUST be overridden from parent-class (otherwise this class can not work) *************************/ @@ -101,10 +97,10 @@ class RestApiRequest extends Restler * Override parent method...because we don't want to call it! * The original method would set some properties (e.g. set this object into static properties of global classes) */ - public function __construct(RestApiRequestScope $restApiRequestScope, Cache $typo3Cache) - { - $this->restApiRequestScope = $restApiRequestScope; - $this->typo3Cache = $typo3Cache; + public function __construct( + private readonly RestApiRequestScope $restApiRequestScope, + private readonly Cache $typo3Cache + ) { } /** @@ -235,7 +231,7 @@ protected function postCall() $_GET, $this->apiMethodInfo->metadata, $this->responseData, - get_class($this->responseFormat), + $this->responseFormat::class, [] // we don't know which headers would be 'normally' send - because this is an internal REST-API-call ); } diff --git a/Classes/System/RestApi/RestApiRequestException.php b/Classes/System/RestApi/RestApiRequestException.php index 5ecaa7d..0401053 100644 --- a/Classes/System/RestApi/RestApiRequestException.php +++ b/Classes/System/RestApi/RestApiRequestException.php @@ -5,7 +5,7 @@ /*************************************************************** * Copyright notice * - * (c) 2015 AOE GmbH + * (c) 2024 AOE GmbH * * All rights reserved * diff --git a/Classes/System/RestApi/RestApiRequestScope.php b/Classes/System/RestApi/RestApiRequestScope.php index 5849cde..f503dce 100644 --- a/Classes/System/RestApi/RestApiRequestScope.php +++ b/Classes/System/RestApi/RestApiRequestScope.php @@ -5,7 +5,7 @@ /*************************************************************** * Copyright notice * - * (c) 2015 AOE GmbH + * (c) 2024 AOE GmbH * * All rights reserved * diff --git a/Classes/System/Restler/AbstractExceptionHandler.php b/Classes/System/Restler/AbstractExceptionHandler.php index 632b346..d1d28cf 100644 --- a/Classes/System/Restler/AbstractExceptionHandler.php +++ b/Classes/System/Restler/AbstractExceptionHandler.php @@ -5,7 +5,7 @@ /*************************************************************** * Copyright notice * - * (c) 2015 AOE GmbH + * (c) 2024 AOE GmbH * * All rights reserved * @@ -26,7 +26,6 @@ * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ -use Aoe\Restler\Configuration\ExtensionConfiguration; use Luracast\Restler\RestException; use Luracast\Restler\Restler; use Luracast\Restler\Scope; @@ -37,13 +36,6 @@ */ abstract class AbstractExceptionHandler { - protected ExtensionConfiguration $extensionConfiguration; - - public function __construct(ExtensionConfiguration $extensionConfiguration) - { - $this->extensionConfiguration = $extensionConfiguration; - } - /** * handle HTTP-Status-Codes of type 1xx */ diff --git a/Classes/System/Restler/Builder.php b/Classes/System/Restler/Builder.php index 3c92fd0..4d072f1 100644 --- a/Classes/System/Restler/Builder.php +++ b/Classes/System/Restler/Builder.php @@ -5,7 +5,7 @@ /*************************************************************** * Copyright notice * - * (c) 2015 AOE GmbH + * (c) 2024 AOE GmbH * * All rights reserved * @@ -28,7 +28,6 @@ use Aoe\Restler\Configuration\ExtensionConfiguration; use Aoe\Restler\System\TYPO3\Cache; -use Error; use InvalidArgumentException; use Luracast\Restler\Defaults; use Luracast\Restler\Scope; @@ -37,18 +36,13 @@ use TYPO3\CMS\Core\Cache\CacheManager; use TYPO3\CMS\Core\SingletonInterface; use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Extbase\Object\ObjectManager; class Builder implements SingletonInterface { - private ExtensionConfiguration $extensionConfiguration; - - private CacheManager $cacheManager; - - public function __construct(ExtensionConfiguration $extensionConfiguration, CacheManager $cacheManager) - { - $this->extensionConfiguration = $extensionConfiguration; - $this->cacheManager = $cacheManager; + public function __construct( + private readonly ExtensionConfiguration $extensionConfiguration, + private readonly CacheManager $cacheManager, + ) { } /** @@ -143,32 +137,12 @@ private function addApiClassesByGlobalArray(RestlerExtended $restler): void } /** - * use auto-loading for PHP-classes of restler-framework and Extbase/TYPO3 (use dependency-injection of Extbase) + * use autoload for PHP-classes of restler-framework and Extbase/TYPO3 (use dependency-injection of Extbase) */ private function setAutoLoading(): void { - // set auto-loading for Extbase/TYPO3-classes - Scope::$resolver = static function ($className) { - try { - return GeneralUtility::makeInstance($className); - } catch (Error $error) { - // @TODO TYPO3 v12: - // Using of ObjectManager will be removed in TYPO3v12. Currently, we must use the ObjectManager - // as a fallback because it can happen, that e.g. the REST-controllers (which 3rd-party-extensions - // provide), are not supporting the new dependency-injection (via symfony) of TYPO3! - - // Log deprecation-notice - $info = '%s should implement TYPO3\CMS\Core\SingletonInterface - otherwise the class can '; - $info .= 'not be created by GeneralUtility::makeInstance() in TYPO3v12 (error-code: %s)!'; - trigger_error( - sprintf($info, $className, (string) $error->getCode()), - E_USER_DEPRECATED - ); - - // use legacy ObjectManager to create the required object - return GeneralUtility::makeInstance(ObjectManager::class)->get($className); - } - }; + // set autoload for Extbase/TYPO3-classes + Scope::$resolver = static fn ($className): object => GeneralUtility::makeInstance($className); } /** diff --git a/Classes/System/Restler/Configuration.php b/Classes/System/Restler/Configuration.php index b5b422d..6f99143 100644 --- a/Classes/System/Restler/Configuration.php +++ b/Classes/System/Restler/Configuration.php @@ -5,7 +5,7 @@ /*************************************************************** * Copyright notice * - * (c) 2021 AOE GmbH + * (c) 2024 AOE GmbH * * All rights reserved * @@ -41,11 +41,9 @@ */ class Configuration implements ConfigurationInterface { - private ExtensionConfiguration $extensionConfiguration; - - public function __construct(ExtensionConfiguration $extensionConfiguration) - { - $this->extensionConfiguration = $extensionConfiguration; + public function __construct( + private readonly ExtensionConfiguration $extensionConfiguration + ) { } /** diff --git a/Classes/System/Restler/ConfigurationInterface.php b/Classes/System/Restler/ConfigurationInterface.php index 535b5a0..68e917c 100644 --- a/Classes/System/Restler/ConfigurationInterface.php +++ b/Classes/System/Restler/ConfigurationInterface.php @@ -5,7 +5,7 @@ /*************************************************************** * Copyright notice * - * (c) 2021 AOE GmbH + * (c) 2024 AOE GmbH * * All rights reserved * diff --git a/Classes/System/Restler/Format/HalJsonFormat.php b/Classes/System/Restler/Format/HalJsonFormat.php index a507c5a..02ee315 100644 --- a/Classes/System/Restler/Format/HalJsonFormat.php +++ b/Classes/System/Restler/Format/HalJsonFormat.php @@ -114,7 +114,7 @@ public function encode($data, $humanReadable = false) if (self::$unEscapedUnicode) { $result = preg_replace_callback( '/\\\u(\w\w\w\w)/', - static function (array $matches) { + static function (array $matches): string|false { if (function_exists('mb_convert_encoding')) { return mb_convert_encoding(pack('H*', $matches[1]), 'UTF-8', 'UTF-16BE'); } @@ -154,13 +154,13 @@ public function decode($data): ?array } try { - $decoded = json_decode($data, false, 512, $options); + $decoded = json_decode((string) $data, false, 512, $options); $this->handleJsonError(); } catch (\RuntimeException $runtimeException) { throw new RestException('400', $runtimeException->getMessage()); } - if (strlen($data) && $decoded === null || $decoded === $data) { + if (strlen((string) $data) && $decoded === null || $decoded === $data) { throw new RestException('400', 'Error parsing JSON'); } diff --git a/Classes/System/Restler/RestlerExtended.php b/Classes/System/Restler/RestlerExtended.php index 6278c79..d39c82e 100644 --- a/Classes/System/Restler/RestlerExtended.php +++ b/Classes/System/Restler/RestlerExtended.php @@ -5,7 +5,7 @@ /*************************************************************** * Copyright notice * - * (c) 2021 AOE GmbH + * (c) 2024 AOE GmbH * * All rights reserved * @@ -37,10 +37,6 @@ class RestlerExtended extends Restler { - protected ?ServerRequestInterface $request; - - private Cache $typo3Cache; - /***************************************************************************************************************************/ /***************************************************************************************************************************/ /* Block of methods, which MUST be overriden from parent-class (otherwise we can't use the TYPO3-caching-framework) ********/ @@ -54,13 +50,13 @@ class RestlerExtended extends Restler * every time to map it to the URL * * @param bool $refreshCache will update the cache when set to true - * @param ServerRequestInterface $request frontend request + * @param ServerRequestInterface $request frontend request */ public function __construct( - Cache $typo3Cache, + private readonly Cache $typo3Cache, $productionMode = false, $refreshCache = false, - ServerRequestInterface $request = null + private readonly ?ServerRequestInterface $request = null ) { parent::__construct($productionMode, $refreshCache); @@ -73,9 +69,6 @@ public function __construct( Scope::$classAliases['HalJsonFormat'] = \Aoe\Restler\System\Restler\Format\HalJsonFormat::class; $this->setSupportedFormats('HalJsonFormat'); - $this->typo3Cache = $typo3Cache; - $this->request = $request; - // set pathes from request if present if ($this->request !== null) { $this->url = $this->getPath(); @@ -91,7 +84,7 @@ public function handle() try { // get information about the REST-request (this is required to check, if we can handle the REST-request by TYPO3-cache) $this->get(); - } catch (RestException $restException) { + } catch (RestException) { // Exception occurred (e.g. 'Error encoding/decoding JSON') during getting information about REST-request: // Let restler handle the error (e.g. that JSON could not be read) - and NOT the TYPO3-exception-handling! return parent::handle(); @@ -143,7 +136,10 @@ protected function getPath(): string ->withPath($siteBasePath); // set url with base path removed - return rtrim(preg_replace('%^' . preg_quote($siteBasePath, '%') . '%', '', $this->request->getUri()->getPath()), '/'); + return rtrim( + (string) preg_replace('%^' . preg_quote((string) $siteBasePath, '%') . '%', '', $this->request->getUri()->getPath()), + '/' + ); } return parent::getPath(); @@ -163,7 +159,7 @@ protected function postCall() $_GET, $this->apiMethodInfo->metadata, $this->responseData, - get_class($this->responseFormat), + $this->responseFormat::class, headers_list() ); } @@ -180,7 +176,7 @@ private function handleRequestByTypo3Cache(): string } else { // set/manipulate headers foreach ($cacheEntry['responseHeaders'] as $responseHeader) { - if (substr($responseHeader, 0, 8) === 'Expires:') { + if (str_starts_with((string) $responseHeader, 'Expires:')) { if ($cacheEntry['frontendCacheExpires'] === 0) { $expires = $cacheEntry['frontendCacheExpires']; } else { diff --git a/Classes/System/Restler/Routes.php b/Classes/System/Restler/Routes.php index 2aa03bd..545980c 100644 --- a/Classes/System/Restler/Routes.php +++ b/Classes/System/Restler/Routes.php @@ -17,7 +17,7 @@ public static function containsUrl(string $uri): bool { foreach (self::findAll() as $routes) { foreach ($routes as $route) { - $routeMatcher = '/^' . preg_quote('/' . rtrim($route['route']['url'], '/*'), '/') . '/'; + $routeMatcher = '/^' . preg_quote('/' . rtrim((string) $route['route']['url'], '/*'), '/') . '/'; if (is_array($route['route']['arguments'])) { foreach ($route['route']['arguments'] as $argumentName => $argumentNumber) { diff --git a/Classes/System/RestlerBuilderAware.php b/Classes/System/RestlerBuilderAware.php index 75b7705..774b842 100644 --- a/Classes/System/RestlerBuilderAware.php +++ b/Classes/System/RestlerBuilderAware.php @@ -5,7 +5,7 @@ /*************************************************************** * Copyright notice * - * (c) 2015 AOE GmbH + * (c) 2024 AOE GmbH * * All rights reserved * @@ -39,11 +39,9 @@ abstract class RestlerBuilderAware private ?Builder $restlerBuilder = null; - private ExtensionConfiguration $extensionConfiguration; - - public function __construct(ExtensionConfiguration $extensionConfiguration) - { - $this->extensionConfiguration = $extensionConfiguration; + public function __construct( + private readonly ExtensionConfiguration $extensionConfiguration + ) { } /** diff --git a/Classes/System/TYPO3/Cache.php b/Classes/System/TYPO3/Cache.php index 0ce8120..50c20e9 100644 --- a/Classes/System/TYPO3/Cache.php +++ b/Classes/System/TYPO3/Cache.php @@ -5,7 +5,7 @@ /*************************************************************** * Copyright notice * - * (c) 2016 AOE GmbH + * (c) 2024 AOE GmbH * * All rights reserved * @@ -64,7 +64,7 @@ class Cache implements SingletonInterface */ public const API_METHOD_TYPO3CACHE_TAGS = 'restler_typo3cache_tags'; - private FrontendInterface $cache; + private readonly FrontendInterface $cache; public function __construct(CacheManager $cacheManager) { @@ -93,7 +93,7 @@ public function cacheResponseByTypo3Cache( $identifier = $this->buildIdentifier($requestUri, $requestGetData); $frontendCacheExpires = (int) ($apiMethodInfoMetadata['expires'] ?? 0); $typo3CacheExpires = (int) $apiMethodInfoMetadata[self::API_METHOD_TYPO3CACHE_EXPIRES]; - $typo3CacheTags = explode(',', $apiMethodInfoMetadata[self::API_METHOD_TYPO3CACHE_TAGS]); + $typo3CacheTags = explode(',', (string) $apiMethodInfoMetadata[self::API_METHOD_TYPO3CACHE_TAGS]); $cacheData = []; $cacheData['responseCode'] = $responseCode; diff --git a/Classes/System/TYPO3/Loader.php b/Classes/System/TYPO3/Loader.php index 22e9fd5..c34cb15 100644 --- a/Classes/System/TYPO3/Loader.php +++ b/Classes/System/TYPO3/Loader.php @@ -5,7 +5,7 @@ /*************************************************************** * Copyright notice * - * (c) 2021 AOE GmbH + * (c) 2024 AOE GmbH * * All rights reserved * @@ -38,9 +38,8 @@ use TYPO3\CMS\Core\Site\Entity\Site; use TYPO3\CMS\Core\Site\SiteFinder; use TYPO3\CMS\Core\TimeTracker\TimeTracker; -use TYPO3\CMS\Core\TypoScript\TemplateService; +use TYPO3\CMS\Core\TypoScript\FrontendTypoScript; use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Core\Utility\VersionNumberUtility; use TYPO3\CMS\Frontend\Authentication\FrontendUserAuthentication; use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController; use TYPO3\CMS\Frontend\Http\RequestHandler; @@ -51,32 +50,14 @@ class Loader implements SingletonInterface { - protected TimeTracker $timeTracker; - - private BackendUserAuthenticator $backendUserAuthenticator; - - private FrontendUserAuthenticator $frontendUserAuthenticator; - - private MockRequestHandler $mockRequestHandler; - - private RequestHandler $requestHandler; - - private TypoScriptFrontendInitialization $typoScriptFrontendInitialization; - public function __construct( - BackendUserAuthenticator $backendUserAuthenticator, - FrontendUserAuthenticator $frontendUserAuthenticator, - MockRequestHandler $mockRequestHandler, - RequestHandler $requestHandler, - TimeTracker $timeTracker, - TypoScriptFrontendInitialization $typoScriptFrontendInitialization + private readonly BackendUserAuthenticator $backendUserAuthenticator, + private readonly FrontendUserAuthenticator $frontendUserAuthenticator, + private readonly MockRequestHandler $mockRequestHandler, + private readonly RequestHandler $requestHandler, + private readonly TimeTracker $timeTracker, + private readonly TypoScriptFrontendInitialization $typoScriptFrontendInitialization ) { - $this->backendUserAuthenticator = $backendUserAuthenticator; - $this->frontendUserAuthenticator = $frontendUserAuthenticator; - $this->mockRequestHandler = $mockRequestHandler; - $this->requestHandler = $requestHandler; - $this->timeTracker = $timeTracker; - $this->typoScriptFrontendInitialization = $typoScriptFrontendInitialization; } /** @@ -193,15 +174,7 @@ public function initializeFrontendRendering(int $pageId = 0, int $type = 0, bool $controller->getContext() ->setAspect('typoscript', new TypoScriptAspect($forcedTemplateParsing)); } - - if (VersionNumberUtility::convertVersionNumberToInteger(VersionNumberUtility::getNumericTypo3Version()) > 11005000) { - // it's TYPO3v11 or higher - $prepareTypoScriptFrontendRendering = new PrepareTypoScriptFrontendRendering($this->timeTracker); - } else { - // it's TYPO3v10 or lower - $prepareTypoScriptFrontendRendering = new PrepareTypoScriptFrontendRendering($GLOBALS['TSFE']); - } - + $prepareTypoScriptFrontendRendering = new PrepareTypoScriptFrontendRendering($this->timeTracker); $prepareTypoScriptFrontendRendering->process($this->getRequest(), $this->mockRequestHandler); self::setRequest($this->mockRequestHandler->getRequest()); } @@ -230,7 +203,8 @@ private function getRequest(): ServerRequestInterface private function isFrontendInitialized(): bool { - return ($GLOBALS['TSFE'] ?? null) instanceof TypoScriptFrontendController && - $GLOBALS['TSFE']->tmpl instanceof TemplateService; + return ($GLOBALS['TYPO3_REQUEST'] ?? null) instanceof ServerRequestInterface && + $GLOBALS['TYPO3_REQUEST']->getAttribute('frontend.controller') instanceof TypoScriptFrontendController && + $GLOBALS['TYPO3_REQUEST']->getAttribute('frontend.typoscript') instanceof FrontendTypoScript; } } diff --git a/Classes/System/TYPO3/MockRequestHandler.php b/Classes/System/TYPO3/MockRequestHandler.php index 66f3691..1bdccaf 100644 --- a/Classes/System/TYPO3/MockRequestHandler.php +++ b/Classes/System/TYPO3/MockRequestHandler.php @@ -5,7 +5,7 @@ /*************************************************************** * Copyright notice * - * (c) 2021 AOE GmbH + * (c) 2024 AOE GmbH * * All rights reserved * diff --git a/Classes/System/TYPO3/RestlerEnhancer.php b/Classes/System/TYPO3/RestlerEnhancer.php index 13fb5d4..583f1c9 100644 --- a/Classes/System/TYPO3/RestlerEnhancer.php +++ b/Classes/System/TYPO3/RestlerEnhancer.php @@ -21,7 +21,7 @@ */ class RestlerEnhancer extends RestlerBuilderAware implements DecoratingEnhancerInterface { - private string $default; + private readonly string $default; public function __construct(array $configuration) { diff --git a/README.md b/README.md index e32c376..c3377df 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,11 @@ # Restler for TYPO3 +[![Latest Stable Version](http://poser.pugx.org/aoe/restler/v)](https://packagist.org/packages/aoe/restler) [![Tests](https://github.com/AOEpeople/TYPO3_Restler/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/AOEpeople/TYPO3_Restler/actions) [![Code Coverage](https://scrutinizer-ci.com/g/AOEpeople/TYPO3_Restler/badges/coverage.png?b=main)](https://scrutinizer-ci.com/g/AOEpeople/TYPO3_Restler/?branch=main) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/AOEpeople/TYPO3_Restler/badges/quality-score.png?b=main)](https://scrutinizer-ci.com/g/AOEpeople/TYPO3_Restler/?branch=main) +[![License](http://poser.pugx.org/aoe/restler/license)](https://packagist.org/packages/aoe/restler) +[![Total Downloads](http://poser.pugx.org/aoe/restler/downloads)](https://packagist.org/packages/aoe/restler) This is a TYPO3-Extension, that integrates the popular [PHP REST-framework Restler](https://github.com/Luracast/Restler) in TYPO3. @@ -16,12 +19,13 @@ composer require aoe/restler ## Versions and Support -| Release | TYPO3 | PHP | Fixes will contain -|---|---|---|---| -| 10.x.y | 10.4-11.5 | 7.2-7.4 | Features, Bugfixes, Security Updates -| 9.x.y | 9.5 | 7.2-7.4 | Security Updates -| 8.x.y | 8.7 | 7.2-7.4 | Bugfixes, Security Updates -| 2.x.y | 7.6 | 5.5-5.6 | End of life +| Release | TYPO3 | PHP | Fixes will contain | +|---------|-----------|---------|--------------------------------------| +| 12.x.y | 12.4 | 8.1-8.3 | Features, Bugfixes, Security Updates | +| 11.x.y | 11.5 | 7.4-8.3 | Security Updates | +| 10.x.y | 10.4-11.5 | 7.2-7.4 | End of life | +| 9.x.y | 9.5 | 7.2-7.4 | End of life | +| 8.x.y | 8.7 | 7.2-7.4 | End of life | ## Documentation diff --git a/Tests/Unit/BaseTestCase.php b/Tests/Unit/BaseTestCase.php index 783e95d..f838de8 100644 --- a/Tests/Unit/BaseTestCase.php +++ b/Tests/Unit/BaseTestCase.php @@ -5,7 +5,7 @@ /*************************************************************** * Copyright notice * - * (c) 2021 AOE GmbH + * (c) 2024 AOE GmbH * * All rights reserved * @@ -42,7 +42,7 @@ abstract class BaseTestCase extends UnitTestCase */ protected function callUnaccessibleMethodOfObject($object, $methodName, array $methodParams = []) { - $class = new \ReflectionClass(get_class($object)); + $class = new \ReflectionClass($object::class); $method = $class->getMethod($methodName); $method->setAccessible(true); diff --git a/Tests/Unit/Configuration/ExtensionConfigurationTest.php b/Tests/Unit/Configuration/ExtensionConfigurationTest.php index b58f098..1154397 100644 --- a/Tests/Unit/Configuration/ExtensionConfigurationTest.php +++ b/Tests/Unit/Configuration/ExtensionConfigurationTest.php @@ -5,7 +5,7 @@ /*************************************************************** * Copyright notice * - * (c) 2021 AOE GmbH + * (c) 2024 AOE GmbH * * All rights reserved * @@ -44,6 +44,8 @@ class ExtensionConfigurationTest extends BaseTestCase */ protected function setUp(): void { + parent::setUp(); + $mockedExtConfig = [ 'refreshCache' => '0', 'productionContext' => '1', diff --git a/Tests/Unit/Controller/BeUserAuthenticationControllerTest.php b/Tests/Unit/Controller/BeUserAuthenticationControllerTest.php index 11ebda2..ffa6188 100644 --- a/Tests/Unit/Controller/BeUserAuthenticationControllerTest.php +++ b/Tests/Unit/Controller/BeUserAuthenticationControllerTest.php @@ -5,7 +5,7 @@ /*************************************************************** * Copyright notice * - * (c) 2021 AOE GmbH + * (c) 2024 AOE GmbH * * All rights reserved * diff --git a/Tests/Unit/Controller/ExplorerAuthenticationControllerTest.php b/Tests/Unit/Controller/ExplorerAuthenticationControllerTest.php index 0087487..7efdc33 100644 --- a/Tests/Unit/Controller/ExplorerAuthenticationControllerTest.php +++ b/Tests/Unit/Controller/ExplorerAuthenticationControllerTest.php @@ -5,7 +5,7 @@ /*************************************************************** * Copyright notice * - * (c) 2021 AOE GmbH + * (c) 2024 AOE GmbH * * All rights reserved * diff --git a/Tests/Unit/Controller/FeUserAuthenticationControllerTest.php b/Tests/Unit/Controller/FeUserAuthenticationControllerTest.php index d03e629..4e59bae 100644 --- a/Tests/Unit/Controller/FeUserAuthenticationControllerTest.php +++ b/Tests/Unit/Controller/FeUserAuthenticationControllerTest.php @@ -5,7 +5,7 @@ /*************************************************************** * Copyright notice * - * (c) 2021 AOE GmbH + * (c) 2024 AOE GmbH * * All rights reserved * diff --git a/Tests/Unit/System/DispatcherTest.php b/Tests/Unit/System/DispatcherTest.php index bc81726..8cbc20d 100644 --- a/Tests/Unit/System/DispatcherTest.php +++ b/Tests/Unit/System/DispatcherTest.php @@ -5,7 +5,7 @@ /*************************************************************** * Copyright notice * - * (c) 2021 AOE GmbH + * (c) 2024 AOE GmbH * * All rights reserved * diff --git a/Tests/Unit/System/RestApi/RestApiClientTest.php b/Tests/Unit/System/RestApi/RestApiClientTest.php index 8669c2c..9424206 100644 --- a/Tests/Unit/System/RestApi/RestApiClientTest.php +++ b/Tests/Unit/System/RestApi/RestApiClientTest.php @@ -5,7 +5,7 @@ /*************************************************************** * Copyright notice * - * (c) 2021 AOE GmbH + * (c) 2024 AOE GmbH * * All rights reserved * diff --git a/Tests/Unit/System/RestApi/RestApiRequestTest.php b/Tests/Unit/System/RestApi/RestApiRequestTest.php index cef8c43..7b8c57c 100644 --- a/Tests/Unit/System/RestApi/RestApiRequestTest.php +++ b/Tests/Unit/System/RestApi/RestApiRequestTest.php @@ -5,7 +5,7 @@ /*************************************************************** * Copyright notice * - * (c) 2021 AOE GmbH + * (c) 2024 AOE GmbH * * All rights reserved * @@ -176,7 +176,7 @@ public function testShouldRestoreOriginalRestApiRequestWhenExecutionOfRestApiReq try { $this->restApiRequest->executeRestApiRequest($requestMethod, $requestUri); - } catch (Exception $e) { + } catch (Exception) { } $this->assertEquals($this->originalGetVars, $_GET); @@ -205,7 +205,7 @@ public function testShouldRestoreOriginalRestApiRequestWhenExecutionOfRestApiReq try { $this->restApiRequest->executeRestApiRequest($requestMethod, $requestUri); - } catch (Exception $e) { + } catch (Exception) { } $this->assertEquals($this->originalGetVars, $_GET); diff --git a/Tests/Unit/System/Restler/BuilderTest.php b/Tests/Unit/System/Restler/BuilderTest.php index cfe0c0b..9e0c31d 100644 --- a/Tests/Unit/System/Restler/BuilderTest.php +++ b/Tests/Unit/System/Restler/BuilderTest.php @@ -5,7 +5,7 @@ /*************************************************************** * Copyright notice * - * (c) 2021 AOE GmbH + * (c) 2024 AOE GmbH * * All rights reserved * diff --git a/Tests/Unit/System/Restler/ConfigurationTest.php b/Tests/Unit/System/Restler/ConfigurationTest.php index 1000c85..0f4aa49 100644 --- a/Tests/Unit/System/Restler/ConfigurationTest.php +++ b/Tests/Unit/System/Restler/ConfigurationTest.php @@ -5,7 +5,7 @@ /*************************************************************** * Copyright notice * - * (c) 2021 AOE GmbH + * (c) 2024 AOE GmbH * * All rights reserved * diff --git a/Tests/Unit/System/Restler/ExceptionHandlerTest.php b/Tests/Unit/System/Restler/ExceptionHandlerTest.php index e8d7989..ff0eded 100644 --- a/Tests/Unit/System/Restler/ExceptionHandlerTest.php +++ b/Tests/Unit/System/Restler/ExceptionHandlerTest.php @@ -5,7 +5,7 @@ /*************************************************************** * Copyright notice * - * (c) 2021 AOE GmbH + * (c) 2024 AOE GmbH * * All rights reserved * diff --git a/Tests/Unit/System/Restler/Fixtures/ExceptionHandler.php b/Tests/Unit/System/Restler/Fixtures/ExceptionHandler.php index 586bf31..774cde5 100644 --- a/Tests/Unit/System/Restler/Fixtures/ExceptionHandler.php +++ b/Tests/Unit/System/Restler/Fixtures/ExceptionHandler.php @@ -5,7 +5,7 @@ /*************************************************************** * Copyright notice * - * (c) 2015 AOE GmbH + * (c) 2024 AOE GmbH * * All rights reserved * diff --git a/Tests/Unit/System/Restler/Fixtures/InvalidConfiguration.php b/Tests/Unit/System/Restler/Fixtures/InvalidConfiguration.php index b54f1db..130fdeb 100644 --- a/Tests/Unit/System/Restler/Fixtures/InvalidConfiguration.php +++ b/Tests/Unit/System/Restler/Fixtures/InvalidConfiguration.php @@ -5,7 +5,7 @@ /*************************************************************** * Copyright notice * - * (c) 2015 AOE GmbH + * (c) 2024 AOE GmbH * * All rights reserved * diff --git a/Tests/Unit/System/Restler/Fixtures/ValidConfiguration.php b/Tests/Unit/System/Restler/Fixtures/ValidConfiguration.php index aeaaa0a..51cd464 100644 --- a/Tests/Unit/System/Restler/Fixtures/ValidConfiguration.php +++ b/Tests/Unit/System/Restler/Fixtures/ValidConfiguration.php @@ -5,7 +5,7 @@ /*************************************************************** * Copyright notice * - * (c) 2015 AOE GmbH + * (c) 2024 AOE GmbH * * All rights reserved * diff --git a/Tests/Unit/System/TYPO3/CacheTest.php b/Tests/Unit/System/TYPO3/CacheTest.php index 72b2e6c..118d718 100644 --- a/Tests/Unit/System/TYPO3/CacheTest.php +++ b/Tests/Unit/System/TYPO3/CacheTest.php @@ -5,7 +5,7 @@ /*************************************************************** * Copyright notice * - * (c) 2021 AOE GmbH + * (c) 2024 AOE GmbH * * All rights reserved * diff --git a/Tests/phpunit.xml b/Tests/phpunit.xml index ea3341e..d0e1914 100644 --- a/Tests/phpunit.xml +++ b/Tests/phpunit.xml @@ -1,31 +1,30 @@ - + + ./ - - - ../Classes - - - \ No newline at end of file + + + ../Classes + + + diff --git a/composer.json b/composer.json index cd012cd..8e395fd 100644 --- a/composer.json +++ b/composer.json @@ -14,23 +14,23 @@ } ], "require": { - "php": "^7.4 || ^8.0", + "php": "^8.1", "ext-json": "*", "ext-mbstring": "*", "ext-iconv": "*", - "typo3/cms-core": "^11.5", + "typo3/cms-core": "^12.4", "luracast/restler": "^5.0", "cweagans/composer-patches": "^1.7" }, "require-dev": { - "typo3/testing-framework": "^7.0.4", + "typo3/testing-framework": "^8.0", "phpspec/prophecy-phpunit": "^2.0", - "phpunit/phpcov": "*", + "phpunit/phpcov": "^9.0.0", "phpcompatibility/php-compatibility": "^9.3", "phpstan/phpstan": "^1.10", "rector/rector": "^1.0", "symplify/easy-coding-standard": "12.1.14", - "symplify/phpstan-rules": "12.4.8" + "symplify/phpstan-rules": "^13.0" }, "keywords": [ "TYPO3", @@ -52,6 +52,7 @@ "config": { "vendor-dir": ".Build/vendor", "bin-dir": ".Build/bin", + "process-timeout": 0, "allow-plugins": { "typo3/cms-composer-installers": true, "typo3/class-alias-loader": true, @@ -65,21 +66,17 @@ ], "test:unit": [ "[ -e .Build/bin/phpunit ] || composer update", - "TYPO3_PATH_ROOT=.Build/Web .Build/bin/phpunit -c .Build/vendor/typo3/testing-framework/Resources/Core/Build/UnitTests-v10.xml Tests/Unit" + "XDEBUG_MODE=coverage TYPO3_PATH_ROOT=.Build/Web .Build/bin/phpunit -c Tests/phpunit.xml Tests/Unit" ], "test:unit-filter": [ "[ -e .Build/bin/phpunit ] || composer update", - "TYPO3_PATH_ROOT=.Build/Web .Build/bin/phpunit -c .Build/vendor/typo3/testing-framework/Resources/Core/Build/UnitTests-v10.xml Tests/Unit --filter=ExceptionHandlerTest" + "XDEBUG_MODE=coverage TYPO3_PATH_ROOT=.Build/Web .Build/bin/phpunit -c Tests/phpunit.xml Tests/Unit --filter=ExceptionHandlerTest" ], "code-style": [ "[ -e ./.Build/bin/rector ] || composer install", "./.Build/bin/ecs check --config .code-quality/ecs.php", "./.Build/bin/rector process --dry-run --config .code-quality/rector.php" ], - "code-style-upgrade": [ - "[ -e ./.Build/bin/rector ] || composer install", - "./.Build/bin/rector process --dry-run --config .code-quality/rector-8_0.php" - ], "code-analysis": [ "./.Build/bin/phpstan analyse -c .code-quality/phpstan.neon --memory-limit=1G" ], @@ -87,11 +84,9 @@ "./.Build/bin/phpstan analyse -c .code-quality/phpstan.neon --memory-limit=1G --generate-baseline --allow-empty-baseline" ], "code-compatibility": [ - "[ -e ./.Build/vendor/symplify/easy-coding-standard/vendor/squizlabs/php_codesniffer/bin/phpcs ] || composer install", + "[ -e ./.Build/vendor/symplify/easy-coding-standard/vendor/squizlabs/php_codesniffer/bin/phpcs ] || composer update", "[ -d ./reports/php_checkstyle ] || mkdir -p reports/php_checkstyle/", "./.code-quality/configure-checkstyle.sh", - "./.Build/vendor/symplify/easy-coding-standard/vendor/squizlabs/php_codesniffer/bin/phpcs -d memory_limit=1G --standard=PHPCompatibility --colors --ignore=*/.Build/*,*.min.js -p . --runtime-set testVersion 7.4", - "./.Build/vendor/symplify/easy-coding-standard/vendor/squizlabs/php_codesniffer/bin/phpcs -d memory_limit=1G --standard=PHPCompatibility --colors --ignore=*/.Build/*,*.min.js -p . --runtime-set testVersion 8.0", "./.Build/vendor/symplify/easy-coding-standard/vendor/squizlabs/php_codesniffer/bin/phpcs -d memory_limit=1G --standard=PHPCompatibility --colors --ignore=*/.Build/*,*.min.js -p . --runtime-set testVersion 8.1", "./.Build/vendor/symplify/easy-coding-standard/vendor/squizlabs/php_codesniffer/bin/phpcs -d memory_limit=1G --standard=PHPCompatibility --colors --ignore=*/.Build/*,*.min.js -p . --runtime-set testVersion 8.2", "./.Build/vendor/symplify/easy-coding-standard/vendor/squizlabs/php_codesniffer/bin/phpcs -d memory_limit=1G --standard=PHPCompatibility --colors --ignore=*/.Build/*,*.min.js -p . --runtime-set testVersion 8.3" @@ -102,12 +97,8 @@ "@composer code-compatibility" ], "extension-release": [ - "rm -rf .github", - "rm -rf .Build", - "rm -rf .code-quality", - "rm -rf Tests/", - "rm .gitignore", - "rm .scrutinizer.yml" + "@composer install --no-dev", + "rm -rf .github .Build code-quality Tests .gitignore scrutinizer.yml" ] }, "scripts-descriptions": { @@ -115,7 +106,7 @@ }, "extra": { "branch-alias": { - "dev-main": "11.0.x-dev" + "dev-main": "12.0.x-dev" }, "typo3/cms": { "cms-package-dir": "{$vendor-dir}/typo3/cms", diff --git a/ext_emconf.php b/ext_emconf.php index 855e3b7..b8255fe 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -20,10 +20,10 @@ 'state' => 'stable', 'uploadfolder' => 0, 'clearCacheOnLoad' => 0, - 'version' => '11.2.0', + 'version' => '12.0.0', 'constraints' => [ 'depends' => [ - 'typo3' => '11.0.0-11.5.99' + 'typo3' => '12.4.0-12.4.99' ], 'conflicts' => [], 'suggests' => [], diff --git a/ext_localconf.php b/ext_localconf.php index b6625fb..d6af314 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -6,9 +6,7 @@ use TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend; use TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend; -if (!defined('TYPO3_MODE')) { - die('Access denied.'); -} +defined('TYPO3') or die(); // base restler annotations $restlerAnnotations = ['url',