Skip to content

Commit fd6b328

Browse files
authored
[make:*] use static return type instead of self for setters (#1242)
1 parent 03e3f83 commit fd6b328

File tree

61 files changed

+111
-111
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+111
-111
lines changed

src/Util/ClassSourceManipulator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1073,7 +1073,7 @@ private function makeMethodFluent(Builder\Method $methodBuilder): void
10731073
$methodBuilder
10741074
->addStmt($this->createBlankLineNode(self::CONTEXT_CLASS_METHOD))
10751075
->addStmt(new Node\Stmt\Return_(new Node\Expr\Variable('this')));
1076-
$methodBuilder->setReturnType('self');
1076+
$methodBuilder->setReturnType('static');
10771077
}
10781078

10791079
private function isInSameNamespace(string $class): bool

tests/Doctrine/fixtures/expected_no_overwrite/src/Entity/BaseClient.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function getName(): ?string
3838
return $this->name;
3939
}
4040

41-
public function setName(string $name): self
41+
public function setName(string $name): static
4242
{
4343
$this->name = $name;
4444

@@ -50,7 +50,7 @@ public function getMagic(): ?int
5050
return $this->magic;
5151
}
5252

53-
public function setMagic(int $magic): self
53+
public function setMagic(int $magic): static
5454
{
5555
$this->magic = $magic;
5656

@@ -62,7 +62,7 @@ public function getCreator(): ?User
6262
return $this->creator;
6363
}
6464

65-
public function setCreator(?User $creator): self
65+
public function setCreator(?User $creator): static
6666
{
6767
$this->creator = $creator;
6868

tests/Doctrine/fixtures/expected_no_overwrite/src/Entity/Client.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function getEmbed(): Embed
3535
return $this->embed;
3636
}
3737

38-
public function setEmbed(Embed $embed): self
38+
public function setEmbed(Embed $embed): static
3939
{
4040
$this->embed = $embed;
4141

@@ -47,7 +47,7 @@ public function getApiKey(): ?string
4747
return $this->apiKey;
4848
}
4949

50-
public function setApiKey(string $apiKey): self
50+
public function setApiKey(string $apiKey): static
5151
{
5252
$this->apiKey = $apiKey;
5353

@@ -62,7 +62,7 @@ public function getTags(): Collection
6262
return $this->tags;
6363
}
6464

65-
public function addTag(Tag $tag): self
65+
public function addTag(Tag $tag): static
6666
{
6767
if (!$this->tags->contains($tag)) {
6868
$this->tags->add($tag);
@@ -71,7 +71,7 @@ public function addTag(Tag $tag): self
7171
return $this;
7272
}
7373

74-
public function removeTag(Tag $tag): self
74+
public function removeTag(Tag $tag): static
7575
{
7676
$this->tags->removeElement($tag);
7777

tests/Doctrine/fixtures/expected_no_overwrite/src/Entity/Embed.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public function getVal(): ?int
1616
return $this->val;
1717
}
1818

19-
public function setVal(int $val): self
19+
public function setVal(int $val): static
2020
{
2121
$this->val = $val;
2222

tests/Doctrine/fixtures/expected_no_overwrite/src/Entity/User.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function getAvatars(): Collection
5353
return $this->avatars;
5454
}
5555

56-
public function addAvatar(UserAvatar $avatar): self
56+
public function addAvatar(UserAvatar $avatar): static
5757
{
5858
if (!$this->avatars->contains($avatar)) {
5959
$this->avatars->add($avatar);
@@ -63,7 +63,7 @@ public function addAvatar(UserAvatar $avatar): self
6363
return $this;
6464
}
6565

66-
public function removeAvatar(UserAvatar $avatar): self
66+
public function removeAvatar(UserAvatar $avatar): static
6767
{
6868
if ($this->avatars->removeElement($avatar)) {
6969
// set the owning side to null (unless already changed)
@@ -88,7 +88,7 @@ public function getTags(): Collection
8888
return $this->tags;
8989
}
9090

91-
public function addTag(Tag $tag): self
91+
public function addTag(Tag $tag): static
9292
{
9393
if (!$this->tags->contains($tag)) {
9494
$this->tags->add($tag);
@@ -97,7 +97,7 @@ public function addTag(Tag $tag): self
9797
return $this;
9898
}
9999

100-
public function removeTag(Tag $tag): self
100+
public function removeTag(Tag $tag): static
101101
{
102102
$this->tags->removeElement($tag);
103103

tests/Doctrine/fixtures/expected_no_overwrite/src/Entity/UserAvatar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function getUser(): ?User
2626
return $this->user;
2727
}
2828

29-
public function setUser(?User $user): self
29+
public function setUser(?User $user): static
3030
{
3131
$this->user = $user;
3232

tests/Doctrine/fixtures/expected_no_overwrite/src/Entity/UserProfile.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function getUser(): ?User
2727
return $this->user;
2828
}
2929

30-
public function setUser(User $user): self
30+
public function setUser(User $user): static
3131
{
3232
$this->user = $user;
3333

tests/Doctrine/fixtures/expected_overwrite/src/Entity/BaseClient.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function getName(): ?string
3838
return $this->name;
3939
}
4040

41-
public function setName(string $name): self
41+
public function setName(string $name): static
4242
{
4343
$this->name = $name;
4444

@@ -50,7 +50,7 @@ public function getMagic(): ?int
5050
return $this->magic;
5151
}
5252

53-
public function setMagic(int $magic): self
53+
public function setMagic(int $magic): static
5454
{
5555
$this->magic = $magic;
5656

@@ -62,7 +62,7 @@ public function getCreator(): ?User
6262
return $this->creator;
6363
}
6464

65-
public function setCreator(?User $creator): self
65+
public function setCreator(?User $creator): static
6666
{
6767
$this->creator = $creator;
6868

tests/Doctrine/fixtures/expected_overwrite/src/Entity/Client.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function getEmbed(): Embed
3535
return $this->embed;
3636
}
3737

38-
public function setEmbed(Embed $embed): self
38+
public function setEmbed(Embed $embed): static
3939
{
4040
$this->embed = $embed;
4141

@@ -47,7 +47,7 @@ public function getApiKey(): ?string
4747
return $this->apiKey;
4848
}
4949

50-
public function setApiKey(string $apiKey): self
50+
public function setApiKey(string $apiKey): static
5151
{
5252
$this->apiKey = $apiKey;
5353

@@ -62,7 +62,7 @@ public function getTags(): Collection
6262
return $this->tags;
6363
}
6464

65-
public function addTag(Tag $tag): self
65+
public function addTag(Tag $tag): static
6666
{
6767
if (!$this->tags->contains($tag)) {
6868
$this->tags->add($tag);
@@ -71,7 +71,7 @@ public function addTag(Tag $tag): self
7171
return $this;
7272
}
7373

74-
public function removeTag(Tag $tag): self
74+
public function removeTag(Tag $tag): static
7575
{
7676
$this->tags->removeElement($tag);
7777

tests/Doctrine/fixtures/expected_overwrite/src/Entity/Embed.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public function getVal(): ?int
1616
return $this->val;
1717
}
1818

19-
public function setVal(int $val): self
19+
public function setVal(int $val): static
2020
{
2121
$this->val = $val;
2222

0 commit comments

Comments
 (0)