Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
- 8.2
- 8.3
- 8.4
- 8.5
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down Expand Up @@ -112,6 +113,8 @@ jobs:
typo3-version: '^13.4'
- php-version: '8.4'
typo3-version: '^13.4'
- php-version: '8.5'
typo3-version: '^13.4'
steps:
- uses: actions/checkout@v3

Expand Down Expand Up @@ -143,6 +146,8 @@ jobs:
typo3-version: '^13.4'
- php-version: '8.4'
typo3-version: '^13.4'
- php-version: '8.5'
typo3-version: '^13.4'
steps:
- uses: actions/checkout@v3

Expand Down
7 changes: 5 additions & 2 deletions Classes/Domain/Model/MarkerCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,13 @@ public function get(string $markerKey): Marker
}

/**
* @return mixed[]
* @return list<string>
*/
public function getMarkerKeys(): array
{
return array_keys($this->data);
return array_map(
static fn (Marker $marker): string => $marker->getMarkerWithBrackets(),
array_values($this->data),
);
}
}
1 change: 0 additions & 1 deletion Classes/EventListener/ContentProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

use Sinso\Variables\Service\VariablesService;
use TYPO3\CMS\Core\Attribute\AsEventListener;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Frontend\Event\AfterCacheableContentIsGeneratedEvent;

class ContentProcessor
Expand Down
4 changes: 2 additions & 2 deletions Classes/EventListener/ModifyCacheLifetime.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
use TYPO3\CMS\Core\Attribute\AsEventListener;
use TYPO3\CMS\Frontend\Event\ModifyCacheLifetimeForPageEvent;

