A variable is assigned to itself
What it finds
$x = $x, $this->name = $this->name: assigning something to itself does nothing, and usually stands for an assignment to something else, as in a constructor that meant $this->name = $name. Targets that call something on the way may name different places on each side and are left alone, and so are elements, as $s[0] = $s[0], which is written on purpose to make PHP copy a shared string or array.
From the rule's source, self_assignment.rs.
<?phpclass Point{ private $x; private $cells = []; public function __construct($x, $yValue) { $this->x = $this->x;tx0 reports: $this->x is assigned to itself $x = $x;tx0 reports: $x is assigned to itself $this->cells[$x] = $this->cells[$x]; $this->x = $x; $this->next()->x = $this->next()->x; $yValue = &$yValue; }} Turn it on, off or suppress it
The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:
[rules]
"tx0/php:self-assignment" = "off"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/php:self-assignment] reason="..."tx0 explain tx0/php:self-assignment shows the same in the terminal. Found a false positive? Report it.