diff --git a/.github/workflows/tasks.yml b/.github/workflows/tasks.yml index 735984c..ac43d24 100644 --- a/.github/workflows/tasks.yml +++ b/.github/workflows/tasks.yml @@ -9,15 +9,20 @@ jobs: strategy: fail-fast: false matrix: - php: [ '8.1', '8.2', '8.3' ] - typo3: [ '11', '12' ] + php: [ '8.1', '8.2', '8.3', '8.4' ] + typo3: [ '11', '12', '13' ] + exclude: + - php: '8.1' + typo3: '13' + - php: '8.4' + typo3: '11' steps: - name: Setup PHP with PECL extension uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} - - uses: actions/checkout@v2 - - uses: actions/cache@v2 + - uses: actions/checkout@v5 + - uses: actions/cache@v3 with: path: ~/.composer/cache/files key: ${{ runner.os }}-${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }} @@ -26,4 +31,3 @@ jobs: - run: composer require typo3/minimal="^${{ matrix.typo3 }}" --dev - run: composer install --no-interaction --no-progress - run: ./vendor/bin/grumphp run --ansi - diff --git a/Classes/Middleware/MinifyMiddleware.php b/Classes/Middleware/MinifyMiddleware.php index 17a3480..085279a 100644 --- a/Classes/Middleware/MinifyMiddleware.php +++ b/Classes/Middleware/MinifyMiddleware.php @@ -11,10 +11,13 @@ use Psr\Http\Server\RequestHandlerInterface; use TYPO3\CMS\Core\Http\Response; use TYPO3\CMS\Core\Http\Stream; -use TYPO3\CMS\Core\Utility\GeneralUtility; class MinifyMiddleware implements MiddlewareInterface { + public function __construct(private readonly MinifyService $minifyService) + { + } + public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface { // minimize only html @@ -30,9 +33,7 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface $body->rewind(); $html = $body->getContents(); - $minifyService = GeneralUtility::makeInstance(MinifyService::class); - assert($minifyService instanceof MinifyService); - $html = $minifyService->minify($html); + $html = $this->minifyService->minify($html); $body = new Stream('php://temp', 'wb+'); $body->write($html); $response = $response->withBody($body); diff --git a/Classes/Service/MinifyService.php b/Classes/Service/MinifyService.php index 393cb69..84850b3 100644 --- a/Classes/Service/MinifyService.php +++ b/Classes/Service/MinifyService.php @@ -4,8 +4,10 @@ namespace Pluswerk\PlusMinify\Service; +use Symfony\Component\DependencyInjection\Attribute\Autoconfigure; use voku\helper\HtmlMin; +#[Autoconfigure(public: true)] class MinifyService { public function minify(string $html): string @@ -39,7 +41,7 @@ public function minify(string $html): string $output = []; $languageMeta = preg_match_all('##', $html, $output); if ($languageMeta) { - $insertAt = strpos($html, (string)$output[0][0]) + strlen($output[0][0]); + $insertAt = strpos($html, $output[0][0]) + strlen($output[0][0]); $html = substr($html, 0, $insertAt) . $typo3Comment . substr($html, $insertAt); } else { $html = $htmlMin->minify($html); diff --git a/Configuration/Services.yaml b/Configuration/Services.yaml index 2ef850d..d1adcd0 100644 --- a/Configuration/Services.yaml +++ b/Configuration/Services.yaml @@ -4,10 +4,6 @@ services: autoconfigure: true public: false - Pluswerk\PlusMinify\Service\: - resource: '../Classes/Service/*' - public: true - Pluswerk\PlusMinify\EventListener\RenderedEventListener: tags: - name: event.listener diff --git a/composer.json b/composer.json index 4dbf1e0..2072b57 100644 --- a/composer.json +++ b/composer.json @@ -8,16 +8,16 @@ "source": "https://github.com/pluswerk/minify" }, "require": { - "php": "~8.1.0 || ~8.2.0 || ~8.3.0", + "php": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0", "composer-runtime-api": "^2", - "typo3/cms-core": "^11.5 || ^12.4", - "voku/html-min": "^4.5" + "typo3/cms-core": "^11.5 || ^12.4 || ^13.4", + "voku/html-min": "^4.5.1" }, "require-dev": { - "andersundsehr/ssi-include": "^1.1.0", - "pluswerk/grumphp-config": "^7", - "saschaegerer/phpstan-typo3": "^1.10.0", - "ssch/typo3-rector": "^2.5.0" + "andersundsehr/ssi-include": "^1.1.0 || ^2.2.0", + "pluswerk/grumphp-config": "^7 || ^10", + "saschaegerer/phpstan-typo3": "^1.10.0 || ^2.1.1", + "ssch/typo3-rector": "^2.5.0 || ^3.6.2" }, "autoload": { "psr-4": { diff --git a/ext_emconf.php b/ext_emconf.php index 31e2c71..5ff53a8 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -13,7 +13,7 @@ 'version' => InstalledVersions::getPrettyVersion('pluswerk/minify'), 'constraints' => [ 'depends' => [ - 'typo3' => '11.5.0 - 12.99.99', + 'typo3' => '11.5.0 - 13.99.99', ], 'conflicts' => [], 'suggests' => [], diff --git a/rector.php b/rector.php index eb71986..0f267f7 100644 --- a/rector.php +++ b/rector.php @@ -14,14 +14,14 @@ $rectorConfig->cacheDirectory('./var/cache/rector'); $rectorConfig->paths( - array_filter(explode("\n", (string)shell_exec("git ls-files | xargs ls -d 2>/dev/null | grep '\.php$'"))) + array_filter(explode("\n", (string)shell_exec("git ls-files | xargs ls -d 2>/dev/null | grep -E '\.(php)$'"))) ); // define sets of rules $rectorConfig->sets( [ ...RectorSettings::sets(true), - ...RectorSettings::setsTypo3(true), + ...RectorSettings::setsTypo3(false), ] ); @@ -31,6 +31,7 @@ [ ...RectorSettings::skip(), ...RectorSettings::skipTypo3(), + /** * rector should not touch these files */