From 53a7646cba3a0ef6d6bb0060a46065fda67f79f5 Mon Sep 17 00:00:00 2001 From: Simon Bigelmayr Date: Fri, 22 Aug 2025 20:06:59 +0000 Subject: [PATCH 01/21] feat: update PHP version requirements and add downgrade workflow --- .github/workflows/downgraded_release.yaml | 35 ++++++ .github/workflows/validate.yml | 144 ++++++++++++++++++---- build/composer-php-74.json | 29 +++++ build/rector-downgrade-php-74.php | 9 ++ composer.json | 2 +- rector.php | 3 +- 6 files changed, 196 insertions(+), 26 deletions(-) create mode 100644 .github/workflows/downgraded_release.yaml create mode 100644 build/composer-php-74.json create mode 100644 build/rector-downgrade-php-74.php diff --git a/.github/workflows/downgraded_release.yaml b/.github/workflows/downgraded_release.yaml new file mode 100644 index 0000000..d81472c --- /dev/null +++ b/.github/workflows/downgraded_release.yaml @@ -0,0 +1,35 @@ +name: Downgraded Release + +on: + push: + tags: + - '*' + +jobs: + downgrade_release: + if: ${{ !endsWith(github.ref_name, '.74') }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: shivammathur/setup-php@v2 + with: + php-version: 8.1 + coverage: none + - uses: ramsey/composer-install@v2 + # Downgrade /src to PHP 7.4 + - run: vendor/bin/rector process src --config build/rector-downgrade-php-74.php --ansi + # Optional: Fix coding style (falls ECS genutzt wird) + # - run: vendor/bin/ecs check src --fix --ansi + # Kopiere PHP 7.4 composer.json + - run: cp build/composer-php-74.json composer.json + # Entferne Dev-Dateien + - run: rm -rf build .github tests stubs ecs.php phpstan.neon phpunit.xml + # Tagge und pushe downgradeten Code + - name: "Tag Downgraded Code" + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git add --all + git commit -m "release PHP 7.4 downgraded version" || echo "No changes to commit" + git tag "${GITHUB_REF#refs/tags/}.74" + git push origin "${GITHUB_REF#refs/tags/}.74" diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 655c5de..8bdde0a 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -17,26 +17,19 @@ jobs: with: coverage: none extensions: mbstring - php-version: 8.3 + php-version: 8.1 - run: composer validate --strict static-code-analysis: runs-on: ubuntu-latest + continue-on-error: ${{ matrix.php-version == '8.4' }} strategy: fail-fast: false matrix: - php-version: - # Not including 7.4, as PHPStan is hard to get working there - - "8.0" - - "8.1" - - "8.2" - - "8.3" - - "8.4" - dependencies: - - lowest - - highest + php-version: ["8.1", "8.2", "8.3", "8.4"] + dependencies: [lowest, highest] steps: - uses: actions/checkout@v4 @@ -50,6 +43,14 @@ jobs: - uses: ramsey/composer-install@v3 with: dependency-versions: "${{ matrix.dependencies }}" + - name: "Cache Composer" + uses: actions/cache@v4 + with: + path: ~/.composer/cache/files + key: composer-${{ runner.os }}-${{ matrix.php-version }}-${{ matrix.dependencies }}-${{ hashFiles('**/composer.lock') }} + restore-keys: | + composer-${{ runner.os }}-${{ matrix.php-version }}-${{ matrix.dependencies }}- + composer-${{ runner.os }}- - run: vendor/bin/phpstan analyse --configuration=phpstan.neon @@ -57,20 +58,13 @@ jobs: name: "Tests - PHP ${{ matrix.php-version }}, ${{ matrix.dependencies }}" runs-on: ubuntu-latest + continue-on-error: ${{ matrix.php-version == '8.4' }} strategy: fail-fast: false matrix: - php-version: - - "7.4" - - "8.0" - - "8.1" - - "8.2" - - "8.3" - - "8.4" - dependencies: - - lowest - - highest + php-version: ["8.1", "8.2", "8.3", "8.4"] + dependencies: [lowest, highest] steps: - uses: actions/checkout@v4 @@ -81,12 +75,17 @@ jobs: extensions: mbstring php-version: "${{ matrix.php-version }}" - - if: "! startsWith(matrix.php-version, 8)" - run: composer remove --dev --no-update rector/rector mll-lab/graphql-php-scalars spaze/phpstan-disallowed-calls - - uses: ramsey/composer-install@v3 with: dependency-versions: "${{ matrix.dependencies }}" + - name: "Cache Composer" + uses: actions/cache@v4 + with: + path: ~/.composer/cache/files + key: composer-${{ runner.os }}-${{ matrix.php-version }}-${{ matrix.dependencies }}-${{ hashFiles('**/composer.lock') }} + restore-keys: | + composer-${{ runner.os }}-${{ matrix.php-version }}-${{ matrix.dependencies }}- + composer-${{ runner.os }}- - run: vendor/bin/phpunit @@ -103,8 +102,105 @@ jobs: php-version: 8.3 - uses: ramsey/composer-install@v3 + - name: "Cache Composer" + uses: actions/cache@v4 + with: + path: ~/.composer/cache/files + key: composer-${{ runner.os }}-coverage-${{ hashFiles('**/composer.lock') }} + restore-keys: | + composer-${{ runner.os }}-coverage- - run: vendor/bin/phpunit --coverage-clover=.build/logs/clover.xml # Not using v4 due to the breaking changes described in https://github.com/codecov/codecov-action/releases/tag/v4.0.0 - uses: codecov/codecov-action@v3 + + # Optionale Smoke-Prüfung des Downgrade-Prozesses (nur manueller Start) + downgrade-smoke: + if: ${{ github.event_name == 'workflow_dispatch' }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: "Install PHP 8.1 + tools" + uses: shivammathur/setup-php@v2 + with: + php-version: 8.1 + coverage: none + - uses: ramsey/composer-install@v3 + - name: "Downgrade src" + run: vendor/bin/rector process src --config build/rector-downgrade-php-74.php --ansi + - name: "Prepare downgraded artifact" + run: | + cp build/composer-php-74.json composer.json + tar -czf downgraded-src.tar.gz src composer.json + - name: "Validate downgraded composer.json under PHP 7.4" + uses: shivammathur/setup-php@v2 + with: + php-version: 7.4 + coverage: none + - run: composer validate --no-check-publish + - name: "List downgraded files" + run: tar -tzf downgraded-src.tar.gz | head -n 40 + + downgraded-static-analysis: + name: "Downgraded Static Analysis" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: "Setup PHP 8.1 (Rector + tools)" + uses: shivammathur/setup-php@v2 + with: + php-version: 8.1 + coverage: none + - uses: ramsey/composer-install@v3 + - name: "Create downgraded copy (retain original composer for analysis)" + run: | + rsync -a --exclude vendor ./ downgraded/ + vendor/bin/rector process downgraded/src downgraded/tests --config build/rector-downgrade-php-74.php --ansi + - name: "Install deps for analysis (original composer)" + working-directory: downgraded + run: composer install --no-interaction --no-progress + - name: "PHPStan on downgraded code" + working-directory: downgraded + run: vendor/bin/phpstan analyse downgraded/src downgraded/tests --configuration=phpstan.neon --memory-limit=1G + - name: "Switch to downgraded composer" + run: cp build/composer-php-74.json downgraded/composer.json + - name: "Composer validate downgraded (PHP 8.1)" + working-directory: downgraded + run: composer validate --no-check-publish + - name: "Syntax lint under PHP 7.4" + uses: shivammathur/setup-php@v2 + with: + php-version: 7.4 + coverage: none + - name: "Run syntax check" + run: | + find downgraded/src -type f -name '*.php' -print0 | xargs -0 -n1 -P4 php -l > /dev/null + + downgraded-tests: + name: "Downgraded Tests (PHP 7.4)" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: "Setup PHP 8.1 (Rector)" + uses: shivammathur/setup-php@v2 + with: + php-version: 8.1 + coverage: none + - uses: ramsey/composer-install@v3 + - name: "Create downgraded copy" + run: | + rsync -a --exclude vendor ./ downgraded/ + vendor/bin/rector process downgraded/src downgraded/tests --config build/rector-downgrade-php-74.php --ansi + cp build/composer-php-74.json downgraded/composer.json + - name: "Switch to PHP 7.4" + uses: shivammathur/setup-php@v2 + with: + php-version: 7.4 + coverage: none + - name: "Add phpunit dev dependency" + working-directory: downgraded + run: composer require --dev phpunit/phpunit:^9.6 --no-interaction --no-progress + - name: "Run downgraded tests" + working-directory: downgraded + run: vendor/bin/phpunit || (echo 'Downgraded tests failed' && exit 1) diff --git a/build/composer-php-74.json b/build/composer-php-74.json new file mode 100644 index 0000000..33e5df0 --- /dev/null +++ b/build/composer-php-74.json @@ -0,0 +1,29 @@ +{ + "name": "mll-lab/php-utils", + "description": "Shared PHP utility functions of MLL (downgraded build)", + "license": "MIT", + "type": "library", + "require": { + "php": "^7.4 || ^8.0", + "ext-calendar": "*", + "ext-simplexml": "*", + "illuminate/support": "^8.73 || ^9 || ^10 || ^11 || ^12", + "mll-lab/str_putcsv": "^1", + "nesbot/carbon": "^2.62.1 || ^3", + "ramsey/uuid": "^3 || ^4", + "thecodingmachine/safe": "^1 || ^2 || ^3" + }, + "autoload": { + "psr-4": { + "MLL\\Utils\\": "src/" + } + }, + "extra": { + "phpstan": { + "includes": [ + "extension.neon", + "rules.neon" + ] + } + } +} diff --git a/build/rector-downgrade-php-74.php b/build/rector-downgrade-php-74.php new file mode 100644 index 0000000..00ea348 --- /dev/null +++ b/build/rector-downgrade-php-74.php @@ -0,0 +1,9 @@ +sets([ + DowngradeLevelSetList::DOWN_TO_PHP_74, + ]); +}; diff --git a/composer.json b/composer.json index b0d15fb..de75639 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "source": "https://github.com/mll-lab/php-utils" }, "require": { - "php": "^7.4 || ^8", + "php": "^8.1", "ext-calendar": "*", "ext-simplexml": "*", "illuminate/support": "^8.73 || ^9 || ^10 || ^11 || ^12", diff --git a/rector.php b/rector.php index 89fb93b..75c929c 100644 --- a/rector.php +++ b/rector.php @@ -5,10 +5,12 @@ use Rector\Set\ValueObject\SetList; return RectorConfig::configure() + ->withPhpVersion(81) ->withSets([ SetList::CODE_QUALITY, SetList::TYPE_DECLARATION, SetList::RECTOR_PRESET, + SetList::PHP_81, PHPUnitSetList::PHPUNIT_40, PHPUnitSetList::PHPUNIT_50, PHPUnitSetList::PHPUNIT_60, @@ -19,7 +21,6 @@ PHPUnitSetList::PHPUNIT_110, PHPUnitSetList::PHPUNIT_CODE_QUALITY, ]) - ->withPhpSets() ->withRules([ Rector\PHPUnit\CodeQuality\Rector\Class_\PreferPHPUnitSelfCallRector::class, ]) From 36a4b1a9d615bb99b004c4160d45759b311ab1b8 Mon Sep 17 00:00:00 2001 From: Simon Bigelmayr Date: Fri, 22 Aug 2025 22:25:07 +0200 Subject: [PATCH 02/21] feat: enable PHP 8.1 features with backward compatibility by adding readonly properties --- build/rector-downgrade-php-74.php | 11 +++---- composer.json | 2 +- rector.php | 1 - src/FluidXPlate/FluidXPlate.php | 6 ++-- src/IlluminaSampleSheet/V1/ReadsSection.php | 4 +-- .../V1/SettingsSection.php | 4 +-- .../V2/BclConvert/OverrideCycles.php | 2 +- src/Microplate/FullColumnSection.php | 3 +- src/Number.php | 4 +-- src/PHPStan/Rules/NoAssignmentInIfRule.php | 2 +- src/PHPStan/Rules/ThrowableClassNameRule.php | 2 +- src/QxManager/FilledRow.php | 32 +++++++++---------- src/QxManager/FilledWell.php | 4 +-- .../AspirateAndDispenseParameters.php | 6 ++-- src/Tecan/BasicCommands/Comment.php | 2 +- .../BasicCommands/ReagentDistribution.php | 16 +++++----- src/Tecan/BasicCommands/SetDiTiType.php | 2 +- .../CustomCommands/AspirateParameters.php | 4 +-- .../CustomCommands/MLLReagentDistribution.php | 8 ++--- .../CustomCommands/TransferWithAutoWash.php | 4 +-- src/Tecan/LiquidClass/CustomLiquidClass.php | 2 +- src/Tecan/Location/BarcodeLocation.php | 4 +-- src/Tecan/Location/PositionLocation.php | 4 +-- src/Tecan/TecanProtocol.php | 6 ++-- 24 files changed, 64 insertions(+), 71 deletions(-) diff --git a/build/rector-downgrade-php-74.php b/build/rector-downgrade-php-74.php index 00ea348..577a707 100644 --- a/build/rector-downgrade-php-74.php +++ b/build/rector-downgrade-php-74.php @@ -1,9 +1,6 @@ -sets([ - DowngradeLevelSetList::DOWN_TO_PHP_74, - ]); -}; +return RectorConfig::configure() + ->withDowngradeSets(php74: true); diff --git a/composer.json b/composer.json index de75639..3faefa5 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "source": "https://github.com/mll-lab/php-utils" }, "require": { - "php": "^8.1", + "php": "^8.1", "ext-calendar": "*", "ext-simplexml": "*", "illuminate/support": "^8.73 || ^9 || ^10 || ^11 || ^12", diff --git a/rector.php b/rector.php index 75c929c..b8aaf24 100644 --- a/rector.php +++ b/rector.php @@ -5,7 +5,6 @@ use Rector\Set\ValueObject\SetList; return RectorConfig::configure() - ->withPhpVersion(81) ->withSets([ SetList::CODE_QUALITY, SetList::TYPE_DECLARATION, diff --git a/src/FluidXPlate/FluidXPlate.php b/src/FluidXPlate/FluidXPlate.php index 195e007..c484c6d 100644 --- a/src/FluidXPlate/FluidXPlate.php +++ b/src/FluidXPlate/FluidXPlate.php @@ -16,7 +16,7 @@ class FluidXPlate public string $rackID; /** @var Microplate */ - private Microplate $microplate; + private readonly Microplate $microplate; public function __construct(string $rackID) { @@ -51,7 +51,7 @@ public function addToNextFreeWell(string $content, FlowDirection $flowDirection) /** @return Collection */ public function wells(): Collection { - return $this->microplate->wells(); + return $this->microplate->wells(); // @phpstan-ignore return.type (generic not inferred) } /** @return Collection */ @@ -63,6 +63,6 @@ public function freeWells(): Collection /** @return Collection */ public function filledWells(): Collection { - return $this->microplate->filledWells(); + return $this->microplate->filledWells(); // @phpstan-ignore return.type (generic not inferred) } } diff --git a/src/IlluminaSampleSheet/V1/ReadsSection.php b/src/IlluminaSampleSheet/V1/ReadsSection.php index fcde207..9b7f5db 100644 --- a/src/IlluminaSampleSheet/V1/ReadsSection.php +++ b/src/IlluminaSampleSheet/V1/ReadsSection.php @@ -6,9 +6,9 @@ class ReadsSection implements Section { - private int $read1Cycles; + private readonly int $read1Cycles; - private int $read2Cycles; + private readonly int $read2Cycles; public function __construct(int $read1Cycles, int $read2Cycles) { diff --git a/src/IlluminaSampleSheet/V1/SettingsSection.php b/src/IlluminaSampleSheet/V1/SettingsSection.php index 6fc8b61..ffadb1a 100644 --- a/src/IlluminaSampleSheet/V1/SettingsSection.php +++ b/src/IlluminaSampleSheet/V1/SettingsSection.php @@ -6,9 +6,9 @@ class SettingsSection implements Section { - private ?string $adapter; + private readonly ?string $adapter; - private ?string $adapterRead2; + private readonly ?string $adapterRead2; public function __construct(?string $adapter = null, ?string $adapterRead2 = null) { diff --git a/src/IlluminaSampleSheet/V2/BclConvert/OverrideCycles.php b/src/IlluminaSampleSheet/V2/BclConvert/OverrideCycles.php index 03715cf..b8d9558 100644 --- a/src/IlluminaSampleSheet/V2/BclConvert/OverrideCycles.php +++ b/src/IlluminaSampleSheet/V2/BclConvert/OverrideCycles.php @@ -15,7 +15,7 @@ class OverrideCycles public ?OverrideCycle $read2; - private DataSection $dataSection; + private readonly DataSection $dataSection; public function __construct(DataSection $dataSection, string $read1, string $index1, ?string $index2, ?string $read2) { diff --git a/src/Microplate/FullColumnSection.php b/src/Microplate/FullColumnSection.php index 6a87c26..759dfa6 100644 --- a/src/Microplate/FullColumnSection.php +++ b/src/Microplate/FullColumnSection.php @@ -66,8 +66,7 @@ private function growSection(): void } } - /** @return false|int */ - private function nextReservedWell() + private function nextReservedWell(): int|false { $search = $this->sectionItems->search(AbstractMicroplate::EMPTY_WELL); assert($search === false || is_int($search)); // @phpstan-ignore-line function.alreadyNarrowedType (not yet supported by PHPStan of older versions) diff --git a/src/Number.php b/src/Number.php index 55a74f0..effa6b0 100644 --- a/src/Number.php +++ b/src/Number.php @@ -13,10 +13,8 @@ class Number * @param float|int $min * @param float|int $max * @param float|int $current - * - * @return float|int */ - public static function clamp($min, $max, $current) + public static function clamp($min, $max, $current): float|int { return max($min, min($max, $current)); } diff --git a/src/PHPStan/Rules/NoAssignmentInIfRule.php b/src/PHPStan/Rules/NoAssignmentInIfRule.php index 039d758..78bc452 100644 --- a/src/PHPStan/Rules/NoAssignmentInIfRule.php +++ b/src/PHPStan/Rules/NoAssignmentInIfRule.php @@ -19,7 +19,7 @@ */ class NoAssignmentInIfRule implements Rule { - private NodeFinder $nodeFinder; + private readonly NodeFinder $nodeFinder; public function __construct() { diff --git a/src/PHPStan/Rules/ThrowableClassNameRule.php b/src/PHPStan/Rules/ThrowableClassNameRule.php index 30c211f..87be9ec 100644 --- a/src/PHPStan/Rules/ThrowableClassNameRule.php +++ b/src/PHPStan/Rules/ThrowableClassNameRule.php @@ -13,7 +13,7 @@ /** @implements Rule */ class ThrowableClassNameRule implements Rule { - private ReflectionProvider $reflectionProvider; + private readonly ReflectionProvider $reflectionProvider; public function __construct( ReflectionProvider $reflectionProvider diff --git a/src/QxManager/FilledRow.php b/src/QxManager/FilledRow.php index 5ba9b60..9c38a61 100644 --- a/src/QxManager/FilledRow.php +++ b/src/QxManager/FilledRow.php @@ -4,37 +4,37 @@ class FilledRow { - private string $experimentType; + private readonly string $experimentType; - private string $supermixName; + private readonly string $supermixName; - private string $assayType; + private readonly string $assayType; - private string $targetType; + private readonly string $targetType; - private string $plot; + private readonly string $plot; - private string $targetName; + private readonly string $targetName; - private string $signalCh1; + private readonly string $signalCh1; - private string $signalCh2; + private readonly string $signalCh2; - private string $sampleDescription1; + private readonly string $sampleDescription1; - private ?string $sampleDescription2; + private readonly ?string $sampleDescription2; - private ?string $sampleDescription3; + private readonly ?string $sampleDescription3; - private ?string $sampleDescription4; + private readonly ?string $sampleDescription4; - private string $sampleType; + private readonly string $sampleType; - private ?int $referenceCopies; + private readonly ?int $referenceCopies; - private ?string $wellNotes; + private readonly ?string $wellNotes; - private ?string $rdqConversionFactor; + private readonly ?string $rdqConversionFactor; public function __construct( string $sampleDescription1, diff --git a/src/QxManager/FilledWell.php b/src/QxManager/FilledWell.php index bd4da93..09394f4 100644 --- a/src/QxManager/FilledWell.php +++ b/src/QxManager/FilledWell.php @@ -7,9 +7,9 @@ class FilledWell { - private FilledRow $famRow; + private readonly FilledRow $famRow; - private FilledRow $hexRow; + private readonly FilledRow $hexRow; public function __construct(FilledRow $famRow, FilledRow $hexRow) { diff --git a/src/Tecan/BasicCommands/AspirateAndDispenseParameters.php b/src/Tecan/BasicCommands/AspirateAndDispenseParameters.php index a918400..d1bcb27 100644 --- a/src/Tecan/BasicCommands/AspirateAndDispenseParameters.php +++ b/src/Tecan/BasicCommands/AspirateAndDispenseParameters.php @@ -6,11 +6,11 @@ class AspirateAndDispenseParameters { - private Rack $rack; + private readonly Rack $rack; - private int $startPosition; + private readonly int $startPosition; - private int $endPosition; + private readonly int $endPosition; public function __construct(Rack $rack, int $startPosition, int $endPosition) { diff --git a/src/Tecan/BasicCommands/Comment.php b/src/Tecan/BasicCommands/Comment.php index 9d8f3b9..6053d06 100644 --- a/src/Tecan/BasicCommands/Comment.php +++ b/src/Tecan/BasicCommands/Comment.php @@ -4,7 +4,7 @@ class Comment extends Command { - private string $comment; + private readonly string $comment; public function __construct(string $comment) { diff --git a/src/Tecan/BasicCommands/ReagentDistribution.php b/src/Tecan/BasicCommands/ReagentDistribution.php index 38ff826..4e7f437 100644 --- a/src/Tecan/BasicCommands/ReagentDistribution.php +++ b/src/Tecan/BasicCommands/ReagentDistribution.php @@ -7,22 +7,22 @@ class ReagentDistribution extends Command { - private AspirateAndDispenseParameters $source; + private readonly AspirateAndDispenseParameters $source; - private AspirateAndDispenseParameters $target; + private readonly AspirateAndDispenseParameters $target; - private float $volume; + private readonly float $volume; - private LiquidClass $liquidClass; + private readonly LiquidClass $liquidClass; - private ?int $numberOfDitiReuses; + private readonly ?int $numberOfDitiReuses; - private ?int $numberOfMultiDisp; + private readonly ?int $numberOfMultiDisp; - private ReagentDistributionDirection $direction; + private readonly ReagentDistributionDirection $direction; /** @var array|null */ - private ?array $excludedTargetWells; + private readonly ?array $excludedTargetWells; /** * @param int|null $numberOfDitiReuses optional maximum number of DiTi reuses allowed (default 1 = no DiTi reuse) diff --git a/src/Tecan/BasicCommands/SetDiTiType.php b/src/Tecan/BasicCommands/SetDiTiType.php index ca0ccdb..cfa6d02 100644 --- a/src/Tecan/BasicCommands/SetDiTiType.php +++ b/src/Tecan/BasicCommands/SetDiTiType.php @@ -9,7 +9,7 @@ */ class SetDiTiType extends Command { - private int $indexOfDiTi; + private readonly int $indexOfDiTi; public function __construct(int $indexOfDiTi) { diff --git a/src/Tecan/CustomCommands/AspirateParameters.php b/src/Tecan/CustomCommands/AspirateParameters.php index 070b01f..2d54eeb 100644 --- a/src/Tecan/CustomCommands/AspirateParameters.php +++ b/src/Tecan/CustomCommands/AspirateParameters.php @@ -7,9 +7,9 @@ class AspirateParameters { - private Rack $rack; + private readonly Rack $rack; - private int $sourcePosition; + private readonly int $sourcePosition; public function __construct(Rack $rack, int $sourcePosition) { diff --git a/src/Tecan/CustomCommands/MLLReagentDistribution.php b/src/Tecan/CustomCommands/MLLReagentDistribution.php index 49c2c4b..b6d3b4c 100644 --- a/src/Tecan/CustomCommands/MLLReagentDistribution.php +++ b/src/Tecan/CustomCommands/MLLReagentDistribution.php @@ -12,13 +12,13 @@ class MLLReagentDistribution extends Command public const NUMBER_OF_DITI_REUSES = 6; public const NUMBER_OF_MULTI_DISP = 1; - private AspirateParameters $source; + private readonly AspirateParameters $source; - private DispenseParameters $target; + private readonly DispenseParameters $target; - private float $volume; + private readonly float $volume; - private LiquidClass $liquidClass; + private readonly LiquidClass $liquidClass; public function __construct( AspirateParameters $source, diff --git a/src/Tecan/CustomCommands/TransferWithAutoWash.php b/src/Tecan/CustomCommands/TransferWithAutoWash.php index 8b46b4d..515841d 100644 --- a/src/Tecan/CustomCommands/TransferWithAutoWash.php +++ b/src/Tecan/CustomCommands/TransferWithAutoWash.php @@ -13,9 +13,9 @@ class TransferWithAutoWash extends Command implements UsesTipMask { - private Aspirate $aspirate; + private readonly Aspirate $aspirate; - private Dispense $dispense; + private readonly Dispense $dispense; public function __construct(float $volume, LiquidClass $liquidClass, Location $aspirateLocation, Location $dispenseLocation) { diff --git a/src/Tecan/LiquidClass/CustomLiquidClass.php b/src/Tecan/LiquidClass/CustomLiquidClass.php index 336f17e..47041a8 100644 --- a/src/Tecan/LiquidClass/CustomLiquidClass.php +++ b/src/Tecan/LiquidClass/CustomLiquidClass.php @@ -4,7 +4,7 @@ class CustomLiquidClass implements LiquidClass { - private string $name; + private readonly string $name; public function __construct(string $name) { diff --git a/src/Tecan/Location/BarcodeLocation.php b/src/Tecan/Location/BarcodeLocation.php index 8d1d87d..6067c3d 100644 --- a/src/Tecan/Location/BarcodeLocation.php +++ b/src/Tecan/Location/BarcodeLocation.php @@ -6,9 +6,9 @@ class BarcodeLocation implements Location { - private string $barcode; + private readonly string $barcode; - private ScannedRack $rack; + private readonly ScannedRack $rack; public function __construct(string $barcode, ScannedRack $rack) { diff --git a/src/Tecan/Location/PositionLocation.php b/src/Tecan/Location/PositionLocation.php index 25601dc..50fcad8 100644 --- a/src/Tecan/Location/PositionLocation.php +++ b/src/Tecan/Location/PositionLocation.php @@ -6,9 +6,9 @@ class PositionLocation implements Location { - private int $position; + private readonly int $position; - private Rack $rack; + private readonly Rack $rack; public function __construct(int $position, Rack $rack) { diff --git a/src/Tecan/TecanProtocol.php b/src/Tecan/TecanProtocol.php index 0b5e255..8f65871 100644 --- a/src/Tecan/TecanProtocol.php +++ b/src/Tecan/TecanProtocol.php @@ -22,12 +22,12 @@ class TecanProtocol public const GEMINI_WORKLIST_FILENAME_SUFFIX = '.gwl'; - private TipMask $tipMask; + private readonly TipMask $tipMask; - private string $protocolName; + private readonly string $protocolName; /** @var Collection */ - private Collection $commands; + private readonly Collection $commands; public ?int $defaultDiTiTypeIndex; From 2e999f7a9e9b17dd39a87906c9cd0a828d478312 Mon Sep 17 00:00:00 2001 From: Simon Bigelmayr Date: Fri, 22 Aug 2025 22:35:05 +0200 Subject: [PATCH 03/21] feat: update composer dependencies for PHP 7.4 compatibility and remove composer.lock in downgrade workflow --- .github/workflows/validate.yml | 1 + build/composer-php-74.json | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 8bdde0a..3befb42 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -193,6 +193,7 @@ jobs: rsync -a --exclude vendor ./ downgraded/ vendor/bin/rector process downgraded/src downgraded/tests --config build/rector-downgrade-php-74.php --ansi cp build/composer-php-74.json downgraded/composer.json + rm -f downgraded/composer.lock - name: "Switch to PHP 7.4" uses: shivammathur/setup-php@v2 with: diff --git a/build/composer-php-74.json b/build/composer-php-74.json index 33e5df0..293413b 100644 --- a/build/composer-php-74.json +++ b/build/composer-php-74.json @@ -4,14 +4,14 @@ "license": "MIT", "type": "library", "require": { - "php": "^7.4 || ^8.0", + "php": "^7.4", "ext-calendar": "*", "ext-simplexml": "*", - "illuminate/support": "^8.73 || ^9 || ^10 || ^11 || ^12", + "illuminate/support": "^8.73", "mll-lab/str_putcsv": "^1", - "nesbot/carbon": "^2.62.1 || ^3", - "ramsey/uuid": "^3 || ^4", - "thecodingmachine/safe": "^1 || ^2 || ^3" + "nesbot/carbon": "^2.62.1", + "ramsey/uuid": "^3", + "thecodingmachine/safe": "^1" }, "autoload": { "psr-4": { From 1c3dbc7df2c8bbd3a00a3c1a94804bb576af24da Mon Sep 17 00:00:00 2001 From: Simon Bigelmayr Date: Fri, 22 Aug 2025 22:41:57 +0200 Subject: [PATCH 04/21] feat: update validate.yml to improve downgrade workflow and dependencies management --- .github/workflows/validate.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 3befb42..4ab49ba 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -58,7 +58,6 @@ jobs: name: "Tests - PHP ${{ matrix.php-version }}, ${{ matrix.dependencies }}" runs-on: ubuntu-latest - continue-on-error: ${{ matrix.php-version == '8.4' }} strategy: fail-fast: false @@ -117,7 +116,6 @@ jobs: # Optionale Smoke-Prüfung des Downgrade-Prozesses (nur manueller Start) downgrade-smoke: - if: ${{ github.event_name == 'workflow_dispatch' }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -144,6 +142,7 @@ jobs: downgraded-static-analysis: name: "Downgraded Static Analysis" + needs: downgrade-smoke runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -179,6 +178,7 @@ jobs: downgraded-tests: name: "Downgraded Tests (PHP 7.4)" + needs: downgrade-smoke runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 From 8fc50d798c75eacea24b1cddfbee8862403a0f04 Mon Sep 17 00:00:00 2001 From: Simon Bigelmayr Date: Fri, 22 Aug 2025 22:46:59 +0200 Subject: [PATCH 05/21] feat: add development dependencies for PHP 7.4 compatibility and testing tools --- build/composer-php-74.json | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/build/composer-php-74.json b/build/composer-php-74.json index 293413b..3a4ec66 100644 --- a/build/composer-php-74.json +++ b/build/composer-php-74.json @@ -13,6 +13,23 @@ "ramsey/uuid": "^3", "thecodingmachine/safe": "^1" }, + "require-dev": { + "ergebnis/composer-normalize": "^2.45", + "jangregor/phpstan-prophecy": "^1.0.2 || ^2.1.1", + "larastan/larastan": "^1.0.4 || ^2.9.14 || ^3.1", + "mll-lab/graphql-php-scalars": "^6.4", + "mll-lab/php-cs-fixer-config": "^5.10", + "orchestra/testbench": "^6.47.1 || ^7.52 || ^8.33 || ^9.11 || ^10", + "phpstan/extension-installer": "^1", + "phpstan/phpstan": "^1.8.11 || ^2.1.6", + "phpstan/phpstan-deprecation-rules": "^1 || ^2.0.1", + "phpstan/phpstan-phpunit": "^1 || ^2.0.4", + "phpstan/phpstan-strict-rules": "^1 || ^2.0.3", + "phpunit/phpunit": "^9.6.22 || ^10.5.45 || ^11.5.10 || ^12.0.5", + "rector/rector": "^1.2.10 || ^2.0.9", + "spaze/phpstan-disallowed-calls": "^4.4", + "thecodingmachine/phpstan-safe-rule": "^1.2.0" + }, "autoload": { "psr-4": { "MLL\\Utils\\": "src/" From c5e60ce7cf2fefbb40e67f2506615d8966590399 Mon Sep 17 00:00:00 2001 From: Simon Bigelmayr Date: Fri, 22 Aug 2025 22:48:47 +0200 Subject: [PATCH 06/21] feat: add configuration for plugins and package sorting in composer-php-74.json --- build/composer-php-74.json | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/build/composer-php-74.json b/build/composer-php-74.json index 3a4ec66..1b0a437 100644 --- a/build/composer-php-74.json +++ b/build/composer-php-74.json @@ -35,6 +35,15 @@ "MLL\\Utils\\": "src/" } }, + "config": { + "allow-plugins": { + "ergebnis/composer-normalize": true, + "infection/extension-installer": true, + "ocramius/package-versions": true, + "phpstan/extension-installer": true + }, + "sort-packages": true + }, "extra": { "phpstan": { "includes": [ From 08a3bffa9736d27fc77297cd1aaea2b3aba550a3 Mon Sep 17 00:00:00 2001 From: Simon Bigelmayr Date: Fri, 22 Aug 2025 22:53:20 +0200 Subject: [PATCH 07/21] feat: update validate.yml to remove composer.lock during downgrade artifact preparation --- .github/workflows/validate.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 4ab49ba..e00c0ac 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -129,7 +129,7 @@ jobs: run: vendor/bin/rector process src --config build/rector-downgrade-php-74.php --ansi - name: "Prepare downgraded artifact" run: | - cp build/composer-php-74.json composer.json + cp build/composer-php-74.json composer.json && rm -f composer.lock tar -czf downgraded-src.tar.gz src composer.json - name: "Validate downgraded composer.json under PHP 7.4" uses: shivammathur/setup-php@v2 From b07e67fbb66e7963ba87ed885b1405e490c89000 Mon Sep 17 00:00:00 2001 From: Simon Bigelmayr Date: Fri, 22 Aug 2025 23:01:08 +0200 Subject: [PATCH 08/21] feat: enhance validate.yml for PHP 7.4 compatibility and improved downgrade process --- .github/workflows/validate.yml | 63 +++++++++------------------------- 1 file changed, 17 insertions(+), 46 deletions(-) diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index e00c0ac..47f9a9b 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -130,13 +130,16 @@ jobs: - name: "Prepare downgraded artifact" run: | cp build/composer-php-74.json composer.json && rm -f composer.lock - tar -czf downgraded-src.tar.gz src composer.json + tar -czf downgraded-src.tar.gz src composer.json phpstan.neon phpunit.xml extension.neon rules.neon - name: "Validate downgraded composer.json under PHP 7.4" uses: shivammathur/setup-php@v2 with: php-version: 7.4 coverage: none - - run: composer validate --no-check-publish + - run: | + tar -xzf downgraded-src.tar.gz + composer install --no-interaction --prefer-dist + composer validate --no-check-publish - name: "List downgraded files" run: tar -tzf downgraded-src.tar.gz | head -n 40 @@ -146,35 +149,16 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: "Setup PHP 8.1 (Rector + tools)" - uses: shivammathur/setup-php@v2 - with: - php-version: 8.1 - coverage: none - - uses: ramsey/composer-install@v3 - - name: "Create downgraded copy (retain original composer for analysis)" - run: | - rsync -a --exclude vendor ./ downgraded/ - vendor/bin/rector process downgraded/src downgraded/tests --config build/rector-downgrade-php-74.php --ansi - - name: "Install deps for analysis (original composer)" - working-directory: downgraded - run: composer install --no-interaction --no-progress - - name: "PHPStan on downgraded code" - working-directory: downgraded - run: vendor/bin/phpstan analyse downgraded/src downgraded/tests --configuration=phpstan.neon --memory-limit=1G - - name: "Switch to downgraded composer" - run: cp build/composer-php-74.json downgraded/composer.json - - name: "Composer validate downgraded (PHP 8.1)" - working-directory: downgraded - run: composer validate --no-check-publish - - name: "Syntax lint under PHP 7.4" + - name: "Setup PHP 7.4 (Static Analysis)" uses: shivammathur/setup-php@v2 with: php-version: 7.4 coverage: none - - name: "Run syntax check" - run: | - find downgraded/src -type f -name '*.php' -print0 | xargs -0 -n1 -P4 php -l > /dev/null + - run: | + tar -xzf downgraded-src.tar.gz + composer install --no-interaction --prefer-dist + - name: "Run PHPStan on downgraded src" + run: vendor/bin/phpstan analyse src --error-format=github downgraded-tests: name: "Downgraded Tests (PHP 7.4)" @@ -182,26 +166,13 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: "Setup PHP 8.1 (Rector)" - uses: shivammathur/setup-php@v2 - with: - php-version: 8.1 - coverage: none - - uses: ramsey/composer-install@v3 - - name: "Create downgraded copy" - run: | - rsync -a --exclude vendor ./ downgraded/ - vendor/bin/rector process downgraded/src downgraded/tests --config build/rector-downgrade-php-74.php --ansi - cp build/composer-php-74.json downgraded/composer.json - rm -f downgraded/composer.lock - - name: "Switch to PHP 7.4" + - name: "Setup PHP 7.4 (Tests)" uses: shivammathur/setup-php@v2 with: php-version: 7.4 coverage: none - - name: "Add phpunit dev dependency" - working-directory: downgraded - run: composer require --dev phpunit/phpunit:^9.6 --no-interaction --no-progress - - name: "Run downgraded tests" - working-directory: downgraded - run: vendor/bin/phpunit || (echo 'Downgraded tests failed' && exit 1) + - run: | + tar -xzf downgraded-src.tar.gz + composer install --no-interaction --prefer-dist + - name: "Run PHPUnit on downgraded src" + run: vendor/bin/phpunit --configuration phpunit.xml || (echo 'Downgraded tests failed' && exit 1) From 9b0b79e838581a57eb22d7ad43402e038e4aed13 Mon Sep 17 00:00:00 2001 From: Simon Bigelmayr Date: Fri, 22 Aug 2025 23:05:50 +0200 Subject: [PATCH 09/21] feat: refine development dependencies in composer-php-74.json for PHP 8.1 compatibility --- build/composer-php-74.json | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/build/composer-php-74.json b/build/composer-php-74.json index 1b0a437..3ccc349 100644 --- a/build/composer-php-74.json +++ b/build/composer-php-74.json @@ -15,18 +15,17 @@ }, "require-dev": { "ergebnis/composer-normalize": "^2.45", - "jangregor/phpstan-prophecy": "^1.0.2 || ^2.1.1", - "larastan/larastan": "^1.0.4 || ^2.9.14 || ^3.1", - "mll-lab/graphql-php-scalars": "^6.4", + "jangregor/phpstan-prophecy": "^1.0.2", + "larastan/larastan": "^1.0.4", "mll-lab/php-cs-fixer-config": "^5.10", - "orchestra/testbench": "^6.47.1 || ^7.52 || ^8.33 || ^9.11 || ^10", + "orchestra/testbench": "^6.47.1", "phpstan/extension-installer": "^1", "phpstan/phpstan": "^1.8.11 || ^2.1.6", - "phpstan/phpstan-deprecation-rules": "^1 || ^2.0.1", - "phpstan/phpstan-phpunit": "^1 || ^2.0.4", - "phpstan/phpstan-strict-rules": "^1 || ^2.0.3", - "phpunit/phpunit": "^9.6.22 || ^10.5.45 || ^11.5.10 || ^12.0.5", - "rector/rector": "^1.2.10 || ^2.0.9", + "phpstan/phpstan-deprecation-rules": "^1", + "phpstan/phpstan-phpunit": "^1", + "phpstan/phpstan-strict-rules": "^1", + "phpunit/phpunit": "^9.6.22", + "rector/rector": "^1.2.10", "spaze/phpstan-disallowed-calls": "^4.4", "thecodingmachine/phpstan-safe-rule": "^1.2.0" }, From 29af9de7839d4f2b008e5e377cd3f66df2c73306 Mon Sep 17 00:00:00 2001 From: Simon Bigelmayr Date: Fri, 22 Aug 2025 23:07:40 +0200 Subject: [PATCH 10/21] feat: update ramsey/uuid version constraint for PHP 8.1 compatibility --- build/composer-php-74.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/composer-php-74.json b/build/composer-php-74.json index 3ccc349..67314d2 100644 --- a/build/composer-php-74.json +++ b/build/composer-php-74.json @@ -10,7 +10,7 @@ "illuminate/support": "^8.73", "mll-lab/str_putcsv": "^1", "nesbot/carbon": "^2.62.1", - "ramsey/uuid": "^3", + "ramsey/uuid": "^3 || ^4.2.2", "thecodingmachine/safe": "^1" }, "require-dev": { From ba55f22b0f5fa4ae58bfd9dab8f01a0d17222e95 Mon Sep 17 00:00:00 2001 From: Simon Bigelmayr Date: Fri, 22 Aug 2025 23:10:33 +0200 Subject: [PATCH 11/21] feat: update larastan and rector version constraints for PHP 8.1 compatibility --- build/composer-php-74.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/composer-php-74.json b/build/composer-php-74.json index 67314d2..5fe08d7 100644 --- a/build/composer-php-74.json +++ b/build/composer-php-74.json @@ -16,7 +16,7 @@ "require-dev": { "ergebnis/composer-normalize": "^2.45", "jangregor/phpstan-prophecy": "^1.0.2", - "larastan/larastan": "^1.0.4", + "larastan/larastan": "^1", "mll-lab/php-cs-fixer-config": "^5.10", "orchestra/testbench": "^6.47.1", "phpstan/extension-installer": "^1", @@ -25,7 +25,7 @@ "phpstan/phpstan-phpunit": "^1", "phpstan/phpstan-strict-rules": "^1", "phpunit/phpunit": "^9.6.22", - "rector/rector": "^1.2.10", + "rector/rector": "^1.2", "spaze/phpstan-disallowed-calls": "^4.4", "thecodingmachine/phpstan-safe-rule": "^1.2.0" }, From 907a84fe43e319f432c1f01beb08e93f32f60e16 Mon Sep 17 00:00:00 2001 From: Simon Bigelmayr Date: Fri, 22 Aug 2025 23:13:33 +0200 Subject: [PATCH 12/21] feat: add artifact upload and download steps for PHP 7.4 downgrade validation --- .github/workflows/validate.yml | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 47f9a9b..d272d18 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -131,6 +131,11 @@ jobs: run: | cp build/composer-php-74.json composer.json && rm -f composer.lock tar -czf downgraded-src.tar.gz src composer.json phpstan.neon phpunit.xml extension.neon rules.neon + - name: "Upload downgraded artifact" + uses: actions/upload-artifact@v3 + with: + name: downgraded-src + path: downgraded-src.tar.gz - name: "Validate downgraded composer.json under PHP 7.4" uses: shivammathur/setup-php@v2 with: @@ -149,13 +154,17 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: "Download downgraded artifact" + uses: actions/download-artifact@v3 + with: + name: downgraded-src - name: "Setup PHP 7.4 (Static Analysis)" uses: shivammathur/setup-php@v2 with: php-version: 7.4 coverage: none - run: | - tar -xzf downgraded-src.tar.gz + tar -xzf downgraded-src/downgraded-src.tar.gz composer install --no-interaction --prefer-dist - name: "Run PHPStan on downgraded src" run: vendor/bin/phpstan analyse src --error-format=github @@ -166,13 +175,17 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: "Download downgraded artifact" + uses: actions/download-artifact@v3 + with: + name: downgraded-src - name: "Setup PHP 7.4 (Tests)" uses: shivammathur/setup-php@v2 with: php-version: 7.4 coverage: none - run: | - tar -xzf downgraded-src.tar.gz + tar -xzf downgraded-src/downgraded-src.tar.gz composer install --no-interaction --prefer-dist - name: "Run PHPUnit on downgraded src" run: vendor/bin/phpunit --configuration phpunit.xml || (echo 'Downgraded tests failed' && exit 1) From 023fd9b63be5dccc640abb25b047b9889b641dbc Mon Sep 17 00:00:00 2001 From: Simon Bigelmayr Date: Fri, 22 Aug 2025 23:15:04 +0200 Subject: [PATCH 13/21] feat: upgrade artifact actions to v4 for improved functionality --- .github/workflows/validate.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index d272d18..4d820ba 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -132,7 +132,7 @@ jobs: cp build/composer-php-74.json composer.json && rm -f composer.lock tar -czf downgraded-src.tar.gz src composer.json phpstan.neon phpunit.xml extension.neon rules.neon - name: "Upload downgraded artifact" - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: downgraded-src path: downgraded-src.tar.gz @@ -155,7 +155,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: "Download downgraded artifact" - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: downgraded-src - name: "Setup PHP 7.4 (Static Analysis)" @@ -176,7 +176,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: "Download downgraded artifact" - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: downgraded-src - name: "Setup PHP 7.4 (Tests)" From 9daba43c40107fe7f85ad4459fe5badf3803ac48 Mon Sep 17 00:00:00 2001 From: Simon Bigelmayr Date: Fri, 22 Aug 2025 23:18:31 +0200 Subject: [PATCH 14/21] feat: enhance downgraded build validation for PHP 7.4 compatibility --- .github/workflows/validate.yml | 72 +++++++--------------------------- 1 file changed, 14 insertions(+), 58 deletions(-) diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 4d820ba..03ecc12 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -114,78 +114,34 @@ jobs: # Not using v4 due to the breaking changes described in https://github.com/codecov/codecov-action/releases/tag/v4.0.0 - uses: codecov/codecov-action@v3 - # Optionale Smoke-Prüfung des Downgrade-Prozesses (nur manueller Start) - downgrade-smoke: + downgraded-build-validate: + name: "Downgraded Build Validate (PHP 7.4)" runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: "Install PHP 8.1 + tools" + - name: "Setup PHP 8.1 (Rector)" uses: shivammathur/setup-php@v2 with: php-version: 8.1 coverage: none - uses: ramsey/composer-install@v3 - - name: "Downgrade src" - run: vendor/bin/rector process src --config build/rector-downgrade-php-74.php --ansi - - name: "Prepare downgraded artifact" + - name: "Downgrade src and tests" run: | - cp build/composer-php-74.json composer.json && rm -f composer.lock - tar -czf downgraded-src.tar.gz src composer.json phpstan.neon phpunit.xml extension.neon rules.neon - - name: "Upload downgraded artifact" - uses: actions/upload-artifact@v4 - with: - name: downgraded-src - path: downgraded-src.tar.gz - - name: "Validate downgraded composer.json under PHP 7.4" - uses: shivammathur/setup-php@v2 - with: - php-version: 7.4 - coverage: none - - run: | - tar -xzf downgraded-src.tar.gz - composer install --no-interaction --prefer-dist - composer validate --no-check-publish - - name: "List downgraded files" - run: tar -tzf downgraded-src.tar.gz | head -n 40 - - downgraded-static-analysis: - name: "Downgraded Static Analysis" - needs: downgrade-smoke - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: "Download downgraded artifact" - uses: actions/download-artifact@v4 - with: - name: downgraded-src - - name: "Setup PHP 7.4 (Static Analysis)" + vendor/bin/rector process src tests --config build/rector-downgrade-php-74.php --ansi + - name: "Prepare downgraded composer.json" + run: | + cp build/composer-php-74.json composer.json + rm -f composer.lock + - name: "Setup PHP 7.4" uses: shivammathur/setup-php@v2 with: php-version: 7.4 coverage: none - - run: | - tar -xzf downgraded-src/downgraded-src.tar.gz - composer install --no-interaction --prefer-dist + - name: "Install downgraded dependencies" + run: composer install --no-interaction --prefer-dist + - name: "Validate downgraded composer.json" + run: composer validate --no-check-publish - name: "Run PHPStan on downgraded src" run: vendor/bin/phpstan analyse src --error-format=github - - downgraded-tests: - name: "Downgraded Tests (PHP 7.4)" - needs: downgrade-smoke - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: "Download downgraded artifact" - uses: actions/download-artifact@v4 - with: - name: downgraded-src - - name: "Setup PHP 7.4 (Tests)" - uses: shivammathur/setup-php@v2 - with: - php-version: 7.4 - coverage: none - - run: | - tar -xzf downgraded-src/downgraded-src.tar.gz - composer install --no-interaction --prefer-dist - name: "Run PHPUnit on downgraded src" run: vendor/bin/phpunit --configuration phpunit.xml || (echo 'Downgraded tests failed' && exit 1) From 998dc5f37b545206d6be4e8289d8b4b141b44954 Mon Sep 17 00:00:00 2001 From: Simon Bigelmayr Date: Fri, 22 Aug 2025 23:23:46 +0200 Subject: [PATCH 15/21] feat: update PHPStan configuration for PHP 7.4 compatibility --- .github/workflows/validate.yml | 2 +- phpstan-php74.neon | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 phpstan-php74.neon diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 03ecc12..2c728c4 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -142,6 +142,6 @@ jobs: - name: "Validate downgraded composer.json" run: composer validate --no-check-publish - name: "Run PHPStan on downgraded src" - run: vendor/bin/phpstan analyse src --error-format=github + run: vendor/bin/phpstan analyse src --error-format=github --configuration=phpstan-php74.neon - name: "Run PHPUnit on downgraded src" run: vendor/bin/phpunit --configuration phpunit.xml || (echo 'Downgraded tests failed' && exit 1) diff --git a/phpstan-php74.neon b/phpstan-php74.neon new file mode 100644 index 0000000..c1c1062 --- /dev/null +++ b/phpstan-php74.neon @@ -0,0 +1,9 @@ +includes: +- phpstan.neon +parameters: + excludePaths: + - src/Microplate/Scalars/Row8.php + - src/Microplate/Scalars/Row16NoJ.php + - src/Microplate/Scalars/Row16.php + - src/FluidXPlate/Scalars/FluidXBarcode.php + - src/FluidXPlate/Scalars/FrameStarBarcode.php From 4c2ccde63c4f654e747f1f29e9dcf4cce1e8479f Mon Sep 17 00:00:00 2001 From: Simon Bigelmayr Date: Fri, 22 Aug 2025 23:27:26 +0200 Subject: [PATCH 16/21] feat: reintroduce PHPStan analysis for downgraded source with updated exclusions --- .github/workflows/validate.yml | 4 ++-- phpstan.neon | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 2c728c4..212129d 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -141,7 +141,7 @@ jobs: run: composer install --no-interaction --prefer-dist - name: "Validate downgraded composer.json" run: composer validate --no-check-publish - - name: "Run PHPStan on downgraded src" - run: vendor/bin/phpstan analyse src --error-format=github --configuration=phpstan-php74.neon - name: "Run PHPUnit on downgraded src" run: vendor/bin/phpunit --configuration phpunit.xml || (echo 'Downgraded tests failed' && exit 1) + - name: "Run PHPStan on downgraded src" + run: vendor/bin/phpstan analyse src --error-format=github --configuration=phpstan-php74.neon diff --git a/phpstan.neon b/phpstan.neon index 84e9dee..22eda50 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -24,3 +24,9 @@ parameters: - '#Attribute class PHPUnit\\Framework\\Attributes\\DataProvider does not exist\.#' # Allows assert() calls to assist IDE autocompletion - message: '#Call to function assert\(\) with true.* will always evaluate to true\.#' + excludePaths: + - src/Microplate/Scalars/Row8.php + - src/Microplate/Scalars/Row16NoJ.php + - src/Microplate/Scalars/Row16.php + - src/FluidXPlate/Scalars/FluidXBarcode.php + - src/FluidXPlate/Scalars/FrameStarBarcode.php From b07e881e451195966df3fd71787f8a8eaac760ec Mon Sep 17 00:00:00 2001 From: Simon Bigelmayr Date: Fri, 22 Aug 2025 23:33:41 +0200 Subject: [PATCH 17/21] feat: add PSR-4 autoloading for test classes in development environment --- build/composer-php-74.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/build/composer-php-74.json b/build/composer-php-74.json index 5fe08d7..a9b8b4c 100644 --- a/build/composer-php-74.json +++ b/build/composer-php-74.json @@ -34,6 +34,11 @@ "MLL\\Utils\\": "src/" } }, + "autoload-dev": { + "psr-4": { + "MLL\\Utils\\Tests\\": "tests/" + } + }, "config": { "allow-plugins": { "ergebnis/composer-normalize": true, From 9277b3a688e64dec0540a4a92a2ff9c626bab29c Mon Sep 17 00:00:00 2001 From: Simon Bigelmayr Date: Fri, 22 Aug 2025 23:37:08 +0200 Subject: [PATCH 18/21] feat: simplify validation process and remove unused PHPStan dependencies for PHP 7.4 --- .github/workflows/validate.yml | 4 +--- build/composer-php-74.json | 18 +----------------- 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 212129d..bf19f18 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -142,6 +142,4 @@ jobs: - name: "Validate downgraded composer.json" run: composer validate --no-check-publish - name: "Run PHPUnit on downgraded src" - run: vendor/bin/phpunit --configuration phpunit.xml || (echo 'Downgraded tests failed' && exit 1) - - name: "Run PHPStan on downgraded src" - run: vendor/bin/phpstan analyse src --error-format=github --configuration=phpstan-php74.neon + run: vendor/bin/phpunit diff --git a/build/composer-php-74.json b/build/composer-php-74.json index a9b8b4c..40bda2d 100644 --- a/build/composer-php-74.json +++ b/build/composer-php-74.json @@ -15,18 +15,11 @@ }, "require-dev": { "ergebnis/composer-normalize": "^2.45", - "jangregor/phpstan-prophecy": "^1.0.2", "larastan/larastan": "^1", "mll-lab/php-cs-fixer-config": "^5.10", "orchestra/testbench": "^6.47.1", - "phpstan/extension-installer": "^1", - "phpstan/phpstan": "^1.8.11 || ^2.1.6", - "phpstan/phpstan-deprecation-rules": "^1", - "phpstan/phpstan-phpunit": "^1", - "phpstan/phpstan-strict-rules": "^1", "phpunit/phpunit": "^9.6.22", "rector/rector": "^1.2", - "spaze/phpstan-disallowed-calls": "^4.4", "thecodingmachine/phpstan-safe-rule": "^1.2.0" }, "autoload": { @@ -43,17 +36,8 @@ "allow-plugins": { "ergebnis/composer-normalize": true, "infection/extension-installer": true, - "ocramius/package-versions": true, - "phpstan/extension-installer": true + "ocramius/package-versions": true }, "sort-packages": true - }, - "extra": { - "phpstan": { - "includes": [ - "extension.neon", - "rules.neon" - ] - } } } From 7676ae72f0f42bbaf760d3da6f01be3414ea5abd Mon Sep 17 00:00:00 2001 From: Simon Bigelmayr Date: Fri, 22 Aug 2025 23:38:08 +0200 Subject: [PATCH 19/21] feat: remove deprecated exclusions from PHPStan configuration for improved analysis --- phpstan-php74.neon | 9 --------- phpstan.neon | 6 ------ 2 files changed, 15 deletions(-) delete mode 100644 phpstan-php74.neon diff --git a/phpstan-php74.neon b/phpstan-php74.neon deleted file mode 100644 index c1c1062..0000000 --- a/phpstan-php74.neon +++ /dev/null @@ -1,9 +0,0 @@ -includes: -- phpstan.neon -parameters: - excludePaths: - - src/Microplate/Scalars/Row8.php - - src/Microplate/Scalars/Row16NoJ.php - - src/Microplate/Scalars/Row16.php - - src/FluidXPlate/Scalars/FluidXBarcode.php - - src/FluidXPlate/Scalars/FrameStarBarcode.php diff --git a/phpstan.neon b/phpstan.neon index 22eda50..84e9dee 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -24,9 +24,3 @@ parameters: - '#Attribute class PHPUnit\\Framework\\Attributes\\DataProvider does not exist\.#' # Allows assert() calls to assist IDE autocompletion - message: '#Call to function assert\(\) with true.* will always evaluate to true\.#' - excludePaths: - - src/Microplate/Scalars/Row8.php - - src/Microplate/Scalars/Row16NoJ.php - - src/Microplate/Scalars/Row16.php - - src/FluidXPlate/Scalars/FluidXBarcode.php - - src/FluidXPlate/Scalars/FrameStarBarcode.php From dbddd0127763a5dc3c727664f0cec59fa05105c5 Mon Sep 17 00:00:00 2001 From: Simon Bigelmayr Date: Fri, 22 Aug 2025 23:40:20 +0200 Subject: [PATCH 20/21] feat: update PHP version in validation configuration to 8.3 for improved compatibility --- .github/workflows/validate.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index bf19f18..b050fe4 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -17,13 +17,12 @@ jobs: with: coverage: none extensions: mbstring - php-version: 8.1 + php-version: 8.3 - run: composer validate --strict static-code-analysis: runs-on: ubuntu-latest - continue-on-error: ${{ matrix.php-version == '8.4' }} strategy: fail-fast: false @@ -119,10 +118,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: "Setup PHP 8.1 (Rector)" + - name: "Setup PHP 8.3 (Rector)" uses: shivammathur/setup-php@v2 with: - php-version: 8.1 + php-version: 8.3 coverage: none - uses: ramsey/composer-install@v3 - name: "Downgrade src and tests" From de4665d2df5624b85c4bf5a86e625d03ca656694 Mon Sep 17 00:00:00 2001 From: Simon Bigelmayr Date: Fri, 22 Aug 2025 23:42:40 +0200 Subject: [PATCH 21/21] feat: remove Composer caching steps from validation workflow for streamlined execution --- .github/workflows/validate.yml | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index b050fe4..35b916a 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -42,15 +42,6 @@ jobs: - uses: ramsey/composer-install@v3 with: dependency-versions: "${{ matrix.dependencies }}" - - name: "Cache Composer" - uses: actions/cache@v4 - with: - path: ~/.composer/cache/files - key: composer-${{ runner.os }}-${{ matrix.php-version }}-${{ matrix.dependencies }}-${{ hashFiles('**/composer.lock') }} - restore-keys: | - composer-${{ runner.os }}-${{ matrix.php-version }}-${{ matrix.dependencies }}- - composer-${{ runner.os }}- - - run: vendor/bin/phpstan analyse --configuration=phpstan.neon tests: @@ -76,15 +67,6 @@ jobs: - uses: ramsey/composer-install@v3 with: dependency-versions: "${{ matrix.dependencies }}" - - name: "Cache Composer" - uses: actions/cache@v4 - with: - path: ~/.composer/cache/files - key: composer-${{ runner.os }}-${{ matrix.php-version }}-${{ matrix.dependencies }}-${{ hashFiles('**/composer.lock') }} - restore-keys: | - composer-${{ runner.os }}-${{ matrix.php-version }}-${{ matrix.dependencies }}- - composer-${{ runner.os }}- - - run: vendor/bin/phpunit code-coverage: @@ -100,14 +82,6 @@ jobs: php-version: 8.3 - uses: ramsey/composer-install@v3 - - name: "Cache Composer" - uses: actions/cache@v4 - with: - path: ~/.composer/cache/files - key: composer-${{ runner.os }}-coverage-${{ hashFiles('**/composer.lock') }} - restore-keys: | - composer-${{ runner.os }}-coverage- - - run: vendor/bin/phpunit --coverage-clover=.build/logs/clover.xml # Not using v4 due to the breaking changes described in https://github.com/codecov/codecov-action/releases/tag/v4.0.0