-
-
Notifications
You must be signed in to change notification settings - Fork 737
Closed
rectorphp/rector-src
#7086Labels
Description
Bug Report
| Subject | Details |
|---|---|
| Rector version | 2.1.2 |
When running AddOverrideAttributeToOverriddenMethodsRector in a Silverstripe 5 project, it makes troubles in Page and PageController. Those classes are for historical reasons in global namespace and wrapped in namespace { ... }
For some reasons, rector also adds use Overwrite; statement which gives me a PHP Warning:
Warning: The use statement with non-compound name 'Override' has no effect in /var/www/html/app/src/PageController.php on line 5
Minimal PHP Code Causing Issue
<?php
namespace {
use SilverStripe\CMS\Controllers\ContentController;
class PageController extends ContentController
{
//here will rector add #[Override]
protected function init()
{
parent::init();
// You can include any CSS or JS required by your project here.
// See: https://docs.silverstripe.org/en/developer_guides/templates/requirements/
}
}
}When I remove the namespace {} construct, everything is fine.
Expected Behaviour
Rector should check if I'm in global namespace and then not import global classes.