File tree 6 files changed +88
-5
lines changed
src/Model/Resource/Attribute
tests/Bridge/OpenAPI/Model
6 files changed +88
-5
lines changed Original file line number Diff line number Diff line change 3
3
declare (strict_types=1 );
4
4
5
5
use Rector \Config \RectorConfig ;
6
+ use Rector \Doctrine \Set \DoctrineSetList ;
7
+ use Rector \Php80 \Rector \Class_ \AnnotationToAttributeRector ;
8
+ use Rector \Php80 \ValueObject \AnnotationToAttribute ;
9
+ use Rector \Symfony \Set \SensiolabsSetList ;
10
+ use Rector \Symfony \Set \SymfonySetList ;
11
+ use Symfony \Bridge \Doctrine \Validator \Constraints \UniqueEntity ;
6
12
7
- return RectorConfig::configure ()
8
- ->withPaths ([
13
+ return static function (RectorConfig $ rectorConfig ): void {
14
+ // Paths for Rector to act upon
15
+ $ rectorConfig ->paths ([
9
16
__DIR__ . '/src ' ,
10
17
__DIR__ . '/tests ' ,
11
- ])
12
- ->withPhpSets (true )
13
- ->withRules ([
14
18
]);
19
+
20
+ $ rectorConfig ->sets ([
21
+ DoctrineSetList::ANNOTATIONS_TO_ATTRIBUTES ,
22
+ SymfonySetList::ANNOTATIONS_TO_ATTRIBUTES ,
23
+ SensiolabsSetList::ANNOTATIONS_TO_ATTRIBUTES ,
24
+ ]);
25
+ $ rectorConfig ->ruleWithConfiguration (AnnotationToAttributeRector::class, [
26
+ new AnnotationToAttribute (UniqueEntity::class),
27
+ ]);
28
+ };
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+
5
+ namespace Undabot \SymfonyJsonApi \Model \Resource \Attribute ;
6
+
7
+ use Attribute as PhpAttribute ;
8
+
9
+ #[PhpAttribute(PhpAttribute::TARGET_PROPERTY | PhpAttribute::IS_REPEATABLE )]
10
+ class Attribute
11
+ {
12
+ public function __construct (
13
+ public string $ name ,
14
+ public ?string $ description = null ,
15
+ public ?string $ example = null ,
16
+ public ?string $ format = null ,
17
+ public bool $ nullable = false
18
+ ) {}
19
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+
5
+ namespace Undabot \SymfonyJsonApi \Model \Resource \Attribute ;
6
+
7
+ abstract class Relationship
8
+ {
9
+ public function __construct (
10
+ public string $ name ,
11
+ public ?string $ type = null ,
12
+ public ?string $ description = null ,
13
+ public bool $ nullable = false
14
+ ) {}
15
+
16
+ abstract public function isToMany (): bool ;
17
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+
5
+ namespace Undabot \SymfonyJsonApi \Model \Resource \Attribute ;
6
+
7
+ use Attribute as PhpAttribute ;
8
+
9
+ #[PhpAttribute(PhpAttribute::TARGET_PROPERTY | PhpAttribute::IS_REPEATABLE )]
10
+ class ToMany extends Relationship
11
+ {
12
+ public function isToMany (): bool
13
+ {
14
+ return true ;
15
+ }
16
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+
5
+ namespace Undabot \SymfonyJsonApi \Model \Resource \Attribute ;
6
+
7
+ use Attribute as PhpAttribute ;
8
+
9
+ #[PhpAttribute(PhpAttribute::TARGET_PROPERTY | PhpAttribute::IS_REPEATABLE )]
10
+ class ToOne extends Relationship
11
+ {
12
+ public function isToMany (): bool
13
+ {
14
+ return false ;
15
+ }
16
+ }
Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ class Article implements ApiModel
45
45
*
46
46
* @Attribute(name="eventDate")
47
47
*/
48
+ #[\Undabot \SymfonyJsonApi \Model \Resource \Attribute \Attribute('ovoJeIme ' )]
48
49
private $ date ;
49
50
50
51
/**
You can’t perform that action at this time.
0 commit comments