From 8945a47cb36a0217fe0d1483ab9633010e923f2d Mon Sep 17 00:00:00 2001 From: Jonas Staudenmeir Date: Tue, 19 Nov 2024 21:43:11 +0100 Subject: [PATCH] Updates --- composer.json | 5 ++-- phpstan.neon.dist | 3 --- src/Eloquent/HasGraphRelationships.php | 3 +++ src/Eloquent/HasRecursiveRelationships.php | 3 +++ .../Concatenation/IsConcatenableRelation.php | 2 +- .../Graph/Traits/IsRecursiveRelation.php | 4 +-- .../IsConcatenableAncestorsRelation.php | 2 +- .../IsConcatenableDescendantsRelation.php | 2 +- .../Traits/IsOfDescendantsRelation.php | 2 +- .../Relations/Traits/IsRecursiveRelation.php | 2 +- .../Traits/BuildsAdjacencyListQueries.php | 2 +- src/Eloquent/Traits/HasAdjacencyList.php | 2 ++ src/Eloquent/Traits/HasGraphAdjacencyList.php | 2 ++ .../Traits/HasGraphRelationshipScopes.php | 3 +++ .../Traits/HasOfDescendantsRelationships.php | 27 ++++++++++--------- src/Eloquent/Traits/HasQueryConstraints.php | 3 +++ .../HasRecursiveRelationshipHelpers.php | 3 +++ .../Traits/HasRecursiveRelationshipScopes.php | 3 +++ src/Query/Grammars/ExpressionGrammar.php | 4 +-- src/Query/Grammars/FirebirdGrammar.php | 2 ++ src/Query/Grammars/PostgresGrammar.php | 17 ++---------- src/Query/Grammars/SQLiteGrammar.php | 17 ++---------- src/Query/Grammars/SqlServerGrammar.php | 17 ++---------- .../Traits/CompilesMySqlAdjacencyLists.php | 9 +------ types/Graph/Scopes.php | 10 +++---- types/Tree/Relationships.php | 15 ++++++----- types/Tree/Scopes.php | 16 +++++------ 27 files changed, 80 insertions(+), 100 deletions(-) diff --git a/composer.json b/composer.json index ea8005f..7a33e5e 100644 --- a/composer.json +++ b/composer.json @@ -17,9 +17,10 @@ "require-dev": { "barryvdh/laravel-ide-helper": "^3.0", "harrygulliford/laravel-firebird": "^3.3", - "larastan/larastan": "^3", + "larastan/larastan": "^3.0", + "laravel/framework": "^11.0", "mockery/mockery": "^1.5.1", - "orchestra/testbench": "^9.0", + "orchestra/testbench-core": "^9.5", "phpunit/phpunit": "^11.0", "singlestoredb/singlestoredb-laravel": "^1.5.4", "staudenmeir/eloquent-has-many-deep": "^1.20" diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 0d360e2..81f13db 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -2,10 +2,7 @@ parameters: level: 9 paths: - src - treatPhpDocTypesAsCertain: false ignoreErrors: - - - identifier: trait.unused - '#Unsafe usage of new static\(\).#' - '#Access to an undefined property Illuminate\\Database\\Eloquent\\Model::\$laravel_through_key#' - '#Call to an undefined method TRelatedModel of Illuminate\\Database\\Eloquent\\Model#' diff --git a/src/Eloquent/HasGraphRelationships.php b/src/Eloquent/HasGraphRelationships.php index 32994b2..f897e59 100644 --- a/src/Eloquent/HasGraphRelationships.php +++ b/src/Eloquent/HasGraphRelationships.php @@ -5,6 +5,9 @@ use Staudenmeir\LaravelAdjacencyList\Eloquent\Traits\HasGraphAdjacencyList; use Staudenmeir\LaravelCte\Eloquent\QueriesExpressions; +/** + * @phpstan-ignore trait.unused + */ trait HasGraphRelationships { use HasGraphAdjacencyList; diff --git a/src/Eloquent/HasRecursiveRelationships.php b/src/Eloquent/HasRecursiveRelationships.php index 3458308..ce7756c 100644 --- a/src/Eloquent/HasRecursiveRelationships.php +++ b/src/Eloquent/HasRecursiveRelationships.php @@ -5,6 +5,9 @@ use Staudenmeir\LaravelAdjacencyList\Eloquent\Traits\HasAdjacencyList; use Staudenmeir\LaravelCte\Eloquent\QueriesExpressions; +/** + * @phpstan-ignore trait.unused + */ trait HasRecursiveRelationships { use HasAdjacencyList; diff --git a/src/Eloquent/Relations/Graph/Traits/Concatenation/IsConcatenableRelation.php b/src/Eloquent/Relations/Graph/Traits/Concatenation/IsConcatenableRelation.php index 4b62bd9..f44046b 100644 --- a/src/Eloquent/Relations/Graph/Traits/Concatenation/IsConcatenableRelation.php +++ b/src/Eloquent/Relations/Graph/Traits/Concatenation/IsConcatenableRelation.php @@ -183,7 +183,7 @@ public function matchResultsForDeepRelationship( * Build the model dictionary for a deep relation. * * @param \Illuminate\Database\Eloquent\Collection $results - * @return array> + * @return array> */ protected function buildDictionaryForDeepRelationship(Collection $results): array { diff --git a/src/Eloquent/Relations/Graph/Traits/IsRecursiveRelation.php b/src/Eloquent/Relations/Graph/Traits/IsRecursiveRelation.php index 730b88d..1115c39 100644 --- a/src/Eloquent/Relations/Graph/Traits/IsRecursiveRelation.php +++ b/src/Eloquent/Relations/Graph/Traits/IsRecursiveRelation.php @@ -51,7 +51,7 @@ public function __construct( /** * Add the recursive expression for an eager load of the relation. * - * @param list $models + * @param array $models * @param string $column * @return void */ @@ -80,7 +80,7 @@ protected function addEagerExpression(array $models, string $column): void * Build model dictionary. * * @param \Illuminate\Database\Eloquent\Collection $results - * @return array> + * @return array> */ protected function buildDictionary(Collection $results) { diff --git a/src/Eloquent/Relations/Traits/Concatenation/IsConcatenableAncestorsRelation.php b/src/Eloquent/Relations/Traits/Concatenation/IsConcatenableAncestorsRelation.php index 46017b9..2fd7d3d 100644 --- a/src/Eloquent/Relations/Traits/Concatenation/IsConcatenableAncestorsRelation.php +++ b/src/Eloquent/Relations/Traits/Concatenation/IsConcatenableAncestorsRelation.php @@ -66,7 +66,7 @@ public function matchResultsForDeepRelationship( * Build the model dictionary for a deep relation. * * @param \Illuminate\Database\Eloquent\Collection $results - * @return array> + * @return array> */ protected function buildDictionaryForDeepRelationship(Collection $results): array { diff --git a/src/Eloquent/Relations/Traits/Concatenation/IsConcatenableDescendantsRelation.php b/src/Eloquent/Relations/Traits/Concatenation/IsConcatenableDescendantsRelation.php index dfa3833..256adf6 100644 --- a/src/Eloquent/Relations/Traits/Concatenation/IsConcatenableDescendantsRelation.php +++ b/src/Eloquent/Relations/Traits/Concatenation/IsConcatenableDescendantsRelation.php @@ -70,7 +70,7 @@ public function matchResultsForDeepRelationship( * Build the model dictionary for a deep relation. * * @param \Illuminate\Database\Eloquent\Collection $results - * @return array> + * @return array> */ protected function buildDictionaryForDeepRelationship(Collection $results): array { diff --git a/src/Eloquent/Relations/Traits/IsOfDescendantsRelation.php b/src/Eloquent/Relations/Traits/IsOfDescendantsRelation.php index 103cb54..e7e0e4f 100644 --- a/src/Eloquent/Relations/Traits/IsOfDescendantsRelation.php +++ b/src/Eloquent/Relations/Traits/IsOfDescendantsRelation.php @@ -87,7 +87,7 @@ public function addEagerConstraints(array $models) * Set the where clause on the recursive expression query for an eager load of the relation. * * @param \Staudenmeir\LaravelAdjacencyList\Eloquent\Builder<\Illuminate\Database\Eloquent\Model> $query - * @param list $models + * @param array $models * @return void */ public function addEagerExpressionWhereConstraints(Builder $query, array $models) diff --git a/src/Eloquent/Relations/Traits/IsRecursiveRelation.php b/src/Eloquent/Relations/Traits/IsRecursiveRelation.php index 0fa8232..80356c1 100644 --- a/src/Eloquent/Relations/Traits/IsRecursiveRelation.php +++ b/src/Eloquent/Relations/Traits/IsRecursiveRelation.php @@ -41,7 +41,7 @@ public function __construct(Builder $query, Model $parent, $foreignKey, $localKe * Build model dictionary. * * @param \Illuminate\Database\Eloquent\Collection $results - * @return array> + * @return array> */ protected function buildDictionary(Collection $results) { diff --git a/src/Eloquent/Traits/BuildsAdjacencyListQueries.php b/src/Eloquent/Traits/BuildsAdjacencyListQueries.php index 70b9233..b210fc1 100644 --- a/src/Eloquent/Traits/BuildsAdjacencyListQueries.php +++ b/src/Eloquent/Traits/BuildsAdjacencyListQueries.php @@ -56,7 +56,7 @@ public function getModels($columns = ['*']) /** * Replace the separator in a PostgreSQL path column. * - * @param list $items + * @param array $items * @param string $path * @param string $separator * @return void diff --git a/src/Eloquent/Traits/HasAdjacencyList.php b/src/Eloquent/Traits/HasAdjacencyList.php index e19fa2f..65bcc5e 100644 --- a/src/Eloquent/Traits/HasAdjacencyList.php +++ b/src/Eloquent/Traits/HasAdjacencyList.php @@ -26,6 +26,8 @@ * @property-read static $rootAncestorOrSelf * @property-read Collection $siblings * @property-read Collection $siblingsAndSelf + * + * @phpstan-ignore trait.unused */ trait HasAdjacencyList { diff --git a/src/Eloquent/Traits/HasGraphAdjacencyList.php b/src/Eloquent/Traits/HasGraphAdjacencyList.php index 7715b13..6fc22ed 100644 --- a/src/Eloquent/Traits/HasGraphAdjacencyList.php +++ b/src/Eloquent/Traits/HasGraphAdjacencyList.php @@ -18,6 +18,8 @@ * @property-read Collection $descendantsAndSelf * @property-read Collection $parents * @property-read Collection $parentsAndSelf + * + * @phpstan-ignore trait.unused */ trait HasGraphAdjacencyList { diff --git a/src/Eloquent/Traits/HasGraphRelationshipScopes.php b/src/Eloquent/Traits/HasGraphRelationshipScopes.php index 8c39481..9e3b742 100644 --- a/src/Eloquent/Traits/HasGraphRelationshipScopes.php +++ b/src/Eloquent/Traits/HasGraphRelationshipScopes.php @@ -6,6 +6,9 @@ use Illuminate\Support\Collection; use Staudenmeir\LaravelAdjacencyList\Query\Grammars\ExpressionGrammar; +/** + * @phpstan-ignore trait.unused + */ trait HasGraphRelationshipScopes { /** diff --git a/src/Eloquent/Traits/HasOfDescendantsRelationships.php b/src/Eloquent/Traits/HasOfDescendantsRelationships.php index c7083fb..b3a5892 100644 --- a/src/Eloquent/Traits/HasOfDescendantsRelationships.php +++ b/src/Eloquent/Traits/HasOfDescendantsRelationships.php @@ -9,6 +9,9 @@ use Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\HasManyOfDescendants; use Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\MorphToManyOfDescendants; +/** + * @phpstan-ignore trait.unused + */ trait HasOfDescendantsRelationships { /** @@ -19,7 +22,7 @@ trait HasOfDescendantsRelationships * @param class-string $related * @param string|null $foreignKey * @param string|null $localKey - * @return \Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\HasManyOfDescendants + * @return \Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\HasManyOfDescendants */ public function hasManyOfDescendants($related, $foreignKey = null, $localKey = null) { @@ -47,7 +50,7 @@ public function hasManyOfDescendants($related, $foreignKey = null, $localKey = n * @param class-string $related * @param string|null $foreignKey * @param string|null $localKey - * @return \Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\HasManyOfDescendants + * @return \Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\HasManyOfDescendants */ public function hasManyOfDescendantsAndSelf($related, $foreignKey = null, $localKey = null) { @@ -71,13 +74,13 @@ public function hasManyOfDescendantsAndSelf($related, $foreignKey = null, $local * Instantiate a new HasManyOfDescendants relationship. * * @template TRelatedModel of Model - * @template TDeclaringModel of $this + * * @param \Illuminate\Database\Eloquent\Builder $query * @param TRelatedModel $parent * @param string $foreignKey * @param string $localKey * @param bool $andSelf - * @return \Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\HasManyOfDescendants + * @return \Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\HasManyOfDescendants */ protected function newHasManyOfDescendants(Builder $query, Model $parent, $foreignKey, $localKey, $andSelf) { @@ -95,7 +98,7 @@ protected function newHasManyOfDescendants(Builder $query, Model $parent, $forei * @param string|null $relatedPivotKey * @param string|null $parentKey * @param string|null $relatedKey - * @return \Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\BelongsToManyOfDescendants + * @return \Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\BelongsToManyOfDescendants */ public function belongsToManyOfDescendants( $related, @@ -139,7 +142,7 @@ public function belongsToManyOfDescendants( * @param string|null $relatedPivotKey * @param string|null $parentKey * @param string|null $relatedKey - * @return \Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\BelongsToManyOfDescendants + * @return \Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\BelongsToManyOfDescendants */ public function belongsToManyOfDescendantsAndSelf( $related, @@ -185,7 +188,7 @@ public function belongsToManyOfDescendantsAndSelf( * @param string $parentKey * @param string $relatedKey * @param bool $andSelf - * @return \Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\BelongsToManyOfDescendants + * @return \Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\BelongsToManyOfDescendants */ protected function newBelongsToManyOfDescendants( Builder $query, @@ -222,7 +225,7 @@ protected function newBelongsToManyOfDescendants( * @param string|null $parentKey * @param string|null $relatedKey * @param bool $inverse - * @return \Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\MorphToManyOfDescendants + * @return \Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\MorphToManyOfDescendants */ public function morphToManyOfDescendants( $related, @@ -276,7 +279,7 @@ public function morphToManyOfDescendants( * @param string|null $parentKey * @param string|null $relatedKey * @param bool $inverse - * @return \Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\MorphToManyOfDescendants + * @return \Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\MorphToManyOfDescendants */ public function morphToManyOfDescendantsAndSelf( $related, @@ -332,7 +335,7 @@ public function morphToManyOfDescendantsAndSelf( * @param string $relatedKey * @param bool $inverse * @param bool $andSelf - * @return \Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\MorphToManyOfDescendants + * @return \Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\MorphToManyOfDescendants */ protected function newMorphToManyOfDescendants( Builder $query, @@ -372,7 +375,7 @@ protected function newMorphToManyOfDescendants( * @param string|null $relatedPivotKey * @param string|null $parentKey * @param string|null $relatedKey - * @return \Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\MorphToManyOfDescendants + * @return \Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\MorphToManyOfDescendants */ public function morphedByManyOfDescendants( $related, @@ -411,7 +414,7 @@ public function morphedByManyOfDescendants( * @param string|null $relatedPivotKey * @param string|null $parentKey * @param string|null $relatedKey - * @return \Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\MorphToManyOfDescendants + * @return \Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\MorphToManyOfDescendants */ public function morphedByManyOfDescendantsAndSelf( $related, diff --git a/src/Eloquent/Traits/HasQueryConstraints.php b/src/Eloquent/Traits/HasQueryConstraints.php index b13a5cb..29174ec 100644 --- a/src/Eloquent/Traits/HasQueryConstraints.php +++ b/src/Eloquent/Traits/HasQueryConstraints.php @@ -2,6 +2,9 @@ namespace Staudenmeir\LaravelAdjacencyList\Eloquent\Traits; +/** + * @phpstan-ignore trait.unused + */ trait HasQueryConstraints { /** diff --git a/src/Eloquent/Traits/HasRecursiveRelationshipHelpers.php b/src/Eloquent/Traits/HasRecursiveRelationshipHelpers.php index 998e4f8..bc5bb34 100644 --- a/src/Eloquent/Traits/HasRecursiveRelationshipHelpers.php +++ b/src/Eloquent/Traits/HasRecursiveRelationshipHelpers.php @@ -4,6 +4,9 @@ use Illuminate\Database\Eloquent\Model; +/** + * @phpstan-ignore trait.unused + */ trait HasRecursiveRelationshipHelpers { /** diff --git a/src/Eloquent/Traits/HasRecursiveRelationshipScopes.php b/src/Eloquent/Traits/HasRecursiveRelationshipScopes.php index f180814..a4d1fcc 100644 --- a/src/Eloquent/Traits/HasRecursiveRelationshipScopes.php +++ b/src/Eloquent/Traits/HasRecursiveRelationshipScopes.php @@ -7,6 +7,9 @@ use Illuminate\Database\Query\JoinClause; use Staudenmeir\LaravelAdjacencyList\Query\Grammars\ExpressionGrammar; +/** + * @phpstan-ignore trait.unused + */ trait HasRecursiveRelationshipScopes { /** diff --git a/src/Query/Grammars/ExpressionGrammar.php b/src/Query/Grammars/ExpressionGrammar.php index bfad29c..a4e9792 100644 --- a/src/Query/Grammars/ExpressionGrammar.php +++ b/src/Query/Grammars/ExpressionGrammar.php @@ -9,7 +9,7 @@ interface ExpressionGrammar /** * Compile an initial path. * - * @param string $column + * @param string|\Illuminate\Contracts\Database\Query\Expression $column * @param string $alias * @return string */ @@ -18,7 +18,7 @@ public function compileInitialPath($column, $alias); /** * Compile a recursive path. * - * @param string $column + * @param string|\Illuminate\Contracts\Database\Query\Expression $column * @param string $alias * @param bool $reverse * @return string diff --git a/src/Query/Grammars/FirebirdGrammar.php b/src/Query/Grammars/FirebirdGrammar.php index 79f8625..7de8fad 100644 --- a/src/Query/Grammars/FirebirdGrammar.php +++ b/src/Query/Grammars/FirebirdGrammar.php @@ -10,11 +10,13 @@ class FirebirdGrammar extends Base implements ExpressionGrammar { use OrdersByPath; + /** @inheritDoc */ public function compileInitialPath($column, $alias) { return 'cast(' . $this->wrap($column) . ' as varchar(8191)) as ' . $this->wrap($alias); } + /** @inheritDoc */ public function compileRecursivePath($column, $alias, bool $reverse = false) { $wrappedColumn = $this->wrap($column); diff --git a/src/Query/Grammars/PostgresGrammar.php b/src/Query/Grammars/PostgresGrammar.php index 05ee021..1a1d2ae 100644 --- a/src/Query/Grammars/PostgresGrammar.php +++ b/src/Query/Grammars/PostgresGrammar.php @@ -9,13 +9,7 @@ class PostgresGrammar extends Base implements ExpressionGrammar { use OrdersByPath; - /** - * Compile an initial path. - * - * @param string $column - * @param string $alias - * @return string - */ + /** @inheritDoc */ public function compileInitialPath($column, $alias) { if (is_string($column) && $this->model->isIntegerAttribute($column)) { @@ -25,14 +19,7 @@ public function compileInitialPath($column, $alias) return 'array[('.$this->wrap($column)." || '')::varchar] as ".$this->wrap($alias); } - /** - * Compile a recursive path. - * - * @param string $column - * @param string $alias - * @param bool $reverse - * @return string - */ + /** @inheritDoc */ public function compileRecursivePath($column, $alias, bool $reverse = false) { $wrappedColumn = $this->wrap($column); diff --git a/src/Query/Grammars/SQLiteGrammar.php b/src/Query/Grammars/SQLiteGrammar.php index d38347f..77400d8 100644 --- a/src/Query/Grammars/SQLiteGrammar.php +++ b/src/Query/Grammars/SQLiteGrammar.php @@ -9,26 +9,13 @@ class SQLiteGrammar extends Base implements ExpressionGrammar { use OrdersByPath; - /** - * Compile an initial path. - * - * @param string $column - * @param string $alias - * @return string - */ + /** @inheritDoc */ public function compileInitialPath($column, $alias) { return 'cast(' . $this->wrap($column) . ' as text) as ' . $this->wrap($alias); } - /** - * Compile a recursive path. - * - * @param string $column - * @param string $alias - * @param bool $reverse - * @return string - */ + /** @inheritDoc */ public function compileRecursivePath($column, $alias, bool $reverse = false) { $wrappedColumn = $this->wrap($column); diff --git a/src/Query/Grammars/SqlServerGrammar.php b/src/Query/Grammars/SqlServerGrammar.php index 235140c..1d503bb 100644 --- a/src/Query/Grammars/SqlServerGrammar.php +++ b/src/Query/Grammars/SqlServerGrammar.php @@ -10,26 +10,13 @@ class SqlServerGrammar extends Base implements ExpressionGrammar { use OrdersByPath; - /** - * Compile an initial path. - * - * @param string $column - * @param string $alias - * @return string - */ + /** @inheritDoc */ public function compileInitialPath($column, $alias) { return 'cast('.$this->wrap($column).' as varchar(max)) as '.$this->wrap($alias); } - /** - * Compile a recursive path. - * - * @param string $column - * @param string $alias - * @param bool $reverse - * @return string - */ + /** @inheritDoc */ public function compileRecursivePath($column, $alias, bool $reverse = false) { $wrappedColumn = $this->wrap($column); diff --git a/src/Query/Grammars/Traits/CompilesMySqlAdjacencyLists.php b/src/Query/Grammars/Traits/CompilesMySqlAdjacencyLists.php index 4a5435d..383e2ac 100644 --- a/src/Query/Grammars/Traits/CompilesMySqlAdjacencyLists.php +++ b/src/Query/Grammars/Traits/CompilesMySqlAdjacencyLists.php @@ -15,14 +15,7 @@ public function compileInitialPath($column, $alias) return 'cast(' . $this->wrap($column) . ' as char(65535)) as ' . $this->wrap($alias); } - /** - * Compile a recursive path. - * - * @param string $column - * @param string $alias - * @param bool $reverse - * @return string - */ + /** @inheritDoc */ public function compileRecursivePath($column, $alias, bool $reverse = false) { $wrappedColumn = $this->wrap($column); diff --git a/types/Graph/Scopes.php b/types/Graph/Scopes.php index 9c9d723..ff195ff 100644 --- a/types/Graph/Scopes.php +++ b/types/Graph/Scopes.php @@ -9,27 +9,27 @@ function test(Node $node): void { assertType( - 'Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\Graph\Ancestors', + 'Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\Graph\Ancestors', $node->ancestors()->subgraph(fn () => null) ); assertType( - 'Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\Graph\Ancestors', + 'Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\Graph\Ancestors', $node->ancestors()->whereDepth(3) ); assertType( - 'Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\Graph\Ancestors', + 'Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\Graph\Ancestors', $node->ancestors()->breadthFirst() ); assertType( - 'Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\Graph\Ancestors', + 'Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\Graph\Ancestors', $node->ancestors()->depthFirst() ); assertType( - 'Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\Graph\Ancestors', + 'Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\Graph\Ancestors', $node->ancestors()->whereDepth(3)->breadthFirst() ); } diff --git a/types/Tree/Relationships.php b/types/Tree/Relationships.php index 2c55cdd..cecc79f 100644 --- a/types/Tree/Relationships.php +++ b/types/Tree/Relationships.php @@ -27,7 +27,7 @@ function test(User $user): void ); assertType( - 'Illuminate\Database\Eloquent\Relations\HasMany', + 'Illuminate\Database\Eloquent\Relations\HasMany', $user->children() ); @@ -75,33 +75,34 @@ function test(User $user): void 'Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\Siblings', $user->siblingsAndSelf() ); + assertType( - 'Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\BelongsToManyOfDescendants', + 'Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\BelongsToManyOfDescendants', $user->belongsToManyOfDescendants(Role::class) ); assertType( - 'Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\BelongsToManyOfDescendants', + 'Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\BelongsToManyOfDescendants', $user->belongsToManyOfDescendantsAndSelf(Role::class) ); assertType( - 'Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\HasManyOfDescendants', + 'Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\HasManyOfDescendants', $user->hasManyOfDescendantsAndSelf(Post::class) ); assertType( - 'Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\HasManyOfDescendants', + 'Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\HasManyOfDescendants', $user->hasManyOfDescendantsAndSelf(Post::class) ); assertType( - 'Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\MorphToManyOfDescendants', + 'Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\MorphToManyOfDescendants', $user->morphToManyOfDescendants(Tag::class, 'taggable') ); assertType( - 'Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\MorphToManyOfDescendants', + 'Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\MorphToManyOfDescendants', $user->morphToManyOfDescendantsAndSelf(Tag::class, 'taggable') ); } diff --git a/types/Tree/Scopes.php b/types/Tree/Scopes.php index 2bd979e..0d08baa 100644 --- a/types/Tree/Scopes.php +++ b/types/Tree/Scopes.php @@ -19,42 +19,42 @@ function test(User $user): void ); assertType( - 'Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\Ancestors', + 'Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\Ancestors', $user->ancestors()->doesntHaveChildren() ); assertType( - 'Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\Ancestors', + 'Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\Ancestors', $user->ancestors()->hasChildren() ); assertType( - 'Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\Ancestors', + 'Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\Ancestors', $user->ancestors()->hasParent() ); assertType( - 'Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\Ancestors', + 'Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\Ancestors', $user->ancestors()->isLeaf() ); assertType( - 'Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\Ancestors', + 'Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\Ancestors', $user->ancestors()->isRoot() ); assertType( - 'Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\Ancestors', + 'Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\Ancestors', $user->ancestors()->breadthFirst() ); assertType( - 'Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\Ancestors', + 'Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\Ancestors', $user->ancestors()->depthFirst() ); assertType( - 'Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\Ancestors', + 'Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\Ancestors', $user->ancestors()->hasChildren()->breadthFirst() ); }