File tree 3 files changed +13
-12
lines changed
3 files changed +13
-12
lines changed Original file line number Diff line number Diff line change @@ -167,14 +167,14 @@ of the getSpecial() method to its return value.
167
167
{
168
168
169
169
#[Column(type: 'string', nullable: true)]
170
- protected $special;
170
+ protected string|null $special = null ;
171
171
172
- public function setSpecial(string $special): void
172
+ public function setSpecial(string|null $special): void
173
173
{
174
174
$this->special = $special;
175
175
}
176
176
177
- public function getSpecial(): string
177
+ public function getSpecial(): string|null
178
178
{
179
179
return $this->special;
180
180
}
Original file line number Diff line number Diff line change @@ -33,9 +33,9 @@ and year of production as primary keys:
33
33
{
34
34
public function __construct(
35
35
#[Id, Column(type: 'string')]
36
- string $name,
36
+ private string $name,
37
37
#[Id, Column(type: 'integer')]
38
- int $year,
38
+ private int $year,
39
39
) {
40
40
}
41
41
@@ -235,14 +235,14 @@ One good example for this is a user-address relationship:
235
235
class User
236
236
{
237
237
#[Id, Column(type: 'integer'), GeneratedValue]
238
- private $id;
238
+ private int|null $id = null ;
239
239
}
240
240
241
241
#[Entity]
242
242
class Address
243
243
{
244
244
#[Id, OneToOne(targetEntity: User::class)]
245
- private $user;
245
+ private User|null $user = null ;
246
246
}
247
247
248
248
.. code-block :: yaml
@@ -299,9 +299,10 @@ of products purchased and maybe even the current price.
299
299
#[Column(type: 'datetime')]
300
300
private DateTime $created;
301
301
302
- public function __construct(Customer $customer)
303
- {
304
- $this->customer = $customer;
302
+ public function __construct(
303
+ #[ManyToOne(targetEntity: Customer::class)]
304
+ private Customer $customer,
305
+ ) {
305
306
$this->items = new ArrayCollection();
306
307
$this->created = new DateTime("now");
307
308
}
Original file line number Diff line number Diff line change @@ -22,9 +22,9 @@ can specify the ``@OrderBy`` in the following way:
22
22
{
23
23
// ...
24
24
25
- #[ManyToMany(targetEntity: " Group" )]
25
+ #[ManyToMany(targetEntity: Group::class )]
26
26
#[OrderBy(["name" => "ASC"])]
27
- private $groups;
27
+ private Collection $groups;
28
28
}
29
29
30
30
.. code-block :: xml
You can’t perform that action at this time.
0 commit comments