Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHPStan lvl 4 & Fix/issue 233 followup #257

Merged
merged 44 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
0ffbca1
Add failing test
SanderMuller Aug 28, 2024
99ae3c0
reduce fatal error to phpstan failure
SanderMuller Aug 28, 2024
5f1132b
WIP
SanderMuller Aug 29, 2024
52a13dc
wip
SanderMuller Aug 29, 2024
90ea5fc
wip
SanderMuller Aug 29, 2024
9c5957a
Followup of fix/issue-233
SanderMuller Aug 29, 2024
d4c6fd3
phpstan lvl 3
SanderMuller Aug 29, 2024
6f07063
level 4
SanderMuller Aug 29, 2024
96d8f7e
Merge branch 'main' into fix/issue-233-followup
SanderMuller Aug 29, 2024
b4642ec
resolve merge conflicts
SanderMuller Aug 29, 2024
f2d51a9
Update HasOfDescendantsRelationships.php
SanderMuller Aug 29, 2024
c5d65e0
Resolve error
staudenmeir Aug 29, 2024
63749db
Fix Singlestore getExpressionGrammar
SanderMuller Aug 30, 2024
8fe6aae
Update BuildsAdjacencyListQueries.php
SanderMuller Aug 30, 2024
d5c585f
Use inheritDoc where possible
SanderMuller Sep 4, 2024
b77d671
Resolve @phpstan-ignore return.phpDocType
SanderMuller Sep 4, 2024
edd14cf
add phpstan/phpstan-phpunit
SanderMuller Sep 4, 2024
156dd5e
Lock phpstan/phpstan to 1.11.1 for now
SanderMuller Sep 4, 2024
9111f06
Merge branch 'main' into fix/issue-233-followup
staudenmeir Sep 7, 2024
04e23fb
wip
SanderMuller Sep 9, 2024
3e7b50b
WIP
SanderMuller Sep 9, 2024
25bc3c2
wip
SanderMuller Sep 9, 2024
60550bd
Update HasRecursiveRelationshipScopes.php
SanderMuller Sep 9, 2024
e6ae2f3
Update IsOfDescendantsRelation.php
SanderMuller Sep 9, 2024
6db83a8
Update composer.json
SanderMuller Sep 9, 2024
7c2d568
Refactoring
staudenmeir Sep 11, 2024
44b2389
Merge branch 'main' into fix/issue-233-followup
SanderMuller Sep 13, 2024
402f62d
Use native return types without docblock
SanderMuller Sep 13, 2024
816f8c3
Apply review feedback
SanderMuller Sep 13, 2024
863b045
Restore phpdoc
SanderMuller Sep 13, 2024
487ecd0
Remove "tests" path
staudenmeir Sep 23, 2024
e99b860
Increase PHPStan level
staudenmeir Sep 23, 2024
15e238f
Update return types
staudenmeir Sep 23, 2024
c332549
Merge branch 'main' into fix/issue-233-followup
staudenmeir Sep 29, 2024
e90dbf3
Refactoring
staudenmeir Sep 29, 2024
265a8b7
Adjust to interface changes
staudenmeir Sep 29, 2024
3513905
Remove mixin
staudenmeir Sep 29, 2024
491801a
Remove "tests" path
staudenmeir Sep 29, 2024
809f806
Improve types
staudenmeir Sep 29, 2024
b38e7c8
Revert breaking changes
staudenmeir Sep 29, 2024
485076c
Formatting
staudenmeir Sep 29, 2024
b8fb6fc
Add type checks
staudenmeir Sep 30, 2024
1178425
Add type checks
staudenmeir Sep 30, 2024
1b70a20
Formatting
staudenmeir Sep 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ includes:
- ./vendor/larastan/larastan/extension.neon
- ./vendor/phpstan/phpstan-mockery/extension.neon
parameters:
level: 2
level: 4
staudenmeir marked this conversation as resolved.
Show resolved Hide resolved
paths:
- src
- tests
Expand All @@ -14,3 +14,5 @@ parameters:
- '#Call to an undefined method TModel of Illuminate\\Database\\Eloquent\\Model#'
- '#Call to an undefined method Illuminate\\Database\\Eloquent\\Model::#'
- '#Call to an undefined method Illuminate\\Database\\Eloquent\\Builder#'
- identifier: expr.resultUnused
path: tests
staudenmeir marked this conversation as resolved.
Show resolved Hide resolved
3 changes: 2 additions & 1 deletion src/Eloquent/Graph/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ class Collection extends Base
* Generate a nested tree.
*
* @param string $childrenRelation
* @return $this<int, TModel>
* @return static<TKey, TModel>
* @phpstan-ignore return.phpDocType
SanderMuller marked this conversation as resolved.
Show resolved Hide resolved
*/
public function toTree(string $childrenRelation = 'children'): static
{
Expand Down
4 changes: 2 additions & 2 deletions src/Eloquent/Relations/BelongsToManyOfDescendants.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ class BelongsToManyOfDescendants extends BelongsToMany
* Create a new belongs to many of descendants relationship instance.
*
* @param \Illuminate\Database\Eloquent\Builder<TRelatedModel> $query
* @param \Illuminate\Database\Eloquent\Model $parent
* @param string $table
* @param TRelatedModel $parent
SanderMuller marked this conversation as resolved.
Show resolved Hide resolved
* @param string|class-string<TRelatedModel> $table
* @param string $foreignPivotKey
* @param string $relatedPivotKey
* @param string $parentKey
Expand Down
4 changes: 2 additions & 2 deletions src/Eloquent/Relations/Bloodline.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class Bloodline extends Descendants
/**
* Create a new bloodline relationship instance.
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param \Illuminate\Database\Eloquent\Model $parent
* @param \Illuminate\Database\Eloquent\Builder<TRelatedModel> $query
* @param TRelatedModel $parent
* @param string $foreignKey
* @param string $localKey
* @return void
Expand Down
10 changes: 5 additions & 5 deletions src/Eloquent/Relations/Descendants.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function addConstraints()
/**
* Set the constraints for an eager load of the relation.
*
* @param array $models
* @param \Illuminate\Database\Eloquent\Model[] $models
* @return void
*/
public function addEagerConstraints(array $models)
Expand All @@ -68,8 +68,8 @@ public function addEagerConstraints(array $models)
/**
* Match the eagerly loaded results to their parents.
*
* @param array $models
* @param \Illuminate\Database\Eloquent\Collection $results
* @param \Illuminate\Database\Eloquent\Model[] $models
* @param \Illuminate\Database\Eloquent\Collection<array-key, \Illuminate\Database\Eloquent\Model> $results
* @param string $relation
* @return array
*/
Expand All @@ -93,8 +93,8 @@ public function match(array $models, Collection $results, $relation)
/**
* Build model dictionary.
*
* @param \Illuminate\Database\Eloquent\Collection $results
* @return array
* @param \Illuminate\Database\Eloquent\Collection<array-key, \Illuminate\Database\Eloquent\Model> $results
* @return array<string, \Illuminate\Database\Eloquent\Model[]>
*/
protected function buildDictionary(Collection $results)
{
Expand Down
6 changes: 3 additions & 3 deletions src/Eloquent/Relations/Graph/Ancestors.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function addConstraints()
/**
* Set the constraints for an eager load of the relation.
*
* @param array $models
* @param \Illuminate\Database\Eloquent\Model[] $models
* @return void
*/
public function addEagerConstraints(array $models)
Expand All @@ -60,8 +60,8 @@ public function addEagerConstraints(array $models)
/**
* Build model dictionary.
*
* @param \Illuminate\Database\Eloquent\Collection $results
* @return array
* @param \Illuminate\Database\Eloquent\Collection<array-key, \Illuminate\Database\Eloquent\Model> $results
* @return array<string, \Illuminate\Database\Eloquent\Model[]>
*/
SanderMuller marked this conversation as resolved.
Show resolved Hide resolved
protected function buildDictionary(Collection $results)
{
Expand Down
6 changes: 3 additions & 3 deletions src/Eloquent/Relations/Graph/Descendants.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function addConstraints()
/**
* Set the constraints for an eager load of the relation.
*
* @param array $models
* @param \Illuminate\Database\Eloquent\Model[] $models
* @return void
*/
public function addEagerConstraints(array $models)
Expand All @@ -60,8 +60,8 @@ public function addEagerConstraints(array $models)
/**
* Build model dictionary.
*
* @param \Illuminate\Database\Eloquent\Collection $results
* @return array
* @param \Illuminate\Database\Eloquent\Collection<array-key, \Illuminate\Database\Eloquent\Model> $results
* @return array<string, \Illuminate\Database\Eloquent\Model[]>
*/
SanderMuller marked this conversation as resolved.
Show resolved Hide resolved
protected function buildDictionary(Collection $results)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ protected function replacePathSeparator(Collection $models, string $column, stri
* Set the constraints for an eager load of the deep relation.
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param array $models
* @param \Illuminate\Database\Eloquent\Model[] $models
* @return void
*/
public function addEagerConstraintsToDeepRelationship(Builder $query, array $models): void
Expand Down Expand Up @@ -140,8 +140,8 @@ protected function mergeExpressions(Builder $query, Builder $from): Builder
/**
* Match the eagerly loaded results for a deep relationship to their parents.
*
* @param array $models
* @param \Illuminate\Database\Eloquent\Collection $results
* @param \Illuminate\Database\Eloquent\Model[] $models
* @param \Illuminate\Database\Eloquent\Collection<array-key, \Illuminate\Database\Eloquent\Model> $results
* @param string $relation
* @param string $type
* @return array
Expand Down Expand Up @@ -174,8 +174,8 @@ public function matchResultsForDeepRelationship(
/**
* Build the model dictionary for a deep relation.
*
* @param \Illuminate\Database\Eloquent\Collection $results
* @return array
* @param \Illuminate\Database\Eloquent\Collection<array-key, \Illuminate\Database\Eloquent\Model> $results
* @return array<string, \Illuminate\Database\Eloquent\Model[]>
*/
protected function buildDictionaryForDeepRelationship(Collection $results): array
{
Expand Down
6 changes: 3 additions & 3 deletions src/Eloquent/Relations/Graph/Traits/IsRecursiveRelation.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function __construct(
/**
* Add the recursive expression for an eager load of the relation.
*
* @param array $models
* @param \Illuminate\Database\Eloquent\Model[] $models
* @param string $column
* @return void
*/
Expand Down Expand Up @@ -75,8 +75,8 @@ protected function addEagerExpression(array $models, string $column): void
/**
* Build model dictionary.
*
* @param \Illuminate\Database\Eloquent\Collection $results
* @return array
* @param \Illuminate\Database\Eloquent\Collection<array-key, \Illuminate\Database\Eloquent\Model> $results
* @return array<string, \Illuminate\Database\Eloquent\Model[]>
*/
protected function buildDictionary(Collection $results)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Eloquent/Relations/HasManyOfDescendants.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class HasManyOfDescendants extends HasMany
* Create a new has many of descendants relationship instance.
*
* @param \Illuminate\Database\Eloquent\Builder<TRelatedModel> $query
* @param \Illuminate\Database\Eloquent\Model $parent
* @param TRelatedModel $parent
* @param string $foreignKey
* @param string $localKey
* @param bool $andSelf
Expand Down
6 changes: 3 additions & 3 deletions src/Eloquent/Relations/MorphToManyOfDescendants.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class MorphToManyOfDescendants extends BelongsToManyOfDescendants
/**
* The class name of the morph type constraint.
*
* @var string
* @var class-string<TRelatedModel>
*/
protected $morphClass;

Expand All @@ -41,7 +41,7 @@ class MorphToManyOfDescendants extends BelongsToManyOfDescendants
* @param \Illuminate\Database\Eloquent\Builder<TRelatedModel> $query
* @param \Illuminate\Database\Eloquent\Model $parent
* @param string $name
* @param string $table
* @param string|class-string<TRelatedModel> $table
* @param string $foreignPivotKey
* @param string $relatedPivotKey
* @param string $parentKey
Expand Down Expand Up @@ -97,7 +97,7 @@ protected function addExpressionWhereConstraints(Builder $query)
* Set the where clause on the recursive expression query for an eager load of the relation.
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param array $models
* @param \Illuminate\Database\Eloquent\Model[] $models
* @return void
*/
public function addEagerExpressionWhereConstraints(Builder $query, array $models)
Expand Down
4 changes: 2 additions & 2 deletions src/Eloquent/Relations/RootAncestor.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ class RootAncestor extends HasOne
/**
* Create a new root ancestor relationship instance.
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param \Illuminate\Database\Eloquent\Model $parent
* @param \Illuminate\Database\Eloquent\Builder<TRelatedModel> $query
* @param TRelatedModel $parent
* @param string $foreignKey
* @param string $localKey
* @return void
Expand Down
4 changes: 2 additions & 2 deletions src/Eloquent/Relations/RootAncestorOrSelf.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class RootAncestorOrSelf extends RootAncestor
/**
* Create a new root ancestor or self relationship instance.
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param \Illuminate\Database\Eloquent\Model $parent
* @param \Illuminate\Database\Eloquent\Builder<TRelatedModel> $query
* @param TRelatedModel $parent
* @param string $foreignKey
* @param string $localKey
* @return void
Expand Down
10 changes: 5 additions & 5 deletions src/Eloquent/Relations/Siblings.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
/**
* Create a new siblings relationship instance.
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param \Illuminate\Database\Eloquent\Model $parent
* @param \Illuminate\Database\Eloquent\Builder<TRelatedModel> $query
* @param TRelatedModel $parent
* @param string $foreignKey
* @param string $localKey
* @param bool $andSelf
Expand Down Expand Up @@ -65,7 +65,7 @@
/**
* Set the constraints for an eager load of the relation.
*
* @param array $models
* @param \Illuminate\Database\Eloquent\Model[] $models
* @return void
*/
public function addEagerConstraints(array $models)
Expand All @@ -76,7 +76,7 @@
function (Builder $query) use ($keys) {
$query->whereIn($this->foreignKey, $keys);

if (in_array(null, $keys, true)) {

Check failure on line 79 in src/Eloquent/Relations/Siblings.php

View workflow job for this annotation

GitHub Actions / phpstan (8.3, stable)

Call to function in_array() with arguments null, array<int, int|string> and true will always evaluate to false.
$query->orWhereNull($this->foreignKey);
}
}
Expand All @@ -86,8 +86,8 @@
/**
* Match the eagerly loaded results to their parents.
*
* @param array $models
* @param \Illuminate\Database\Eloquent\Collection $results
* @param \Illuminate\Database\Eloquent\Model[] $models
* @param \Illuminate\Database\Eloquent\Collection<array-key, \Illuminate\Database\Eloquent\Model> $results
* @param string $relation
* @return array
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ trait IsConcatenableAncestorsRelation
* Set the constraints for an eager load of the deep relation.
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param array $models
* @param \Illuminate\Database\Eloquent\Model[] $models
* @return void
*/
public function addEagerConstraintsToDeepRelationship(Builder $query, array $models): void
Expand All @@ -27,8 +27,8 @@ public function addEagerConstraintsToDeepRelationship(Builder $query, array $mod
/**
* Match the eagerly loaded results for a deep relationship to their parents.
*
* @param array $models
* @param \Illuminate\Database\Eloquent\Collection $results
* @param \Illuminate\Database\Eloquent\Model[] $models
* @param \Illuminate\Database\Eloquent\Collection<array-key, \Illuminate\Database\Eloquent\Model> $results
* @param string $relation
* @param string $type
* @return array
Expand Down Expand Up @@ -61,8 +61,8 @@ public function matchResultsForDeepRelationship(
/**
* Build the model dictionary for a deep relation.
*
* @param \Illuminate\Database\Eloquent\Collection $results
* @return array
* @param \Illuminate\Database\Eloquent\Collection<array-key, \Illuminate\Database\Eloquent\Model> $results
* @return array<string, \Illuminate\Database\Eloquent\Model[]>
*/
protected function buildDictionaryForDeepRelationship(Collection $results): array
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ trait IsConcatenableDescendantsRelation
* Set the constraints for an eager load of the deep relation.
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param array $models
* @param \Illuminate\Database\Eloquent\Model[] $models
* @return void
*/
public function addEagerConstraintsToDeepRelationship(Builder $query, array $models): void
Expand All @@ -33,8 +33,8 @@ public function addEagerConstraintsToDeepRelationship(Builder $query, array $mod
/**
* Match the eagerly loaded results for a deep relationship to their parents.
*
* @param array $models
* @param \Illuminate\Database\Eloquent\Collection $results
* @param \Illuminate\Database\Eloquent\Model[] $models
* @param \Illuminate\Database\Eloquent\Collection<array-key, \Illuminate\Database\Eloquent\Model> $results
* @param string $relation
* @param string $type
* @return array
Expand Down Expand Up @@ -65,8 +65,8 @@ public function matchResultsForDeepRelationship(
/**
* Build the model dictionary for a deep relation.
*
* @param \Illuminate\Database\Eloquent\Collection $results
* @return array
* @param \Illuminate\Database\Eloquent\Collection<array-key, \Illuminate\Database\Eloquent\Model> $results
* @return array<string, \Illuminate\Database\Eloquent\Model[]>
*/
protected function buildDictionaryForDeepRelationship(Collection $results): array
{
Expand Down
24 changes: 12 additions & 12 deletions src/Eloquent/Relations/Traits/IsAncestorRelation.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function addConstraints()
/**
* Set the constraints for an eager load of the relation.
*
* @param array $models
* @param \Illuminate\Database\Eloquent\Model[] $models
* @return void
*/
public function addEagerConstraints(array $models)
Expand All @@ -52,7 +52,7 @@ public function addEagerConstraints(array $models)
/**
* Get all of the primary keys for an array of models.
*
* @param array $models
* @param \Illuminate\Database\Eloquent\Model[] $models
* @param string $key
* @return array
*/
Expand All @@ -68,8 +68,8 @@ protected function getKeys(array $models, $key = null)
/**
* Match the eagerly loaded results to their many parents.
*
* @param array $models
* @param \Illuminate\Database\Eloquent\Collection $results
* @param \Illuminate\Database\Eloquent\Model[] $models
* @param \Illuminate\Database\Eloquent\Collection<array-key, \Illuminate\Database\Eloquent\Model> $results
* @param string $relation
* @param string $type
* @return array
Expand All @@ -96,10 +96,10 @@ public function matchOneOrMany(array $models, Collection $results, $relation, $t
/**
* Add the constraints for a relationship query.
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param \Illuminate\Database\Eloquent\Builder $parentQuery
* @param \Staudenmeir\LaravelAdjacencyList\Eloquent\Builder<\Illuminate\Database\Eloquent\Model> $query
* @param \Staudenmeir\LaravelAdjacencyList\Eloquent\Builder<\Illuminate\Database\Eloquent\Model> $parentQuery
* @param array|mixed $columns
* @return \Illuminate\Database\Eloquent\Builder
* @return \Staudenmeir\LaravelAdjacencyList\Eloquent\Builder<\Illuminate\Database\Eloquent\Model>
*/
public function getRelationExistenceQuery(Builder $query, Builder $parentQuery, $columns = ['*'])
SanderMuller marked this conversation as resolved.
Show resolved Hide resolved
{
Expand All @@ -123,10 +123,10 @@ public function getRelationExistenceQuery(Builder $query, Builder $parentQuery,
/**
* Add the constraints for a relationship query on the same table.
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param \Illuminate\Database\Eloquent\Builder $parentQuery
* @param \Staudenmeir\LaravelAdjacencyList\Eloquent\Builder<\Illuminate\Database\Eloquent\Model> $query
* @param \Staudenmeir\LaravelAdjacencyList\Eloquent\Builder<\Illuminate\Database\Eloquent\Model> $parentQuery
* @param array|mixed $columns
* @return \Illuminate\Database\Eloquent\Builder
* @return \Staudenmeir\LaravelAdjacencyList\Eloquent\Builder<\Illuminate\Database\Eloquent\Model>
*/
public function getRelationExistenceQueryForSelfRelation(Builder $query, Builder $parentQuery, $columns = ['*'])
{
Expand Down Expand Up @@ -157,9 +157,9 @@ public function getRelationExistenceQueryForSelfRelation(Builder $query, Builder
* Add a recursive expression to the query.
*
* @param callable $constraint
* @param \Illuminate\Database\Eloquent\Builder|null $query
* @param \Staudenmeir\LaravelAdjacencyList\Eloquent\Builder<\Illuminate\Database\Eloquent\Model>|null $query
* @param string|null $from
* @return \Illuminate\Database\Eloquent\Builder
* @return \Staudenmeir\LaravelAdjacencyList\Eloquent\Builder<\Illuminate\Database\Eloquent\Model>
*/
protected function addExpression(callable $constraint, ?Builder $query = null, $from = null)
{
Expand Down
Loading
Loading