kalessil / phpinspectionsea

A Static Code Analyzer for PHP (a PhpStorm/Idea Plugin)
https://plugins.jetbrains.com/plugin/7622?pr=phpStorm
Other
1.44k stars 118 forks source link

Problem with 'Use ::class instead' fix #1459

Closed HenkPoley closed 4 years ago

HenkPoley commented 4 years ago
Subject Details
Plugin Php Inspections (EA Extended) 4.0.1.1
Language level PHP 7.0

Current behaviour

In some case it will try to import (use) the class itself.

namespace Some\NameSpace;
+ use Some\NameSpace\ClassName;

class ClassName{

  function someFunction() {
-    echo 'Some\NameSpace\ClassName';
+    echo ClassName::class;
  }
}

Expected behaviour

Just echo ClassName::class; ?

Environment details

PhpStorm 2019.3 Build #PS-193.5233.101, built on November 27, 2019 Runtime version: 11.0.4+10-b520.11 amd64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o Windows 10 10.0 GC: ParNew, ConcurrentMarkSweep Memory: 6110M Cores: 4 Registry: run.processes.with.pty=TRUE, ide.balloon.shadow.size=0 Non-Bundled Plugins: BashSupport, Realigner, com.alayouni.ansiHighlight, com.intellij.ideolog, com.kalessil.phpStorm.phpInspectionsEA, com.urswolfer.intellij.plugin.gerrit, de.espend.idea.laravel, de.espend.idea.php.toolbox, de.espend.idea.php.annotation, intellij.prettierJS, izhangzhihao.rainbow.brackets, mobi.hsz.idea.gitignore, net.seesharpsoft.intellij.plugins.csv, org.elm.klazuka, org.jetbrains.plugins.rest, org.psliwa.idea.composer, org.sylfra.idea.plugins.linessorter, ru.adelf.idea.dotenv

kalessil commented 4 years ago

Thank you for reporting @HenkPoley, good catch. I'll take care of fixing this.

kalessil commented 4 years ago

@HenkPoley, looks like we have implemented this long time ago. Please check the inspection settings: there is "Use relative QN where possible" option there. it should do the trick.