Skip to content

Commit f20b97f

Browse files
authored
Merge pull request #60 from assoconnect/jwa_delete_annotation
Delete doctrine/annotation, use attribute instead
2 parents da8a955 + 57158bc commit f20b97f

23 files changed

Lines changed: 63 additions & 200 deletions

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
"require-dev": {
5050
"doctrine/cache": "~1.0",
5151
"symfony/phpunit-bridge": "^6.4.3",
52-
"doctrine/annotations": "~1.0",
5352
"phpunit/phpunit": "^9.6.16",
5453
"symfony/framework-bundle": "^6.4",
5554
"symfony/yaml": "^6.4",

src/Test/Functional/App/Entity/MyEmbeddable.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,10 @@
66

77
use Doctrine\ORM\Mapping as ORM;
88

9-
/**
10-
* @ORM\Embeddable()
11-
*/
9+
#[ORM\Embeddable]
1210
class MyEmbeddable
1311
{
14-
/**
15-
* @ORM\Column(type="boolean")
16-
*/
12+
#[ORM\Column(type: 'boolean')]
1713
public bool $bool;
1814

1915
public function __construct(bool $bool)

src/Test/Functional/App/Entity/MyEntity.php

Lines changed: 53 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -9,227 +9,153 @@
99
use Doctrine\ORM\Mapping as ORM;
1010
use Money\Currency;
1111

12-
/**
13-
* @AssoConnectAssert\Entity()
14-
* @ORM\Entity()
15-
*/
12+
#[
13+
AssoConnectAssert\Entity,
14+
ORM\Entity,
15+
]
1616
class MyEntity
1717
{
18-
/**
19-
* @ORM\Id
20-
* @ORM\Column(type="integer")
21-
* @ORM\GeneratedValue(strategy="NONE")
22-
*/
18+
#[
19+
ORM\Id,
20+
ORM\Column(type: 'integer'),
21+
ORM\GeneratedValue(strategy: 'NONE'),
22+
]
2323
public int $id;
2424

2525
/**
26-
* @ORM\Column(type="array")
2726
* @var array<mixed>
2827
*/
28+
#[ORM\Column(type: 'array')]
2929
public array $array;
3030

31-
/**
32-
* @ORM\Column(type="bic")
33-
*/
31+
#[ORM\Column(type: 'bic')]
3432
public string $bic;
3533

36-
/**
37-
* @ORM\Column(type="bigint")
38-
*/
34+
#[ORM\Column(type: 'bigint')]
3935
public int $bigint;
4036

41-
/**
42-
* @ORM\Column(type="bigint", options={"unsigned"=true})
43-
*/
37+
#[ORM\Column(type: 'bigint', options: ['unsigned' => true])]
4438
public int $bigintUnsigned;
4539

46-
/**
47-
* @ORM\Column(type="boolean")
48-
*/
40+
#[ORM\Column(type: 'boolean')]
4941
public bool $boolean;
5042

51-
/**
52-
* @ORM\Column(type="country")
53-
*/
43+
#[ORM\Column(type: 'country')]
5444
public string $country;
5545

56-
/**
57-
* @ORM\Column(type="currency")
58-
*/
46+
#[ORM\Column(type: 'currency')]
5947
public Currency $currency;
6048

61-
/**
62-
* @ORM\Column(type="date")
63-
*/
49+
#[ORM\Column(type: 'date')]
6450
public \DateTime $date;
6551

66-
/**
67-
* @ORM\Column(type="datetime")
68-
*/
52+
#[ORM\Column(type: 'datetime')]
6953
public \DateTime $datetime;
7054

71-
/**
72-
* @ORM\Column(type="decimal", precision=5, scale=3)
73-
*/
55+
#[ORM\Column(type: 'decimal', precision: 5, scale: 3)]
7456
public float $decimal;
7557

76-
/**
77-
* @ORM\Column(type="email")
78-
*/
58+
#[ORM\Column(type: 'email')]
7959
public string $email;
8060

81-
/**
82-
* @ORM\Column(type="float")
83-
*/
61+
#[ORM\Column(type: 'float')]
8462
public float $float;
8563

86-
/**
87-
* @ORM\Column(type="iban")
88-
*/
64+
#[ORM\Column(type: 'iban')]
8965
public string $iban;
9066

91-
/**
92-
* @ORM\Column(type="integer")
93-
*/
67+
#[ORM\Column(type: 'integer')]
9468
public int $integer;
9569

96-
/**
97-
* @ORM\Column(type="ip")
98-
*/
70+
#[ORM\Column(type: 'ip')]
9971
public string $ip;
10072

101-
/**
102-
* @ORM\Column(type="json")
103-
*/
73+
#[ORM\Column(type: 'json')]
10474
public string $json;
10575

106-
/**
107-
* @ORM\Column(type="latitude")
108-
*/
76+
#[ORM\Column(type: 'latitude')]
10977
public string $latitude;
11078

111-
/**
112-
* @ORM\Column(type="locale")
113-
*/
79+
#[ORM\Column(type: 'locale')]
11480
public string $locale;
11581

116-
/**
117-
* @ORM\Column(type="longitude")
118-
*/
82+
#[ORM\Column(type: 'longitude')]
11983
public string $longitude;
12084

121-
/**
122-
* @ORM\Column(type="money")
123-
*/
85+
#[ORM\Column(type: 'money')]
12486
public float $money;
12587

126-
/**
127-
* @ORM\Column(type="string", nullable=false)
128-
*/
88+
#[ORM\Column(type: 'string', nullable: false)]
12989
public string $notNullable;
13090

131-
/**
132-
* @ORM\Column(type="percent")
133-
*/
91+
#[ORM\Column(type: 'percent')]
13492
public float $percent;
13593

136-
/**
137-
* @ORM\Column(type="phone")
138-
*/
94+
#[ORM\Column(type: 'phone')]
13995
public string $phone;
14096

141-
/**
142-
* @ORM\Column(type="phonelandline")
143-
*/
97+
#[ORM\Column(type: 'phonelandline')]
14498
public string $phonelandline;
14599

146-
/**
147-
* @ORM\Column(type="phonemobile")
148-
*/
100+
#[ORM\Column(type: 'phonemobile')]
149101
public string $phonemobile;
150102

151-
/**
152-
* @ORM\Column(type="smallint")
153-
*/
103+
#[ORM\Column(type: 'smallint')]
154104
public int $smallint;
155105

156-
/**
157-
* @ORM\Column(type="smallint", options={"unsigned"=true})
158-
*/
106+
#[ORM\Column(type: 'smallint', options: ['unsigned' => true])]
159107
public int $smallintUnsigned;
160108

161-
/**
162-
* @ORM\Column(type="string", length=10)
163-
*/
109+
#[ORM\Column(type: 'string', length: 10)]
164110
public string $string;
165111

166-
/**
167-
* @ORM\Column(type="text", length=10)
168-
*/
112+
#[ORM\Column(type: 'text', length: 10)]
169113
public string $text;
170114

171-
/**
172-
* @ORM\Column(type="timezone")
173-
*/
115+
#[ORM\Column(type: 'timezone')]
174116
public string $timezone;
175117

176-
/**
177-
* @ORM\Column(type="uuid")
178-
*/
118+
#[ORM\Column(type: 'uuid')]
179119
public string $uuid;
180120

181-
/**
182-
* @ORM\Column(type="uuid_binary_ordered_time")
183-
*/
121+
#[ORM\Column(type: 'uuid_binary_ordered_time')]
184122
public string $uuid_binary_ordered_time;
185123

186124
/**
187125
* ASSOCIATIONS
188126
*/
189127

190-
/**
191-
* @ORM\ManyToOne(targetEntity="MyEntityParent")
192-
*/
128+
#[ORM\ManyToOne(targetEntity: MyEntityParent::class)]
193129
public ?MyEntityParent $parentNullable;
194130

195-
/**
196-
* @ORM\ManyToOne(targetEntity="MyEntityParent")
197-
* @ORM\JoinColumn(nullable=false)
198-
*/
131+
#[
132+
ORM\ManyToOne(targetEntity: MyEntityParent::class),
133+
ORM\JoinColumn(nullable: false)
134+
]
199135
public MyEntityParent $parentNotNullable;
200136

201-
/**
202-
* @ORM\OneToMany(targetEntity="MyEntityParent", mappedBy="mainChild")
203-
*/
137+
#[ORM\OneToMany(targetEntity: MyEntityParent::class, mappedBy: 'mainChild')]
204138
public MyEntityParent $mainParent;
205139

206140
/**
207-
* @ORM\ManyToMany(targetEntity="MyEntityParent")
208-
* @var array<MyEntityParent>
141+
* @var array<MyEntityParent> $parents
209142
*/
143+
#[ORM\ManyToMany(targetEntity: MyEntityParent::class)]
210144
public array $parents;
211145

212146
/**
213147
* EMBEDDABLES
214148
*/
215149

216-
/**
217-
* @ORM\Embedded(class="MyEmbeddable")
218-
*/
150+
#[ORM\Embedded(class: 'MyEmbeddable')]
219151
public MyEmbeddable $embeddable;
220152

221-
/**
222-
* @ORM\Column(type="date_absolute")
223-
*/
153+
#[ORM\Column(type: 'date_absolute')]
224154
public AbsoluteDate $absoluteDate;
225155

226-
/**
227-
* @ORM\Column(type="frenchRna")
228-
*/
156+
#[ORM\Column(type: 'frenchRna')]
229157
public string $frenchRNA;
230158

