Skip to content

Commit aa8609a

Browse files
committed
Add type-hints in annotation classes
1 parent e0cfa21 commit aa8609a

23 files changed

+138
-151
lines changed

.php_cs.dist

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

33
$finder = PhpCsFixer\Finder::create()
4-
->exclude('vendor')
4+
->exclude('Annotation')
55
->name('*.php')
66
->in([__DIR__.'/src', __DIR__.'/tests'])
77
;

phpstan-baseline.neon

-25
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,6 @@ parameters:
4545
count: 1
4646
path: src/Config/Parser/AnnotationParser.php
4747

48-
-
49-
message: "#^Access to an undefined property object\\:\\:\\$name\\.$#"
50-
count: 1
51-
path: src/Config/Parser/AnnotationParser.php
52-
53-
-
54-
message: "#^Offset 'type' does not exist on array\\|string\\.$#"
55-
count: 2
56-
path: src/Config/Parser/AnnotationParser.php
57-
5848
-
5949
message: "#^Access to an undefined property GraphQL\\\\Language\\\\AST\\\\Node\\:\\:\\$description\\.$#"
6050
count: 1
@@ -175,11 +165,6 @@ parameters:
175165
count: 1
176166
path: src/Relay/Connection/Output/Connection.php
177167

178-
-
179-
message: "#^Cannot call method then\\(\\) on array\\|object\\.$#"
180-
count: 1
181-
path: src/Relay/Connection/Paginator.php
182-
183168
-
184169
message: "#^Possibly invalid array key type \\(array\\|string\\|null\\)\\.$#"
185170
count: 1
@@ -195,11 +180,6 @@ parameters:
195180
count: 1
196181
path: src/Relay/Mutation/PayloadDefinition.php
197182

198-
-
199-
message: "#^Parameter \\#1 \\$schema of static method Overblog\\\\GraphQLBundle\\\\Event\\\\ExecutorArgumentsEvent\\:\\:create\\(\\) expects Overblog\\\\GraphQLBundle\\\\Definition\\\\Type\\\\ExtensibleSchema, GraphQL\\\\Type\\\\Schema given\\.$#"
200-
count: 1
201-
path: src/Request/Executor.php
202-
203183
-
204184
message: "#^Parameter \\#1 \\$function of function call_user_func_array expects callable\\(\\)\\: mixed, array\\(mixed, mixed\\) given\\.$#"
205185
count: 1
@@ -210,11 +190,6 @@ parameters:
210190
count: 1
211191
path: src/Resolver/TypeResolver.php
212192

213-
-
214-
message: "#^If condition is always true\\.$#"
215-
count: 1
216-
path: src/Transformer/ArgumentsTransformer.php
217-
218193
-
219194
message: "#^Array \\(array\\<Symfony\\\\Component\\\\Validator\\\\Mapping\\\\PropertyMetadata\\>\\) does not accept Overblog\\\\GraphQLBundle\\\\Validator\\\\Mapping\\\\PropertyMetadata\\.$#"
220195
count: 1

src/Annotation/Access.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ final class Access implements Annotation
1919
*
2020
* @var string
2121
*/
22-
public $value;
22+
public string $value;
2323
}

src/Annotation/Arg.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ final class Arg implements Annotation
1919
*
2020
* @var string
2121
*/
22-
public $name;
22+
public string $name;
2323

2424
/**
2525
* Argument description.
2626
*
2727
* @var string
2828
*/
29-
public $description;
29+
public string $description;
3030

3131
/**
3232
* Argument type.
@@ -35,7 +35,7 @@ final class Arg implements Annotation
3535
*
3636
* @var string
3737
*/
38-
public $type;
38+
public string $type;
3939

4040
/**
4141
* Default argument value.

src/Annotation/Deprecated.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ final class Deprecated implements Annotation
1919
*
2020
* @var string
2121
*/
22-
public $value;
22+
public string $value;
2323
}

src/Annotation/Description.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ final class Description implements Annotation
1919
*
2020
* @var string
2121
*/
22-
public $value;
22+
public string $value;
2323
}

src/Annotation/Enum.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ final class Enum implements Annotation
1717
*
1818
* @var string
1919
*/
20-
public $name;
20+
public string $name;
2121

2222
/**
2323
* @var array<\Overblog\GraphQLBundle\Annotation\EnumValue>
2424
*/
25-
public $values;
25+
public array $values;
2626
}

src/Annotation/EnumValue.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ final class EnumValue implements Annotation
1515
/**
1616
* @var string
1717
*/
18-
public $name;
18+
public string $name;
1919

2020
/**
2121
* @var string
2222
*/
23-
public $description;
23+
public string $description;
2424

2525
/**
2626
* @var string
2727
*/
28-
public $deprecationReason;
28+
public string $deprecationReason;
2929
}

src/Annotation/Field.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class Field implements Annotation
1717
*
1818
* @var string
1919
*/
20-
public $name;
20+
public string $name;
2121

