Skip to content

Commit 683c628

Browse files
committed
minor #15614 Replaced doctrine annotations with attributes (zspine)
This PR was merged into the 5.3 branch. Discussion ---------- Replaced doctrine annotations with attributes I'm not sure whether this is a significant change, but I'd like to keep the usage examples consistent across configuration types. <!-- If your pull request fixes a BUG, use the oldest maintained branch that contains the bug (see https://symfony.com/releases for the list of maintained branches). If your pull request documents a NEW FEATURE, use the same Symfony branch where the feature was introduced (and `5.x` for features of unreleased versions). --> Commits ------- 8d9a114 Replaced doctrine annotations with attributes
2 parents dbf431f + 8d9a114 commit 683c628

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

reference/constraints/UniqueEntity.rst

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,11 @@ between all of the rows in your user table:
7676
7777
use Symfony\Component\Validator\Constraints as Assert;
7878
79-
/**
80-
* @ORM\Entity
81-
*/
79+
#[ORM\Entity]
8280
#[UniqueEntity('email')]
8381
class User
8482
{
85-
/**
86-
* @ORM\Column(name="email", type="string", length=255, unique=true)
87-
*/
83+
#[ORM\Column(name: 'email', type: 'string', length: 255, unique: true)]
8884
#[Assert\Email]
8985
protected $email;
9086
}
@@ -223,27 +219,22 @@ Consider this example:
223219
// src/Entity/Service.php
224220
namespace App\Entity;
225221
222+
use App\Entity\Host;
226223
use Doctrine\ORM\Mapping as ORM;
227224
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
228225
229-
/**
230-
* @ORM\Entity
231-
*/
226+
#[ORM\Entity]
232227
#[UniqueEntity(
233228
fields: ['host', 'port'],
234229
errorPath: 'port',
235230
message: 'This port is already in use on that host.',
236231
)]
237232
class Service
238233
{
239-
/**
240-
* @ORM\ManyToOne(targetEntity="App\Entity\Host")
241-
*/
234+
#[ORM\ManyToOne(targetEntity: Host::class)]
242235
public $host;
243236
244-
/**
245-
* @ORM\Column(type="integer")
246-
*/
237+
#[ORM\Column(type: 'integer')]
247238
public $port;
248239
}
249240

0 commit comments

Comments
 (0)