Run Rector on your code to see what it can do for you:

 <?php
 #[ORM\Entity()]
 class DemoFile
     #[ORM\Column()]
     #[ORM\GeneratedValue(strategy: 'AUTO')]
     protected ?int $id = null;
- 
-    #[ORM\Column(type: 'string', length: 300)]
-    protected string $category;
     
-    public function __construct(string $category)
-    {
-        $this->category = $category;
+    public function __construct(#[ORM\Column(type: 'string', length: 300)]
+    protected string $category)
+    {
     }
 }
PHP snippet to change

Applied Rules:

Not a change you expect?

Config  rector.php
Rector version: ac3a94 - released at 2025-05-11 00:39