Skip to content

Commit 0606f81

Browse files
committed
fix phpstan
1 parent 1c265a7 commit 0606f81

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"orchestra/testbench": "^8.0|^9.0|^10.0",
2424
"laravel/legacy-factories": "^1.0.4",
2525
"friendsofphp/php-cs-fixer": "^3.13",
26-
"larastan/larastan": "^2.0"
26+
"larastan/larastan": "^2.0|^3.0"
2727
},
2828
"autoload": {
2929
"psr-4": {

tests/Models/User.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44

55
use Cesargb\Database\Support\CascadeDelete;
66
use Illuminate\Database\Eloquent\Model;
7+
use Illuminate\Database\Eloquent\Relations\MorphOne;
78

89
/**
9-
* @property \Tests\Models\Image $image
10+
* @property ?\Tests\Models\Image $image
1011
*/
1112
class User extends Model
1213
{
@@ -16,7 +17,7 @@ class User extends Model
1617

1718
protected $fillable = ['name'];
1819

19-
public function image()
20+
public function image(): MorphOne
2021
{
2122
return $this->morphOne(Image::class, 'imageable');
2223
}

tests/Morph/CleanTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function test_clean_residual_morph_relations_from_model_morph_many()
7575

7676
$this->assertEquals(2, $numRowsDeleted);
7777
$this->assertEquals(2, Option::count());
78-
$this->assertNotNull(2, Photo::where('id', 1)->first()->options()->count());
78+
$this->assertEquals(2, Photo::where('id', 1)->first()->options()->count());
7979
}
8080

8181
public function test_clean_residual_morph_relations_from_model_morph_to_many()

tests/Morph/DeleteTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function test_delete_morph_relations_from_event_model__morph_one()
2222
});
2323

2424
$this->assertEquals(2, Image::count());
25-
$this->assertNotNull(User::first()->image);
25+
$this->assertNotNull(User::with('image')->first()->image);
2626

2727
User::first()->delete();
2828

@@ -38,12 +38,12 @@ public function test_delete_morph_relations_from_record_model__morph_one()
3838
});
3939

4040
$this->assertEquals(2, Image::count());
41-
$this->assertNotNull(User::first()->image);
41+
$this->assertNotNull(User::with('image')->first()->image);
4242

4343
(new Morph())->delete(User::first());
4444

4545
$this->assertEquals(1, Image::count());
46-
$this->assertNull(User::first()->image);
46+
$this->assertNull(User::with('image')->first()->image);
4747
}
4848

4949
public function test_delete_morph_relations_from_record_model__morph_many()

0 commit comments

Comments
 (0)