idea-php-annotation-plugin icon indicating copy to clipboard operation
idea-php-annotation-plugin copied to clipboard

Renaming parameter with same name of one attributes will causes an exception

Open rentalhost opened this issue 9 years ago • 0 comments

Renaming a parameter that have the same name of one of declared attributes will causes a conflict. This plugin will select the @attribute and if you apply the renaming process you will have a PS exception.

For instance:

class Test
{
    /**
     * @param $param
     */
    public function test($param)
    {
    }
}

Select $param and call rename (Refactor / Rename...), it'll select both $param, but will include too @param. If you try to rename it to, for instance, $test, the code will seems like:

class Test
{
    /**
     * @[test] $[test]
     */
    public function test($[test])
    {
    }
}

After you press enter to confirm the renaming, it'll displays the Refactoring Preview window with three options (both $param and too @param). If you just do refactoring as is, it'll rename the code to:

class Test
{
    /**
     * @param $[test]
     */
    public function test($param)
    {
    }
}

Note that it will rename only the annotation parameter, but will not affects the @param (will back to normal), but too will not apply on method parameter (will back to $param). It occur because an exception is thrown after you try do that (full exception log).

Cannot find manipulator for phpDocParam in phpDocParam:null class class
de.espend.idea.php.annotation.reference.
    DocTagNameAnnotationReferenceContributor$PhpDocTagReference
java.lang.Throwable
    at com.intellij.openapi.diagnostic.Logger.error(Logger.java:132)
    at com.intellij.psi.PsiReferenceBase.getManipulator(PsiReferenceBase.java:139)
    at com.intellij.psi.PsiReferenceBase.handleElementRename(PsiReferenceBase.java:115)
    at com.intellij.refactoring.rename.RenameUtil.rename(RenameUtil.java:266)
    ...

You can check this issue on this video (unlisted): PHP Annotations 4.2 issue.

This issue was registered on Jetbrains Youtrack too, but was not related to this platform. WI-33848

Plugin Version PHP Annotations 4.2

Software Version PhpStorm 2016.3 EAP Build #PS-163.7342.9, built on November 2, 2016 JRE: 1.8.0_112-release-408-b2 x86 JVM: OpenJDK Server VM by JetBrains s.r.o

rentalhost avatar Nov 08 '16 13:11 rentalhost