Skip to content

StringClassNameToClassConstantRector transforms strings into namespaces when should not do it #1539

@Aerendir

Description

@Aerendir
    ---------- begin diff ----------
--- Original
+++ New
@@ -188,7 +188,7 @@
         }

         if (null !== $exception && $event->isDebug()) {
-            $this->getLogger()->error('{message}', ['exception' => $exception, 'message' => $message]);
+            $this->getLogger()->error('{message}', [\exception::class => $exception, 'message' => $message]);
         }

         $this->getConsoleNotificationManager()->write('errorLine', $message);
    ----------- end diff -----------

    ---------- begin diff ----------
--- Original
+++ New
@@ -218,7 +218,7 @@
             $options = $reflected->invoke($s3Adapter, 'dummy');

             $bucket    = $options['Bucket'];
-            $directory = $options['directory'];
+            $directory = $options[\directory::class];
         }

         return 'S3://' . $bucket . '/' . $directory . '/';
    ----------- end diff -----------

Applied rectors:

 * Rector\Php\Rector\String_\StringClassNameToClassConstantRector

Assuming both classes exist (\Exception and \Directory), the rector anyway transforms them wrongly using all lowercase letters.

But the main problem here is that both exception and directory are keys of an array, so should not be transformed at all.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions