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 3d1cf59 commit d0bed70
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/Eloquent/Relations/Traits/IsCustomizable.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ trait IsCustomizable
/**
* The custom constraints callback for an eager load of the relation.
*
* @var callable(\Illuminate\Database\Eloquent\Builder<TRelatedModel>, array<int, TDeclaringModel>): void
* @var callable(\Illuminate\Database\Eloquent\Builder<TRelatedModel>, array<int, \Illuminate\Database\Eloquent\Model>): void
*/
protected $customEagerConstraintsCallback = null;

Expand Down Expand Up @@ -65,7 +65,7 @@ public function withCustomThroughKeyCallback(callable $callback): static
/**
* Set the custom constraints callback for an eager load of the relation.
*
* @param callable(\Illuminate\Database\Eloquent\Builder<TRelatedModel>, array<int, TDeclaringModel>): void $callback
* @param callable(\Illuminate\Database\Eloquent\Builder<TRelatedModel>, array<int, \Illuminate\Database\Eloquent\Model>): void $callback
* @return $this
*/
public function withCustomEagerConstraintsCallback(callable $callback): static
Expand Down
17 changes: 12 additions & 5 deletions src/Eloquent/Relations/Traits/RetrievesIntermediateTables.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ trait RetrievesIntermediateTables
/**
* The intermediate tables to retrieve.
*
* @var array<string, array{table: string, columns: array<string>, class: class-string<\Illuminate\Database\Eloquent\Model>, postProcessor: callable|null}>
* @var array<string, array{table: string,
* columns: array<int, string>,
* class: class-string<\Illuminate\Database\Eloquent\Model>,
* postProcessor: callable(\Illuminate\Database\Eloquent\Model, array<string, mixed>): array<string, mixed>|null}>
*/
protected $intermediateTables = [];

Expand Down Expand Up @@ -44,7 +47,7 @@ public function withIntermediate($class, array $columns = ['*'], $accessor = nul
* @param list<string> $columns
* @param class-string<\Illuminate\Database\Eloquent\Model> $class
* @param string|null $accessor
* @param callable|null $postProcessor
* @param callable(\Illuminate\Database\Eloquent\Model, array<string, mixed>): array<string, mixed>|null $postProcessor
* @return $this
*/
public function withPivot(
Expand All @@ -58,6 +61,7 @@ public function withPivot(
/** @var \Illuminate\Database\Connection $connection */
$connection = $this->query->getConnection();

/** @var array<int, string> $columns */
$columns = $connection->getSchemaBuilder()->getColumnListing($table);
}

Expand All @@ -75,7 +79,7 @@ public function withPivot(
/**
* Get the intermediate columns for the relation.
*
* @return array<string>
* @return array<int, string>
*/
protected function intermediateColumns()
{
Expand Down Expand Up @@ -131,7 +135,10 @@ protected function hydrateIntermediateRelations(array $models)
* Get the intermediate relationship from the query.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param array{table: string, columns: array<string>, class: class-string<\Illuminate\Database\Eloquent\Model>, postProcessor: callable|null} $intermediateTable
* @param array{table: string,
* columns: array<int, string>,
* class: class-string<\Illuminate\Database\Eloquent\Model>,
* postProcessor: callable(\Illuminate\Database\Eloquent\Model, array<string, mixed>): array<string, mixed>|null} $intermediateTable
* @param string $prefix
* @return \Illuminate\Database\Eloquent\Model
*/
Expand Down Expand Up @@ -195,7 +202,7 @@ protected function prefix($accessor)
/**
* Get the intermediate tables.
*
* @return array<string, array{table: string, columns: array<string>, class: class-string<\Illuminate\Database\Eloquent\Model>, postProcessor: callable|null}>
* @return array<string, array{table: string, columns: array<int, string>, class: class-string<\Illuminate\Database\Eloquent\Model>, postProcessor: callable|null}>
*/
public function getIntermediateTables(): array
{
Expand Down
4 changes: 2 additions & 2 deletions src/Eloquent/Relations/Traits/SupportsCompositeKeys.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ protected function addConstraintsWithCompositeKey(): void
/**
* Set the constraints for an eager load of the relation for a leading composite key.
*
* @param array<\Illuminate\Database\Eloquent\Model> $models
* @param array<int, \Illuminate\Database\Eloquent\Model> $models
* @return void
*/
protected function addEagerConstraintsWithCompositeKey(array $models): void
Expand Down Expand Up @@ -159,7 +159,7 @@ protected function buildDictionaryWithCompositeKey(Collection $results): array
/**
* Get the columns to select for a leading composite key.
*
* @return array<string>
* @return array<int, string>
*/
protected function shouldSelectWithCompositeKey(): array
{
Expand Down
2 changes: 1 addition & 1 deletion src/HasManyDeep.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ protected function performJoin(?Builder $query = null)
* Set the select clause for the relation query.
*
* @param list<string> $columns
* @return array<string>
* @return array<int, string>
*/
protected function shouldSelect(array $columns = ['*'])
{
Expand Down

0 comments on commit d0bed70

Please sign in to comment.