Skip to content

Commit 70d5b47

Browse files
committed
TASK: Adjust PHP8 persistence test-fixtures to php 8 syntax
- ORM annotations > ORM attributes - Flow annotation > Flow attributes - @param and @return annotations to parameter and return types !!! Nested attributes are not supported in php 8.0 so they stay annotations for now !!!
1 parent 28b319f commit 70d5b47

38 files changed

+277
-735
lines changed

Neos.Flow/Tests/Functional/Persistence/FixturesPHP8/AbstractEntity.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@
1616

1717
/**
1818
* A sample entity for tests
19-
*
20-
* @Flow\Entity
21-
* @ORM\InheritanceType("JOINED")
2219
*/
20+
#[Flow\Entity]
21+
#[ORM\InheritanceType('JOINED')]
2322
abstract class AbstractEntity
2423
{
2524
}

Neos.Flow/Tests/Functional/Persistence/FixturesPHP8/AnnotatedIdEntity.php

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,44 +16,28 @@
1616

1717
/**
1818
* A sample entity that has a property with a Id annotation
19-
*
20-
* @Flow\Entity
2119
*/
20+
#[Flow\Entity]
2221
class AnnotatedIdEntity
2322
{
24-
/**
25-
* @ORM\Id
26-
* @ORM\GeneratedValue
27-
* @ORM\SequenceGenerator(sequenceName="annotatedidentity_seq")
28-
* @var string
29-
*/
30-
protected $id;
23+
#[ORM\Id]
24+
#[ORM\GeneratedValue]
25+
#[ORM\SequenceGenerator(sequenceName: 'annotatedidentity_seq')]
26+
protected string $id;
3127

32-
/**
33-
* @var string
34-
*/
35-
protected $title;
28+
protected string $title;
3629

37-
/**
38-
* @return string
39-
*/
40-
public function getId()
30+
public function getId(): string
4131
{
4232
return $this->id;
4333
}
4434

45-
/**
46-
* @param string $title
47-
*/
48-
public function setTitle($title)
35+
public function setTitle(string $title): void
4936
{
5037
$this->title = $title;
5138
}
5239

53-
/**
54-
* @return string
55-
*/
56-
public function getTitle()
40+
public function getTitle(): string
5741
{
5842
return $this->title;
5943
}

Neos.Flow/Tests/Functional/Persistence/FixturesPHP8/AnnotatedIdentitiesEntity.php

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -15,51 +15,32 @@
1515

1616
/**
1717
* A sample entity that has properties with an Identity annotation
18-
*
19-
* @Flow\Entity
2018
*/
19+
#[Flow\Entity]
2120
class AnnotatedIdentitiesEntity
2221
{
23-
/**
24-
* @Flow\Identity
25-
* @var string
26-
*/
27-
protected $author;
22+
#[Flow\Identity]
23+
protected string $author;
2824

29-
/**
30-
* @Flow\Identity
31-
* @var string
32-
*/
33-
protected $title;
25+
#[Flow\Identity]
26+
protected string $title;
3427

35-
/**
36-
* @param string $author
37-
*/
38-
public function setAuthor($author)
28+
public function setAuthor(string $author): void
3929
{
4030
$this->author = $author;
4131
}
4232

43-
/**
44-
* @return string
45-
*/
46-
public function getAuthor()
33+
public function getAuthor(): string
4734
{
4835
return $this->author;
4936
}
5037

51-
/**
52-
* @param string $title
53-
*/
54-
public function setTitle($title)
38+
public function setTitle(string $title): void
5539
{
5640
$this->title = $title;
5741
}
5842

59-
/**
60-
* @return string
61-
*/
62-
public function getTitle()
43+
public function getTitle(): string
6344
{
6445
return $this->title;
6546
}

Neos.Flow/Tests/Functional/Persistence/FixturesPHP8/CleanupObject.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,14 @@
1313

1414
class CleanupObject
1515
{
16-
/**
17-
* @var boolean
18-
*/
19-
protected $state = false;
16+
protected bool $state = false;
2017

21-
public function toggleState()
18+
public function toggleState(): void
2219
{
2320
$this->state = !$this->state;
2421
}
2522

26-
/**
27-
* @return boolean
28-
*/
29-
public function getState()
23+
public function getState(): bool
3024
{
3125
return $this->state;
3226
}

Neos.Flow/Tests/Functional/Persistence/FixturesPHP8/Comment.php

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,30 +16,19 @@
1616

1717
/**
1818
* A sample entity for tests
19-
*
20-
* @Flow\Entity
2119
*/
20+
#[Flow\Entity]
2221
class Comment
2322
{
24-
/**
25-
* @var string
26-
*/
27-
protected $content = '';
23+
protected string $content = '';
2824

29-
/**
30-
* @return string
31-
* @ORM\PrePersist
32-
*/
33-
public function getContent()
25+
#[ORM\PrePersist]
26+
public function getContent(): string
3427
{
3528
return $this->content;
3629
}
3730

38-
/**
39-
* @param string $content
40-
* @return void
41-
*/
42-
public function setContent($content)
31+
public function setContent(string $content): void
4332
{
4433
$this->content = $content;
4534
}

Neos.Flow/Tests/Functional/Persistence/FixturesPHP8/CommentRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
/**
1818
* A repository for comments
19-
* @Flow\Scope("singleton")
2019
*/
20+
#[Flow\Scope('singleton')]
2121
class CommentRepository extends Repository
2222
{
2323
/**

Neos.Flow/Tests/Functional/Persistence/FixturesPHP8/CommonObject.php

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,15 @@
1919
*/
2020
class CommonObject
2121
{
22-
/**
23-
* @var string
24-
*/
25-
protected $foo;
22+
protected ?string $foo;
2623

27-
/**
28-
* @param string $foo
29-
* @return $this
30-
*/
31-
public function setFoo($foo = null)
24+
public function setFoo(?string $foo = null): self
3225
{
3326
$this->foo = $foo;
3427
return $this;
3528
}
3629

37-
/**
38-
* @return string
39-
*/
40-
public function getFoo()
30+
public function getFoo(): ?string
4131
{
4232
return $this->foo;
4333
}

Neos.Flow/Tests/Functional/Persistence/FixturesPHP8/CompositeKeyTestEntity.php

Lines changed: 12 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -16,56 +16,35 @@
1616

1717
/**
1818
* A simple entity for persistence tests
19-
*
20-
* @Flow\Entity
21-
* @ORM\Table(name="persistence_php8_compsitekeytestentity")
2219
*/
20+
#[Flow\Entity]
21+
#[ORM\Table(name: 'persistence_php8_compsitekeytestentity')]
2322
class CompositeKeyTestEntity
2423
{
25-
/**
26-
* @var string
27-
* @ORM\Id
28-
* @ORM\Column(length=20)
29-
*/
30-
protected $name = '';
24+
#[ORM\Id]
25+
#[ORM\Column(length: 20)]
26+
protected string $name = '';
3127

32-
/**
33-
* @var TestEntity
34-
* @ORM\Id
35-
* @ORM\ManyToOne
36-
*/
37-
protected $relatedEntity;
28+
#[ORM\Id]
29+
#[ORM\ManyToOne]
30+
protected TestEntity $relatedEntity;
3831

39-
/**
40-
* @return string
41-
*/
42-
public function getName()
32+
public function getName(): string
4333
{
4434
return $this->name;
4535
}
4636

47-
/**
48-
* @param string $name
49-
* @return void
50-
*/
51-
public function setName($name)
37+
public function setName(string $name): void
5238
{
5339
$this->name = $name;
5440
}
5541

56-
/**
57-
* @param TestEntity $relatedEntity
58-
* @return void
59-
*/
60-
public function setRelatedEntity(TestEntity $relatedEntity)
42+
public function setRelatedEntity(TestEntity $relatedEntity): void
6143
{
6244
$this->relatedEntity = $relatedEntity;
6345
}
6446

65-
/**
66-
* @return TestEntity
67-
*/
68-
public function getRelatedEntity()
47+
public function getRelatedEntity(): TestEntity
6948
{
7049
return $this->relatedEntity;
7150
}

Neos.Flow/Tests/Functional/Persistence/FixturesPHP8/EntityWithIndexedRelation.php

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,23 @@
1818

1919
/**
2020
* A sample entity that has a property with an indexed relation
21-
*
22-
* @Flow\Scope("prototype")
23-
* @Flow\Entity
2421
*/
22+
#[Flow\Scope('prototype')]
23+
#[Flow\Entity]
2524
class EntityWithIndexedRelation
2625
{
2726
/**
2827
* @var Collection<AnnotatedIdentitiesEntity>
29-
* @ORM\ManyToMany(indexBy="author")
3028
*/
31-
protected $annotatedIdentitiesEntities;
29+
#[ORM\ManyToMany(indexBy: 'author')]
30+
protected Collection $annotatedIdentitiesEntities;
3231

3332
/**
3433
* @var Collection<RelatedIndexEntity>
3534
* @ORM\OneToMany(indexBy="sorting", mappedBy="entityWithIndexedRelation")
3635
*/
37-
protected $relatedIndexEntities;
36+
#[ORM\OneToMany(indexBy: 'sorting', mappedBy: 'entityWithIndexedRelation')]
37+
protected Collection $relatedIndexEntities;
3838

3939
/**
4040
* Constructor
@@ -46,42 +46,38 @@ public function __construct()
4646
}
4747

4848
/**
49-
* @param \Doctrine\Common\Collections\Collection $annotatedIdentitiesEntities
49+
* @param Collection<AnnotatedIdentitiesEntity> $annotatedIdentitiesEntities
5050
*/
51-
public function setAnnotatedIdentitiesEntities($annotatedIdentitiesEntities)
51+
public function setAnnotatedIdentitiesEntities(Collection $annotatedIdentitiesEntities): void
5252
{
5353
$this->annotatedIdentitiesEntities = $annotatedIdentitiesEntities;
5454
}
5555

5656
/**
57-
* @return \Doctrine\Common\Collections\Collection
57+
* @return Collection<AnnotatedIdentitiesEntity>
5858
*/
59-
public function getAnnotatedIdentitiesEntities()
59+
public function getAnnotatedIdentitiesEntities(): Collection
6060
{
6161
return $this->annotatedIdentitiesEntities;
6262
}
6363

6464
/**
65-
* @param \Doctrine\Common\Collections\Collection $relatedIndexEntities
65+
* @param Collection<RelatedIndexEntity> $relatedIndexEntities
6666
*/
67-
public function setRelatedIndexEntities($relatedIndexEntities)
67+
public function setRelatedIndexEntities(Collection $relatedIndexEntities): void
6868
{
6969
$this->relatedIndexEntities = $relatedIndexEntities;
7070
}
7171

7272
/**
73-
* @return \Doctrine\Common\Collections\Collection
73+
* @return Collection<RelatedIndexEntity>
7474
*/
75-
public function getRelatedIndexEntities()
75+
public function getRelatedIndexEntities(): Collection
7676
{
7777
return $this->relatedIndexEntities;
7878
}
7979

80-
/**
81-
* @param string $sorting
82-
* @param RelatedIndexEntity $relatedIndexEntity
83-
*/
84-
public function setRelatedIndexEntity($sorting, RelatedIndexEntity $relatedIndexEntity)
80+
public function setRelatedIndexEntity(string $sorting, RelatedIndexEntity $relatedIndexEntity): void
8581
{
8682
$relatedIndexEntity->setSorting($sorting);
8783
$relatedIndexEntity->setEntityWithIndexedRelation($this);

0 commit comments

Comments
 (0)