Skip to content

Commit

Permalink
TASK: Make TYPO3 13 compatiblity
Browse files Browse the repository at this point in the history
  • Loading branch information
sabbelasichon committed Jan 14, 2025
1 parent a56123f commit 6177782
Show file tree
Hide file tree
Showing 12 changed files with 95 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/php_linter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: [ 7.4, 8.0, 8.1 ]
php-versions: [ 8.1, 8.2, 8.3, 8.4 ]
steps:
- uses: actions/checkout@v4

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/phpstan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:

- uses: shivammathur/setup-php@v2
with:
php-version: 8.0
php-version: 8.1
coverage: none
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ jobs:
max-parallel: 2
matrix:
typo3-versions:
- { typo3: ^10.4, testing: ^6, php: 7.4 }
- { typo3: ^11.5, testing: ^7, php: 8.0 }
- { typo3: ^12.4, testing: ^7, php: 8.1 }
- { typo3: ^13.4, testing: ^8, php: 8.2 }

name: "Run tests with PHP ${{ matrix.typo3-versions.php }}
using TYPO3 ${{ matrix.typo3-versions.typo3 }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/weekly_pull_requests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
-
uses: shivammathur/setup-php@v2
with:
php-version: 8.0
php-version: 8.1
coverage: none

- uses: "ramsey/composer-install@v2"
Expand Down
6 changes: 3 additions & 3 deletions Classes/Adapter/Psr16Adapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function __construct(FrontendInterface $cache)
$this->cache = $cache;
}

public function get($key, $default = null)
public function get($key, $default = null): mixed
{
$result = $this->cache->get($this->hash($key));

Expand All @@ -34,7 +34,7 @@ public function get($key, $default = null)
return $result;
}

