<?php
final class ChildClass extends VendorClass
{
private bool $executed;
public function run(): void
{
$this->executed = false;
parent::run();
if (!$this->executed) {
echo 'not run';
}
}
protected function execute(): void
{
$this->executed = true;
parent::run();
}
}
class VendorClass
{
public function run()
{
$this->execute();
}
protected function execute()
{
}
}
(new ChildClass)->run();
Responsible rules
RemoveAlwaysTrueIfConditionRector
Expected Behavior
Rector should skip it. Adding the return value of : void in the vendor run method fixes the issue.
Bug Report
Minimal PHP Code Causing Issue
See https://getrector.com/demo/8d8a04b4-7402-4bb6-8126-f484e690111c
Responsible rules
RemoveAlwaysTrueIfConditionRector
Expected Behavior
Rector should skip it. Adding the return value of
: void
in the vendorrun
method fixes the issue.