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

 
 class A
 {
-    private bool $validated = false;
+    private bool $validated = true;
     
     protected function __construct()
     {
         $this->validate();
-        
-        $this->validated = true;
     }
 
     public function assertIsValidated() : void
PHP snippet to change
Config  rector.php
Rector version: a693af - released at 2026-08-04 12:12