diff --git a/.github/workflows/tasks.yml b/.github/workflows/tasks.yml
index 6b25d01..f1952fe 100644
--- a/.github/workflows/tasks.yml
+++ b/.github/workflows/tasks.yml
@@ -9,13 +9,11 @@ jobs:
strategy:
fail-fast: false
matrix:
- php: [ '7.4', '8.0', '8.1' ]
- typo3: [ '10', '11' ]
+ php: [ '8.0', '8.1', '8.2' ]
+ typo3: [ '11', '12' ]
exclude:
- php: '8.0'
- typo3: '10'
- - php: '8.1'
- typo3: '10'
+ typo3: '12'
steps:
- name: Setup PHP with PECL extension
uses: shivammathur/setup-php@v2
diff --git a/.gitignore b/.gitignore
index c34116b..b324833 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,4 @@
vendor
public
composer.lock
+var/
\ No newline at end of file
diff --git a/Classes/Middleware/MinifyMiddleware.php b/Classes/Middleware/MinifyMiddleware.php
index 947bc3f..17a3480 100644
--- a/Classes/Middleware/MinifyMiddleware.php
+++ b/Classes/Middleware/MinifyMiddleware.php
@@ -20,7 +20,7 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
// minimize only html
$response = $handler->handle($request);
foreach ($response->getHeader('Content-Type') as $contentType) {
- if (strpos($contentType, 'text/html') !== 0) {
+ if (!str_starts_with($contentType, 'text/html')) {
return $response;
}
}
@@ -37,6 +37,7 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
$body->write($html);
$response = $response->withBody($body);
}
+
return $response;
}
}
diff --git a/Classes/Service/MinifyService.php b/Classes/Service/MinifyService.php
index 932a8c4..9dfabe9 100644
--- a/Classes/Service/MinifyService.php
+++ b/Classes/Service/MinifyService.php
@@ -29,6 +29,7 @@ public function minify(string $html): string
$htmlMin->doRemoveOmittedQuotes($this->isFeatureActive('remove_omitted_quotes'));
$htmlMin->doRemoveOmittedHtmlTags($this->isFeatureActive('remove_omitted_html_tags'));
$htmlMin->doRemoveComments($this->isFeatureActive('remove_comments'));
+
$originalHtml = $html;
// Not nice but this is really hardcoded in the core.
@@ -36,9 +37,9 @@ public function minify(string $html): string
$typo3Comment = $this->preserveTypo3Comment($html);
$html = $htmlMin->minify($html);
$output = [];
- $languageMeta = preg_match_all('//', $html, $output);
+ $languageMeta = preg_match_all('##', $html, $output);
if ($languageMeta) {
- $insertAt = strpos($html, $output[0][0]) + strlen($output[0][0]);
+ $insertAt = strpos($html, (string)$output[0][0]) + strlen($output[0][0]);
$html = substr($html, 0, $insertAt) . $typo3Comment . substr($html, $insertAt);
} else {
$html = $htmlMin->minify($html);
@@ -48,8 +49,9 @@ public function minify(string $html): string
}
if (empty($html)) {
- $html = $originalHtml;
+ return $originalHtml;
}
+
return $html;
}
@@ -66,7 +68,7 @@ protected function preserveTypo3Comment(string $html): string
$typo3CommentStop = strpos($html, '-->', $typo3CommentStart);
$typo3Comment = substr($html, $typo3CommentStart, $typo3CommentStop - $typo3CommentStart + 3);
- if (strpos($typo3Comment, 'TYPO3') !== false) {
+ if (str_contains($typo3Comment, 'TYPO3')) {
return $typo3Comment;
}
diff --git a/Configuration/RequestMiddlewares.php b/Configuration/RequestMiddlewares.php
index 78a5bbe..58931ec 100644
--- a/Configuration/RequestMiddlewares.php
+++ b/Configuration/RequestMiddlewares.php
@@ -1,9 +1,11 @@
[
'minify/service/htmlminifier' => [
- 'target' => \Pluswerk\PlusMinify\Middleware\MinifyMiddleware::class,
+ 'target' => MinifyMiddleware::class,
// in the request direction it is after these middlewares:
// but in response direction it is before these middlewares:
'after' => [
diff --git a/composer.json b/composer.json
index 95b86dd..3bf2ca8 100644
--- a/composer.json
+++ b/composer.json
@@ -17,28 +17,25 @@
"typo3/cms-composer-installers": true,
"typo3/class-alias-loader": true,
"phpro/grumphp": true,
- "pluswerk/grumphp-config": true
+ "pluswerk/grumphp-config": true,
+ "phpstan/extension-installer": true
},
"sort-packages": true
},
"extra" : {
- "typo3/cms" : {
- "extension-key" : "minify"
- },
- "pluswerk/grumphp-config": {
- "auto-setting": true
- },
- "grumphp": {
- "config-default-path": "vendor/pluswerk/grumphp-config/grumphp.yml"
+ "typo3/cms": {
+ "extension-key": "minify"
}
},
"require" : {
- "php": "~7.4 || ~8.0 || ~8.1",
+ "php": "~8.0 || ~8.1 || ~8.2",
"composer-runtime-api": "^2",
- "typo3/cms-core": "^10.4 || ^11.5",
+ "typo3/cms-core": "^11.5 || ^12.4",
"voku/html-min": "^4"
},
"require-dev": {
- "pluswerk/grumphp-config": "^5"
+ "pluswerk/grumphp-config": "^6",
+ "saschaegerer/phpstan-typo3": "^1.8.2",
+ "ssch/typo3-rector": "^1.1.3"
}
}
diff --git a/ext_emconf.php b/ext_emconf.php
index bbedd1a..c181fbe 100644
--- a/ext_emconf.php
+++ b/ext_emconf.php
@@ -1,5 +1,7 @@
'+Pluswerk: Minify',
@@ -8,14 +10,10 @@
'author' => 'Stefan Lamm',
'author_email' => 'stefan.lamm@pluswerk.ag',
'state' => 'stable',
- 'internal' => '',
- 'uploadfolder' => '0',
- 'createDirs' => '',
- 'clearCacheOnLoad' => false,
- 'version' => \Composer\InstalledVersions::getPrettyVersion('pluswerk/minify'),
+ 'version' => InstalledVersions::getPrettyVersion('pluswerk/minify'),
'constraints' => [
'depends' => [
- 'typo3' => '10.4.0 - 11.99.99',
+ 'typo3' => '10.4.0 - 12.99.99',
],
'conflicts' => [],
'suggests' => [],
diff --git a/grumphp.yml b/grumphp.yml
new file mode 100644
index 0000000..3a60a5a
--- /dev/null
+++ b/grumphp.yml
@@ -0,0 +1,16 @@
+imports:
+ - { resource: vendor/pluswerk/grumphp-config/grumphp.yml }
+parameters:
+ convention.process_timeout: 240
+ convention.security_checker_blocking: true
+ convention.jsonlint_ignore_pattern: { }
+ convention.xmllint_ignore_pattern: { }
+ convention.yamllint_ignore_pattern: { }
+ convention.phpcslint_ignore_pattern: { }
+ convention.phpcslint_exclude: { }
+ convention.xlifflint_ignore_pattern: { }
+ convention.rector_ignore_pattern: { }
+ convention.rector_enabled: true
+ convention.rector_config: rector.php
+ convention.rector_clear-cache: false
+ convention.phpstan_level: null
diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon
new file mode 100644
index 0000000..aab4991
--- /dev/null
+++ b/phpstan-baseline.neon
@@ -0,0 +1,2 @@
+parameters:
+ ignoreErrors: []
diff --git a/phpstan.neon b/phpstan.neon
new file mode 100644
index 0000000..e178ba6
--- /dev/null
+++ b/phpstan.neon
@@ -0,0 +1,7 @@
+includes:
+ - phpstan-baseline.neon
+ - vendor/andersundsehr/phpstan-git-files/extension.php
+
+parameters:
+ level: 8
+ reportUnmatchedIgnoredErrors: false
diff --git a/rector.php b/rector.php
new file mode 100644
index 0000000..2da6bd0
--- /dev/null
+++ b/rector.php
@@ -0,0 +1,42 @@
+parallel();
+ $rectorConfig->importNames();
+ $rectorConfig->importShortClasses();
+ $rectorConfig->cacheClass(FileCacheStorage::class);
+ $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$'")))
+ );
+
+ // define sets of rules
+ $rectorConfig->sets(
+ [
+ ...RectorSettings::sets(true),
+ ...RectorSettings::setsTypo3(false),
+ ]
+ );
+
+ // remove some rules
+ // ignore some files
+ $rectorConfig->skip(
+ [
+ ...RectorSettings::skip(),
+ ...RectorSettings::skipTypo3(),
+
+ /**
+ * rector should not touch these files
+ */
+ //__DIR__ . '/src/Example',
+ //__DIR__ . '/src/Example.php',
+ ]
+ );
+};