2222
/**
2323
* Field Type.
@@ -26,21 +26,21 @@ class Field implements Annotation
2626
*
2727
* @var string
2828
*/
29-
public $type;
29+
public string $type;
3030

3131
/**
3232
* Field arguments.
3333
*
3434
* @var array<\Overblog\GraphQLBundle\Annotation\Arg>
3535
*/
36-
public $args;
36+
public array $args = [];
3737

3838
/**
3939
* Resolver for this property.
4040
*
4141
* @var string
4242
*/
43-
public $resolve;
43+
public string $resolve;
4444

4545
/**
4646
* Args builder.

src/Annotation/FieldsBuilder.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ final class FieldsBuilder implements Annotation
1919
*
2020
* @var string
2121
*/
22-
public $builder;
22+
public string $builder;
2323

2424
/**
2525
* The builder config.

src/Annotation/Input.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ final class Input implements Annotation
1717
*
1818
* @var string
1919
*/
20-
public $name;
20+
public string $name;
2121

2222
/**
2323
* Is the type a relay input.
2424
*
2525
* @var bool
2626
*/
27-
public $isRelay = false;
27+
public bool $isRelay = false;
2828
}

src/Annotation/IsPublic.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ final class IsPublic implements Annotation
1919
*
2020
* @var string
2121
*/
22-
public $value;
22+
public string $value;
2323
}

src/Annotation/Mutation.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ final class Mutation extends Field
1717
*
1818
* @var array<string>
1919
*/
20-
public $targetType;
20+
public array $targetType;
2121
}

src/Annotation/Provider.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ final class Provider implements Annotation
1717
*
1818
* @var string
1919
*/
20-
public $prefix;
20+
public string $prefix;
2121
}

src/Annotation/Query.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ final class Query extends Field
1717
*
1818
* @var array<string>
1919
*/
20-
public $targetType;
20+
public array $targetType;
2121
}

src/Annotation/Relay/Connection.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ final class Connection extends Type
1919
*
2020
* @var string
2121
*/
22-
public $edge;
22+
public string $edge;
2323

2424
/**
2525
* Connection Node type.
2626
*
2727
* @var string
2828
*/
29-
public $node;
29+
public string $node;
3030
}

src/Annotation/Relay/Edge.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ final class Edge extends Type
2121
*
2222
* @var string
2323
*/
24-
public $node;
24+
public string $node;
2525
}

src/Annotation/Scalar.php

+3-6
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,13 @@
1313
final class Scalar implements Annotation
1414
{
1515
/**
16-
* Scalar name.
17-
*
1816
* @var string
1917
*/
20-
public $name;
18+
public string $name;
19+
2120

2221
/**
23-
* Scalar type.
24-
*
2522
* @var string
2623
*/
27-
public $scalarType;
24+
public string $scalarType;
2825
}

src/Annotation/Type.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -17,40 +17,40 @@ class Type implements Annotation
1717
*
1818
* @var string
1919
*/
20-
public $name;
20+
public string $name;
2121

2222
/**
2323
* Type inherited interfaces.
2424
*
2525
* @var string[]
2626
*/
27-
public $interfaces;
27+
public array $interfaces;
2828

2929
/**
3030
* Is the type a relay payload.
3131
*
3232
* @var bool
3333
*/
34-
public $isRelay = false;
34+
public bool $isRelay = false;
3535

3636
/**
3737
* Expression to a target fields resolver.
3838
*
3939
* @var string
4040
*/
41-
public $resolveField;
41+
public string $resolveField;
4242

4343
/**
4444
* List of fields builder.
4545
*
4646
* @var array<\Overblog\GraphQLBundle\Annotation\FieldsBuilder>
4747
*/
48-
public $builders = [];
48+
public array $builders = [];
4949

5050
/**
5151
* Expression to resolve type for interfaces.
5252
*
5353
* @var string
5454
*/
55-
public $isTypeOf;
55+
public string $isTypeOf;
5656
}

src/Annotation/TypeInterface.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ final class TypeInterface implements Annotation
1717
*
1818
* @var string
1919
*/
20-
public $name;
20+
public string $name;
2121

2222
/**
2323
* Resolver type for interface.
@@ -26,5 +26,5 @@ final class TypeInterface implements Annotation
2626
*
2727
* @var string
2828
*/
29-
public $resolveType;
29+
public string $resolveType;
3030
}

src/Annotation/Union.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@ final class Union implements Annotation
1717
*
1818
* @var string
1919
*/
20-
public $name;
20+
public string $name;
2121

2222
/**
2323
* Union types.
2424
*
2525
* @var array<string>
2626
*/
27-
public $types;
27+
public array $types;
2828

2929
/**
3030
* Resolver type for union.
3131
*
3232
* @var string
3333
*/
34-
public $resolveType;
34+
public string $resolveType;
3535
}

0 commit comments

Comments
 (0)