Skip to content

Commit 30c2164

Browse files
author
Matej Grgić
committed
refactor: linting
1 parent a6e314a commit 30c2164

File tree

11 files changed

+46
-5
lines changed

11 files changed

+46
-5
lines changed

composer.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
4141
"lint": [
4242
"PHP_CS_FIXER_IGNORE_ENV=1 php-cs-fixer fix --diff --ansi --dry-run"
4343
],
44+
"lint:fix": [
45+
"php-cs-fixer fix --diff --ansi --using-cache=no"
46+
],
4447
"phpstan": [
4548
"php -d memory_limit=-1 vendor/bin/phpstan analyse -n --ansi --no-progress"
4649
],
@@ -49,6 +52,7 @@
4952
],
5053
"qc": [
5154
"@lint",
55+
"@lint-fix",
5256
"@phpstan",
5357
"@test"
5458
]

src/Http/Service/Factory/RequestFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function createResourceRequest(): CreateResourceRequest
6969
* can already have ID as a property. Consider having ID strategy
7070
* set through configuration.
7171
*/
72-
if (false === array_key_exists('id', $requestPrimaryData)) {
72+
if (false === \array_key_exists('id', $requestPrimaryData)) {
7373
$requestPrimaryData['id'] = (string) Uuid::uuid4();
7474
}
7575

tests/Bridge/OpenAPI/Model/Article.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ class Article implements ApiModel
6565
* @var string
6666
*
6767
* @ToOne(name="category", type="category", nullable=true)
68+
*
6869
* @Assert\Type(type="string")
6970
*/
7071
private $categoryId;
@@ -73,6 +74,7 @@ class Article implements ApiModel
7374
* @var string[]
7475
*
7576
* @ToMany(name="tags", type="tag", nullable=false)
77+
*
7678
* @Assert\Type(type="array")
7779
*/
7880
private $tagIds;
@@ -81,6 +83,7 @@ class Article implements ApiModel
8183
* @var string
8284
*
8385
* @Attribute(format="datetime", example="2001")
86+
*
8487
* @Assert\NotBlank
8588
*/
8689
private $createdAt;

tests/Bridge/OpenAPI/ResourceReadSchema/ResourceReadSchemaTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,30 +54,35 @@ public function testResourceAttributesAreCorrectlyConverted(): void
5454

5555
/**
5656
* @JsonApi\Attribute
57+
*
5758
* @Assert\Type(type="integer")
5859
*/
5960
public int $integerProperty;
6061

6162
/**
6263
* @JsonApi\Attribute(nullable=true)
64+
*
6365
* @Assert\Type(type="integer")
6466
*/
6567
public ?int $nullableIntegerProperty;
6668

6769
/**
6870
* @JsonApi\Attribute
71+
*
6972
* @Assert\Type(type="boolean")
7073
*/
7174
public bool $booleanProperty1;
7275

7376
/**
7477
* @JsonApi\Attribute
78+
*
7579
* @Assert\Type(type="bool")
7680
*/
7781
public bool $booleanProperty2;
7882

7983
/**
8084
* @JsonApi\Attribute
85+
*
8186
* @Assert\Type(type="float")
8287
*/
8388
public float $floatProperty;

tests/Integration/Resource/Denormalizer/ResourceDenormalizerTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use Doctrine\Common\Annotations\AnnotationReader;
88
use PHPUnit\Framework\TestCase;
99
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory;
10-
use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader;
1110
use Symfony\Component\Serializer\Mapping\Loader\AttributeLoader;
1211
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
1312
use Undabot\JsonApi\Implementation\Model\Resource\Resource;

tests/Integration/Resource/Denormalizer/ResourceWithAliasesDenormalizerTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use Doctrine\Common\Annotations\AnnotationReader;
88
use PHPUnit\Framework\TestCase;
99
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory;
10-
use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader;
1110
use Symfony\Component\Serializer\Mapping\Loader\AttributeLoader;
1211
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
1312
use Undabot\JsonApi\Implementation\Model\Resource\Resource;

tests/Integration/Resource/Factory/ResourceFactoryTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ final class ResourceDto implements ApiModel
275275

276276
/**
277277
* @JsonApi\Attribute
278+
*
278279
* @Assert\NotBlank
279280
*/
280281
public string $title;
@@ -292,8 +293,11 @@ final class ResourceDto implements ApiModel
292293
* @var array<int,string>
293294
*
294295
* @JsonApi\ToMany(type="tags")
296+
*
295297
* @Assert\All({
298+
*
296299
* @Assert\NotBlank,
300+
*
297301
* @Assert\Type("string")
298302
* })
299303
*/
@@ -303,8 +307,11 @@ final class ResourceDto implements ApiModel
303307
* @var array<int,string>
304308
*
305309
* @JsonApi\ToMany(type="comments")
310+
*
306311
* @Assert\All({
312+
*
307313
* @Assert\NotBlank,
314+
*
308315
* @Assert\Type("string")
309316
* })
310317
*/

tests/Integration/Resource/Metadata/ResourceAttributesMetadataTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,11 @@ private function getResource()
200200
* @var string
201201
*
202202
* @JsonApi\Attribute
203+
*
203204
* @Assert\NotBlank
205+
*
204206
* @Assert\Length(min=100, max=200)
207+
*
205208
* @Assert\Type(type="string")
206209
*/
207210
public $name;
@@ -210,6 +213,7 @@ private function getResource()
210213
* @var null|string
211214
*
212215
* @JsonApi\Attribute
216+
*
213217
* @Assert\Type(type="string")
214218
*/
215219
public $summary;
@@ -218,7 +222,9 @@ private function getResource()
218222
* @var \DateTimeImmutable
219223
*
220224
* @JsonApi\Attribute
225+
*
221226
* @Assert\NotBlank
227+
*
222228
* @Assert\Type(type="datetime")
223229
*/
224230
public $publishedAt;
@@ -227,7 +233,9 @@ private function getResource()
227233
* @var bool
228234
*
229235
* @JsonApi\Attribute
236+
*
230237
* @Assert\NotBlank
238+
*
231239
* @Assert\Type(type="bool")
232240
*/
233241
public $active;

tests/Integration/Resource/Validation/ResourceValidationTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,11 @@ class ResourceDto
2828
* @var string
2929
*
3030
* @JsonApi\Attribute
31+
*
3132
* @Assert\NotBlank
33+
*
3234
* @Assert\Length(min=10, max=100)
35+
*
3336
* @Assert\Type(type="string")
3437
*/
3538
public $title;
@@ -38,7 +41,9 @@ class ResourceDto
3841
* @var string
3942
*
4043
* @JsonApi\Attribute
44+
*
4145
* @Assert\Type(type="string")
46+
*
4247
* @Assert\Regex(pattern="/^\d+-\d+-\d+$/")
4348
*/
4449
public $date;
@@ -47,7 +52,9 @@ class ResourceDto
4752
* @var string
4853
*
4954
* @JsonApi\Attribute
55+
*
5056
* @Assert\Type(type="string")
57+
*
5158
* @Assert\NotNull
5259
*/
5360
public $summary;
@@ -56,6 +63,7 @@ class ResourceDto
5663
* @var null|string
5764
*
5865
* @JsonApi\ToOne(type="people")
66+
*
5967
* @Assert\NotBlank
6068
*/
6169
public $author;
@@ -64,6 +72,7 @@ class ResourceDto
6472
* @var string[]
6573
*
6674
* @JsonApi\ToMany(type="tags")
75+
*
6776
* @Assert\NotBlank
6877
*/
6978
public $tags = [];

tests/Unit/Http/Model/Response/ResourceCollectionResponseTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,15 +147,15 @@ public function testFromArrayWillThrowExceptionGivenInvalidArgumentsPresent(
147147
$resourceMocks = [];
148148
$includeMocks = [];
149149
foreach ($resources as $resource) {
150-
if (true === is_string($resource)) {
150+
if (true === \is_string($resource)) {
151151
$resourceMocks[] = $this->createMock($resource);
152152
} else {
153153
$resourceMocks[] = $resource;
154154
}
155155
}
156156

157157
foreach ($included as $include) {
158-
if (true === is_string($include)) {
158+
if (true === \is_string($include)) {
159159
$includeMocks[] = $this->createMock($include);
160160
} else {
161161
$includeMocks[] = $include;

0 commit comments

Comments
 (0)