public function set($key, $value, $ttl = null)
public function set($key, $value, $ttl = null): bool
{
if ($ttl instanceof \DateInterval) {
$lifetime = $this->calculateLifetimeFromDateInterval($ttl);
Expand All @@ -59,7 +59,7 @@ public function clear(): bool
return true;
}

public function getMultiple($keys, $default = null): array
public function getMultiple($keys, $default = null): iterable
{
$result = [];
foreach ($keys as $key) {
Expand Down
3 changes: 0 additions & 3 deletions Classes/Adapter/Psr6Adapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ public function getItem($key): CacheItemInterface
return new CacheItem($key, $data, true);
}

/**
* @return iterable<CacheItemInterface>
*/
public function getItems(array $keys = []): iterable
{
$cacheItems = [];
Expand Down
13 changes: 5 additions & 8 deletions Classes/CacheItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ final class CacheItem implements CacheItemInterface

private ?int $expiry = null;

/**
* @param mixed $data
*/
public function __construct(string $key, $data, bool $isHit)
public function __construct(string $key, mixed $data, bool $isHit)
{
$this->key = $key;
$this->value = $data;
Expand All @@ -42,7 +39,7 @@ public function getKey(): string
return $this->key;
}

public function get()
public function get(): mixed
{
return $this->value;
}
Expand All @@ -52,14 +49,14 @@ public function isHit(): bool
return $this->isHit;
}

public function set($value): CacheItemInterface
public function set($value): static
{
$this->value = $value;

return $this;
}

public function expiresAt($expiration): CacheItemInterface
public function expiresAt($expiration): static
{
if ($expiration === null) {
$this->expiry = null;
Expand All @@ -75,7 +72,7 @@ public function expiresAt($expiration): CacheItemInterface
return $this;
}

public function expiresAfter($time): CacheItemInterface
public function expiresAfter($time): static
{
if ($time === null) {
$this->expiry = null;
Expand Down
47 changes: 38 additions & 9 deletions Tests/Build/FunctionalTests.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,42 @@
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="true" bootstrap="../../.Build/vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTestsBootstrap.php" colors="true" processIsolation="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory>../../Classes/</directory>
</include>
</coverage>
<!--
Boilerplate for a functional test suite setup.
This file is loosely maintained within TYPO3 testing-framework, extensions
are encouraged to not use it directly, but to copy it to an own place,
for instance Build/FunctionalTests.xml.
Note FunctionalTestsBootstrap.php should be copied along the way.
Functional tests should extend \TYPO3\TestingFramework\Core\Tests\FunctionalTestCase,
take a look at this class for further documentation on how to run the suite.
TYPO3 CMS functional test suite also needs phpunit bootstrap code, the
file is located next to this .xml as FunctionalTestsBootstrap.php
-->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd"
backupGlobals="true"
beStrictAboutTestsThatDoNotTestAnything="false"
bootstrap="FunctionalTestsBootstrap.php"
cacheDirectory=".phpunit.cache"
cacheResult="false"
colors="true"
displayDetailsOnTestsThatTriggerDeprecations="true"
displayDetailsOnTestsThatTriggerErrors="true"
displayDetailsOnTestsThatTriggerNotices="true"
displayDetailsOnTestsThatTriggerWarnings="true"
failOnDeprecation="true"
failOnNotice="true"
failOnRisky="true"
failOnWarning="true"
>
<testsuites>
<testsuite name="typo3_psr6_cache_adapter tests">
<directory>../../Tests/Functional/</directory>
<testsuite name="Functional tests">
<directory>./../Functional/</directory>
</testsuite>
</testsuites>
</phpunit>
<php>
<ini name="display_errors" value="1"/>
<env name="TYPO3_CONTEXT" value="Testing"/>
</php>
</phpunit>
33 changes: 33 additions & 0 deletions Tests/Build/FunctionalTestsBootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/

use TYPO3\TestingFramework\Core\Testbase;

/**
* Boilerplate for a functional test phpunit boostrap file.
*
* This file is loosely maintained within TYPO3 testing-framework, extensions
* are encouraged to not use it directly, but to copy it to an own place,
* usually in parallel to a FunctionalTests.xml file.
*
* This file is defined in FunctionalTests.xml and called by phpunit
* before instantiating the test suites.
*/
(static function () {
$testbase = new Testbase();
$testbase->defineOriginalRootPath();
$testbase->createDirectory(ORIGINAL_ROOT . 'typo3temp/var/tests');
$testbase->createDirectory(ORIGINAL_ROOT . 'typo3temp/var/transient');
})();
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* LICENSE.txt file that was distributed with this source code.
*/

defined('TYPO3_MODE') || die('Access denied.');
defined('TYPO3') || die('Access denied.');

if (! isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['typo3_psr_cache_adapter_test']) || ! is_array(
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['typo3_psr_cache_adapter_test']
Expand Down
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
}
],
"require": {
"php": "^7.4 || ^8.0",
"typo3/cms-core": "^10.4 || ^11.4 || ^12.4",
"psr/cache": "^1.0 || ^2.0",
"psr/simple-cache": "^1.0"
"php": "^8.1",
"typo3/cms-core": "^12.4 || ^13.4",
"psr/cache": "^2.0 || ^3.0",
"psr/simple-cache": "^2.0 || ^3.0"
},
"require-dev": {
"symplify/easy-coding-standard": "^12.0",
"typo3/testing-framework": "^6.16 || ^7.0",
"typo3/testing-framework": "^7.0 || ^8.0",
"php-parallel-lint/php-parallel-lint": "^1.3",
"phpstan/phpstan": "^1.8",
"saschaegerer/phpstan-typo3": "^1.8",
Expand Down Expand Up @@ -76,7 +76,7 @@
},
"extra": {
"branch-alias": {
"dev-main": "1.0.x-dev"
"dev-main": "2.0.x-dev"
},
"typo3/cms": {
"extension-key": "typo3_psr_cache_adapter",
Expand Down
7 changes: 5 additions & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ parameters:
- Classes
- Tests
- Configuration
checkMissingIterableValueType: false
ignoreErrors:
-
identifier: missingType.iterableValue
excludePaths:
analyse:
- Tests/Functional/Fixtures/Extensions/*
- Tests/Functional/Fixtures/Extensions/*
- Tests/Build/*

0 comments on commit 6177782

Please sign in to comment.