Skip to content

Commit

Permalink
feat: TYPO3 v12 compatibility (#85)
Browse files Browse the repository at this point in the history
* chore: prepare for TYPO3_v12

* chore: prepare for TYPO3_v12 - update github actions

* chore: prepare for TYPO3_v12 - update github actions - fix typo

* chore: prepare for TYPO3_v12 - update github actions - fix path to phpunit

* chore: v12 only

* chore: v12 only, code-style

* chore: code-style

* docs: readme, year update

* docs: more badges

* chore: ecs config

* chore: minor adjustment

* chore: PHP 8.4 experimental

* Revert "chore: PHP 8.4 experimental"

This reverts commit 4ab6a71.

* chore: fix javascript include

* chore: cleanup the code

---------

Co-authored-by: thomas.layh <[email protected]>
Co-authored-by: Jürgen Kußmann <[email protected]>
  • Loading branch information
3 people authored Jul 16, 2024
1 parent 102d561 commit 7ec19f2
Show file tree
Hide file tree
Showing 50 changed files with 176 additions and 387 deletions.
11 changes: 0 additions & 11 deletions .code-quality/ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@

declare(strict_types=1);

use PhpCsFixer\Fixer\FunctionNotation\FunctionTypehintSpaceFixer;
use PhpCsFixer\Fixer\Operator\NotOperatorWithSuccessorSpaceFixer;
use PhpCsFixer\Fixer\Phpdoc\GeneralPhpdocAnnotationRemoveFixer;
use PhpCsFixer\Fixer\Strict\DeclareStrictTypesFixer;
use Rector\Naming\Rector\ClassMethod\RenameParamToMatchTypeRector;
use Symplify\CodingStandard\Fixer\ArrayNotation\ArrayListItemNewlineFixer;
use Symplify\CodingStandard\Fixer\ArrayNotation\ArrayOpenerAndCloserNewlineFixer;
use Symplify\CodingStandard\Fixer\LineLength\DocBlockLineLengthFixer;
use Symplify\CodingStandard\Fixer\LineLength\LineLengthFixer;
use Symplify\EasyCodingStandard\Config\ECSConfig;
use Symplify\EasyCodingStandard\ValueObject\Option;
Expand All @@ -36,17 +33,9 @@
)
->withSkip([
NotOperatorWithSuccessorSpaceFixer::class => null,
DocBlockLineLengthFixer::class => null,
ArrayListItemNewlineFixer::class => null,
ArrayOpenerAndCloserNewlineFixer::class => null,
FunctionTypehintSpaceFixer::class => [
__DIR__ . '/../Tests/Unit/TYPO3/AdditionalResponseHeadersTest.php',
__DIR__ . '/../Classes/TYPO3/Hooks/ClearCacheMenuHook.php',
__DIR__ . '/../Classes/TYPO3/Configuration/ExtensionConfiguration.php',
],
DeclareStrictTypesFixer::class => null,
GeneralPhpdocAnnotationRemoveFixer::class => null,
RenameParamToMatchTypeRector::class => null,

])
->withSpacing(OPTION::INDENTATION_SPACES, "\n");
60 changes: 0 additions & 60 deletions .code-quality/ecs_old.php

This file was deleted.

28 changes: 8 additions & 20 deletions .code-quality/phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,6 @@ parameters:
message: "#^Method Aoe\\\\Restler\\\\System\\\\Restler\\\\RestlerExtended\\:\\:postCall\\(\\) has no return type specified\\.$#"
count: 1
path: ../Classes/System/Restler/RestlerExtended.php
-
message: "#^Dead catch \\- Error is never thrown in the try block\\.$#"
count: 1
path: ../Classes/System/Restler/Builder.php
-
message: "#^Anonymous variable in a `\\$request\\-\\>getAttribute\\('site'\\)\\-\\>\\.\\.\\.\\(\\)` method call can lead to false dead methods\\. Make sure the variable type is known$#"
count: 1
path: ../Classes/System/Dispatcher.php
-
message: "#^Anonymous variable in a `\\$request\\-\\>getAttribute\\('site'\\)\\-\\>getBase\\(\\)\\-\\>\\.\\.\\.\\(\\)` method call can lead to false dead methods\\. Make sure the variable type is known$#"
count: 1
path: ../Classes/System/Dispatcher.php
-
message: "#^Anonymous variable in a `\\$this\\-\\>request\\-\\>getAttribute\\('site'\\)\\-\\>\\.\\.\\.\\(\\)` method call can lead to false dead methods\\. Make sure the variable type is known$#"
count: 1
path: ../Classes/System/Restler/RestlerExtended.php
-
message: "#^Anonymous variable in a `\\$this\\-\\>request\\-\\>getAttribute\\('site'\\)\\-\\>getBase\\(\\)\\-\\>\\.\\.\\.\\(\\)` method call can lead to false dead methods\\. Make sure the variable type is known$#"
count: 1
path: ../Classes/System/Restler/RestlerExtended.php
-
message: "#^Method Aoe\\\\Restler\\\\System\\\\RestApi\\\\RestApiRequest\\:\\:composeHeaders\\(\\) has no return type specified\\.$#"
count: 1
Expand All @@ -64,3 +44,11 @@ parameters:
message: "#^Comparison operation \"\\>\" between int\\<1, max\\> and 0 is always true\\.$#"
count: 1
path: ../Classes/System/Restler/Format/HalJsonFormat.php
-
message: "#^Interface (.*) has only single implementer. Consider using the class directly as there is no point in using the interface.$#"
count: 1
path: ../Classes/System/Restler/ConfigurationInterface.php
-
message: "#^Unable to resolve the template type T in call to method static method (.*)$#"
count: 2
path: ../Classes/System/Restler/Builder.php
5 changes: 3 additions & 2 deletions .code-quality/phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ parameters:
paths:
- "../Classes/"

