Skip to content

Commit 1f9dd9c

Browse files
authored
Clean up proto ci steps and fix PHPStan with latest dependencies
1 parent fe37f79 commit 1f9dd9c

File tree

12 files changed

+36
-31
lines changed

12 files changed

+36
-31
lines changed

.github/workflows/proto.yml renamed to .github/workflows/generate-proto-code.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: "Build protobuf"
1+
name: "Generate proto code"
22
on:
33
push:
44
branches:
@@ -8,7 +8,7 @@ on:
88
- 'buf.gen.yaml'
99

1010
jobs:
11-
proto:
11+
generate-proto-code:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- uses: actions/checkout@v4

.github/workflows/update-reports-proto.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
name: "Update reports.proto"
1+
name: "Update `reports.proto`"
22
on:
33
workflow_dispatch:
44
schedule:
55
- cron: "0 0 * * 0"
66

77
jobs:
8-
proto:
8+
update-reports-proto:
99
runs-on: ubuntu-latest
1010
steps:
1111
- uses: actions/checkout@v4
@@ -22,7 +22,7 @@ jobs:
2222
2323
- uses: peter-evans/create-pull-request@v5
2424
with:
25-
title: 'Updated `reports.proto`'
26-
commit_message: Updated `reports.proto`
25+
title: Update `reports.proto`
26+
commit-message: Update `reports.proto`
2727
branch: patch/update-reports-proto
2828
delete-branch: true

phpstan.neon

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ parameters:
5353
# Laravel 11 changes a lot of generics
5454
- '#generic class (Illuminate\\Database\\Eloquent\\Builder|Laravel\\Scout\\Builder)( but)? does not specify its types#'
5555
- '#contains generic type Illuminate\\Testing\\TestResponse<.+> but class Illuminate\\Testing\\TestResponse is not generic\.#'
56-
- '#Generic type Illuminate\\Database\\Eloquent\\Relations\\(HasOne|HasMany|BelongsToMany|MorphOne|MorphMany|MorphToMany)<.+> in PHPDoc tag @return specifies \d template types, but class Illuminate\\Database\\Eloquent\\Relations\\\1 supports only \d: .+#'
56+
- '#Generic type Illuminate\\.+ specifies \d template types, but (class|interface) Illuminate\\.+ supports only \d: .+#'
5757
- '#Method .+ should return Illuminate\\Database\\Eloquent\\Relations\\(HasOne|HasMany|BelongsToMany|MorphOne|MorphMany|MorphToMany)<(.+), .+> but returns Illuminate\\Database\\Eloquent\\Relations\\\1<\2>.#'
5858
- '#Method .+ should return Illuminate\\Database\\Eloquent\\Relations\\(BelongsTo|MorphTo)<(.+), \$this\((.+)\)> but returns Illuminate\\Database\\Eloquent\\Relations\\\1<\2, \3>.#'
59-
- '#Generic type Illuminate\\Database\\Eloquent\\Relations\\(HasOneThrough|HasManyThrough)<.+, .+, .+> in PHPDoc tag @return specifies 3 template types, but class Illuminate\\Database\\Eloquent\\Relations\\\1 supports only 1: TRelatedModel#'
6059
- '#Method .+ should return Illuminate\\Database\\Eloquent\\Relations\\(HasOneThrough|HasManyThrough)<(.+), .+> but returns Illuminate\\Database\\Eloquent\\Relations\\\1<\2>.#'
60+
- '#Return type of call to method Illuminate\\Database\\Eloquent\\Relations\\BelongsToMany<.+>::save\(\) contains unresolvable type\.#'
6161

6262
# Different between PHPUnit versions
6363
- '#PHPDoc tag @return contains generic type PHPUnit\\Framework\\MockObject\\Builder\\InvocationMocker<stdClass> but class PHPUnit\\Framework\\MockObject\\Builder\\InvocationMocker is not generic.#'

