Skip to content

Commit b01fd47

Browse files
committed
minor #5558 replace annotations by attributes in test entities (emmanuel-tilleuls)
This PR was merged into the 4.x branch. Discussion ---------- replace annotations by attributes in test entities The tests jobs of my previous PR (#5555) failed with errors : ``` The service "doctrine.orm.default_annotation_metadata_driver" has a dependency on a non-existent service doctrine.orm.metadata.annotation_reader". ``` This PR replaces annotations by PHP 8 attributes. This change allows tests to pass for PR #5555 (The actual code change in entities has been made by rector) Commits ------- f544918 replace annotations by attributes in test entities
2 parents 31ab6bf + f544918 commit b01fd47

File tree

4 files changed

+29
-69
lines changed

4 files changed

+29
-69
lines changed

tests/TestApplication/config/packages/doctrine.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
'mappings' => [
1414
'TestEntities' => [
1515
'is_bundle' => false,
16-
'type' => 'annotation',
16+
'type' => 'attribute',
1717
'dir' => '%kernel.project_dir%/src/Entity',
1818
'prefix' => 'EasyCorp\Bundle\EasyAdminBundle\Tests\TestApplication\Entity',
1919
'alias' => 'app',

tests/TestApplication/src/Entity/BlogPost.php

Lines changed: 12 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,52 +6,34 @@
66
use Doctrine\Common\Collections\Collection;
77
use Doctrine\ORM\Mapping as ORM;
88

9-
/**
10-
* @ORM\Entity
11-
*/
9+
#[ORM\Entity]
1210
class BlogPost
1311
{
14-
/**
15-
* @ORM\Id
16-
* @ORM\GeneratedValue
17-
* @ORM\Column(type="integer")
18-
*/
12+
#[ORM\Id]
13+
#[ORM\GeneratedValue]
14+
#[ORM\Column(type: 'integer')]
1915
private $id;
2016

21-
/**
22-
* @ORM\Column(type="string", length=255)
23-
*/
17+
#[ORM\Column(type: 'string', length: 255)]
2418
private $title;
2519

26-
/**
27-
* @ORM\Column(type="string", length=255)
28-
*/
20+
#[ORM\Column(type: 'string', length: 255)]
2921
private $slug;
3022

31-
/**
32-
* @ORM\Column(type="text")
33-
*/
23+
#[ORM\Column(type: 'text')]
3424
private $content;
3525

36-
/**
37-
* @ORM\ManyToMany(targetEntity=Category::class, inversedBy="blogPosts")
38-
*/
26+
#[ORM\ManyToMany(targetEntity: Category::class, inversedBy: 'blogPosts')]
3927
private $categories;
4028

41-
/**
42-
* @ORM\Column(type="datetime")
43-
*/
29+
#[ORM\Column(type: 'datetime')]
4430
private $createdAt;
4531

46-
/**
47-
* @ORM\Column(type="datetime_immutable", nullable=true)
48-
*/
32+
#[ORM\Column(type: 'datetime_immutable', nullable: true)]
4933
private $publishedAt;
5034

51-
/**
52-
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="blogPosts")
53-
* @ORM\JoinColumn(nullable=false)
54-
*/
35+
#[ORM\ManyToOne(targetEntity: User::class, inversedBy: 'blogPosts')]
36+
#[ORM\JoinColumn(nullable: false)]
5537
private $author;
5638

5739
public function __construct()

tests/TestApplication/src/Entity/Category.php

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,36 +6,24 @@
66
use Doctrine\Common\Collections\Collection;
77
use Doctrine\ORM\Mapping as ORM;
88

9-
/**
10-
* @ORM\Entity
11-
*/
9+
#[ORM\Entity]
1210
class Category
1311
{
14-
/**
15-
* @ORM\Id
16-
* @ORM\GeneratedValue
17-
* @ORM\Column(type="integer")
18-
*/
12+
#[ORM\Id]
13+
#[ORM\GeneratedValue]
14+
#[ORM\Column(type: 'integer')]
1915
private $id;
2016

21-
/**
22-
* @ORM\Column(type="string", length=255)
23-
*/
17+
#[ORM\Column(type: 'string', length: 255)]
2418
private $name;
2519

26-
/**
27-
* @ORM\Column(type="string", length=255)
28-
*/
20+
#[ORM\Column(type: 'string', length: 255)]
2921
private $slug;
3022

31-
/**
32-
* @ORM\ManyToMany(targetEntity=BlogPost::class, mappedBy="categories")
33-
*/
23+
#[ORM\ManyToMany(targetEntity: BlogPost::class, mappedBy: 'categories')]
3424
private $blogPosts;
3525

36-
/**
37-
* @ORM\Column(type="boolean")
38-
*/
26+
#[ORM\Column(type: 'boolean')]
3927
private bool $active = false;
4028

4129
public function __construct()

tests/TestApplication/src/Entity/User.php

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,22 @@
66
use Doctrine\Common\Collections\Collection;
77
use Doctrine\ORM\Mapping as ORM;
88

9-
/**
10-
* @ORM\Entity
11-
* @ORM\Table(name="`user`")
12-
*/
9+
#[ORM\Entity]
10+
#[ORM\Table(name: '`user`')]
1311
class User
1412
{
15-
/**
16-
* @ORM\Id
17-
* @ORM\GeneratedValue
18-
* @ORM\Column(type="integer")
19-
*/
13+
#[ORM\Id]
14+
#[ORM\GeneratedValue]
15+
#[ORM\Column(type: 'integer')]
2016
private $id;
2117

22-
/**
23-
* @ORM\Column(type="string", length=255)
24-
*/
18+
#[ORM\Column(type: 'string', length: 255)]
2519
private $name;
2620

27-
/**
28-
* @ORM\Column(type="string", length=255)
29-
*/
21+
#[ORM\Column(type: 'string', length: 255)]
3022
private $email;
3123

32-
/**
33-
* @ORM\OneToMany(targetEntity=BlogPost::class, mappedBy="author", orphanRemoval=true)
34-
*/
24+
#[ORM\OneToMany(targetEntity: BlogPost::class, mappedBy: 'author', orphanRemoval: true)]
3525
private $blogPosts;
3626

3727
public function __construct()

0 commit comments

Comments
 (0)