Skip to content

Commit

Permalink
Increase PHPStan level
Browse files Browse the repository at this point in the history
  • Loading branch information
staudenmeir committed Aug 28, 2024
1 parent 361f47d commit 33f1bd0
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
},
"require-dev": {
"barryvdh/laravel-ide-helper": "^3.0",
"larastan/larastan": "^2.9",
"orchestra/testbench": "^9.0",
"phpstan/phpstan": "^1.10",
"phpunit/phpunit": "^11.0"
Expand Down
4 changes: 3 additions & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
includes:
- ./vendor/larastan/larastan/extension.neon
parameters:
level: 0
level: 1
paths:
- src
- tests
3 changes: 2 additions & 1 deletion src/Relations/BelongsToThrough.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ class BelongsToThrough extends Relation
* @param string $prefix
* @param array $foreignKeyLookup
* @param array $localKeyLookup
*
* @return void
*
* @phpstan-ignore constructor.unusedParameter($localKey)
*/
public function __construct(
Builder $query,
Expand Down
13 changes: 7 additions & 6 deletions tests/Models/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@

namespace Tests\Models;

use Znck\Eloquent\Relations\BelongsToThrough;
use Znck\Eloquent\Traits\HasTableAlias;

class Comment extends Model
{
use HasTableAlias;

public function country()
public function country(): BelongsToThrough
{
return $this->belongsToThrough(Country::class, [User::class, Post::class])->withDefault();
}

public function countryWithCustomForeignKeys()
public function countryWithCustomForeignKeys(): BelongsToThrough
{
return $this->belongsToThrough(
Country::class,
Expand All @@ -24,22 +25,22 @@ public function countryWithCustomForeignKeys()
);
}

public function countryWithTrashedUser()
public function countryWithTrashedUser(): BelongsToThrough
{
return $this->country()->withTrashed(['users.deleted_at']);
}

public function countryWithPrefix()
public function countryWithPrefix(): BelongsToThrough
{
return $this->belongsToThrough(Country::class, [User::class, Post::class], null, 'custom_');
}

public function grandparent()
public function grandparent(): BelongsToThrough
{
return $this->belongsToThrough(self::class, self::class.' as alias', null, '', [self::class => 'parent_id']);
}

public function user()
public function user(): BelongsToThrough
{
return $this->belongsToThrough(User::class, Post::class);
}
Expand Down

0 comments on commit 33f1bd0

Please sign in to comment.