@@ -169,95 +169,95 @@ We keep up the example of an Article with arbitrary attributes, the mapping look
169
169
170
170
.. configuration-block ::
171
171
172
- .. code-block :: php
172
+ .. code-block :: attribute
173
173
174
174
<?php
175
175
namespace Application\Model;
176
176
177
177
use Doctrine\Common\Collections\ArrayCollection;
178
178
179
- /**
180
- * @Entity
181
- */
179
+ #[Entity]
182
180
class Article
183
181
{
184
- /** @Id @ Column(type=" integer") @ GeneratedValue */
182
+ #[Id, Column(type: ' integer'), GeneratedValue]
185
183
private int|null $id = null;
186
- /** @ Column(type=" string") */
184
+ #[ Column(type: ' string')]
187
185
private string $title;
188
186
189
- /**
190
- * @OneToMany(targetEntity="ArticleAttribute", mappedBy="article", cascade={"ALL"}, indexBy="attribute")
191
- * @var Collection<int , ArticleAttribute >
192
- */
187
+ /** @var ArrayCollection<string, ArticleAttribute> */
188
+ #[OneToMany(targetEntity: ArticleAttribute::class, mappedBy: 'article', cascade: ['ALL'], indexBy: 'attribute')]
193
189
private Collection $attributes;
194
190
195
- public function addAttribute($name, $value): void
191
+ public function addAttribute(string $name, ArticleAttribute $value): void
196
192
{
197
193
$this->attributes[$name] = new ArticleAttribute($name, $value, $this);
198
194
}
199
195
}
200
196
201
- /**
202
- * @Entity
203
- */
197
+ #[Entity]
204
198
class ArticleAttribute
205
199
{
206
- /** @Id @ ManyToOne(targetEntity=" Article" , inversedBy=" attributes") */
207
- private Article|null $article;
200
+ #[Id, ManyToOne(targetEntity: Article::class , inversedBy: ' attributes')]
201
+ private Article $article;
208
202
209
- /** @Id @ Column(type=" string") */
203
+ #[Id, Column(type: ' string')]
210
204
private string $attribute;
211
205
212
- /** @ Column(type=" string") */
206
+ #[ Column(type: ' string')]
213
207
private string $value;
214
208
215
- public function __construct($name, $value, $article)
209
+ public function __construct(string $name, string $value, Article $article)
216
210
{
217
211
$this->attribute = $name;
218
212
$this->value = $value;
219
213
$this->article = $article;
220
214
}
221
215
}
222
216
223
- .. code-block :: attribute
217
+ .. code-block :: annotation
224
218
225
219
<?php
226
220
namespace Application\Model;
227
221
228
222
use Doctrine\Common\Collections\ArrayCollection;
229
223
230
- #[Entity]
224
+ /**
225
+ * @Entity
226
+ */
231
227
class Article
232
228
{
233
- #[Id, Column(type: ' integer'), GeneratedValue]
229
+ /** @Id @ Column(type=" integer") @ GeneratedValue */
234
230
private int|null $id = null;
235
- #[ Column(type: ' string')]
231
+ /** @ Column(type=" string") */
236
232
private string $title;
237
233
238
- /** @var ArrayCollection<string, ArticleAttribute> */
239
- #[OneToMany(targetEntity: ArticleAttribute::class, mappedBy: 'article', cascade: ['ALL'], indexBy: 'attribute')]
234
+ /**
235
+ * @OneToMany(targetEntity="ArticleAttribute", mappedBy="article", cascade={"ALL"}, indexBy="attribute")
236
+ * @var Collection<int, ArticleAttribute>
237
+ */
240
238
private Collection $attributes;
241
239
242
- public function addAttribute(string $name, ArticleAttribute $value): void
240
+ public function addAttribute($name, $value): void
243
241
{
244
242
$this->attributes[$name] = new ArticleAttribute($name, $value, $this);
245
243
}
246
244
}
247
245
248
- #[Entity]
246
+ /**
247
+ * @Entity
248
+ */
249
249
class ArticleAttribute
250
250
{
251
- #[Id, ManyToOne(targetEntity: Article::class , inversedBy: ' attributes')]
252
- private Article $article;
251
+ /** @Id @ ManyToOne(targetEntity=" Article" , inversedBy=" attributes") */
252
+ private Article|null $article;
253
253
254
- #[Id, Column(type: ' string')]
254
+ /** @Id @ Column(type=" string") */
255
255
private string $attribute;
256
256
257
- #[ Column(type: ' string')]
257
+ /** @ Column(type=" string") */
258
258
private string $value;
259
259
260
- public function __construct(string $name, string $value, Article $article)
260
+ public function __construct($name, $value, $article)
261
261
{
262
262
$this->attribute = $name;
263
263
$this->value = $value;
0 commit comments