Skip to content

Commit

Permalink
Increase PHPStan level
Browse files Browse the repository at this point in the history
  • Loading branch information
staudenmeir committed Sep 30, 2024
1 parent a535c05 commit 3eaab72
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 10 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

[![CI](https://github.com/staudenmeir/laravel-adjacency-list/actions/workflows/ci.yml/badge.svg)](https://github.com/staudenmeir/laravel-adjacency-list/actions/workflows/ci.yml?query=branch%3Amain)
[![Code Coverage](https://codecov.io/gh/staudenmeir/laravel-adjacency-list/graph/badge.svg?token=VhZ3oBh1YE)](https://codecov.io/gh/staudenmeir/laravel-adjacency-list)
[![PHPStan](https://img.shields.io/badge/PHPStan-level%209-brightgreen.svg?style=flat)](https://github.com/staudenmeir/laravel-adjacency-list/actions/workflows/static-analysis.yml?query=branch%3Amain)
[![Latest Stable Version](https://poser.pugx.org/staudenmeir/laravel-adjacency-list/v/stable)](https://packagist.org/packages/staudenmeir/laravel-adjacency-list)
[![Total Downloads](https://poser.pugx.org/staudenmeir/laravel-adjacency-list/downloads)](https://packagist.org/packages/staudenmeir/laravel-adjacency-list/stats)
[![License](https://poser.pugx.org/staudenmeir/laravel-adjacency-list/license)](https://github.com/staudenmeir/laravel-adjacency-list/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: 8
level: 9
paths:
- src
ignoreErrors:
Expand Down
9 changes: 8 additions & 1 deletion src/Eloquent/Relations/Descendants.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,14 @@ protected function buildDictionary(Collection $results)
})->all();
}

/** @inheritDoc */
/**
* Add the constraints for an internal relationship existence query.
*
* @param \Illuminate\Database\Eloquent\Builder<TRelatedModel> $query
* @param \Illuminate\Database\Eloquent\Builder<TDeclaringModel> $parentQuery
* @param list<string|\Illuminate\Database\Query\Expression>|string|\Illuminate\Database\Query\Expression $columns
* @return \Illuminate\Database\Eloquent\Builder<TRelatedModel>
*/
public function getRelationExistenceQuery(Builder $query, Builder $parentQuery, $columns = ['*'])
{
if ($query->getQuery()->from === $parentQuery->getQuery()->from) {
Expand Down
9 changes: 8 additions & 1 deletion src/Eloquent/Relations/Graph/Ancestors.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,14 @@ protected function buildDictionary(Collection $results)
return $dictionary;
}

/** @inheritDoc */
/**
* Add the constraints for an internal relationship existence query.
*
* @param \Illuminate\Database\Eloquent\Builder<TRelatedModel> $query
* @param \Illuminate\Database\Eloquent\Builder<TDeclaringModel> $parentQuery
* @param list<string|\Illuminate\Database\Query\Expression>|string|\Illuminate\Database\Query\Expression $columns
* @return \Illuminate\Database\Eloquent\Builder<TRelatedModel>
*/
public function getRelationExistenceQuery(Builder $query, Builder $parentQuery, $columns = ['*'])
{
if ($query->getQuery()->from === $parentQuery->getQuery()->from) {
Expand Down
9 changes: 8 additions & 1 deletion src/Eloquent/Relations/Graph/Descendants.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,14 @@ protected function buildDictionary(Collection $results)
return $dictionary;
}

/** @inheritDoc */
/**
* Add the constraints for an internal relationship existence query.
*
* @param \Illuminate\Database\Eloquent\Builder<TRelatedModel> $query
* @param \Illuminate\Database\Eloquent\Builder<TDeclaringModel> $parentQuery
* @param list<string|\Illuminate\Database\Query\Expression>|string|\Illuminate\Database\Query\Expression $columns
* @return \Illuminate\Database\Eloquent\Builder<TRelatedModel>
*/
public function getRelationExistenceQuery(Builder $query, Builder $parentQuery, $columns = ['*'])
{
if ($query->getQuery()->from === $parentQuery->getQuery()->from) {
Expand Down
9 changes: 3 additions & 6 deletions src/IdeHelper/RecursiveRelationsHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,10 @@
use Staudenmeir\LaravelAdjacencyList\Eloquent\HasGraphRelationships;
use Staudenmeir\LaravelAdjacencyList\Eloquent\HasRecursiveRelationships;

/**
* @template TRelationship {name: string, manyRelation: boolean, comment: string}
*/
class RecursiveRelationsHook implements ModelHookInterface
{
/**
* @var list<array<TRelationship>>
* @var list<array{name: string, manyRelation: boolean, comment: string}>
*/
protected static array $treeRelationships = [
[
Expand Down Expand Up @@ -83,7 +80,7 @@ class RecursiveRelationsHook implements ModelHookInterface
];

/**
* @var list<array<TRelationship>>
* @var list<array{name: string, manyRelation: boolean, comment: string}>
*/
protected static array $graphRelationships = [
[
Expand Down Expand Up @@ -152,7 +149,7 @@ public function run(ModelsCommand $command, Model $model): void
}

/**
* @param array<TRelationship> $relationship
* @param array{name: string, manyRelation: boolean, comment: string} $relationship
*/
protected function addRelationship(ModelsCommand $command, array $relationship, string $type): void
{
Expand Down

0 comments on commit 3eaab72

Please sign in to comment.