From 48e4b67511e7f67b48d3fa8eedc932f313504789 Mon Sep 17 00:00:00 2001
From: Toon Verwerft <toonverwerft@gmail.com>
Date: Mon, 17 Jun 2024 08:28:36 +0200
Subject: [PATCH] Return static instance on abstract class setters

Signed-off-by: Toon Verwerft <toonverwerft@gmail.com>
---
 psalm-baseline.xml                        |  8 ++++----
 src/Generator/AbstractGenerator.php       |  8 ++++----
 src/Generator/AbstractMemberGenerator.php | 20 ++++++++++----------
 3 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/psalm-baseline.xml b/psalm-baseline.xml
index b61c482d..3036a1db 100644
--- a/psalm-baseline.xml
+++ b/psalm-baseline.xml
@@ -37,10 +37,10 @@
   </file>
   <file src="src/Generator/AbstractMemberGenerator.php">
     <PossiblyUnusedReturnValue>
-      <code>AbstractMemberGenerator</code>
-      <code>AbstractMemberGenerator</code>
-      <code>AbstractMemberGenerator</code>
-      <code>AbstractMemberGenerator</code>
+      <code>static</code>
+      <code>static</code>
+      <code>static</code>
+      <code>static</code>
     </PossiblyUnusedReturnValue>
     <RedundantCastGivenDocblockType>
       <code>(string) $name</code>
diff --git a/src/Generator/AbstractGenerator.php b/src/Generator/AbstractGenerator.php
index bce234e1..313c9f29 100644
--- a/src/Generator/AbstractGenerator.php
+++ b/src/Generator/AbstractGenerator.php
@@ -38,7 +38,7 @@ public function __construct($options = [])
 
     /**
      * @param  bool $isSourceDirty
-     * @return AbstractGenerator
+     * @return static
      */
     public function setSourceDirty($isSourceDirty = true)
     {
@@ -56,7 +56,7 @@ public function isSourceDirty()
 
     /**
      * @param  string $indentation
-     * @return AbstractGenerator
+     * @return static
      */
     public function setIndentation($indentation)
     {
@@ -74,7 +74,7 @@ public function getIndentation()
 
     /**
      * @param  ?string $sourceContent
-     * @return AbstractGenerator
+     * @return static
      */
     public function setSourceContent($sourceContent)
     {
@@ -93,7 +93,7 @@ public function getSourceContent()
     /**
      * @param  array|Traversable $options
      * @throws Exception\InvalidArgumentException
-     * @return AbstractGenerator
+     * @return static
      */
     public function setOptions($options)
     {
diff --git a/src/Generator/AbstractMemberGenerator.php b/src/Generator/AbstractMemberGenerator.php
index 36276efa..f23f872e 100644
--- a/src/Generator/AbstractMemberGenerator.php
+++ b/src/Generator/AbstractMemberGenerator.php
@@ -27,7 +27,7 @@ abstract class AbstractMemberGenerator extends AbstractGenerator
 
     /**
      * @param  int|int[] $flags
-     * @return AbstractMemberGenerator
+     * @return static
      */
     public function setFlags($flags)
     {
@@ -46,7 +46,7 @@ public function setFlags($flags)
 
     /**
      * @param  int $flag
-     * @return AbstractMemberGenerator
+     * @return static
      */
     public function addFlag($flag)
     {
@@ -56,7 +56,7 @@ public function addFlag($flag)
 
     /**
      * @param  int $flag
-     * @return AbstractMemberGenerator
+     * @return static
      */
     public function removeFlag($flag)
     {
@@ -66,7 +66,7 @@ public function removeFlag($flag)
 
     /**
      * @param  bool $isAbstract
-     * @return AbstractMemberGenerator
+     * @return static
      */
     public function setAbstract($isAbstract)
     {
@@ -83,7 +83,7 @@ public function isAbstract()
 
     /**
      * @param  bool $isInterface
-     * @return AbstractMemberGenerator
+     * @return static
      */
     public function setInterface($isInterface)
     {
@@ -100,7 +100,7 @@ public function isInterface()
 
     /**
      * @param  bool $isFinal
-     * @return AbstractMemberGenerator
+     * @return static
      */
     public function setFinal($isFinal)
     {
@@ -117,7 +117,7 @@ public function isFinal()
 
     /**
      * @param  bool $isStatic
-     * @return AbstractMemberGenerator
+     * @return static
      */
     public function setStatic($isStatic)
     {
@@ -134,7 +134,7 @@ public function isStatic()
 
     /**
      * @param  string $visibility
-     * @return AbstractMemberGenerator
+     * @return static
      */
     public function setVisibility($visibility)
     {
@@ -173,7 +173,7 @@ public function getVisibility()
 
     /**
      * @param  string $name
-     * @return AbstractMemberGenerator
+     * @return static
      */
     public function setName($name)
     {
@@ -192,7 +192,7 @@ public function getName()
     /**
      * @param  DocBlockGenerator|string $docBlock
      * @throws Exception\InvalidArgumentException
-     * @return AbstractMemberGenerator
+     * @return static
      */
     public function setDocBlock($docBlock)
     {