ignoreErrors:
- identifier: missingType.iterableValue

inferPrivatePropertyTypeFromConstructor: true
checkMissingIterableValueType: false
checkGenericClassInNonGenericObjectType: false
checkAlwaysTrueCheckTypeFunctionCall: false
checkAlwaysTrueStrictComparison: false

Expand Down
30 changes: 0 additions & 30 deletions .code-quality/rector-8_0.php

This file was deleted.

4 changes: 0 additions & 4 deletions .code-quality/rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@
use Rector\CodeQuality\Rector\Identical\FlipTypeControlToUseExclusiveTypeRector;
use Rector\Config\RectorConfig;
use Rector\DeadCode\Rector\Property\RemoveUnusedPrivatePropertyRector;
use Rector\EarlyReturn\Rector\If_\ChangeAndIfToEarlyReturnRector;
use Rector\PHPUnit\CodeQuality\Rector\Class_\YieldDataProviderRector;
use Rector\PHPUnit\CodeQuality\Rector\MethodCall\AssertEqualsToSameRector;
use Rector\Set\ValueObject\SetList;
use Rector\PHPUnit\Set\PHPUnitSetList;
use Rector\Privatization\Rector\Class_\FinalizeClassesWithoutChildrenRector;
use Rector\TypeDeclaration\Rector\ClassMethod\AddMethodCallBasedStrictParamTypeRector;
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictSetUpRector;

