Skip to content

Commit 989d1df

Browse files
authored
chore: fix phpstan on 4.3 (#8331)
1 parent 2abda53 commit 989d1df

4 files changed

Lines changed: 15 additions & 15 deletions

File tree

phpstan.neon.dist

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ parameters:
8383
path: src/GraphQl/Tests/Type/TypesContainerTest.php
8484

8585
# Expected, due to backward compatibility
86-
- '#Method GraphQL\\Type\\Definition\\WrappingType::getWrappedType\(\) invoked with 1 parameter, 0 required\.#'
8786
- '#Access to an undefined property GraphQL\\Type\\Definition\\NamedType&GraphQL\\Type\\Definition\\Type::\$name\.#'
8887
- "#Call to function method_exists\\(\\) with 'Symfony\\\\\\\\Component\\\\\\\\PropertyInfo\\\\\\\\PropertyInfoExtractor' and 'getType' will always evaluate to true\\.#"
8988
- "#Call to function method_exists\\(\\) with 'Symfony\\\\\\\\Component\\\\\\\\HttpFoundation\\\\\\\\Request' and 'getContentTypeFormat' will always evaluate to true\\.#"

src/GraphQl/Type/FieldsBuilder.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -435,11 +435,7 @@ private function getResourceFieldConfiguration(?string $property, ?string $field
435435

436436
$graphqlWrappedType = $graphqlType;
437437
if ($graphqlType instanceof WrappingType) {
438-
if (method_exists($graphqlType, 'getInnermostType')) {
439-
$graphqlWrappedType = $graphqlType->getInnermostType();
440-
} else {
441-
$graphqlWrappedType = $graphqlType->getWrappedType(true);
442-
}
438+
$graphqlWrappedType = $graphqlType->getInnermostType();
443439
}
444440
$isStandardGraphqlType = \in_array($graphqlWrappedType, GraphQLType::getStandardTypes(), true);
445441
if ($isStandardGraphqlType) {

src/Laravel/Tests/Console/DumpMetadataCommandTest.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ private function seedCommandModelMetadata(array $attributes, array $relations):
123123
}
124124

125125
/**
126-
* @param list<class-string> $classes
126+
* @param list<string> $classes
127127
*/
128128
private function stubResourceClasses(array $classes): void
129129
{
@@ -144,7 +144,7 @@ private function runDump(): PendingCommand
144144
}
145145

146146
/**
147-
* @return array{fingerprint: string, attributes: array<class-string, mixed>, relations: array<class-string, mixed>}
147+
* @return array{fingerprint: string, attributes: array<mixed, mixed>, relations: array<mixed, mixed>}
148148
*/
149149
private function readDump(): array
150150
{
@@ -158,6 +158,13 @@ private function readDump(): array
158158
$this->fail('The dump file did not contain an array.');
159159
}
160160

161-
return $dumped;
161+
$fingerprint = $dumped['fingerprint'] ?? null;
162+
$attributes = $dumped['attributes'] ?? null;
163+
$relations = $dumped['relations'] ?? null;
164+
if (!\is_string($fingerprint) || !\is_array($attributes) || !\is_array($relations)) {
165+
$this->fail('The dump file did not contain the expected structure.');
166+
}
167+
168+
return ['fingerprint' => $fingerprint, 'attributes' => $attributes, 'relations' => $relations];
162169
}
163170
}

src/Laravel/Tests/Metadata/DumpedMetadataBootTest.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,12 @@ public function testItWarnsWhenTheDumpFingerprintIsStale(): void
7575
{
7676
// The canned dump written in setUp() carries no fingerprint, so it never matches the
7777
// current migrations and must be reported as stale.
78-
Log::spy();
78+
Log::shouldReceive('warning')
79+
->once()
80+
->withArgs(static fn (string $message): bool => str_contains($message, 'stale'));
7981
$this->app->forgetInstance(ModelMetadata::class);
8082

8183
$this->app->make(ModelMetadata::class);
82-
83-
Log::shouldHaveReceived('warning')->withArgs(static fn (string $message): bool => str_contains($message, 'stale'))->once();
8484
}
8585

8686
public function testItDoesNotWarnWhenTheFingerprintMatches(): void
@@ -91,12 +91,10 @@ public function testItDoesNotWarnWhenTheFingerprintMatches(): void
9191
'relations' => [Book::class => self::CANNED_RELATIONS],
9292
]));
9393

94-
Log::spy();
94+
Log::shouldReceive('warning')->never();
9595
$this->app->forgetInstance(ModelMetadata::class);
9696

9797
$this->app->make(ModelMetadata::class);
98-
99-
Log::shouldNotHaveReceived('warning');
10098
}
10199

102100
public function testItIsNotSeededWhenDebugIsEnabled(): void

0 commit comments

Comments
 (0)