231-
/**
232-
* @ORM\Column(type="frenchSiren")
233-
*/
159+
#[ORM\Column(type: 'frenchSiren')]
234160
public string $frenchSIREN;
235161
}

src/Test/Functional/App/Entity/MyEntityParent.php

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,15 @@
77
use AssoConnect\ValidatorBundle\Validator\Constraints as AssoConnectAssert;
88
use Doctrine\ORM\Mapping as ORM;
99

10-
/**
11-
* @AssoConnectAssert\Entity()
12-
* @ORM\Entity()
13-
*/
10+
#[AssoConnectAssert\Entity]
11+
#[ORM\Entity]
1412
class MyEntityParent
1513
{
16-
/**
17-
* @ORM\Id
18-
* @ORM\Column(type="integer")
19-
* @ORM\GeneratedValue(strategy="NONE")
20-
*/
14+
#[ORM\Id]
15+
#[ORM\Column(type: 'integer')]
16+
#[ORM\GeneratedValue(strategy: 'NONE')]
2117
public int $id;
2218

23-
/**
24-
* @ORM\ManyToOne(targetEntity="MyEntity")
25-
*/
19+
#[ORM\ManyToOne(targetEntity: MyEntity::class)]
2620
public MyEntity $mainChild;
2721
}

src/Test/Functional/App/config/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ doctrine:
1111
mappings:
1212
AssoConnect:
1313
is_bundle: false
14-
type: annotation
14+
type: attribute
1515
dir: '%kernel.project_dir%/src/Test/Functional/App/Entity'
1616
prefix: 'AssoConnect\ValidatorBundle\Test\Functional\App\Entity'
1717
alias: App

src/Validator/Constraints/Email.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
use Symfony\Component\Validator\Constraints\Email as _Email;
88

99
/**
10-
* @Annotation
11-
* @Target({"PROPERTY", "METHOD", "ANNOTATION"})
12-
*
1310
* @author Sylvain Fabre <sylvain.fabre@assoconnect.com>
1411
*/
1512
#[\Attribute]

src/Validator/Constraints/EmployerIdentificationNumber.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66

77
use Symfony\Component\Validator\Constraint;
88

9-
/**
10-
* @Annotation
11-
*/
129
#[\Attribute]
1310
class EmployerIdentificationNumber extends Constraint
1411
{

src/Validator/Constraints/Entity.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66

77
use Symfony\Component\Validator\Constraint;
88

9-
/**
10-
* @Annotation
11-
*/
129
#[\Attribute]
1310
class Entity extends Constraint
1411
{

src/Validator/Constraints/EntityValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
use Webmozart\Assert\Assert;
2020

2121
/**
22-
* @Annotation
2322
* @phpstan-import-type FieldMapping from ClassMetadataInfo
2423
*/
24+
#[\Attribute]
2525
class EntityValidator extends ConstraintValidator
2626
{
2727
private EntityManagerInterface $em;

src/Validator/Constraints/FloatScale.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
use Symfony\Component\Validator\Constraint;
88

99
/**
10-
* @Annotation
11-
* @Target({"PROPERTY", "METHOD", "ANNOTATION"})
12-
*
1310
* @author Sylvain Fabre <sylvain.fabre@assoconnect.com>
1411
*/
1512
#[\Attribute]

0 commit comments

Comments
 (0)