Skip to content

(Probably) Coding standard causes Cannot declare class X because the name is already in use, while trying to import FQN of classes  #2307

@JanMikes

Description

@JanMikes
Subject Details
Rector version v0.5.21
PHP version 7.3.4
Full Command vendor/bin/rector p src/Test/Exception.php --set=dead-code -n

Current Behaviour

-class Exception extends \Exception
+use Exception;
+class Exception extends Exception

These changes results in PHP Fatal error: Cannot declare class Test\Exception because the name is already in use, whenever code is processed again by rector or that class is used in another file (i encountered this fatal error when rector was processing next file using that class and it was a bit tricky to find out what is wrong 😄 )

Minimal PHP Code Causing Issue

<?php declare (strict_types=1);

namespace Test;

final class Exception extends \Exception { }

Expected Behaviour

I expect rector to do nothing with this code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions