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
89 changes: 89 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: CI with Composer scripts
on:
push:
paths:
- '**.php'
- '.github/workflows/ci.yml'
- 'Build/phpunit/FunctionalTests.xml'
- 'Build/phpunit/UnitTests.xml'
- 'composer.json'
branches:
- main
pull_request:

permissions:
contents: read

jobs:
php-lint:
runs-on: ubuntu-latest
timeout-minutes: 5
strategy:
fail-fast: true
matrix:
php: [8.2, 8.3, 8.4]

name: "PHP linter - ${{ matrix.php }}"

steps:
- name: "Checkout code"
uses: actions/checkout@v6

- name: "Setup PHP"
uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php }}"
coverage: none

- name: "Run PHP lint"
run: find .*.php *.php Classes Configuration -name '*.php' -print0 | xargs -r -0 -n 1 -P 4 php -l

code-quality:
runs-on: ubuntu-latest
timeout-minutes: 5
strategy:
fail-fast: true
matrix:
command:
- "composer:normalize"
- "composer:psr-verify"
- "php:ecs"
- "php:rector"
- "php:fractor"
- "php:stan"
php: [8.2]

name: "Code quality checks"

steps:
- name: "Checkout code"
uses: actions/checkout@v6

- name: "Setup PHP"
uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php }}"
coverage: none
tools: composer:v2

- name: "Show Composer version"
run: composer --version

- name: "Show the Composer configuration"
run: composer config --global --list

- name: "Cache dependencies installed with composer"
uses: actions/cache@v5
with:
key: "php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}"
path: ~/.cache/composer
restore-keys: "php${{ matrix.php }}-composer-\n"

- name: "Install Composer dependencies"
run: composer install --no-progress

- name: "List Installed Dependencies"
run: composer show -D

- name: "Run command"
run: composer ci:${{ matrix.command }}
42 changes: 0 additions & 42 deletions .github/workflows/tests.yml

This file was deleted.

11 changes: 7 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
.Build/
config/
var/
composer.lock
/.Build/
/.cache/
/.idea/
/config/
/var/
/.env
/composer.lock
98 changes: 98 additions & 0 deletions Build/ecs/ecs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<?php

declare(strict_types=1);

use PhpCsFixer\Fixer\Basic\SingleLineEmptyBodyFixer;
use PhpCsFixer\Fixer\CastNotation\CastSpacesFixer;
use PhpCsFixer\Fixer\Comment\HeaderCommentFixer;
use PhpCsFixer\Fixer\Operator\NotOperatorWithSuccessorSpaceFixer;
use PhpCsFixer\Fixer\Operator\OperatorLinebreakFixer;
use PhpCsFixer\Fixer\Operator\UnaryOperatorSpacesFixer;
use PhpCsFixer\Fixer\Phpdoc\GeneralPhpdocAnnotationRemoveFixer;
use PhpCsFixer\Fixer\Phpdoc\NoSuperfluousPhpdocTagsFixer;
use PhpCsFixer\Fixer\Strict\DeclareStrictTypesFixer;
use PhpCsFixer\Fixer\Strict\StrictComparisonFixer;
use PhpCsFixer\Fixer\Whitespace\MethodChainingIndentationFixer;
use Symplify\CodingStandard\Fixer\LineLength\LineLengthFixer;
use Symplify\CodingStandard\Fixer\Spacing\MethodChainingNewlineFixer;
use Symplify\EasyCodingStandard\Config\ECSConfig;
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;

return static function (ECSConfig $ecsConfig): void {
$ecsConfig->paths([
__DIR__ . '/../../Build',
__DIR__ . '/../../Classes',
__DIR__ . '/../../Configuration',
__DIR__ . '/../../ext_emconf.php',
]);

$ecsConfig->sets([
SetList::PSR_12,
SetList::CLEAN_CODE,
SetList::SYMPLIFY,
SetList::ARRAY,
SetList::COMMON,
SetList::COMMENTS,
SetList::CONTROL_STRUCTURES,
SetList::DOCBLOCK,
SetList::NAMESPACES,
SetList::PHPUNIT,
SetList::SPACES,
SetList::STRICT,
]);

$ecsConfig->ruleWithConfiguration(GeneralPhpdocAnnotationRemoveFixer::class, [
'annotations' => ['author', 'package', 'group'],
]);

$ecsConfig->ruleWithConfiguration(NoSuperfluousPhpdocTagsFixer::class, [
'allow_mixed' => true,
]);

$ecsConfig->ruleWithConfiguration(CastSpacesFixer::class, [
'space' => 'single',
]);

$ecsConfig->ruleWithConfiguration(HeaderCommentFixer::class, [
'header' => <<<EOF
This file is part of the TYPO3 CMS project.

(c) Christoph Lehmann, Simon Schaufelberger

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!
EOF
]);

// Rules that are not in a set
$ecsConfig->rule(OperatorLinebreakFixer::class);
$ecsConfig->rule(SingleLineEmptyBodyFixer::class);

$ecsConfig->skip([
LineLengthFixer::class,
DeclareStrictTypesFixer::class => [
__DIR__ . '/../../ext_emconf.php',
],
NotOperatorWithSuccessorSpaceFixer::class,

StrictComparisonFixer::class,

/*HeaderCommentFixer::class => [
__DIR__ . '/../ecs/ecs.php',
__DIR__ . '/../fractor/fractor.php',
__DIR__ . '/../rector/rector.php',
__DIR__ . '/../../ext_emconf.php',
],*/
HeaderCommentFixer::class,

UnaryOperatorSpacesFixer::class,
MethodChainingIndentationFixer::class,
MethodChainingNewlineFixer::class,
]);
};
32 changes: 32 additions & 0 deletions Build/fractor/fractor.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

declare(strict_types=1);

use a9f\Fractor\Configuration\FractorConfiguration;
use a9f\FractorComposerJson\ChangePackageVersionComposerJsonFractor;
use a9f\FractorComposerJson\ValueObject\PackageAndVersion;
use a9f\Typo3Fractor\Set\Typo3LevelSetList;

return FractorConfiguration::configure()
->withPaths([
__DIR__ . '/../../Classes/',
__DIR__ . '/../../Configuration/',
__DIR__ . '/../../Resources/',
__DIR__ . '/../../composer.json',
__DIR__ . '/../../ext_emconf.php',
])
->withSets([
Typo3LevelSetList::UP_TO_TYPO3_13,
])
->withConfiguredRule(
ChangePackageVersionComposerJsonFractor::class,
[
new PackageAndVersion('typo3/cms-core', '^13.4'),
new PackageAndVersion('typo3/cms-reports', '^13.4'),
// require-dev
new PackageAndVersion('typo3/cms-backend', '^13.4'),
new PackageAndVersion('typo3/cms-fluid', '^13.4'),
new PackageAndVersion('typo3/cms-frontend', '^13.4'),
new PackageAndVersion('typo3/cms-install', '^13.4'),
]
);
2 changes: 2 additions & 0 deletions Build/phpstan/phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
parameters:
ignoreErrors: []
6 changes: 6 additions & 0 deletions Build/phpstan/phpstan-constants.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

declare(strict_types=1);

define('LF', chr(10));
define('CR', chr(13));
20 changes: 20 additions & 0 deletions Build/phpstan/phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
includes:
- phpstan-baseline.neon
#- ../../.Build/vendor/friendsoftypo3/phpstan-typo3/extension.neon

parameters:
# Use local .cache dir instead of /tmp
tmpDir: ../../.cache/phpstan

parallel:
# Don't be overly greedy on machines with more CPU's to be a good neighbor especially on CI
maximumNumberOfProcesses: 5

level: 6

bootstrapFiles:
- phpstan-constants.php

paths:
- ../../Classes
- ../../Configuration
47 changes: 27 additions & 20 deletions rector.php → Build/rector/rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,44 @@
use Ssch\TYPO3Rector\Set\Typo3LevelSetList;
use Ssch\TYPO3Rector\Set\Typo3SetList;

return RectorConfig::configure()
->withPaths([
__DIR__ . '/Classes',
__DIR__ . '/ext_emconf.php',
])
->withPhpVersion(PhpVersion::PHP_82)
->withSets([
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths([
__DIR__ . '/../../Classes',
__DIR__ . '/../../ext_emconf.php',
]);
$rectorConfig->phpVersion(PhpVersion::PHP_82);
$rectorConfig->sets([
// Rector sets
LevelSetList::UP_TO_PHP_82,
SetList::CODE_QUALITY,
SetList::CODING_STYLE,
SetList::DEAD_CODE,
SetList::STRICT_BOOLEANS,
SetList::CODING_STYLE,
//SetList::STRICT_BOOLEANS,
//SetList::NAMING,
SetList::PRIVATIZATION,
SetList::TYPE_DECLARATION,
SetList::EARLY_RETURN,
SetList::INSTANCEOF,

// TYPO3 Sets
Typo3SetList::CODE_QUALITY,
Typo3SetList::GENERAL,
Typo3LevelSetList::UP_TO_TYPO3_13,
])
->withConfiguredRule(ExtEmConfRector::class, [
]);
$rectorConfig->phpstanConfig(Typo3Option::PHPSTAN_FOR_RECTOR_PATH);
$rectorConfig->rules([
AddVoidReturnTypeWhereNoReturnRector::class,
ConvertImplicitVariablesToExplicitGlobalsRector::class,
]);
$rectorConfig->ruleWithConfiguration(ExtEmConfRector::class, [
ExtEmConfRector::PHP_VERSION_CONSTRAINT => '8.2.0-8.4.99',
ExtEmConfRector::TYPO3_VERSION_CONSTRAINT => '13.4.0-13.4.99',
ExtEmConfRector::ADDITIONAL_VALUES_TO_BE_REMOVED => [],
])
->withRules([
ConvertImplicitVariablesToExplicitGlobalsRector::class,
AddVoidReturnTypeWhereNoReturnRector::class,
])
# To have a better analysis from PHPStan, we teach it here some more things
->withPHPStanConfigs([Typo3Option::PHPSTAN_FOR_RECTOR_PATH])
->withImportNames(true, true, false, true)
->withSkip([
]);
$rectorConfig->importNames();
$rectorConfig->importShortClasses(false);
$rectorConfig->skip([
SimplifyBoolIdenticalTrueRector::class,
NewlineAfterStatementRector::class,
]);
};
4 changes: 1 addition & 3 deletions Classes/BinaryNotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@

namespace Lemming\Imageoptimizer;

class BinaryNotFoundException extends \Exception
{
}
class BinaryNotFoundException extends \Exception {}
2 changes: 1 addition & 1 deletion Classes/OptimizeImageService.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function process(
$extension = $pathInfo['extension'];
}
}
$extension = strtolower($extension);
$extension = strtolower((string) $extension);
if ($extension === 'jpeg') {
$extension = 'jpg';
}
Expand Down
3 changes: 1 addition & 2 deletions Classes/Report/StatusReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
{
public function __construct(
private ExtensionConfiguration $extensionConfiguration
) {
}
) {}

public function getLabel(): string
{
Expand Down
Loading