Skip to content

Commit 8ece38a

Browse files
committed
adapt tests
1 parent cdf2440 commit 8ece38a

15 files changed

+51
-31
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"psr/http-message": "^1 || ^2",
3131
"react/http": "^1.6",
3232
"react/promise": "^2.0 || ^3.0",
33-
"rector/rector": "^1.0",
33+
"rector/rector": "^2.0",
3434
"symfony/polyfill-php81": "^1.23",
3535
"symfony/var-exporter": "^5 || ^6 || ^7",
3636
"thecodingmachine/safe": "^1.3 || ^2"

tests/Error/ErrorTest.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use GraphQL\Error\Error;
66
use GraphQL\Error\FormattedError;
7+
use GraphQL\Language\AST\Node;
78
use GraphQL\Language\AST\NullValueNode;
89
use GraphQL\Language\AST\OperationDefinitionNode;
910
use GraphQL\Language\Parser;
@@ -151,7 +152,8 @@ public function testDefaultErrorFormatterIncludesExtensionFields(): void
151152
public function testErrorReadsOverriddenMethods(): void
152153
{
153154
$error = new class('msg', null, null, [], null, null, ['foo' => 'bar']) extends Error {
154-
public function getExtensions(): ?array
155+
/** @return array<string, mixed> */
156+
public function getExtensions(): array
155157
{
156158
$extensions = parent::getExtensions();
157159
$extensions['subfoo'] = 'subbar';
@@ -164,12 +166,13 @@ public function getPositions(): array
164166
return [1 => 2];
165167
}
166168

167-
public function getSource(): ?Source
169+
public function getSource(): Source
168170
{
169171
return new Source('');
170172
}
171173

172-
public function getNodes(): ?array
174+
/** @return list<Node> */
175+
public function getNodes(): array
173176
{
174177
return [];
175178
}
@@ -183,12 +186,14 @@ public function getNodes(): ?array
183186
self::assertNotNull($locatedError->getSource());
184187

185188
$error = new class('msg', new NullValueNode([]), null, []) extends Error {
186-
public function getNodes(): ?array
189+
/** @return list<NullValueNode> */
190+
public function getNodes(): array
187191
{
188192
return [new NullValueNode([])];
189193
}
190194

191-
public function getPath(): ?array
195+
/** @return list<string> */
196+
public function getPath(): array
192197
{
193198
return ['path'];
194199
}

tests/Executor/AbstractTest.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -718,16 +718,20 @@ public function testResolveTypeAllowsResolvingWithTypeName(): void
718718

719719
public function testHintsOnConflictingTypeInstancesInResolveType(): void
720720
{
721-
/** @var InterfaceType $iface */
721+
/** @var InterfaceType|null $iface */
722722
$iface = null;
723723

724-
$createTest = static function () use (&$iface): ObjectType {
724+
$createTest = function () use (&$iface): ObjectType {
725725
return new ObjectType([
726726
'name' => 'Test',
727727
'fields' => [
728728
'a' => Type::string(),
729729
],
730-
'interfaces' => static fn (): array => [$iface],
730+
'interfaces' => function () use ($iface): array {
731+
self::assertNotNull($iface);
732+
733+
return [$iface];
734+
},
731735
]);
732736
};
733737

tests/Executor/ExecutorTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ public function testProvidesInfoAboutCurrentExecutionState(): void
230230
{
231231
$ast = Parser::parse('query ($var: String) { result: test }');
232232

233-
/** @var ResolveInfo $info */
233+
/** @var ResolveInfo|null $info */
234234
$info = null;
235235
$schema = new Schema([
236236
'query' => new ObjectType([
@@ -250,6 +250,8 @@ public function testProvidesInfoAboutCurrentExecutionState(): void
250250

251251
Executor::execute($schema, $ast, $rootValue, null, ['var' => '123']);
252252

253+
self::assertNotNull($info);
254+
253255
/** @var OperationDefinitionNode $operationDefinition */
254256
$operationDefinition = $ast->definitions[0];
255257

@@ -327,7 +329,7 @@ public function testCorrectlyThreadsArguments(): void
327329
]),
328330
]);
329331
Executor::execute($schema, $docAst, null, null, [], 'Example');
330-
self::assertSame($gotHere, true);
332+
self::assertTrue($gotHere);
331333
}
332334

333335
public function testArgsMapper(): void
@@ -400,7 +402,7 @@ public function testArgsMapper(): void
400402
$result = Executor::execute($schema, $docAst);
401403
self::assertSame(1, $mapperCalledCount);
402404
self::assertSame(3, $resolverCalledCount);
403-
self::assertCount(0, $result->errors);
405+
self::assertEmpty($result->errors);
404406
}
405407

406408
/** @see it('nulls out error subtrees') */

tests/Executor/Promise/ReactPromiseAdapterTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ public function setUp(): void
3939

4040
public function testIsThenableReturnsTrueWhenAReactPromiseIsGiven(): void
4141
{
42-
/** @var callable $reactPromiseSetRejectionHandler */
4342
$reactPromiseSetRejectionHandler = \function_exists('\React\Promise\set_rejection_handler')
4443
? '\React\Promise\set_rejection_handler'
4544
: fn ($error) => null;

tests/Executor/Promise/SyncPromiseTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ static function () use (&$onRejectedCalled): void {
110110
self::assertNotSame($promise, $nextPromise);
111111
self::assertSame(SyncPromise::PENDING, $nextPromise->state);
112112
} else {
113+
/** @phpstan-ignore argument.unresolvableType (false positive?) */
113114
self::assertSame(SyncPromise::FULFILLED, $nextPromise->state);
114115
}
115116

@@ -282,6 +283,7 @@ static function () use (&$onFulfilledCalled): void {
282283
self::assertNotSame($promise, $nextPromise);
283284
self::assertSame(SyncPromise::PENDING, $nextPromise->state);
284285
} else {
286+
/** @phpstan-ignore argument.unresolvableType (false positive?) */
285287
self::assertSame(SyncPromise::REJECTED, $nextPromise->state);
286288
}
287289

@@ -389,7 +391,7 @@ public function testPendingPromiseThen(): void
389391
$nextPromise3 = $promise->then($onFulfilled, $onRejected);
390392
$nextPromise4 = $promise->then($onFulfilled, $onRejected);
391393

392-
self::assertCount(0, SyncPromise::getQueue());
394+
self::assertEmpty(SyncPromise::getQueue());
393395
self::assertSame(0, $onFulfilledCount);
394396
self::assertSame(0, $onRejectedCount);
395397
$promise->resolve(1);
@@ -403,7 +405,7 @@ public function testPendingPromiseThen(): void
403405
self::assertSame(SyncPromise::PENDING, $nextPromise4->state);
404406

405407
SyncPromise::runQueue();
406-
self::assertCount(0, SyncPromise::getQueue());
408+
self::assertEmpty(SyncPromise::getQueue());
407409
self::assertSame(3, $onFulfilledCount); // @phpstan-ignore-line side-effects
408410
self::assertSame(0, $onRejectedCount); // @phpstan-ignore-line side-effects
409411
self::assertValidPromise($nextPromise, 1, null, SyncPromise::FULFILLED);

tests/PhpStan/Type/Definition/Type/IsAbstractTypeStaticMethodTypeSpecifyingExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@ public function isStaticMethodSupported(MethodReflection $staticMethodReflection
3737

3838
public function specifyTypes(MethodReflection $staticMethodReflection, StaticCall $node, Scope $scope, TypeSpecifierContext $context): SpecifiedTypes
3939
{
40-
return $this->typeSpecifier->create($node->getArgs()[0]->value, new ObjectType(AbstractType::class), $context);
40+
return $this->typeSpecifier->create($node->getArgs()[0]->value, new ObjectType(AbstractType::class), $context, $scope);
4141
}
4242
}

tests/PhpStan/Type/Definition/Type/IsCompositeTypeStaticMethodTypeSpecifyingExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@ public function isStaticMethodSupported(MethodReflection $staticMethodReflection
3737

3838
public function specifyTypes(MethodReflection $staticMethodReflection, StaticCall $node, Scope $scope, TypeSpecifierContext $context): SpecifiedTypes
3939
{
40-
return $this->typeSpecifier->create($node->getArgs()[0]->value, new ObjectType(CompositeType::class), $context);
40+
return $this->typeSpecifier->create($node->getArgs()[0]->value, new ObjectType(CompositeType::class), $context, $scope);
4141
}
4242
}

tests/PhpStan/Type/Definition/Type/IsInputTypeStaticMethodTypeSpecifyingExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@ public function isStaticMethodSupported(MethodReflection $staticMethodReflection
3737

3838
public function specifyTypes(MethodReflection $staticMethodReflection, StaticCall $node, Scope $scope, TypeSpecifierContext $context): SpecifiedTypes
3939
{
40-
return $this->typeSpecifier->create($node->getArgs()[0]->value, new ObjectType(InputType::class), $context);
40+
return $this->typeSpecifier->create($node->getArgs()[0]->value, new ObjectType(InputType::class), $context, $scope);
4141
}
4242
}

tests/PhpStan/Type/Definition/Type/IsOutputTypeStaticMethodTypeSpecifyingExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@ public function isStaticMethodSupported(MethodReflection $staticMethodReflection
3737

3838
public function specifyTypes(MethodReflection $staticMethodReflection, StaticCall $node, Scope $scope, TypeSpecifierContext $context): SpecifiedTypes
3939
{
40-
return $this->typeSpecifier->create($node->getArgs()[0]->value, new ObjectType(OutputType::class), $context);
40+
return $this->typeSpecifier->create($node->getArgs()[0]->value, new ObjectType(OutputType::class), $context, $scope);
4141
}
4242
}

0 commit comments

Comments
 (0)