I was made a mistake yesterday and spent hours to fix it. I have method like this
{
if (isset($data['y'])) {
$this->y = $data['y'];
}
if (isset($data['z'])) {
$this->y = $data['z']; // <- error here
}
}
And yes, I assign $this->y two times instead of one y and one z :-(
So question: can any static analyze tools catch such errors? I have PHP Storm and Rector, PHPStan, PHP CS Fixer in my CI toolchain but they missed this error.
{ $this->y = $data['y']; $this->y = $data['z']; // <- error here }$data['y']or$data['z']depending on which one has a value?