Skip to content

Commit 2a97706

Browse files
committed
Common project code update
- Upgrade PHPStan - Uninstall deprecated phpstan-shim - Remove all unmatched ignored errors from phpstan-baseline.neon - Rename phpstan.neon.dist (remove .dist suffix) - Upgrade PHPUnit to the latest - Change deprecated test methods accordingly - Update all Symfony version constraints to ^4.4 || ^5.0 - Configure new PHP-CS-Fixer rules: - Remove all unnecessary annotations Manually go through all files and change/fix/tweak code, add type-hints wherever possible.
1 parent ec213ee commit 2a97706

File tree

293 files changed

+5256
-4562
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

293 files changed

+5256
-4562
lines changed

Diff for: .php_cs.dist

+3-13
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,13 @@ return PhpCsFixer\Config::create()
1010
->setRules(
1111
[
1212
'@Symfony' => true,
13-
'@PHP71Migration' => true,
14-
'@PHP71Migration:risky' => true,
15-
'single_blank_line_before_namespace' => true,
16-
'ordered_imports' => true,
17-
# 'ordered_imports' => ['sort_algorithm' => 'alpha', 'imports_order' => ['const', 'class', 'function']],
18-
'concat_space' => ['spacing' => 'none'],
19-
'phpdoc_no_alias_tag' => ['type' => 'var'],
20-
'no_mixed_echo_print' => ['use' => 'echo'],
21-
'binary_operator_spaces' => ['align_double_arrow' => false, 'align_equals' => false],
13+
'ordered_imports' => ['imports_order' => ['class', 'function', 'const']],
2214
'general_phpdoc_annotation_remove' => ['author', 'category', 'copyright', 'created', 'license', 'package', 'since', 'subpackage', 'version'],
23-
'native_function_invocation' => true,
2415
'fully_qualified_strict_types' => true,
2516
'single_line_throw' => false,
26-
'no_superfluous_phpdoc_tags' => false,
2717
'phpdoc_to_comment' => false,
28-
# 'no_superfluous_phpdoc_tags' => ['allow_mixed' => true],
29-
# 'global_namespace_import' => ['import_functions' => true, 'import_classes' => true],
18+
'no_superfluous_phpdoc_tags' => ['allow_mixed' => true],
19+
'global_namespace_import' => ['import_functions' => true, 'import_classes' => true, 'import_constants' => true],
3020
]
3121
)
3222
->setFinder($finder)

Diff for: .travis.yml

+11-10
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,15 @@ script: composer test
3131

3232
jobs:
3333
include:
34-
- php: 7.4snapshot
35-
env: SYMFONY_VERSION=4.3.*
34+
- php: 7.4
35+
env: SYMFONY_VERSION=4.4.*
36+
37+
- php: 7.4
38+
env: SYMFONY_VERSION=5.0.*
39+
40+
- php: 7.4
41+
env: SYMFONY_VERSION=5.1.*
42+
3643
- php: nightly
3744
env: COMPOSER_UPDATE_FLAGS=--ignore-platform-reqs
3845

@@ -41,20 +48,14 @@ jobs:
4148
env: COVERAGE SYMFONY_VERSION=4.4.*
4249
before_script:
4350
- pecl install pcov
44-
# TODO: after deleting the 'lib' folder remove the 'pcov.exclude' and 'pcov.directory' options
45-
script: > # break command into 5 lines
46-
php
47-
-d pcov.enabled=1
48-
-d pcov.directory=.
49-
-d pcov.exclude="/(vendor|tests)/"
50-
bin/phpunit --color=always -v --debug --coverage-clover=build/logs/clover.xml
51+
script: php -dpcov.enabled=1 bin/phpunit --color=always -v --debug --coverage-clover=build/logs/clover.xml
5152
after_script:
5253
- wget https://scrutinizer-ci.com/ocular.phar && travis_retry php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml
5354
- composer require "satooshi/php-coveralls:^1.0" && travis_retry php bin/coveralls -v
5455

5556
- stage: Code Quality
5657
php: 7.4
57-
env: STATIC_ANALYSIS SYMFONY_VERSION=4.3.*
58+
env: STATIC_ANALYSIS SYMFONY_VERSION=4.4.*
5859
install: travis_retry composer install --prefer-dist
5960
script: composer static-analysis
6061

