diff --git a/docs/en/cookbook/decorator-pattern.rst b/docs/en/cookbook/decorator-pattern.rst index f273ac48675..aaff372e856 100644 --- a/docs/en/cookbook/decorator-pattern.rst +++ b/docs/en/cookbook/decorator-pattern.rst @@ -167,14 +167,14 @@ of the getSpecial() method to its return value. { #[Column(type: 'string', nullable: true)] - protected $special; + protected string|null $special = null; - public function setSpecial(string $special): void + public function setSpecial(string|null $special): void { $this->special = $special; } - public function getSpecial(): string + public function getSpecial(): string|null { return $this->special; } diff --git a/docs/en/tutorials/composite-primary-keys.rst b/docs/en/tutorials/composite-primary-keys.rst index f5b69d1b0a1..7c912851ba8 100644 --- a/docs/en/tutorials/composite-primary-keys.rst +++ b/docs/en/tutorials/composite-primary-keys.rst @@ -33,9 +33,9 @@ and year of production as primary keys: { public function __construct( #[Id, Column(type: 'string')] - string $name, + private string $name, #[Id, Column(type: 'integer')] - int $year, + private int $year, ) { } @@ -235,14 +235,14 @@ One good example for this is a user-address relationship: class User { #[Id, Column(type: 'integer'), GeneratedValue] - private $id; + private int|null $id = null; } #[Entity] class Address { #[Id, OneToOne(targetEntity: User::class)] - private $user; + private User|null $user = null; } .. code-block:: yaml @@ -299,9 +299,10 @@ of products purchased and maybe even the current price. #[Column(type: 'datetime')] private DateTime $created; - public function __construct(Customer $customer) - { - $this->customer = $customer; + public function __construct( + #[ManyToOne(targetEntity: Customer::class)] + private Customer $customer, + ) { $this->items = new ArrayCollection(); $this->created = new DateTime("now"); } diff --git a/docs/en/tutorials/ordered-associations.rst b/docs/en/tutorials/ordered-associations.rst index 45ae173703e..a103c74a8b4 100644 --- a/docs/en/tutorials/ordered-associations.rst +++ b/docs/en/tutorials/ordered-associations.rst @@ -22,9 +22,9 @@ can specify the ``@OrderBy`` in the following way: { // ... - #[ManyToMany(targetEntity: "Group")] + #[ManyToMany(targetEntity: Group::class)] #[OrderBy(["name" => "ASC"])] - private $groups; + private Collection $groups; } .. code-block:: xml