rector icon indicating copy to clipboard operation
rector copied to clipboard

[php 8.4] Add property hooks upgrade - optional rule

Open TomasVotruba opened this issue 9 months ago • 0 comments

class Product {
-    private string $name;
-
-    public function getName(): string {
-        return $this->name;
-    }
-
-    public function setName(string $name): void {
-        $this->name = ucfirst($name);
-    }
+    public string $name {
+        get { return $this->name; }
+        set { $this->name = ucfirst($value); }
+    }
}

TomasVotruba avatar May 06 '25 13:05 TomasVotruba