Skip to content

Commit

Permalink
Increase PHPStan level
Browse files Browse the repository at this point in the history
  • Loading branch information
staudenmeir committed Nov 17, 2024
1 parent 689532c commit 3d1cf59
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![CI](https://github.com/staudenmeir/eloquent-has-many-deep/actions/workflows/ci.yml/badge.svg)](https://github.com/staudenmeir/eloquent-has-many-deep/actions/workflows/ci.yml?query=branch%3Amain)
[![Code Coverage](https://codecov.io/gh/staudenmeir/eloquent-has-many-deep/graph/badge.svg?token=H59fIf4mG6)](https://codecov.io/gh/staudenmeir/eloquent-has-many-deep)
[![PHPStan](https://img.shields.io/badge/PHPStan-level%209-brightgreen.svg?style=flat)](https://github.com/staudenmeir/eloquent-has-many-deep/actions/workflows/static-analysis.yml?query=branch%3Amain)
[![PHPStan](https://img.shields.io/badge/PHPStan-level%2010-brightgreen.svg?style=flat)](https://github.com/staudenmeir/eloquent-has-many-deep/actions/workflows/static-analysis.yml?query=branch%3Amain)
[![Latest Stable Version](https://poser.pugx.org/staudenmeir/eloquent-has-many-deep/v/stable)](https://packagist.org/packages/staudenmeir/eloquent-has-many-deep)
[![Total Downloads](https://poser.pugx.org/staudenmeir/eloquent-has-many-deep/downloads)](https://packagist.org/packages/staudenmeir/eloquent-has-many-deep/stats)
[![License](https://poser.pugx.org/staudenmeir/eloquent-has-many-deep/license)](https://github.com/staudenmeir/eloquent-has-many-deep/blob/main/LICENSE)
Expand Down
2 changes: 1 addition & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
parameters:
level: 9
level: 10
paths:
- src
treatPhpDocTypesAsCertain: false
Expand Down
2 changes: 1 addition & 1 deletion phpstan.types.neon.dist
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
includes:
- ./vendor/larastan/larastan/extension.neon
parameters:
level: 9
level: 10
paths:
- types
20 changes: 12 additions & 8 deletions src/Eloquent/Relations/Traits/IsCustomizable.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,44 @@

namespace Staudenmeir\EloquentHasManyDeep\Eloquent\Relations\Traits;

/**
* @template TRelatedModel of \Illuminate\Database\Eloquent\Model
* @template TDeclaringModel of \Illuminate\Database\Eloquent\Model
*/
trait IsCustomizable
{
/**
* The custom callbacks to run at the end of the get() method.
*
* @var list<callable>
* @var list<callable(\Illuminate\Database\Eloquent\Collection<int, TRelatedModel>): void>
*/
protected array $postGetCallbacks = [];

/**
* The custom through key callback for an eager load of the relation.
*
* @var callable
* @var callable(string): string
*/
protected $customThroughKeyCallback = null;

/**
* The custom constraints callback for an eager load of the relation.
*
* @var callable
* @var callable(\Illuminate\Database\Eloquent\Builder<TRelatedModel>, array<int, TDeclaringModel>): void
*/
protected $customEagerConstraintsCallback = null;

/**
* The custom matching callbacks for the eagerly loaded results.
*
* @var list<callable>
* @var list<callable(array<int, TDeclaringModel>, \Illuminate\Database\Eloquent\Collection<int, TRelatedModel>, string, string=): array<int, TDeclaringModel>>
*/
protected array $customEagerMatchingCallbacks = [];

/**
* Set custom callbacks to run at the end of the get() method.
*
* @param list<callable> $callbacks
* @param list<callable(\Illuminate\Database\Eloquent\Collection<int, TRelatedModel>): void> $callbacks
* @return $this
*/
public function withPostGetCallbacks(array $callbacks): static
Expand All @@ -48,7 +52,7 @@ public function withPostGetCallbacks(array $callbacks): static
/**
* Set the custom through key callback for an eager load of the relation.
*
* @param callable $callback
* @param callable(string): string $callback
* @return $this
*/
public function withCustomThroughKeyCallback(callable $callback): static
Expand All @@ -61,7 +65,7 @@ public function withCustomThroughKeyCallback(callable $callback): static
/**
* Set the custom constraints callback for an eager load of the relation.
*
* @param callable $callback
* @param callable(\Illuminate\Database\Eloquent\Builder<TRelatedModel>, array<int, TDeclaringModel>): void $callback
* @return $this
*/
public function withCustomEagerConstraintsCallback(callable $callback): static
Expand All @@ -74,7 +78,7 @@ public function withCustomEagerConstraintsCallback(callable $callback): static
/**
* Set a custom matching callback for the eagerly loaded results.
*
* @param callable $callback
* @param callable(array<int, TDeclaringModel>, \Illuminate\Database\Eloquent\Collection<int, TRelatedModel>, string, string=): array<int, TDeclaringModel> $callback
* @return $this
*/
public function withCustomEagerMatchingCallback(callable $callback): static
Expand Down
1 change: 1 addition & 0 deletions src/Eloquent/Relations/Traits/JoinsThroughParents.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ function (JoinClause $join) use ($joins) {

if ($this->throughParentInstanceSoftDeletes($throughParent)
&& method_exists($throughParent, 'getQualifiedDeletedAtColumn')) {
/** @var string $column */
$column = $throughParent->getQualifiedDeletedAtColumn();

$query->withGlobalScope(__CLASS__ . ":$column", function (Builder $query) use ($column) {
Expand Down
1 change: 1 addition & 0 deletions src/HasManyDeep.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class HasManyDeep extends HasManyThrough implements ConcatenableRelation
use HasEagerLoading;
use HasExistenceQueries;
use IsConcatenable;
/** @use \Staudenmeir\EloquentHasManyDeep\Eloquent\Relations\Traits\IsCustomizable<TRelatedModel, TDeclaringModel> */
use IsCustomizable;
use JoinsThroughParents;
/** @use \Staudenmeir\EloquentHasManyDeep\Eloquent\Relations\Traits\RetrievesIntermediateTables<TRelatedModel, TDeclaringModel> */
Expand Down

0 comments on commit 3d1cf59

Please sign in to comment.