Skip to content

Commit 4baf6b9

Browse files
committed
Level up PHPStan
1 parent 61f8b3c commit 4baf6b9

File tree

5 files changed

+13
-7
lines changed

5 files changed

+13
-7
lines changed

phpstan.neon

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ includes:
77
- vendor/phpstan/phpstan-phpunit/rules.neon
88
parameters:
99
# TODO level up to max
10-
level: 2
10+
level: 3
1111
paths:
1212
- src
1313
- tests

tests/EnumCastTest.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,25 @@ public function test_can_set_model_value_using_enum_instance()
1919
public function test_can_set_model_value_using_enum_value()
2020
{
2121
$model = new Example;
22+
// @phpstan-ignore-next-line loose typing
2223
$model->user_type = UserType::Moderator;
2324

2425
$this->assertEquals(UserType::Moderator(), $model->user_type);
2526
}
2627

2728
public function test_cannot_set_model_value_using_invalid_enum_value()
2829
{
29-
$this->expectException(InvalidEnumMemberException::class);
30-
3130
$model = new Example;
31+
32+
$this->expectException(InvalidEnumMemberException::class);
33+
// @phpstan-ignore-next-line intentionally wrong
3234
$model->user_type = 5;
3335
}
3436

3537
public function test_getting_model_value_returns_enum_instance()
3638
{
3739
$model = new Example;
40+
// @phpstan-ignore-next-line loose typing
3841
$model->user_type = UserType::Moderator;
3942

4043
$this->assertInstanceOf(UserType::class, $model->user_type);

tests/Models/Example.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use Illuminate\Database\Eloquent\Model;
77

88
/**
9-
* @property UserType $user_type
9+
* @property UserType|null $user_type
1010
*/
1111
class Example extends Model
1212
{

tests/Models/NativeCastModel.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use Illuminate\Database\Eloquent\Model;
88

99
/**
10-
* @property UserType $user_type
10+
* @property UserType|null $user_type
1111
* @property UserTypeCustomCast $user_type_custom
1212
*/
1313
class NativeCastModel extends Model

tests/NativeEnumCastTest.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,25 @@ public function test_can_set_model_value_using_enum_instance()
2121
public function test_can_set_model_value_using_enum_value()
2222
{
2323
$model = new NativeCastModel;
24+
// @phpstan-ignore-next-line loose typing
2425
$model->user_type = UserType::Moderator;
2526

2627
$this->assertEquals(UserType::Moderator(), $model->user_type);
2728
}
2829

2930
public function test_cannot_set_model_value_using_invalid_enum_value()
3031
{
31-
$this->expectException(InvalidEnumMemberException::class);
32-
3332
$model = new NativeCastModel;
33+
34+
$this->expectException(InvalidEnumMemberException::class);
35+
// @phpstan-ignore-next-line intentionally wrong
3436
$model->user_type = 5;
3537
}
3638

3739
public function test_getting_model_value_returns_enum_instance()
3840
{
3941
$model = new NativeCastModel;
42+
// @phpstan-ignore-next-line loose typing
4043
$model->user_type = UserType::Moderator;
4144

4245
$this->assertInstanceOf(UserType::class, $model->user_type);

0 commit comments

Comments
 (0)