Skip to content

Commit 070b804

Browse files
authored
Merge pull request #801 from Vincz/master
Annotations refactoring & PHP 8 Attributes
2 parents f9ed247 + a93a003 commit 070b804

File tree

90 files changed

+3412
-1879
lines changed

Some content is hidden

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

90 files changed

+3412
-1879
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ jobs:
3636
- php-version: 7.4
3737
symfony-version: "5.2.*"
3838

39+
- php-version: 8.0
40+
symfony-version: "5.2.*"
41+
3942
name: "PHP ${{ matrix.php-version }} / Symfony ${{ matrix.symfony-version }} Test"
4043

4144
steps:
@@ -187,7 +190,7 @@ jobs:
187190
- name: "Install PHP with coverage"
188191
uses: "shivammathur/setup-php@v2"
189192
with:
190-
php-version: "7.4"
193+
php-version: "8.0"
191194
ini-values: pcov.directory=.
192195
coverage: "pcov"
193196

@@ -198,16 +201,17 @@ jobs:
198201
key: "php-${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}"
199202
restore-keys: "php-${{ matrix.php-version }}-composer-locked-"
200203

204+
- name: "Install Ocular as depencies"
205+
run: composer req "scrutinizer/ocular" --dev --no-update
206+
201207
- name: "Install dependencies"
202208
run: composer update --no-interaction --no-progress
203209

204210
- name: "Run tests with coverage"
205211
run: bin/phpunit --color=always -v --debug --coverage-clover=build/logs/clover.xml
206212

207213
- name: "Upload coverage results to Scrutinizer"
208-
run: |
209-
wget https://scrutinizer-ci.com/ocular.phar
210-
php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml
214+
run: vendor/scrutinizer/ocular/bin/ocular code-coverage:upload --format=php-clover build/logs/clover.xml
211215

212216
- name: "Upload coverage results to Coveralls"
213217
env:

.php_cs.dist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ return PhpCsFixer\Config::create()
1818
'no_superfluous_phpdoc_tags' => ['allow_mixed' => true],
1919
'global_namespace_import' => ['import_functions' => true, 'import_classes' => true, 'import_constants' => true],
2020
'phpdoc_summary' => false,
21+
'hash_to_slash_comment' => false,
22+
'single_line_comment_style' => false
2123
]
2224
)
2325
->setFinder($finder)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ Documentation
7777
- [Data fetching](docs/data-fetching/index.md)
7878
- [Query batching](docs/data-fetching/batching.md)
7979
- [Promise](docs/data-fetching/promise.md)
80-
- [Annotations](docs/annotations/index.md)
80+
- [Annotations & PHP 8 Attributes](docs/annotations/index.md)
8181
- [Validation](docs/validation/index.md)
8282
- [Security](docs/security/index.md)
8383
- [Handle CORS](docs/security/handle-cors.md)

UPGRADE-1.0.md

Lines changed: 71 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@ UPGRADE FROM 0.13 to 1.0
33

44
# Table of Contents
55

6-
- [Customize the cursor encoder of the edges of a connection](#customize-the-cursor-encoder-of-the-edges-of-a-connection)
7-
- [Change arguments of `TypeGenerator`](#change-arguments-of-typegenerator)
8-
- [Add magic `__get` method to `ArgumentInterface` implementors](#add-magic-__get-method-to-argumentinterface-implementors)
6+
- [UPGRADE FROM 0.13 to 1.0](#upgrade-from-013-to-10)
7+
- [Table of Contents](#table-of-contents)
8+
- [Customize the cursor encoder of the edges of a connection](#customize-the-cursor-encoder-of-the-edges-of-a-connection)
9+
- [Change arguments of `TypeGenerator` class](#change-arguments-of-typegenerator-class)
10+
- [Add magic `__get` method to `ArgumentInterface` implementors](#add-magic-__get-method-to-argumentinterface-implementors)
11+
- [Annotations - Flattened annotations](#annotations---flattened-annotations)
12+
- [Annotations - Attributes changed](#annotations---attributes-changed)
913

1014
### Customize the cursor encoder of the edges of a connection
1115

@@ -86,3 +90,67 @@ class Argument implements ArgumentInterface
8690
}
8791
```
8892
If you use your own class for resolver arguments, then it should have a `__get` method as well.
93+
94+
95+
### Annotations - Flattened annotations
96+
97+
In order to prepare to PHP 8 attributes (they don't support nested attributes at the moment. @see https://github.com/symfony/symfony/issues/38503), the following annotations have been flattened: `@FieldsBuilder`, `@FieldBuilder`, `@ArgsBuilder`, `@Arg` and `@EnumValue`.
98+
99+
Before:
100+
```php
101+
/**
102+
* @GQL\Type
103+
*/
104+
class MyType {
105+
/**
106+
* @GQL\Field(args={
107+
* @GQL\Arg(name="arg1", type="String"),
108+
* @GQL\Arg(name="arg2", type="Int")
109+
* })
110+
*/
111+
public function myFields(?string $arg1, ?int $arg2) {..}
112+
}
113+
114+
```
115+
116+
After:
117+
```php
118+
/**
119+
* @GQL\Type
120+
*/
121+
class MyType {
122+
/**
123+
* @GQL\Field
124+
* @GQL\Arg(name="arg1", type="String"),
125+
* @GQL\Arg(name="arg2", type="Int")
126+
*/
127+
public function myFields(?string $arg1, ?int $arg2) {..}
128+
}
129+
130+
```
131+
132+
### Annotations - Attributes changed
133+
134+
Change the attributes name of `@FieldsBuilder` annotation from `builder` and `builderConfig` to `value` and `config`.
135+
136+
Before:
137+
```php
138+
/**
139+
* @GQL\Type(name="MyType", builders={@GQL\FieldsBuilder(builder="Timestamped", builderConfig={opt1: "val1"})})
140+
*/
141+
class MyType {
142+
143+
}
144+
```
145+
146+
After:
147+
```php
148+
/**
149+
* @GQL\Type("MyType")
150+
* @GQL\FieldsBuilder(value="Timestamped", config={opt1: "val1"})
151+
*/
152+
class MyType {
153+
154+
}
155+
```
156+

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
"require": {
2929
"php": ">=7.4",
3030
"ext-json": "*",
31-
"murtukov/php-code-generator": "^0.1.4",
31+
"murtukov/php-code-generator": "^0.1.5",
32+
"phpdocumentor/reflection-docblock": "^5.2",
3233
"psr/log": "^1.0",
3334
"symfony/config": "^4.4 || ^5.0",
3435
"symfony/dependency-injection": "^4.4 || ^5.0",

0 commit comments

Comments
 (0)