Haehnchen / idea-php-symfony2-plugin

IntelliJ IDEA / PhpStorm Symfony Plugin
https://plugins.jetbrains.com/plugin/7219
MIT License
911 stars 137 forks source link

TypeProviders break complex signatures #1263

Open MaXal opened 5 years ago

MaXal commented 5 years ago

Function reference may have signature like #M#C\Foo.get|#M#C\Bar.get. For this case, the method fr.adrienbrault.idea.symfony2plugin.util.PhpTypeProviderUtil#getReferenceSignatureByFirstParameter won't work correctly as well as all providers that call it since they transform the signature into #Ő#M#C\Foo.get|#M#C\Bar.getƂparamValue instead of #Ő#M#C\Foo.getƂparamValue|#Ő#M#C\Bar.getƂparamValue.

MaXal commented 5 years ago

The consequence of the bug is the following exceptions and broken functionality of plugin:

java.lang.RuntimeException: Invalid Signature #M#C\Tests\Feature\ForumTest
    at com.jetbrains.php.PhpIndexImpl.getBySignatureInternal(PhpIndexImpl.java:562)
    at com.jetbrains.php.PhpIndexImpl.getBySignature(PhpIndexImpl.java:436)
    at com.jetbrains.php.PhpIndexImpl.completeType(PhpIndexImpl.java:158)
    at com.jetbrains.php.lang.psi.resolve.types.PhpType.global(PhpType.java:449)
    at com.jetbrains.php.PhpIndexImpl$1.internalCompute(PhpIndexImpl.java:111)
    at com.jetbrains.php.PhpIndexImpl$1.internalCompute(PhpIndexImpl.java:88)
    at com.intellij.openapi.util.Computable$NotNullCachedComputable.compute(Computable.java:57)
    at com.intellij.openapi.util.RecursionManager$2.doPreventingRecursion(RecursionManager.java:113)
    at com.jetbrains.php.PhpIndexImpl.completeThis(PhpIndexImpl.java:88)
    at com.jetbrains.php.PhpIndexImpl$1.internalCompute(PhpIndexImpl.java:119)
    at com.jetbrains.php.PhpIndexImpl$1.internalCompute(PhpIndexImpl.java:88)
    at com.intellij.openapi.util.Computable$NotNullCachedComputable.compute(Computable.java:57)
    at com.intellij.openapi.util.RecursionManager$2.doPreventingRecursion(RecursionManager.java:113)
    at com.jetbrains.php.PhpIndexImpl.completeThis(PhpIndexImpl.java:88)
    at com.jetbrains.php.PhpIndexImpl$1.internalCompute(PhpIndexImpl.java:112)
    at com.jetbrains.php.PhpIndexImpl$1.internalCompute(PhpIndexImpl.java:88)
    at com.intellij.openapi.util.Computable$NotNullCachedComputable.compute(Computable.java:57)
    at com.intellij.openapi.util.RecursionManager$2.doPreventingRecursion(RecursionManager.java:113)
    at com.jetbrains.php.PhpIndexImpl.completeThis(PhpIndexImpl.java:88)
    at com.jetbrains.php.lang.psi.resolve.types.PhpType.globalLocationAware(PhpType.java:422)
    at com.jetbrains.php.lang.psi.elements.impl.MemberReferenceImpl.resolveGlobal(MemberReferenceImpl.java:145)
    at com.jetbrains.php.lang.psi.elements.impl.MethodReferenceImpl.resolveGlobal(MethodReferenceImpl.java:86)
    at com.jetbrains.php.lang.psi.elements.impl.PhpReferenceImpl$1.resolve(PhpReferenceImpl.java:163)
    at com.jetbrains.php.lang.psi.elements.impl.PhpReferenceImpl$1.resolve(PhpReferenceImpl.java:159)
    at com.intellij.psi.impl.source.resolve.ResolveCache.lambda$resolve$0(ResolveCache.java:150)
    at com.intellij.openapi.util.RecursionManager$2.doPreventingRecursion(RecursionManager.java:113)
    at com.intellij.psi.impl.source.resolve.ResolveCache.resolve(ResolveCache.java:149)
    at com.intellij.psi.impl.source.resolve.ResolveCache.resolveWithCaching(ResolveCache.java:180)
    at com.intellij.psi.impl.source.resolve.ResolveCache.resolveWithCaching(ResolveCache.java:172)
    at com.jetbrains.php.lang.psi.elements.impl.PhpReferenceImpl.multiResolve(PhpReferenceImpl.java:154)
    at com.jetbrains.php.lang.psi.elements.impl.PhpReferenceImpl.resolve(PhpReferenceImpl.java:139)
    at com.jetbrains.php.ui.PhpParameterHintManager.<init>(PhpParameterHintManager.java:47)
    at com.jetbrains.php.ui.PhpInlayParameterHintsProvider.getParameterHints(PhpInlayParameterHintsProvider.kt:49)
    at com.intellij.codeInsight.hints.ParameterHintsPass.process(ParameterHintsPass.java:84)
neuro159 commented 5 years ago

Unfortunately, we were unable to foresee this when designing getSignatureAPI and everyone have to deal with this manually...

When namespaces were introduced to PHP it became so that for any non-fully-qualified function ref its signature is always #F/local/namespace/funName|#F/funName plus some more cases arise...