Skip to content

Commit

Permalink
create new php8-1 file
Browse files Browse the repository at this point in the history
  • Loading branch information
calebdw committed Mar 22, 2024
1 parent a14ff22 commit b374448
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
6 changes: 6 additions & 0 deletions tests/Type/GeneralTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

use function version_compare;

use const PHP_VERSION;

class GeneralTypeTest extends TypeInferenceTestCase
{
/** @return iterable<mixed> */
Expand Down Expand Up @@ -61,6 +63,10 @@ public static function dataFileAsserts(): iterable
yield from self::gatherAssertTypes(__DIR__ . '/data/view.php');
yield from self::gatherAssertTypes(__DIR__ . '/data/where-relation.php');

if (version_compare(PHP_VERSION, '8.1.0', '>=')) {
yield from self::gatherAssertTypes(__DIR__ . '/data/model-properties-php8-1.php');
}

if (version_compare(LARAVEL_VERSION, '10.15.0', '>=')) {
yield from self::gatherAssertTypes(__DIR__ . '/data/model-l10-15.php');
}
Expand Down
14 changes: 14 additions & 0 deletions tests/Type/data/model-properties-php8-1.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace ModelProperties;

use App\Casts\BackedEnumeration;
use App\Casts\BasicEnumeration;
use App\User;

use function PHPStan\Testing\assertType;


/** @var User $user */
assertType(BasicEnumeration::class, $user->basic_enum);
assertType(BackedEnumeration::class, $user->backed_enum);
7 changes: 0 additions & 7 deletions tests/Type/data/model-properties.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

use App\Account;
use App\Address;
use App\Casts\BackedEnumeration;
use App\Casts\BasicEnumeration;
use App\Group;
use App\GuardedModel;
use App\Role;
Expand Down Expand Up @@ -50,11 +48,6 @@ function foo(User $user, Account $account, Role $role, Group $group, Team $team,
assertType('int', $user->timestamp);
assertType('\'active\'|\'inactive\'', $user->enum_status);

if (version_compare(PHP_VERSION, '8.1.0', '>=')) {
assertType(BasicEnumeration::class, $user->basic_enum);
assertType(BackedEnumeration::class, $user->backed_enum);
}

// Castable
assertType(Stringable::class, $user->castable_with_argument);

Expand Down

0 comments on commit b374448

Please sign in to comment.