From 201d99c2f35f5847e188d90ce0b8d9450d4cf783 Mon Sep 17 00:00:00 2001 From: Naxvog Date: Tue, 10 Nov 2026 23:12:15 +0100 Subject: [PATCH 1/2] Run the test suite on PHP 8.1 in CI composer.json allows PHP ^8.1, but the CI matrix started at 8.2 and the suite could not even compile on 8.1: two test files declared a trait constant and a readonly class (both PHP 8.2 syntax) at file level. Move those declarations into autoloaded fixtures, guard the one test that was missing a version check, and add 8.1 to the matrix. The 8.1 job turns off Composer's security blocking, because Pest 2 (the only line that supports 8.1) pins PHPUnit <= 10.5.36, which is blocked for a dev-only advisory. The Security Audit job is unchanged. --- .github/workflows/ci.yml | 6 +++++- .../ReadonlyClassWithPromotedProperty.php | 20 +++++++++++++++++++ tests/Fixtures/Types/TraitConstContainer.php | 16 +++++++++++++++ tests/Fixtures/Types/TraitWithConstant.php | 13 ++++++++++++ .../ClassConstKeyShapeTest.php | 17 +--------------- .../PromotedReadonlyPropertyTest.php | 17 +++++++--------- 6 files changed, 62 insertions(+), 27 deletions(-) create mode 100644 tests/Fixtures/Readonly/ReadonlyClassWithPromotedProperty.php create mode 100644 tests/Fixtures/Types/TraitConstContainer.php create mode 100644 tests/Fixtures/Types/TraitWithConstant.php diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 77b4d30d..aeeca167 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -82,7 +82,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, windows-latest, macos-latest] - php: ['8.2', '8.3', '8.4', '8.5'] + php: ['8.1', '8.2', '8.3', '8.4', '8.5'] steps: - name: Checkout Code @@ -99,6 +99,10 @@ jobs: uses: ramsey/composer-install@v3 with: dependency-versions: ${{ matrix.php == '8.2' && 'lowest' || 'highest' }} + env: + # Pest 2 is the only line that runs on PHP 8.1 and it pins PHPUnit <= 10.5.36, which Composer + # blocks for a dev-only advisory (CVE-2026-24765). The Security Audit job still runs unfiltered. + COMPOSER_NO_SECURITY_BLOCKING: ${{ matrix.php == '8.1' && '1' || '0' }} - name: Warm Up TypePHP Cache run: php bin/typephp cache:warm diff --git a/tests/Fixtures/Readonly/ReadonlyClassWithPromotedProperty.php b/tests/Fixtures/Readonly/ReadonlyClassWithPromotedProperty.php new file mode 100644 index 00000000..2beefceb --- /dev/null +++ b/tests/Fixtures/Readonly/ReadonlyClassWithPromotedProperty.php @@ -0,0 +1,20 @@ + $adapters + */ + public function __construct(public iterable $adapters) + { + } +} diff --git a/tests/Fixtures/Types/TraitConstContainer.php b/tests/Fixtures/Types/TraitConstContainer.php new file mode 100644 index 00000000..32a0ec86 --- /dev/null +++ b/tests/Fixtures/Types/TraitConstContainer.php @@ -0,0 +1,16 @@ + $adapters - */ - public function __construct(public iterable $adapters) - { - } -} - describe('Promoted Readonly Property Contracts', function () { test('instantiates class with promoted readonly iterable without throwing Cannot modify readonly property error', function () { $instance = new PromotedReadonlyIterable([new ReadonlyAdapterA()]); @@ -64,6 +55,12 @@ public function __construct(public iterable $adapters) }); test('instantiates PHP 8.2 readonly class with promoted property without throwing Cannot modify readonly property error', function () { + if (PHP_VERSION_ID < 80200) { + expect(true)->toBeTrue(); + + return; + } + $instance = new ReadonlyClassWithPromotedProperty([new ReadonlyAdapterA()]); expect($instance->adapters)->toHaveCount(1); From b421664ebbf4d01d73930a1f0bcafa16be16e963 Mon Sep 17 00:00:00 2001 From: Naxvog Date: Tue, 10 Nov 2026 23:13:21 +0100 Subject: [PATCH 2/2] Remove dead test file and duplicated docblock - tests/SomeTest.php contained only a commented-out test. - Config::get() carried the same docblock twice. --- src/Internal/Util/Config.php | 5 ----- tests/SomeTest.php | 10 ---------- 2 files changed, 15 deletions(-) delete mode 100644 tests/SomeTest.php diff --git a/src/Internal/Util/Config.php b/src/Internal/Util/Config.php index a80dd9f1..9bf293e6 100644 --- a/src/Internal/Util/Config.php +++ b/src/Internal/Util/Config.php @@ -585,11 +585,6 @@ public static function getProjectRoot(?string $startingDir = null): string return self::$projectRoot = '.'; } - /** - * Loads and caches global configuration from 'typephp.php', 'composer.json' extra, extensions, and base defaults. - * - * @return array - */ /** * Loads and caches global configuration from 'typephp.php', 'composer.json' extra, extensions, and base defaults. * diff --git a/tests/SomeTest.php b/tests/SomeTest.php deleted file mode 100644 index 27e4116e..00000000 --- a/tests/SomeTest.php +++ /dev/null @@ -1,10 +0,0 @@ - */ -// $typeArray = [1, 2, 3, '1']; - -// expect($typeArray)->toBeArray(); -// });