Skip to content

Commit 3684424

Browse files
author
Matej Grgić
committed
fix: class metadata as attribute
1 parent fa70fad commit 3684424

32 files changed

+158
-55
lines changed

rector.php

+5-8
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,12 @@
33
declare(strict_types=1);
44

55
use Rector\Config\RectorConfig;
6-
use Rector\Set\ValueObject\LevelSetList;
76

8-
return static function (RectorConfig $rectorConfig): void {
9-
$rectorConfig->paths([
7+
return RectorConfig::configure()
8+
->withPaths([
109
__DIR__ . '/src',
1110
__DIR__ . '/tests',
11+
])
12+
->withPhpSets(true)
13+
->withRules([
1214
]);
13-
14-
$rectorConfig->sets([
15-
LevelSetList::UP_TO_PHP_83,
16-
]);
17-
};

src/Service/Resource/Validation/Constraint/ResourceType.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
/**
1111
* @Annotation
1212
*/
13-
class ResourceType extends Constraint
13+
#[\Attribute] class ResourceType extends Constraint
1414
{
1515
/** @var string */
1616
public $type;

tests/Bridge/OpenAPI/ApiTransformerTest.php

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
namespace Undabot\SymfonyJsonApi\Tests\Bridge\OpenAPI;
66

7+
use PHPUnit\Framework\Attributes\CoversNothing;
8+
use PHPUnit\Framework\Attributes\Small;
79
use PHPUnit\Framework\TestCase;
810
use Symfony\Component\Yaml\Yaml;
911
use Undabot\SymfonyJsonApi\Bridge\OpenApi\ApiTransformer;
@@ -16,6 +18,8 @@
1618
*
1719
* @small
1820
*/
21+
#[CoversNothing]
22+
#[Small]
1923
final class ApiTransformerTest extends TestCase
2024
{
2125
private ApiTransformer $service;

tests/Bridge/OpenAPI/Helper/TypeHelperTest.php

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
namespace Undabot\SymfonyJsonApi\Tests\Bridge\OpenAPI\Helper;
66

7+
use PHPUnit\Framework\Attributes\CoversNothing;
8+
use PHPUnit\Framework\Attributes\Small;
79
use PHPUnit\Framework\TestCase;
810
use Undabot\SymfonyJsonApi\Bridge\OpenApi\Helper\TypeHelper;
911

@@ -14,6 +16,8 @@
1416
*
1517
* @small
1618
*/
19+
#[CoversNothing]
20+
#[Small]
1721
final class TypeHelperTest extends TestCase
1822
{
1923
public function testItResolvesBoolToBoolean(): void

tests/Bridge/OpenAPI/OpenApiGeneratorTest.php

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
namespace Undabot\SymfonyJsonApi\Tests\Bridge\OpenAPI;
66

7+
use PHPUnit\Framework\Attributes\CoversNothing;
8+
use PHPUnit\Framework\Attributes\Small;
79
use PHPUnit\Framework\TestCase;
810
use Undabot\SymfonyJsonApi\Bridge\OpenApi\Model\Api;
911
use Undabot\SymfonyJsonApi\Bridge\OpenApi\OpenApiDefinition;
@@ -16,6 +18,8 @@
1618
*
1719
* @small
1820
*/
21+
#[CoversNothing]
22+
#[Small]
1923
final class OpenApiGeneratorTest extends TestCase
2024
{
2125
private OpenApiGenerator $service;

tests/Bridge/OpenAPI/ResourceReadSchema/ResourceReadSchemaRelationshipsTest.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
namespace Undabot\SymfonyJsonApi\Tests\Bridge\OpenAPI\ResourceReadSchema;
66

77
use Doctrine\Common\Annotations\AnnotationReader;
8+
use PHPUnit\Framework\Attributes\CoversClass;
9+
use PHPUnit\Framework\Attributes\Small;
810
use PHPUnit\Framework\TestCase;
911
use Undabot\SymfonyJsonApi\Bridge\OpenApi\Service\AttributeSchemaFactory;
1012
use Undabot\SymfonyJsonApi\Bridge\OpenApi\Service\RelationshipSchemaFactory;
@@ -17,10 +19,12 @@
1719
/**
1820
* @internal
1921
*
20-
* @covers \Undabot\SymfonyJsonApi\Bridge\OpenApi\Service\ResourceSchemaFactory
22+
* @coversNothing
2123
*
2224
* @small
2325
*/
26+
#[CoversClass('\Undabot\SymfonyJsonApi\Bridge\OpenApi\Service\ResourceSchemaFactory')]
27+
#[Small]
2428
final class ResourceReadSchemaRelationshipsTest extends TestCase
2529
{
2630
private ResourceSchemaFactory $resourceSchemaFactory;

tests/Bridge/OpenAPI/ResourceReadSchema/ResourceReadSchemaTest.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
namespace Undabot\SymfonyJsonApi\Tests\Bridge\OpenAPI\ResourceReadSchema;
66

77
use Doctrine\Common\Annotations\AnnotationReader;
8+
use PHPUnit\Framework\Attributes\CoversClass;
9+
use PHPUnit\Framework\Attributes\Small;
810
use PHPUnit\Framework\TestCase;
911
use Symfony\Component\Validator\Constraints as Assert;
1012
use Undabot\SymfonyJsonApi\Bridge\OpenApi\Service\AttributeSchemaFactory;
@@ -18,10 +20,12 @@
1820
/**
1921
* @internal
2022
*
21-
* @covers \Undabot\SymfonyJsonApi\Bridge\OpenApi\Service\ResourceSchemaFactory
23+
* @coversNothing
2224
*
2325
* @small
2426
*/
27+
#[CoversClass('\Undabot\SymfonyJsonApi\Bridge\OpenApi\Service\ResourceSchemaFactory')]
28+
#[Small]
2529
final class ResourceReadSchemaTest extends TestCase
2630
{
2731
private ResourceSchemaFactory $resourceSchemaFactory;

tests/Bridge/OpenAPI/Schema/AttributeSchemaTest.php

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
namespace Undabot\SymfonyJsonApi\Tests\Bridge\OpenAPI\Schema;
66

7+
use PHPUnit\Framework\Attributes\CoversNothing;
8+
use PHPUnit\Framework\Attributes\Small;
79
use PHPUnit\Framework\TestCase;
810
use Undabot\SymfonyJsonApi\Bridge\OpenApi\Model\JsonApi\Schema\AttributeSchema;
911

@@ -14,6 +16,8 @@
1416
*
1517
* @small
1618
*/
19+
#[CoversNothing]
20+
#[Small]
1721
final class AttributeSchemaTest extends TestCase
1822
{
1923
public function testItCanBeConstructedWithMinimalData(): void

tests/Integration/CreateResourceFromJsonInputTest.php

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
namespace Undabot\SymfonyJsonApi\Tests\Integration;
66

7+
use PHPUnit\Framework\Attributes\CoversNothing;
8+
use PHPUnit\Framework\Attributes\Small;
79
use PHPUnit\Framework\TestCase;
810
use Undabot\JsonApi\Implementation\Encoding\PhpArrayToAttributeCollectionEncoder;
911
use Undabot\JsonApi\Implementation\Encoding\PhpArrayToLinkCollectionEncoder;
@@ -22,6 +24,8 @@
2224
*
2325
* @small
2426
*/
27+
#[CoversNothing]
28+
#[Small]
2529
final class CreateResourceFromJsonInputTest extends TestCase
2630
{
2731
/** @var PhpArrayToResourceEncoder */

tests/Integration/Http/Service/EventSubscriber/ViewResponseSubscriberTest.php

+8-5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
namespace Undabot\SymfonyJsonApi\Tests\Integration\Http\Service\EventSubscriber;
66

7+
use PHPUnit\Framework\Attributes\CoversClass;
8+
use PHPUnit\Framework\Attributes\DataProvider;
9+
use PHPUnit\Framework\Attributes\Medium;
710
use PHPUnit\Framework\TestCase;
811
use Symfony\Component\EventDispatcher\EventDispatcher;
912
use Symfony\Component\HttpFoundation\Request;
@@ -37,10 +40,12 @@
3740
/**
3841
* @internal
3942
*
40-
* @covers \Undabot\SymfonyJsonApi\Http\Service\EventSubscriber\ViewResponseSubscriber
43+
* @coversNothing
4144
*
42-
* @medium
45+
* @small
4346
*/
47+
#[CoversClass('\Undabot\SymfonyJsonApi\Http\Service\EventSubscriber\ViewResponseSubscriber')]
48+
#[Medium]
4449
final class ViewResponseSubscriberTest extends TestCase
4550
{
4651
private ViewResponseSubscriber $viewResponseSubscriber;
@@ -111,9 +116,7 @@ public function testBuildViewWillSetCorrectResponseWithoutLinksInEventGivenValid
111116
self::assertArrayNotHasKey('links', $responseContent);
112117
}
113118

114-
/**
115-
* @dataProvider provideBuildViewWillSetCorrectResponseWithPaginationLinksInEventGivenValidResourceCollectionControllerWithPaginatedResultsCases
116-
*/
119+
#[DataProvider('provideBuildViewWillSetCorrectResponseWithPaginationLinksInEventGivenValidResourceCollectionControllerWithPaginatedResultsCases')]
117120
public function testBuildViewWillSetCorrectResponseWithPaginationLinksInEventGivenValidResourceCollectionControllerWithPaginatedResults(
118121
Request $request,
119122
?string $firstLink,

tests/Integration/Resource/Denormalizer/ResourceDenormalizerTest.php

+5
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,18 @@ public function getOwner(): ?string
9191
}
9292
}
9393

94+
use PHPUnit\Framework\Attributes\CoversNothing;
95+
use PHPUnit\Framework\Attributes\Small;
96+
9497
/**
9598
* @internal
9699
*
97100
* @coversNothing
98101
*
99102
* @small
100103
*/
104+
#[CoversNothing]
105+
#[Small]
101106
final class ResourceDenormalizerTest extends TestCase
102107
{
103108
/** @var ResourceDenormalizer */

tests/Integration/Resource/Denormalizer/ResourceWithAliasesDenormalizerTest.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
namespace Undabot\SymfonyJsonApi\Tests\Integration\Resource\Denormalizer;
66

77
use Doctrine\Common\Annotations\AnnotationReader;
8+
use PHPUnit\Framework\Attributes\CoversClass;
9+
use PHPUnit\Framework\Attributes\Small;
810
use PHPUnit\Framework\TestCase;
911
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory;
1012
use Symfony\Component\Serializer\Mapping\Loader\AttributeLoader;
@@ -40,10 +42,12 @@ public function __construct(
4042
/**
4143
* @internal
4244
*
43-
* @covers \Undabot\SymfonyJsonApi\Service\Resource\Denormalizer\ResourceDenormalizer
45+
* @coversNothing
4446
*
4547
* @small
4648
*/
49+
#[CoversClass('\Undabot\SymfonyJsonApi\Service\Resource\Denormalizer\ResourceDenormalizer')]
50+
#[Small]
4751
final class ResourceWithAliasesDenormalizerTest extends TestCase
4852
{
4953
private ResourceDenormalizer $serializer;

tests/Integration/Resource/Factory/ResourceFactoryTest.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
namespace Undabot\SymfonyJsonApi\Tests\Integration\Resource\Factory;
66

77
use Doctrine\Common\Annotations\AnnotationReader;
8+
use PHPUnit\Framework\Attributes\CoversClass;
9+
use PHPUnit\Framework\Attributes\Small;
810
use PHPUnit\Framework\MockObject\MockObject;
911
use PHPUnit\Framework\TestCase;
1012
use Symfony\Component\Validator\Constraints as Assert;
@@ -28,10 +30,12 @@
2830
/**
2931
* @internal
3032
*
31-
* @covers \Undabot\SymfonyJsonApi\Service\Resource\Factory\ResourceFactory
33+
* @coversNothing
3234
*
3335
* @small
3436
*/
37+
#[CoversClass('\Undabot\SymfonyJsonApi\Service\Resource\Factory\ResourceFactory')]
38+
#[Small]
3539
final class ResourceFactoryTest extends TestCase
3640
{
3741
private ResourceFactory $resourceFactory;

tests/Integration/Resource/Metadata/MetadataFactoryTest.php

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
namespace Undabot\SymfonyJsonApi\Tests\Integration\Resource\Metadata;
66

77
use Doctrine\Common\Annotations\AnnotationReader;
8+
use PHPUnit\Framework\Attributes\CoversNothing;
9+
use PHPUnit\Framework\Attributes\Small;
810
use PHPUnit\Framework\TestCase;
911
use Undabot\SymfonyJsonApi\Model\ApiModel;
1012
use Undabot\SymfonyJsonApi\Model\Resource\Annotation as JsonApi;
@@ -18,6 +20,8 @@
1820
*
1921
* @small
2022
*/
23+
#[CoversNothing]
24+
#[Small]
2125
final class MetadataFactoryTest extends TestCase
2226
{
2327
/** @var ResourceMetadataFactory */

tests/Integration/Resource/Metadata/ResourceAttributesMetadataTest.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44

55
namespace Undabot\SymfonyJsonApi\Tests\Integration\Resource\Metadata;
66

7-
use Doctrine\Common\Annotations\Annotation\IgnoreAnnotation;
87
use Doctrine\Common\Annotations\AnnotationReader;
8+
use PHPUnit\Framework\Attributes\CoversNothing;
9+
use PHPUnit\Framework\Attributes\Small;
910
use PHPUnit\Framework\TestCase;
1011
use Symfony\Component\Validator\Constraint;
1112
use Symfony\Component\Validator\Constraints as Assert;
@@ -20,12 +21,12 @@
2021
/**
2122
* @internal
2223
*
23-
* @IgnoreAnnotation("Assert\NotBlank")
24-
*
2524
* @coversNothing
2625
*
2726
* @small
2827
*/
28+
#[CoversNothing]
29+
#[Small]
2930
final class ResourceAttributesMetadataTest extends TestCase
3031
{
3132
/** @var ResourceMetadataFactory */

tests/Integration/Resource/Metadata/ResourceRelationshipsMetadataTest.php

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
namespace Undabot\SymfonyJsonApi\Tests\Integration\Resource\Metadata;
66

77
use Doctrine\Common\Annotations\AnnotationReader;
8+
use PHPUnit\Framework\Attributes\CoversNothing;
9+
use PHPUnit\Framework\Attributes\Small;
810
use PHPUnit\Framework\TestCase;
911
use Symfony\Component\Validator\Constraint;
1012
use Undabot\SymfonyJsonApi\Model\ApiModel;
@@ -24,6 +26,8 @@
2426
*
2527
* @small
2628
*/
29+
#[CoversNothing]
30+
#[Small]
2731
final class ResourceRelationshipsMetadataTest extends TestCase
2832
{
2933
/** @var ResourceMetadataFactory */

tests/Integration/Resource/Validation/ResourceRelationshipsValidationTest.php

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
namespace Undabot\SymfonyJsonApi\Tests\Integration\Resource\Validation;
66

77
use Doctrine\Common\Annotations\AnnotationReader;
8+
use PHPUnit\Framework\Attributes\CoversNothing;
9+
use PHPUnit\Framework\Attributes\Small;
810
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
911
use Symfony\Component\Validator\Validation;
1012
use Undabot\JsonApi\Implementation\Model\Resource\Resource;
@@ -23,6 +25,8 @@
2325
*
2426
* @small
2527
*/
28+
#[CoversNothing]
29+
#[Small]
2630
final class ResourceRelationshipsValidationTest extends KernelTestCase
2731
{
2832
/** @var ResourceValidator */

tests/Integration/Resource/Validation/ResourceValidationTest.php

+5
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,18 @@ class ResourceDto
8585
public $comments = [];
8686
}
8787

88+
use PHPUnit\Framework\Attributes\CoversNothing;
89+
use PHPUnit\Framework\Attributes\Small;
90+
8891
/**
8992
* @internal
9093
*
9194
* @coversNothing
9295
*
9396
* @small
9497
*/
98+
#[CoversNothing]
99+
#[Small]
95100
final class ResourceValidationTest extends KernelTestCase
96101
{
97102
/** @var ResourceValidator */

tests/Unit/Exception/EventSubscriber/ExceptionListenerTest.php

+6-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44

55
namespace Undabot\SymfonyJsonApi\Tests\Unit\Exception\EventSubscriber;
66

7+
use PHPUnit\Framework\Attributes\CoversClass;
78
use PHPUnit\Framework\Attributes\DataProvider;
9+
use PHPUnit\Framework\Attributes\Medium;
810
use PHPUnit\Framework\MockObject\MockObject;
911
use PHPUnit\Framework\TestCase;
1012
use Symfony\Component\EventDispatcher\EventDispatcher;
@@ -28,10 +30,12 @@
2830
/**
2931
* @internal
3032
*
31-
* @covers \Undabot\SymfonyJsonApi\Exception\EventSubscriber\ExceptionListener
33+
* @coversNothing
3234
*
33-
* @medium
35+
* @small
3436
*/
37+
#[CoversClass('\Undabot\SymfonyJsonApi\Exception\EventSubscriber\ExceptionListener')]
38+
#[Medium]
3539
final class ExceptionListenerTest extends TestCase
3640
{
3741
private MockObject $documentToPhpArrayEncoderInterfaceMock;

0 commit comments

Comments
 (0)