Diff for: README.md

+1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ Documentation
8989
- [Disable introspection](docs/security/disable_introspection.md)
9090
- [Errors handling](docs/error-handling/index.md)
9191
- [Events](docs/events/index.md)
92+
- [Profiler](docs/profiler/index.md)
9293

9394
Talks and slides to help you start
9495
----------------------------------

Diff for: composer.json

+24-22
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,16 @@
2828
"require": {
2929
"php": ">=7.4",
3030
"ext-json": "*",
31-
"murtukov/php-code-generator": "^0.1.2",
31+
"murtukov/php-code-generator": "^0.1.4",
3232
"psr/log": "^1.0",
33-
"symfony/config": "^4.3 || ^5.0",
34-
"symfony/dependency-injection": "^4.3 || ^5.0",
35-
"symfony/event-dispatcher": "^4.3 || ^5.0",
36-
"symfony/expression-language": "^4.3 || ^5.0",
37-
"symfony/framework-bundle": "^4.3 || ^5.0",
38-
"symfony/options-resolver": "^4.3 || ^5.0",
39-
"symfony/property-access": "^4.3 || ^5.0",
40-
"webonyx/graphql-php": "^0.13.5"
33+
"symfony/config": "^4.4 || ^5.0",
34+
"symfony/dependency-injection": "^4.4 || ^5.0",
35+
"symfony/event-dispatcher": "^4.4 || ^5.0",
36+
"symfony/expression-language": "^4.4 || ^5.0",
37+
"symfony/framework-bundle": "^4.4 || ^5.0",
38+
"symfony/options-resolver": "^4.4 || ^5.0",
39+
"symfony/property-access": "^4.4 || ^5.0",
40+
"webonyx/graphql-php": "^14.0.1"
4141
},
4242
"suggest": {
4343
"nelmio/cors-bundle": "For more flexibility when using CORS prefight",
@@ -48,20 +48,22 @@
4848
"require-dev": {
4949
"doctrine/orm": "^2.5",
5050
"phpstan/extension-installer": "^1.0",
51-
"phpstan/phpstan-shim": "^0.11.19",
52-
"phpstan/phpstan-phpunit": "^0.11",
53-
"phpstan/phpstan-symfony": "^0.11",
54-
"phpunit/phpunit": "<8.3",
51+
"phpstan/phpstan": "^0.12.32",
52+
"phpstan/phpstan-phpunit": "^0.12.11",
53+
"phpstan/phpstan-symfony": "^0.12.6",
54+
"phpunit/phpunit": "^9.2",
5555
"react/promise": "^2.5",
56-
"symfony/asset": "^4.3 || ^5.0",
57-
"symfony/browser-kit": "^4.3 || ^5.0",
58-
"symfony/console": "^4.3 || ^5.0",
59-
"symfony/css-selector": "^4.3 || ^5.0",
60-
"symfony/phpunit-bridge": "^4.3 || ^5.0",
61-
"symfony/process": "^4.3 || ^5.0",
62-
"symfony/security-bundle": "^4.3 || ^5.0",
63-
"symfony/validator": "^4.3 || ^5.0",
64-
"symfony/yaml": "^4.3 || ^5.0"
56+
"symfony/asset": "^4.4 || ^5.0",
57+
"symfony/browser-kit": "^4.4 || ^5.0",
58+
"symfony/console": "^4.4 || ^5.0",
59+
"symfony/css-selector": "^4.4 || ^5.0",
60+
"symfony/phpunit-bridge": "^4.4 || ^5.0",
61+
"symfony/process": "^4.4 || ^5.0",
62+
"symfony/security-bundle": "^4.4 || ^5.0",
63+
"symfony/validator": "^4.4 || ^5.0",
64+
"symfony/var-dumper": "^4.4 || ^5.0",
65+
"symfony/yaml": "^4.4 || ^5.0",
66+
"twig/twig": "^2.10|^3.0"
6567
},
6668
"extra": {
6769
"branch-alias": {

Diff for: docs/annotations/index.md

+28-30
Original file line numberDiff line numberDiff line change
@@ -50,47 +50,46 @@ If you use mutations, you need a `RootMutation` type as well.
5050

5151
## Annotations & type inheritance
5252

53-
As PHP classes naturally support inheritances (and so is the annotation reader), it doesn't make sense to allow classes to use the "inherits" option.
54-
The type will inherits the annotations declared on parent classes properties and methods. The annotation on the class itself will not be herited.
55-
53+
As PHP classes naturally support inheritance (and so is the annotation reader), it doesn't make sense to allow classes to use the "inherits" option (as on types declared using YAML).
54+
The type will inherit annotations declared on parent class properties and methods. The annotation on the class itself will not be inherited.
5655

5756
## Annotations, value & default resolver
5857

59-
In GraphQL, when a type's field is resolved, GraphQL expect by default a property (for object) or an index (for array) on the corresponding value returned for the type.
58+
In GraphQL, when a type's field is resolved, GraphQL expects by default a property (for object) or a key (for array) on the corresponding value returned for the type.
6059

61-
For example, if I have a type like that :
60+
For example, if you have a type like that :
6261

6362
```graphql
6463
type Character {
6564
name: String!
6665
}
6766
```
6867

69-
If the field `name` is queried, on a `Character` type instance, the default resolver will try to find a property or index on the related object (the `value`).
70-
So, the value could be an object instance with a `name` property or an array with a `name` index.
68+
If the field `name` is queried, on a `Character` type instance, the default resolver will try to find a property or key on the related variable (the `value`).
69+
So, the `value` could be an object instance with a `name` property or an array with a `name` key.
7170

72-
Except for the root query and the root mutation, the value object is always returned by an other resolver.
73-
For the Root query and the root mutation, the value object is the service with an id equals to the fully qualified name of the query/mutation class.
71+
Except for the root Query and root Mutation types, the `value` variable is always returned by another resolver.
72+
For the root Query and the Root Mutation types, the `value` variable is the service with an id that equals to the fully qualified name of the query/mutation class.
7473

75-
On a `@Field` or `@Query` or `@Mutation`, the following rules apply to guess a resolver when no `resolver` attribute is define on the annotation:
74+
The following rules apply for `@Field`, `@Query` and `@Mutation` annotations to guess a resolver when no `resolver` attribute is defined:
7675

77-
- If the `@Field` apply on a property :
78-
- If the `@Field` attribute `name` is define and not equals to the property name
79-
- `@=value.[property name]` for a regular type
80-
- `@=service([FQN class]).[property name]` for root query or root mutation
76+
- If `@Field` is defined on a property :
77+
- If `@Field`'s attribute `name` is defined and is not equal to the property name
78+
- `@=value.<property name>` for a regular type
79+
- `@=service(<FQCN>).<property name>` for root query or root mutation
8180

82-
- If the `@Field` attribute `name` is not define or equals the property
81+
- If `@Field`'s attribute `name` is not defined or is not equal to the property name
8382
- The default GraphQL resolver will be use for a regular type (no `resolve` configuration will be define).
84-
- `@=service([FQN class]).[name]` for root query or root mutation
83+
- `@=service(<FQCN>).<name>` for root query or root mutation
8584

86-
- If the `@Field` apply on a method :
87-
- `@=call(value.[method name], args)` for a regular type
88-
- `@=call(service([FQN class]).[method name], args)` for root query or mutation
85+
- If `@Field` is defined on a method :
86+
- `@=call(value.<method name>, args)` for a regular type
87+
- `@=call(service(<FQCN>).<method name>, args)` for root query or mutation
8988

9089

9190
## Annotations, Root Query & Root Mutation
9291

93-
If you define your Root Query, or Root Mutation as a class with annotations, it will allow you to define methods directly on the class itself to be expose as GraphQL.
92+
If you define your root Query or root Mutation type as a class with annotations, it will allow you to define methods directly on the class itself to be exposed as GraphQL fields.
9493
For example:
9594

9695
```php
@@ -109,8 +108,8 @@ class RootQuery {
109108
}
110109
```
111110

112-
In order for this to work, the Root Query class must be instanciated at some point if we want to be able to call methods on it.
113-
To do so, the RootQuery class must be define as a service with the class fully qualified name as id.
111+
In order for this to work, the `RootQuery` class must be instanciated at some point if you want to be able to call methods on it.
112+
To do so, the `RootQuery` class must be defined as a service with its FQCN as id.
114113
In the previous example, we need a service name `App\GraphQL\Query\RootQuery`. It works the same way for mutations.
115114
In the previous example, the generated `resolve` config of the `something` field will be `@=service('App\GraphQL\Query\RootQuery').getSomething()`.
116115

@@ -121,9 +120,9 @@ In the previous example, the generated `resolve` config of the `something` field
121120

122121
Based on other Doctrine annotations on your fields, the corresponding GraphQL type can sometimes be guessed automatically.
123122

124-
The type can be auto-guess from :
123+
The type can be auto-guessed from the following annotations:
125124

126-
- `@ORM\Column` annotations, based on the `type` attribute
125+
- `@ORM\Column`, based on the `type` attribute
127126
- `@ORM\ManyToOne`, `@ORM\ManyToMany`, `@ORM\OneToOne`, `@ORM\OneToMany`, based on the `targetEntity` attribute. The target entity must be a GraphQL type itself to work.
128127
- `@ORM\ManyToOne`, `@ORM\OneToOne` The generated type will also use the `@ORM\JoinColumn` annotation and his `nullable` attribute to generate either `Type` or `Type!`
129128
- `@ORM\ManyToMany`, `@ORM\OneToMany` The generated type will always be not null, like `[Type]!` as you're supposed to initialize corresponding properties with an ArrayCollection
@@ -143,9 +142,9 @@ overblog_graphql:
143142
```
144143

145144

146-
### @Field type auto-guessing when applied on a method with a return type hint
145+
### @Field type auto-guessing when defined on a method with a return type hint
147146

148-
The type of a `@Field` annotation can be auto-guessed if it applies on a method with a return type hint.
147+
The type of the `@Field` annotation can be auto-guessed if it's defined on a method with a return type hint.
149148

150149
For example:
151150

@@ -165,9 +164,9 @@ class MyType {
165164

166165
In this example, the type `String!` will be auto-guessed from the return type hint of the method.
167166

168-
### @Field arguments auto-guessing when applied on a method with type hinted parameters
167+
### @Field arguments auto-guessing when defined on a method with type hinted parameters
169168

170-
The arguments of a `@Field` annotation can be auto-guessed if it applies on a method with type hinted arguments. Arguments without default value will be consided required.
169+
The arguments of the `@Field` annotation can be auto-guessed if it's defined on a method with type hinted arguments. Arguments without default value will be consided required.
171170

172171
For example:
173172

@@ -194,7 +193,7 @@ The GraphQL arguments will be auto-guessed as:
194193

195194
### Limitation of auto-guessing:
196195

197-
When trying to auto-guess type or args based on PHP Reflection (from type hinted method parameters or type hinted return value), there is a limitation.
196+
When trying to auto-guess a type or args based on PHP Reflection (from type hinted method parameters or type hinted return value), there is a limitation.
198197
As PHP type hinting doesn't support "array of instances of class", we cannot rely on it to guess the type when dealing with collection of objects.
199198
In these case, you'll need to declare your types or arguments type manually.
200199

@@ -206,4 +205,3 @@ For example, in PHP, a signature like this : `public function getArrayOfStrings(
206205

207206

208207

209-

Diff for: docs/profiler/index.md

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
> _The profiler feature was introduced in the version **1.0**_
2+
3+
# Profiler
4+
5+
This bundle provides a profiler to monitor your GraphQL queries and mutations.
6+
7+
## Configuration
8+
9+
In order to display only GraphQL related requests, the profiler will filter requests based on the requested url.
10+
By default, it will display requests matching the configured endpoint url (ie. The route `overblog_graphql_endpoint`).
11+
12+
If you need to change the behavior (for example if you have parameters in your endpoint url), you can change the matching with the following option:
13+
14+
```yaml
15+
overblog_graphql:
16+
profiler:
17+
query_match: my_string_to_match
18+
```
19+
20+
In the example above, only the requests containing the string `my_string_to_match` will be displayed.

0 commit comments

Comments
 (0)