Skip to content

Commit

Permalink
Increase PHPStan level to 5 (#244)
Browse files Browse the repository at this point in the history
* Increase PHPStan level

* Resolve phpstan ::load error (#245)

* Prepare for Collection::load() fix

---------

Co-authored-by: Sander Muller <[email protected]>
  • Loading branch information
staudenmeir and SanderMuller authored Sep 10, 2024
1 parent dc374a8 commit 39891e6
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"orchestra/testbench": "^9.0",
"phpstan/phpstan": "^1.10",
"phpstan/phpstan-mockery": "^1.1",
"phpstan/phpstan-phpunit": "^1.4",
"phpunit/phpunit": "^11.0",
"staudenmeir/eloquent-json-relations": "^1.11",
"staudenmeir/laravel-adjacency-list": "^1.21"
Expand Down
5 changes: 4 additions & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
includes:
- ./vendor/larastan/larastan/extension.neon
- ./vendor/phpstan/phpstan-mockery/extension.neon
- ./vendor/phpstan/phpstan-phpunit/extension.neon
- ./vendor/phpstan/phpstan-phpunit/rules.neon
parameters:
level: 4
level: 5
paths:
- src
- tests
treatPhpDocTypesAsCertain: false
ignoreErrors:
- '#Unsafe usage of new static\(\).#'
- '#Parameter \#\d+ \$relations of method Illuminate\\Database\\Eloquent\\Collection<[^>]+\>::load\(\) expects#'
3 changes: 2 additions & 1 deletion tests/Concatenation/LaravelAdjacencyList/AncestorsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Tests\Concatenation\LaravelAdjacencyList;

use Illuminate\Database\Eloquent\Relations\Relation;
use Staudenmeir\EloquentHasManyDeep\HasManyDeep;
use Tests\Concatenation\LaravelAdjacencyList\Models\User;

Expand Down Expand Up @@ -65,7 +66,7 @@ public function testEagerLoadingWithHasOneDeep()
public function testLazyEagerLoading()
{
$users = User::all()->load([
'ancestorPosts' => fn (HasManyDeep $query) => $query->orderBy('id'),
'ancestorPosts' => fn (Relation $query) => $query->getQuery()->orderBy('id'),
]);

$this->assertEquals([], $users[0]->ancestorPosts->pluck('id')->all());
Expand Down
3 changes: 2 additions & 1 deletion tests/Concatenation/LaravelAdjacencyList/BloodlineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Tests\Concatenation\LaravelAdjacencyList;

use Illuminate\Database\Eloquent\Relations\Relation;
use Staudenmeir\EloquentHasManyDeep\HasManyDeep;
use Tests\Concatenation\LaravelAdjacencyList\Models\User;

Expand Down Expand Up @@ -35,7 +36,7 @@ public function testEagerLoading()
public function testLazyEagerLoading()
{
$users = User::all()->load([
'bloodlinePosts' => fn (HasManyDeep $query) => $query->orderBy('id'),
'bloodlinePosts' => fn (Relation $query) => $query->getQuery()->orderBy('id'),
]);

$this->assertEquals([10, 20, 30, 40, 50, 60, 70, 80], $users[0]->bloodlinePosts->pluck('id')->all());
Expand Down

0 comments on commit 39891e6

Please sign in to comment.