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
6 changes: 5 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
5 changes: 0 additions & 5 deletions src/Internal/Util/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, mixed>
*/
/**
* Loads and caches global configuration from 'typephp.php', 'composer.json' extra, extensions, and base defaults.
*
Expand Down
20 changes: 20 additions & 0 deletions tests/Fixtures/Readonly/ReadonlyClassWithPromotedProperty.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

declare(strict_types=1);

namespace TypePHP\Tests\Fixtures\Readonly;

use TypePHP\Tests\TypeChecking\Boundaries\ReadonlyAdapterInterface;

/**
* Readonly classes need PHP 8.2+, so this lives outside the test file and is only autoloaded there.
*/
readonly class ReadonlyClassWithPromotedProperty
{
/**
* @param iterable<ReadonlyAdapterInterface> $adapters
*/
public function __construct(public iterable $adapters)
{
}
}
16 changes: 16 additions & 0 deletions tests/Fixtures/Types/TraitConstContainer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

declare(strict_types=1);

namespace TypePHP\Tests\Fixtures\Types;

class TraitConstContainer
{
/**
* @param array{TraitWithConstant::TRAIT_KEY: positive-int} $payload
*/
public function process(array $payload): bool
{
return true;
}
}
13 changes: 13 additions & 0 deletions tests/Fixtures/Types/TraitWithConstant.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

declare(strict_types=1);

namespace TypePHP\Tests\Fixtures\Types;

/**
* Constants in traits need PHP 8.2+, so this lives outside the test file and is only autoloaded there.
*/
trait TraitWithConstant
{
public const TRAIT_KEY = 'trait_action';
}
10 changes: 0 additions & 10 deletions tests/SomeTest.php

This file was deleted.

17 changes: 1 addition & 16 deletions tests/TypeChecking/ArraysAndShapes/ClassConstKeyShapeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,7 @@

use TypePHP\Tests\Fixtures\Types\ConstKeyContainer;
use TypePHP\Tests\Fixtures\Types\MissingConstKeyContainer;

trait TraitWithConstantFixture
{
public const TRAIT_KEY = 'trait_action';
}

class TraitConstContainer
{
/**
* @param array{TraitWithConstantFixture::TRAIT_KEY: positive-int} $payload
*/
public function process(array $payload): bool
{
return true;
}
}
use TypePHP\Tests\Fixtures\Types\TraitConstContainer;

describe('Class Constant Keys in Array Shapes (array{self::CONST_KEY: T})', function () {

Expand Down
17 changes: 7 additions & 10 deletions tests/TypeChecking/Boundaries/PromotedReadonlyPropertyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Closure;
use TypePHP\Exception\TypeError;
use TypePHP\Tests\Fixtures\Readonly\ReadonlyClassWithPromotedProperty;

interface ReadonlyAdapterInterface
{
Expand Down Expand Up @@ -39,16 +40,6 @@ public function __construct(public readonly Closure $factory)
}
}

readonly class ReadonlyClassWithPromotedProperty
{
/**
* @param iterable<ReadonlyAdapterInterface> $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()]);
Expand All @@ -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);
Expand Down
Loading