final class ModifyCacheLifetime
final readonly class ModifyCacheLifetime
{
public function __construct(
private readonly VariablesService $variablesService,
private VariablesService $variablesService,
) {
}

Expand Down
11 changes: 3 additions & 8 deletions Classes/Service/VariablesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ private function replaceMarkersInText(
MarkerCollection $markerCollection,
string &$text
): void {
$markerRegexp = '/(' . implode('|', array_map('preg_quote', $markerCollection->getMarkerKeys())) . ')/';
$markerRegexp = '/(' . implode('|', array_map(preg_quote(...), $markerCollection->getMarkerKeys())) . ')/';

$loops = 0;

Expand Down Expand Up @@ -128,9 +128,7 @@ private function replaceMarkersInText(
private function getMarkers(
ServerRequestInterface $request,
): MarkerCollection {
$pids = array_map(static function ($page) {
return $page['uid'];
}, $request->getAttribute('frontend.page.information')?->getRootLine() ?? []);
$pids = array_map(static fn ($page) => $page['uid'], $request->getAttribute('frontend.page.information')?->getRootLine() ?? []);

$storagePid = $this->getStoragePidFromTypoScript($request);
if (is_int($storagePid)) {
Expand Down Expand Up @@ -183,10 +181,7 @@ private function setCacheTags(
return;
}

$cacheTags = array_map(function (string $tag): CacheTag {
return new CacheTag($tag);
}, $this->cacheTags->toArray());

$cacheTags = array_map(fn (string $tag): CacheTag => new CacheTag($tag), $this->cacheTags->toArray());
$cacheCollector->addCacheTags(...$cacheTags);
}

Expand Down
1 change: 0 additions & 1 deletion Configuration/TCA/tx_variables_marker.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
'starttime' => 'starttime',
'endtime' => 'endtime',
],
'searchFields' => 'marker,replacement',
'iconfile' => 'EXT:variables/Resources/Public/Icons/tx_variables_marker.png'
],
'types' => [
Expand Down
10 changes: 0 additions & 10 deletions Tests/Functional/Caching/AdjustsPageCacheLifetimeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,9 @@
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use Prophecy\Argument;
use Prophecy\PhpUnit\ProphecyTrait;
use Sinso\Variables\EventListener\ModifyCacheLifetime;
use Sinso\Variables\Hooks\DataHandler;
use Sinso\Variables\Service\VariablesService;
use Sinso\Variables\Tests\Functional\Frontend\AbstractProcessesMarkersTestCase;
use TYPO3\CMS\Core\Cache\CacheManager;
use TYPO3\CMS\Core\Context\Context;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\DataHandling\DataHandler as Typo3DataHandler;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Frontend\Cache\CacheLifetimeCalculator;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;

#[CoversClass(ModifyCacheLifetime::class)]
#[CoversClass(VariablesService::class)]
Expand Down
3 changes: 0 additions & 3 deletions Tests/Functional/Caching/FlushViaDataHandlerChangesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,10 @@
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use Prophecy\Argument;
use Prophecy\PhpUnit\ProphecyTrait;
use Sinso\Variables\Hooks\DataHandler;
use TYPO3\CMS\Core\Cache\CacheManager;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\DataHandling\DataHandler as Typo3DataHandler;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;

#[CoversClass(DataHandler::class)]
Expand Down
2 changes: 1 addition & 1 deletion Tests/Unit/Domain/Model/MarkerCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function returnsType(): void
{
$subject = new MarkerCollection();

self::assertSame('Sinso\Variables\Domain\Model\Marker', $subject->getType());
self::assertSame(\Sinso\Variables\Domain\Model\Marker::class, $subject->getType());
}

#[Test]
Expand Down
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@
}
},
"require": {
"php": ">= 8.1 < 8.5",
"php": ">= 8.2 < 8.6",
"ramsey/collection": "^2.0",
"typo3/cms-core": "^13.4"
},
"require-dev": {
"rector/rector": "^0.12.23",
"rector/rector": "^2.6",
"typo3/testing-framework": "^8.0",
"symplify/easy-coding-standard": "^12.3",
"phpstan/extension-installer": "^1.4",
"saschaegerer/phpstan-typo3": "^1.10"
"saschaegerer/phpstan-typo3": "^2.1",
"ssch/typo3-rector": "^3.16"
},
"extra": {
"typo3/cms": {
Expand Down
1 change: 0 additions & 1 deletion ext_localconf.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php

use Sinso\Variables\Hooks\ContentProcessor;
use Sinso\Variables\Hooks\DataHandler;

defined('TYPO3') || die();
Expand Down
159 changes: 156 additions & 3 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,16 +1,169 @@
parameters:
ignoreErrors:
-
message: "#^Cannot cast mixed to int\\.$#"
message: '#^Property TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController\:\:\$content \(string\) does not accept mixed\.$#'
identifier: assign.propertyType
count: 1
path: Classes/EventListener/ContentProcessor.php

-
message: '#^Parameter \$key of class Sinso\\Variables\\Domain\\Model\\Marker constructor expects string, mixed given\.$#'
identifier: argument.type
count: 1
path: Classes/Hooks/DataHandler.php

-
message: '#^Possibly invalid array key type float\|int\|string\.$#'
identifier: offsetAccess.invalidOffset
count: 1
path: Classes/Hooks/DataHandler.php

-
message: '#^Binary operation "\-" between int and mixed results in an error\.$#'
identifier: binaryOp.invalid
count: 1
path: Classes/Service/VariablesService.php

-
message: '#^Binary operation "\." between mixed and '' does not implement '' results in an error\.$#'
identifier: binaryOp.invalid
count: 1
path: Classes/Service/VariablesService.php

-
message: '#^Cannot access offset ''EXTCONF'' on mixed\.$#'
identifier: offsetAccess.nonOffsetAccessible
count: 2
path: Classes/Service/VariablesService.php

-
message: '#^Cannot access offset ''ctrl'' on mixed\.$#'
identifier: offsetAccess.nonOffsetAccessible
count: 1
path: Classes/Service/VariablesService.php

-
message: '#^Cannot access offset ''enablecolumns'' on mixed\.$#'
identifier: offsetAccess.nonOffsetAccessible
count: 1
path: Classes/Service/VariablesService.php

-
message: '#^Cannot access offset ''endtime''\|''starttime'' on mixed\.$#'
identifier: offsetAccess.nonOffsetAccessible
count: 1
path: Classes/Service/VariablesService.php

-
message: '#^Cannot access offset ''marker'' on mixed\.$#'
identifier: offsetAccess.nonOffsetAccessible
count: 1
path: Classes/Service/VariablesService.php

-
message: '#^Cannot access offset ''postProcessMarkers'' on mixed\.$#'
identifier: offsetAccess.nonOffsetAccessible
count: 1
path: Classes/Service/VariablesService.php

-
message: '#^Cannot access offset ''replacement'' on mixed\.$#'
identifier: offsetAccess.nonOffsetAccessible
count: 1
path: Classes/Service/VariablesService.php

-
message: '#^Cannot access offset ''tx_variables_marker'' on mixed\.$#'
identifier: offsetAccess.nonOffsetAccessible
count: 1
path: Classes/Service/VariablesService.php

-
message: '#^Cannot access offset ''uid'' on mixed\.$#'
identifier: offsetAccess.nonOffsetAccessible
count: 2
path: Classes/Service/VariablesService.php

-
message: '#^Cannot access offset ''variables'' on mixed\.$#'
identifier: offsetAccess.nonOffsetAccessible
count: 2
path: Classes/Service/VariablesService.php

-
message: '#^Cannot cast mixed to int\.$#'
identifier: cast.int
count: 3
path: Classes/Service/VariablesService.php

-
message: "#^Parameter \\#1 \\$callback of function array_map expects \\(callable\\(mixed\\)\\: mixed\\)\\|null, 'preg_quote' given\\.$#"
message: '#^Parameter \#1 \$className of static method TYPO3\\CMS\\Core\\Utility\\GeneralUtility\:\:makeInstance\(\) expects class\-string\<object\>, mixed given\.$#'
identifier: argument.type
count: 1
path: Classes/Service/VariablesService.php

-
message: '#^Parameter \#1 \$fieldName of method TYPO3\\CMS\\Core\\Database\\Query\\Expression\\ExpressionBuilder\:\:gt\(\) expects string, mixed given\.$#'
identifier: argument.type
count: 1
path: Classes/Service/VariablesService.php

-
message: '#^Parameter \#1 \$fieldName of method TYPO3\\CMS\\Core\\Database\\Query\\Expression\\ExpressionBuilder\:\:lte\(\) expects string, mixed given\.$#'
identifier: argument.type
count: 1
path: Classes/Service/VariablesService.php

-
message: '#^Parameter \#1 \$identifier of method TYPO3\\CMS\\Core\\Database\\Query\\QueryBuilder\:\:quoteIdentifier\(\) expects string, mixed given\.$#'
identifier: argument.type
count: 2
path: Classes/Service/VariablesService.php

-
message: '#^Parameter \#2 \$array of function implode expects array\<string\>, array given\.$#'
identifier: argument.type
count: 1
path: Classes/Service/VariablesService.php

-
message: "#^Unable to resolve the template type T in call to method static method TYPO3\\\\CMS\\\\Core\\\\Utility\\\\GeneralUtility\\:\\:makeInstance\\(\\)$#"
message: '#^Parameter \$key of class Sinso\\Variables\\Domain\\Model\\Marker constructor expects string, mixed given\.$#'
identifier: argument.type
count: 1
path: Classes/Service/VariablesService.php

-
message: '#^Parameter \$replacement of class Sinso\\Variables\\Domain\\Model\\Marker constructor expects string, mixed given\.$#'
identifier: argument.type
count: 1
path: Classes/Service/VariablesService.php

-
message: '#^Parameter \$uid of class Sinso\\Variables\\Domain\\Model\\Marker constructor expects int, mixed given\.$#'
identifier: argument.type
count: 1
path: Classes/Service/VariablesService.php

-
message: '#^Parameter &\$text by\-ref type of method Sinso\\Variables\\Service\\VariablesService\:\:replaceMarkersInText\(\) expects string, string\|null given\.$#'
identifier: parameterByRef.type
count: 1
path: Classes/Service/VariablesService.php

-
message: '#^Unable to resolve the template type T in call to static method TYPO3\\CMS\\Core\\Utility\\GeneralUtility\:\:makeInstance\(\)$#'
identifier: argument.templateType
count: 1
path: Classes/Service/VariablesService.php

-
message: '#^Parameter \#1 \$params of method Sinso\\Variables\\Hooks\\DataHandler\:\:clearCachePostProc\(\) expects array\<string, mixed\>, array\<mixed\> given\.$#'
identifier: argument.type
count: 1
path: Tests/Functional/Caching/FlushViaDataHandlerChangesTest.php

-
message: '#^Property TYPO3\\TestingFramework\\Core\\Functional\\FunctionalTestCase\:\:\$configurationToUseInTestInstance \(array\<string, mixed\>\) does not accept array\.$#'
identifier: assign.propertyType
count: 1
path: Tests/Functional/Frontend/AbstractProcessesMarkersTestCase.php
Loading
Loading