src/Pagination/ConnectionField.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
class ConnectionField
1515
{
1616
/**
17-
* @param \Illuminate\Contracts\Pagination\LengthAwarePaginator<mixed> $paginator
17+
* @param \Illuminate\Contracts\Pagination\LengthAwarePaginator<*, *> $paginator
1818
*
1919
* @return array{
2020
* hasNextPage: bool,
@@ -52,7 +52,7 @@ public function pageInfoResolver(LengthAwarePaginator $paginator): array
5252
}
5353

5454
/**
55-
* @param \Illuminate\Contracts\Pagination\Paginator<mixed> $paginator
55+
* @param \Illuminate\Contracts\Pagination\Paginator<*, *> $paginator
5656
* @param array<string, mixed> $args
5757
*
5858
* @return Collection<int, array<string, mixed>>

src/Pagination/PaginationArgs.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,20 +106,20 @@ protected static function optimalPaginationType(PaginationType $proposedType, Re
106106
*
107107
* @param \Illuminate\Database\Query\Builder|\Laravel\Scout\Builder|\Illuminate\Database\Eloquent\Builder<TModel>|\Illuminate\Database\Eloquent\Relations\Relation<TModel> $builder
108108
*
109-
* @return \Illuminate\Contracts\Pagination\Paginator<TModel>
109+
* @return \Illuminate\Contracts\Pagination\Paginator<array-key, TModel>
110110
*/
111111
public function applyToBuilder(QueryBuilder|ScoutBuilder|EloquentBuilder|Relation $builder): Paginator
112112
{
113113
if ($this->first === 0) {
114114
if ($this->type->isSimple()) {
115-
return new ZeroPerPagePaginator($this->page);
115+
return new ZeroPerPagePaginator($this->page); // @phpstan-ignore return.type (generic type does not matter)
116116
}
117117

118118
$total = $builder instanceof ScoutBuilder
119119
? 0 // Laravel\Scout\Builder exposes no method to get the total count
120120
: $builder->count(); // @phpstan-ignore-line see Illuminate\Database\Query\Builder::count(), available as a mixin in the other classes
121121

122-
return new ZeroPerPageLengthAwarePaginator($total, $this->page);
122+
return new ZeroPerPageLengthAwarePaginator($total, $this->page); // @phpstan-ignore return.type (generic type does not matter)
123123
}
124124

125125
$methodName = $this->type->isSimple()

src/Pagination/PaginatorField.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
class PaginatorField
99
{
1010
/**
11-
* @param \Illuminate\Contracts\Pagination\LengthAwarePaginator<mixed> $paginator
11+
* @param \Illuminate\Contracts\Pagination\LengthAwarePaginator<*, *> $paginator
1212
*
1313
* @return array{
1414
* count: int,
@@ -36,12 +36,15 @@ public function paginatorInfoResolver(LengthAwarePaginator $paginator): array
3636
}
3737

3838
/**
39-
* @param \Illuminate\Contracts\Pagination\Paginator<mixed> $paginator
39+
* @template TKey of array-key
40+
* @template TValue
4041
*
41-
* @return array<int, mixed>
42+
* @param \Illuminate\Contracts\Pagination\Paginator<TKey, TValue> $paginator
43+
*
44+
* @return array<TKey, TValue>
4245
*/
4346
public function dataResolver(Paginator $paginator): array
4447
{
45-
return $paginator->items();
48+
return $paginator->items(); // @phpstan-ignore return.type (mismatch when Paginator has only 1 generic type)
4649
}
4750
}

src/Pagination/SimplePaginatorField.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class SimplePaginatorField
1010
/**
1111
* Resolve simple paginator info for connection.
1212
*
13-
* @param \Illuminate\Pagination\Paginator<mixed> $root
13+
* @param \Illuminate\Pagination\Paginator<*, *> $root
1414
*
1515
* @return array{
1616
* count: int,
@@ -36,7 +36,7 @@ public function paginatorInfoResolver(Paginator $root): array
3636
/**
3737
* Resolve data for connection.
3838
*
39-
* @param \Illuminate\Pagination\Paginator<mixed> $root
39+
* @param \Illuminate\Pagination\Paginator<*, *> $root
4040
*
4141
* @return \Illuminate\Support\Collection<int, mixed>
4242
*/

src/Pagination/ZeroPerPageLengthAwarePaginator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use Illuminate\Pagination\LengthAwarePaginator;
66
use Illuminate\Support\Collection;
77

8-
/** @extends \Illuminate\Pagination\LengthAwarePaginator<mixed> */
8+
/** @extends \Illuminate\Pagination\LengthAwarePaginator<array-key, mixed> */
99
class ZeroPerPageLengthAwarePaginator extends LengthAwarePaginator
1010
{
1111
public function __construct(int $total, int $page)

src/Pagination/ZeroPerPagePaginator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use Illuminate\Pagination\Paginator;
66
use Illuminate\Support\Collection;
77

8-
/** @extends \Illuminate\Pagination\Paginator<mixed> */
8+
/** @extends \Illuminate\Pagination\Paginator<array-key, mixed> */
99
class ZeroPerPagePaginator extends Paginator
1010
{
1111
public function __construct(int $page)

tests/Integration/Schema/Directives/ScopeDirectiveTest.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@ public function testExplicitName(): void
1414
{
1515
factory(Task::class)->times(2)->create();
1616

17-
/** @var Task $taskWithTag */
1817
$taskWithTag = factory(Task::class)->create();
18+
assert($taskWithTag instanceof Task);
1919

20-
/** @var Tag $tag */
21-
$tag = factory(Tag::class)->make();
22-
$taskWithTag->tags()->save($tag);
20+
$tag = factory(Tag::class)->create();
21+
assert($tag instanceof Tag);
22+
23+
$taskWithTag->tags()->attach($tag);
2324

2425
$this->schema = /** @lang GraphQL */ '
2526
type Query {
@@ -62,11 +63,12 @@ public function testDefaultsScopeToEqualArgumentName(): void
6263
{
6364
factory(Task::class)->times(2)->create();
6465

65-
/** @var Task $taskWithTag */
6666
$taskWithTag = factory(Task::class)->create();
67+
assert($taskWithTag instanceof Task);
68+
69+
$tag = factory(Tag::class)->create();
70+
assert($tag instanceof Tag);
6771

68-
/** @var Tag $tag */
69-
$tag = factory(Tag::class)->make();
7072
$taskWithTag->tags()->save($tag);
7173

7274
$this->schema = /** @lang GraphQL */ '

tests/Unit/Pagination/PaginateDirectiveTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -723,11 +723,11 @@ public function testQueriesFirst0SimplePaginator(): void
723723
/**
724724
* @param array{first: int} $args
725725
*
726-
* @return \Illuminate\Pagination\LengthAwarePaginator<array{id: int}>
726+
* @return \Illuminate\Pagination\LengthAwarePaginator<int, array{id: int}>
727727
*/
728728
public static function returnPaginatedDataInsteadOfBuilder(mixed $root, array $args): LengthAwarePaginator
729729
{
730-
return new LengthAwarePaginator([
730+
return new LengthAwarePaginator([ // @phpstan-ignore return.type (pagination generics changed between Laravel versions)
731731
[
732732
'id' => 1,
733733
],

tests/Utils/Models/User.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public function posts(): HasMany
103103
return $this->hasMany(Post::class);
104104
}
105105

106-
/** @return \Illuminate\Database\Eloquent\Relations\BelongsToMany<\Tests\Utils\Models\Role, $this, \Illuminate\Database\Eloquent\Relations\Pivot> */
106+
/** @return \Illuminate\Database\Eloquent\Relations\BelongsToMany<\Tests\Utils\Models\Role, $this> */
107107
public function roles(): BelongsToMany
108108
{
109109
return $this->belongsToMany(Role::class)

0 commit comments

Comments
 (0)