Skip to content

Commit dfe07a9

Browse files
authored
Switch to PHPStan level 4 (#1013)
1 parent 4944f67 commit dfe07a9

File tree

4 files changed

+24
-17
lines changed

4 files changed

+24
-17
lines changed

phpstan.neon.dist

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
parameters:
22
# TODO increase to max
3-
level: 3
3+
level: 4
44

55
inferPrivatePropertyTypeFromConstructor: true
66

@@ -37,6 +37,10 @@ parameters:
3737
# TODO convert to less magical code
3838
- "~Variable method call on static\\(GraphQL\\\\Server\\\\ServerConfig\\)~"
3939

40+
# PHPStan does not play nicely with markTestSkipped()
41+
- message: "~Unreachable statement - code above always terminates~"
42+
path: tests
43+
4044
includes:
4145
- phpstan-baseline.neon
4246

tests/Executor/Promise/SyncPromiseTest.php renamed to tests/Executor/Promise/SyncPromiseTestTestCaseBase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
use function uniqid;
1414

15-
class SyncPromiseTest extends TestCaseBase
15+
class SyncPromiseTestTestCaseBase extends TestCaseBase
1616
{
1717
public function getFulfilledPromiseResolveData()
1818
{

tests/Language/ParserTest.php

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
use GraphQL\Language\AST\Node;
1212
use GraphQL\Language\AST\NodeKind;
1313
use GraphQL\Language\AST\NodeList;
14-
use GraphQL\Language\AST\ObjectTypeDefinitionNode;
1514
use GraphQL\Language\AST\OperationDefinitionNode;
1615
use GraphQL\Language\AST\SelectionSetNode;
1716
use GraphQL\Language\AST\StringValueNode;
@@ -729,38 +728,38 @@ public function testParsesNestedTypes(): void
729728

730729
public function testPartiallyParsesSource(): void
731730
{
732-
self::assertInstanceOf(
733-
NameNode::class,
734-
Parser::name('Foo')
731+
self::assertSame(
732+
'Foo',
733+
Parser::name('Foo')->value
735734
);
736735

737-
self::assertInstanceOf(
738-
ObjectTypeDefinitionNode::class,
739-
Parser::objectTypeDefinition('type Foo { name: String }')
736+
self::assertSame(
737+
'Foo',
738+
Parser::objectTypeDefinition('type Foo { name: String }')->name->value
740739
);
741740

742741
self::assertInstanceOf(
743742
VariableNode::class,
744743
Parser::valueLiteral('$foo')
745744
);
746745

747-
self::assertInstanceOf(
748-
NodeList::class,
746+
self::assertCount(
747+
1,
749748
Parser::argumentsDefinition('(foo: Int!)')
750749
);
751750

752-
self::assertInstanceOf(
753-
NodeList::class,
751+
self::assertCount(
752+
2,
754753
Parser::directiveLocations('| INPUT_OBJECT | OBJECT')
755754
);
756755

757-
self::assertInstanceOf(
758-
NodeList::class,
756+
self::assertCount(
757+
2,
759758
Parser::implementsInterfaces('implements Foo & Bar')
760759
);
761760

762-
self::assertInstanceOf(
763-
NodeList::class,
761+
self::assertCount(
762+
2,
764763
Parser::unionMemberTypes('= | Foo | Bar')
765764
);
766765

tests/TestCaseBase.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@
88

99
abstract class TestCaseBase extends TestCase
1010
{
11+
/**
12+
* Useful to test code with no observable behaviour other than not crashing.
13+
*/
1114
public static function assertDidNotCrash(): void
1215
{
16+
// @phpstan-ignore-next-line this truism is required to prevent a PHPUnit warning
1317
self::assertTrue(true);
1418
}
1519
}

0 commit comments

Comments
 (0)