Skip to content

Skip AddMissingVarNameFixer for property assignments#45

Merged
TomasVotruba merged 1 commit into
mainfrom
skip-var-name-property-assign
Jul 6, 2026
Merged

Skip AddMissingVarNameFixer for property assignments#45
TomasVotruba merged 1 commit into
mainfrom
skip-var-name-property-assign

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

AddMissingVarNameFixer grabbed the wrong token as the variable name in two cases.

Property assignment

Above a $this->prop = ... assignment, the next T_VARIABLE is $this, so the fixer wrote @var int $this.

 final class SomeClass
 {
     public function run()
     {
-        /** @var int */
+        /** @var int $this */
         $this->value = 1000;
     }
 }

Now skipped when the variable is followed by -> (property access).

Annotations (regression guard)

Docblock annotations like @Entity or @\Doctrine\ORM\Mapping\Entity were already skipped (the regex requires a literal var), but this had no test. Added a fixture to lock the behavior — these are left untouched:

/** @Entity */
private $first;

/** @\Doctrine\ORM\Mapping\Entity */
private $second;

@TomasVotruba TomasVotruba enabled auto-merge (squash) July 6, 2026 19:45
@TomasVotruba TomasVotruba merged commit f273d8a into main Jul 6, 2026
6 of 7 checks passed
@TomasVotruba TomasVotruba deleted the skip-var-name-property-assign branch July 6, 2026 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant