diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bcbba18..d0bda11 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,12 +20,12 @@ permissions: jobs: test: runs-on: ubuntu-latest - name: TYPO3 v13.4 tests on PHP ${{ matrix.php }} + name: TYPO3 v14 tests on PHP ${{ matrix.php }} strategy: fail-fast: false matrix: - php: [8.3, 8.4] + php: [8.4, 8.5] steps: - name: 'Checkout code' @@ -83,7 +83,7 @@ jobs: - name: 'Add title to code coverage summary' shell: bash - run: sed -i '1 i\## TYPO3 v13.4 tests on PHP ${{ matrix.php }}' code-coverage-summary.md + run: sed -i '1 i\## TYPO3 v14 tests on PHP ${{ matrix.php }}' code-coverage-summary.md - name: 'Add code coverage summary as pr comment' uses: marocchino/sticky-pull-request-comment@v2 diff --git a/.phprc b/.phprc index cf02201..c9dc049 100644 --- a/.phprc +++ b/.phprc @@ -1 +1 @@ -8.3 +8.4 diff --git a/.prettierrc.json b/.prettierrc.json index 6bea5ba..dca098b 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -7,7 +7,7 @@ { "files": ["*.php"], "options": { - "phpVersion": "8.3", + "phpVersion": "8.4", "printWidth": 115, "plugins": ["@prettier/plugin-php"] } diff --git a/Classes/Command/GenerateErrorPagesCommand.php b/Classes/Command/GenerateErrorPagesCommand.php index c8ab7ae..af38a6e 100644 --- a/Classes/Command/GenerateErrorPagesCommand.php +++ b/Classes/Command/GenerateErrorPagesCommand.php @@ -17,7 +17,7 @@ use Symfony\Component\Console\Output\OutputInterface; use TYPO3\CMS\Core\Core\Environment; use TYPO3\CMS\Core\Exception\SiteNotFoundException; -use TYPO3\CMS\Core\Http\ServerRequestFactory; +use TYPO3\CMS\Core\Http\ServerRequest; use TYPO3\CMS\Core\LinkHandling\LinkService; use TYPO3\CMS\Core\Site\Entity\Site; use TYPO3\CMS\Core\Site\Entity\SiteLanguage; @@ -92,8 +92,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int continue; } - $request = ServerRequestFactory::fromGlobals() - ->withUri($site->getBase()) + $request = (new ServerRequest($site->getBase())) ->withAttribute('site', $site) ->withAttribute('language', $language); @@ -194,11 +193,11 @@ private function resolveUrl(ServerRequestInterface $request, string $typoLinkUrl $site = GeneralUtility::makeInstance(SiteFinder::class)->getSiteByPageId((int) $urlParams['pageuid']); } catch (SiteNotFoundException) { // Fall back to current request for the site - $site = $request->getAttribute('site', null); + $site = $request->getAttribute('site'); } /** @var SiteLanguage $requestLanguage */ - $requestLanguage = $request->getAttribute('language', null); + $requestLanguage = $request->getAttribute('language'); // Try to get the current request language from the site that was found above if ($requestLanguage instanceof SiteLanguage) { try { diff --git a/Classes/Service/StaticDocumentOutputService.php b/Classes/Service/StaticDocumentOutputService.php index a911bef..7f05dab 100755 --- a/Classes/Service/StaticDocumentOutputService.php +++ b/Classes/Service/StaticDocumentOutputService.php @@ -49,7 +49,7 @@ protected function getErrorDocumentFromFile(int $errorCode, ServerRequestInterfa ]; foreach ($errorDocumentFileNames as $errorDocumentFileName) { $content = $this->getContentFromPath($errorDocumentFileName); - if ($content !== null && $content !== '' && $content !== '0') { + if (!in_array($content, [null, '', '0'], true)) { return $content; } } diff --git a/README.md b/README.md index 9d5af96..a3616cf 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,14 @@ # TYPO3 extension nxerrorhandler -[![TYPO3 V13](https://img.shields.io/badge/TYPO3-13-orange.svg)](https://get.typo3.org/version/13) -[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%208.3-8892BF.svg)](https://php.net/) +[![TYPO3 V14](https://img.shields.io/badge/TYPO3-14-orange.svg)](https://get.typo3.org/version/14) +[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%208.4-8892BF.svg)](https://php.net/) [![GitHub CI status](https://github.com/netlogix/nxerrorhandler/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/netlogix/nxerrorhandler/actions) Improves error handling in TYPO3 by using statically rendered error documents for output to reduce strain on the server. ## Compatibility -The current version of this extension has been tested in TYPO3 13 on PHP 8.3, 8.4. +The current version of this extension has been tested in TYPO3 14 on PHP 8.4, 8.5. ## Usage diff --git a/Tests/Functional/Command/GenerateErrorPagesCommandTest.php b/Tests/Functional/Command/GenerateErrorPagesCommandTest.php index 361613c..a10b77b 100644 --- a/Tests/Functional/Command/GenerateErrorPagesCommandTest.php +++ b/Tests/Functional/Command/GenerateErrorPagesCommandTest.php @@ -4,7 +4,6 @@ namespace Netlogix\Nxerrorhandler\Tests\Functional\Command; -use Override; use FilesystemIterator; use Netlogix\Nxerrorhandler\Command\GenerateErrorPagesCommand; use Netlogix\Nxerrorhandler\Service\ConfigurationService; @@ -16,7 +15,7 @@ use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase; -class GenerateErrorPagesCommandTest extends FunctionalTestCase +final class GenerateErrorPagesCommandTest extends FunctionalTestCase { protected array $pathsToLinkInTestInstance = [ 'typo3conf/ext/nxerrorhandler/Tests/Functional/Fixtures/Sites' => 'typo3conf/sites', @@ -37,28 +36,23 @@ class GenerateErrorPagesCommandTest extends FunctionalTestCase ], ]; - #[Override] protected function setUp(): void { parent::setUp(); - $this->purgeCreatedDirectoriesAndFiles(); } - protected function purgeCreatedDirectoriesAndFiles() + protected function purgeCreatedDirectoriesAndFiles(): void { if (is_dir(ConfigurationService::getErrorDocumentDirectory())) { GeneralUtility::rmdir(ConfigurationService::getErrorDocumentDirectory(), true); } } - #[Override] protected function tearDown(): void { restore_exception_handler(); - parent::tearDown(); - $this->purgeCreatedDirectoriesAndFiles(); } @@ -67,7 +61,7 @@ public function itCreatesErrorDocumentDirectory(): void { $this->assertDirectoryDoesNotExist(ConfigurationService::getErrorDocumentDirectory()); - $subject = $this->createMock(GenerateErrorPagesCommand::class); + $subject = $this->createStub(GenerateErrorPagesCommand::class); $reflectionObject = new ReflectionObject($subject); $reflectionMethod = $reflectionObject->getMethod('initialize'); diff --git a/Tests/Functional/Service/StaticDocumentOutputServiceTest.php b/Tests/Functional/Service/StaticDocumentOutputServiceTest.php index f6aaa2f..7a149ac 100644 --- a/Tests/Functional/Service/StaticDocumentOutputServiceTest.php +++ b/Tests/Functional/Service/StaticDocumentOutputServiceTest.php @@ -4,7 +4,6 @@ namespace Netlogix\Nxerrorhandler\Tests\Functional\Service; -use Override; use Netlogix\Nxerrorhandler\Service\StaticDocumentOutputService; use PHPUnit\Framework\Attributes\Test; use TYPO3\CMS\Core\Http\ServerRequest; @@ -13,7 +12,7 @@ use TYPO3\CMS\Core\Site\SiteFinder; use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase; -class StaticDocumentOutputServiceTest extends FunctionalTestCase +final class StaticDocumentOutputServiceTest extends FunctionalTestCase { protected array $pathsToLinkInTestInstance = [ 'typo3conf/ext/nxerrorhandler/Tests/Functional/Fixtures/Sites' => 'typo3conf/sites', @@ -58,11 +57,9 @@ public function itTriesToFetchContentForLanguageCombinations(): void $subject->getOutput($errorCode, $request); } - #[Override] protected function setUp(): void { parent::setUp(); - $this->importCSVDataSet(__DIR__ . '/../Fixtures/pages.csv'); $this->setUpFrontendRootPage(1); } diff --git a/Tests/Unit/Error/PageContentErrorHandlerTest.php b/Tests/Unit/Error/PageContentErrorHandlerTest.php index ce60499..f755848 100644 --- a/Tests/Unit/Error/PageContentErrorHandlerTest.php +++ b/Tests/Unit/Error/PageContentErrorHandlerTest.php @@ -4,7 +4,6 @@ namespace Netlogix\Nxerrorhandler\Tests\Unit\Error; -use Override; use Netlogix\Nxerrorhandler\Error\PageContentErrorHandler; use Netlogix\Nxerrorhandler\Service\StaticDocumentOutputService; use PHPUnit\Framework\Attributes\Test; @@ -15,7 +14,7 @@ use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; -class PageContentErrorHandlerTest extends UnitTestCase +final class PageContentErrorHandlerTest extends UnitTestCase { private MockObject&PageContentErrorHandler $subject; @@ -56,11 +55,9 @@ public function itReturnsStaticContentIfExists(): void $this->assertSame($content, $resp->getBody()->getContents()); } - #[Override] protected function setUp(): void { parent::setUp(); - $this->subject = $this->getMockBuilder(PageContentErrorHandler::class) ->addMethods([]) ->disableOriginalConstructor() diff --git a/Tests/Unit/Service/ConfigurationServiceTest.php b/Tests/Unit/Service/ConfigurationServiceTest.php index 387d950..05b13ff 100644 --- a/Tests/Unit/Service/ConfigurationServiceTest.php +++ b/Tests/Unit/Service/ConfigurationServiceTest.php @@ -8,7 +8,7 @@ use PHPUnit\Framework\Attributes\Test; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; -class ConfigurationServiceTest extends UnitTestCase +final class ConfigurationServiceTest extends UnitTestCase { #[Test] public function itCanGetErrorDocumentDirectory(): void diff --git a/Tests/Unit/Service/StaticDocumentOutputServiceTest.php b/Tests/Unit/Service/StaticDocumentOutputServiceTest.php index d9fa507..616a688 100644 --- a/Tests/Unit/Service/StaticDocumentOutputServiceTest.php +++ b/Tests/Unit/Service/StaticDocumentOutputServiceTest.php @@ -9,7 +9,7 @@ use TYPO3\CMS\Core\Http\ServerRequest; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; -class StaticDocumentOutputServiceTest extends UnitTestCase +final class StaticDocumentOutputServiceTest extends UnitTestCase { #[Test] public function itAddsCurrentUrlToErrorDocument(): void diff --git a/composer.json b/composer.json index 9ea6bd7..c47ea01 100644 --- a/composer.json +++ b/composer.json @@ -4,16 +4,16 @@ "license": "MIT", "type": "typo3-cms-extension", "require": { - "php": ">=8.3", - "typo3/cms-core": "^13.4", - "typo3/cms-frontend": "^13.4" + "php": "^8.4 || ^8.5", + "typo3/cms-core": "^14.3", + "typo3/cms-frontend": "^14.3" }, "require-dev": { "ext-sqlite3": "*", "ergebnis/composer-normalize": "^2.45", "phpunit/phpcov": "^10.0", - "ssch/typo3-rector": "^3.0", - "typo3/testing-framework": "^9.0" + "ssch/typo3-rector": "^3.14", + "typo3/testing-framework": "^9.6" }, "autoload": { "psr-4": { diff --git a/rector.php b/rector.php index 97c54c7..6f96242 100644 --- a/rector.php +++ b/rector.php @@ -3,7 +3,7 @@ declare(strict_types=1); use Rector\Config\RectorConfig; -use Rector\Php81\Rector\Array_\FirstClassCallableRector; +use Rector\Php81\Rector\Array_\ArrayToFirstClassCallableRector; use Rector\PHPUnit\Set\PHPUnitSetList; use Rector\Set\ValueObject\LevelSetList; use Rector\Set\ValueObject\SetList; @@ -23,18 +23,17 @@ typeDeclarations: true, instanceOf: true, earlyReturn: true, - strictBooleans: true, ) ->withImportNames(removeUnusedImports: true) ->withSets([ - LevelSetList::UP_TO_PHP_83, + LevelSetList::UP_TO_PHP_84, SetList::CODE_QUALITY, SetList::CODING_STYLE, SetList::DEAD_CODE, SetList::TYPE_DECLARATION, SetList::EARLY_RETURN, SetList::INSTANCEOF, - Typo3LevelSetList::UP_TO_TYPO3_13, + Typo3LevelSetList::UP_TO_TYPO3_14, PHPUnitSetList::PHPUNIT_100, PHPUnitSetList::PHPUNIT_CODE_QUALITY, PHPUnitSetList::ANNOTATIONS_TO_ATTRIBUTES, @@ -51,5 +50,5 @@ __DIR__ . '/public/*', __DIR__ . '/.github/*', __DIR__ . '/.Build/*', - FirstClassCallableRector::class => [__DIR__ . '/Configuration/Services.php'], + ArrayToFirstClassCallableRector::class => [__DIR__ . '/Configuration/Services.php'], ]);