Expand All @@ -35,8 +33,6 @@
PHPUnitSetList::PHPUNIT_CODE_QUALITY
])
->withSkip([
FinalizeClassesWithoutChildrenRector::class,
ChangeAndIfToEarlyReturnRector::class,
TypedPropertyFromStrictSetUpRector::class,
AddMethodCallBasedStrictParamTypeRector::class,
FlipTypeControlToUseExclusiveTypeRector::class,
Expand Down
37 changes: 11 additions & 26 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
name: Tests

on:
push:
branches:
- '**'
- '!TYPO3_V10'
- '!TYPO3V8'
- '!TYPO3V9'
pull_request:
branches:
- '**'
- '!TYPO3_V10'
- '!TYPO3V8'
- '!TYPO3V9'
on: [ push, pull_request ]

jobs:
build:
Expand All @@ -22,13 +10,10 @@ jobs:
strategy:
fail-fast: false
matrix:
typo3: [ ^11.5 ]
php: [ '7.4', '8.0', '8.1', '8.2', '8.3' ]
typo3: [ ^12.4 ]
php: [ '8.1', '8.2', '8.3' ]
experimental: [false]
include:
- typo3: ^11.5
php: '8.1'
experimental: true


continue-on-error: ${{ matrix.experimental }}

Expand All @@ -55,29 +40,29 @@ jobs:
- name: Validate composer.json and composer.lock
run: composer validate

- name: Install dependencies with nimut/typo3-complete:${{ matrix.typo3 }}
- name: Install dependencies with typo3/cms-core:${{ matrix.typo3 }}
run: |
composer require --dev nimut/typo3-complete:${{ matrix.typo3 }} --no-progress
composer require --dev typo3/cms-core:${{ matrix.typo3 }} --no-progress
git checkout composer.json
ln -nfs .Build/vendor/typo3/cms/typo3 typo3
- name: Lint PHP
run: find . -name \*.php ! -path "./.Build/*" ! -path "./scripts/*" ! -path "./typo3_src/*" | parallel --gnu php -d display_errors=stderr -l {} > /dev/null \;

- name: Unit Tests without coverage
if: matrix.typo3 != '^11.5' || matrix.php != '8.3'
if: matrix.typo3 != '^12.4' || matrix.php != '8.3'
run: |
export "UNIT_XML"=.Build/vendor/typo3/testing-framework/Resources/Core/Build/UnitTests.xml
export "UNIT_XML"=Tests/phpunit.xml
.Build/bin/phpunit --colors -c $UNIT_XML Tests/Unit
- name: Unit Tests with coverage
if: matrix.typo3 == '^11.5' && matrix.php == '8.3'
if: matrix.typo3 == '^12.4' && matrix.php == '8.3'
run: |
export "UNIT_XML"=.Build/vendor/typo3/testing-framework/Resources/Core/Build/UnitTests-v10.xml
export "UNIT_XML"=Tests/phpunit.xml
.Build/bin/phpunit --coverage-filter Classes --coverage-clover=unittest-coverage.clover --colors -c $UNIT_XML Tests/Unit/
- name: Upload coverage results to Scrutinizer
uses: sudo-bot/action-scrutinizer@latest
if: matrix.typo3 == '^11.5' && matrix.php == '8.3'
if: matrix.typo3 == '^12.4' && matrix.php == '8.3'
with:
cli-args: "--format=php-clover .Build/reports/php_all_tests/coverage_clover.xml --revision=${{ github.event.pull_request.head.sha || github.sha }}"
3 changes: 3 additions & 0 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
build:
nodes:
analysis:
image: default-bionic
environment:
php: 8.3.0
tests:
override:
- php-scrutinizer-run
Expand Down
2 changes: 1 addition & 1 deletion Classes/Configuration/ExtensionConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/***************************************************************
* Copyright notice
*
* (c) 2021 AOE GmbH <[email protected]>
* (c) 2024 AOE GmbH <[email protected]>
*
* All rights reserved
*
Expand Down
10 changes: 4 additions & 6 deletions Classes/Controller/BeUserAuthenticationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/***************************************************************
* Copyright notice
*
* (c) 2021 AOE GmbH <[email protected]>
* (c) 2024 AOE GmbH <[email protected]>
*
* All rights reserved
*
Expand Down Expand Up @@ -63,11 +63,9 @@ class BeUserAuthenticationController implements iAuthenticate
*/
public $restler;

private Loader $typo3Loader;

public function __construct(Loader $typo3Loader)
{
$this->typo3Loader = $typo3Loader;
public function __construct(
private readonly Loader $typo3Loader
) {
$this->restler = Scope::get('Restler');
}

Expand Down
2 changes: 1 addition & 1 deletion Classes/Controller/ExplorerAuthenticationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/***************************************************************
* Copyright notice
*
* (c) 2021 AOE GmbH <[email protected]>
* (c) 2024 AOE GmbH <[email protected]>
*
* All rights reserved
*
Expand Down
10 changes: 4 additions & 6 deletions Classes/Controller/FeUserAuthenticationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/***************************************************************
* Copyright notice
*
* (c) 2021 AOE GmbH <[email protected]>
* (c) 2024 AOE GmbH <[email protected]>
*
* All rights reserved
*
Expand Down Expand Up @@ -89,11 +89,9 @@ class FeUserAuthenticationController implements iAuthenticate
*/
public $restler;

private Loader $typo3Loader;

public function __construct(Loader $typo3Loader)
{
$this->typo3Loader = $typo3Loader;
public function __construct(
private readonly Loader $typo3Loader
) {
$this->restler = Scope::get('Restler');
}

Expand Down
12 changes: 10 additions & 2 deletions Classes/System/Dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/***************************************************************
* Copyright notice
*
* (c) 2015 AOE GmbH <[email protected]>
* (c) 2024 AOE GmbH <[email protected]>
*
* All rights reserved
*
Expand Down Expand Up @@ -83,7 +83,15 @@ protected function extractSiteUrl(ServerRequestInterface $request): string
}

if ($siteBasePath) {
return '/' . rtrim(preg_replace('%^' . preg_quote($siteBasePath, '%') . '%', '', $request->getUri()->getPath()), '/');
return '/' . rtrim(
(string) preg_replace(
'%^' . preg_quote((string) $siteBasePath, '%') . '%',
'',
$request->getUri()
->getPath()
),
'/'
);
}

return $request->getUri()
Expand Down
Loading

0 comments on commit 7ec19f2

Please sign in to comment.