-
-
Notifications
You must be signed in to change notification settings - Fork 735
Description
Bug Report
| Subject | Details |
|---|---|
| Rector version | last dev-main |
| Installed as | composer dependency |
Minimal PHP Code Causing Issue
See https://getrector.com/demo/9ddd11a3-9f6a-411f-802a-b6420d7e9b53
<?php
class Foo {
public function run(bool $param) {}
}
final class DemoFile extends Foo
{
#[Override]
public function run(bool $param) {
if ($this->isTrue($param)) {
return 5;
}
return '10';
}
private function isTrue($value) {
return $value === true;
}
}Responsible rules
DowngradeAttributeToAnnotationRector
Expected Behavior
-
attributes that do not have a corresponding annotation should not be changed instead of being removed completely, as otherwise information is lost (and annotations are just regular code comments in older PHP versions anyway, so there's no reason to completely remove them)
EDIT: at least for non-param annotations, since those need to be removed in all cases, e.g. https://getrector.com/demo/6ae7b65b-69e7-4d2c-b390-1961698831df is correct -
this rector should not modify code it does not even touch - e.g. why does it remove the empty line between
}andreturn '10';or move the{of the function declaration to the next line? These are all unrelated to the annotation and shouldn't be modified