question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

When route annotations are replaced by route attributes, the plugin crash.

See original GitHub issue

Hello,

Thanks a lot for your excellent plugin!

Since the 8th version of PHP allows attributes, it seems that we cannot declare route with attribute yet. As soon as I used them, the plugin encountered a failure, below I paste the trace.

class RegistrationController extends AbstractController
{
    #[Route('/foo', name: 'app_foo')]
    public function bar(){
      //...
    }

    #[Route('/bar', name: 'app_bar')]
    public function bar(){
        if ($foo) {
            return $this->redirectToRoute('app_register');
        }
    }
}

Of course, the link after redirectToRoute is no more available too. As soon as I replace attributes by annotation, your plugin works well.

com.intellij.diagnostic.PluginException: Failed to build index 'fr.adrienbrault.idea.symfony2plugin.routes_object' for file file:///home/alexandre/PhpstormProjects/bb-one/src/Controller/RegistrationController.php (id = 222) (file type = PHP) [Plugin: fr.adrienbrault.idea.symfony2plugin]
	at com.intellij.ide.plugins.PluginManagerCore.createPluginException(PluginManagerCore.java:300)
	at com.intellij.diagnostic.PluginProblemReporterImpl.createPluginExceptionByClass(PluginProblemReporterImpl.java:12)
	at com.intellij.diagnostic.PluginException.createByClass(PluginException.java:81)
	at com.intellij.util.indexing.diagnostic.BrokenIndexingDiagnostics$DefaultListener.onFileIndexMappingFailed(BrokenIndexingDiagnostics.kt:47)
	at com.intellij.util.indexing.FileBasedIndexImpl.updateSingleIndex(FileBasedIndexImpl.java:1501)
	at com.intellij.util.indexing.FileBasedIndexImpl.lambda$doIndexFileContent$23(FileBasedIndexImpl.java:1373)
	at com.intellij.openapi.fileTypes.impl.FileTypeManagerImpl.freezeFileTypeTemporarilyIn(FileTypeManagerImpl.java:555)
	at com.intellij.util.indexing.FileBasedIndexImpl.doIndexFileContent(FileBasedIndexImpl.java:1343)
	at com.intellij.util.indexing.FileBasedIndexImpl.indexFileContent(FileBasedIndexImpl.java:1297)
	at com.intellij.util.indexing.contentQueue.IndexUpdateRunner.lambda$indexOneFileOfJob$2(IndexUpdateRunner.java:252)
	at com.intellij.openapi.application.impl.NonBlockingReadActionImpl$Submission.insideReadAction(NonBlockingReadActionImpl.java:521)
	at com.intellij.openapi.application.impl.NonBlockingReadActionImpl$Submission.lambda$attemptComputation$3(NonBlockingReadActionImpl.java:468)
	at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1096)
	at com.intellij.openapi.progress.util.ProgressIndicatorUtils.lambda$runInReadActionWithWriteActionPriority$0(ProgressIndicatorUtils.java:79)
	at com.intellij.openapi.progress.util.ProgressIndicatorUtils.runActionAndCancelBeforeWrite(ProgressIndicatorUtils.java:157)
	at com.intellij.openapi.progress.util.ProgressIndicatorUtils.lambda$runWithWriteActionPriority$1(ProgressIndicatorUtils.java:119)
	at com.intellij.openapi.progress.ProgressManager.lambda$runProcess$0(ProgressManager.java:57)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:178)
	at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:688)
	at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:634)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:64)
	at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:165)
	at com.intellij.openapi.progress.ProgressManager.runProcess(ProgressManager.java:57)
	at com.intellij.openapi.progress.util.ProgressIndicatorUtils.runWithWriteActionPriority(ProgressIndicatorUtils.java:116)
	at com.intellij.openapi.progress.util.ProgressIndicatorUtils.runInReadActionWithWriteActionPriority(ProgressIndicatorUtils.java:79)
	at com.intellij.openapi.application.impl.NonBlockingReadActionImpl$Submission.attemptComputation(NonBlockingReadActionImpl.java:486)
	at com.intellij.openapi.application.impl.NonBlockingReadActionImpl$Submission.executeSynchronously(NonBlockingReadActionImpl.java:422)
	at com.intellij.openapi.application.impl.NonBlockingReadActionImpl.executeSynchronously(NonBlockingReadActionImpl.java:186)
	at com.intellij.util.indexing.contentQueue.IndexUpdateRunner.indexOneFileOfJob(IndexUpdateRunner.java:255)
	at com.intellij.util.indexing.contentQueue.IndexUpdateRunner.lambda$indexJobsFairly$1(IndexUpdateRunner.java:198)
	at com.intellij.openapi.progress.impl.ProgressSuspender.executeNonSuspendableSection(ProgressSuspender.java:83)
	at com.intellij.util.indexing.contentQueue.IndexUpdateRunner.indexJobsFairly(IndexUpdateRunner.java:201)
	at com.intellij.util.indexing.contentQueue.IndexUpdateRunner.lambda$doIndexFiles$0(IndexUpdateRunner.java:135)
	at com.intellij.util.concurrency.BoundedTaskExecutor.doRun(BoundedTaskExecutor.java:216)
	at com.intellij.util.concurrency.BoundedTaskExecutor.access$200(BoundedTaskExecutor.java:27)
	at com.intellij.util.concurrency.BoundedTaskExecutor$1.execute(BoundedTaskExecutor.java:195)
	at com.intellij.util.ConcurrencyUtil.runUnderThreadName(ConcurrencyUtil.java:213)
	at com.intellij.util.concurrency.BoundedTaskExecutor$1.run(BoundedTaskExecutor.java:184)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:668)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:665)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:665)
	at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: com.intellij.util.indexing.impl.MapReduceIndexMappingException: java.lang.ClassCastException: class com.jetbrains.php.lang.psi.elements.PhpAttribute$PhpAttributeArgument cannot be cast to class com.jetbrains.php.lang.psi.stubs.indexes.expectedArguments.PhpExpectedFunctionArgument (com.jetbrains.php.lang.psi.elements.PhpAttribute$PhpAttributeArgument and com.jetbrains.php.lang.psi.stubs.indexes.expectedArguments.PhpExpectedFunctionArgument are in unnamed module of loader com.intellij.ide.plugins.cl.PluginClassLoader @78ecf973)
	at com.intellij.util.indexing.impl.MapReduceIndex.mapInputAndPrepareUpdate(MapReduceIndex.java:265)
	at com.intellij.indexing.composite.CompositeInvertedIndexBase.updateBaseIndex(CompositeInvertedIndexBase.java:232)
	at com.intellij.indexing.composite.CompositeInvertedIndexBase.mapInputAndPrepareUpdate(CompositeInvertedIndexBase.java:55)
	at com.intellij.indexing.composite.CompositeInvertedIndexBase.mapInputAndPrepareUpdate(CompositeInvertedIndexBase.java:26)
	at com.intellij.util.indexing.FileBasedIndexImpl.updateSingleIndex(FileBasedIndexImpl.java:1491)
	... 40 more
Caused by: java.lang.ClassCastException: class com.jetbrains.php.lang.psi.elements.PhpAttribute$PhpAttributeArgument cannot be cast to class com.jetbrains.php.lang.psi.stubs.indexes.expectedArguments.PhpExpectedFunctionArgument (com.jetbrains.php.lang.psi.elements.PhpAttribute$PhpAttributeArgument and com.jetbrains.php.lang.psi.stubs.indexes.expectedArguments.PhpExpectedFunctionArgument are in unnamed module of loader com.intellij.ide.plugins.cl.PluginClassLoader @78ecf973)
	at fr.adrienbrault.idea.symfony2plugin.stubs.indexes.visitor.AnnotationRouteElementWalkingVisitor.visitPhpAttributesList(AnnotationRouteElementWalkingVisitor.java:184)
	at fr.adrienbrault.idea.symfony2plugin.stubs.indexes.visitor.AnnotationRouteElementWalkingVisitor.visitElement(AnnotationRouteElementWalkingVisitor.java:53)
	at com.intellij.psi.impl.PsiElementBase.accept(PsiElementBase.java:273)
	at com.jetbrains.php.lang.psi.elements.impl.PhpPsiElementImpl.accept(PhpPsiElementImpl.java:76)
	at com.intellij.psi.PsiWalkingState.visit(PsiWalkingState.java:67)
	at com.intellij.psi.PsiWalkingState.visit(PsiWalkingState.java:24)
	at com.intellij.util.WalkingState.walkChildren(WalkingState.java:62)
	at com.intellij.util.WalkingState.elementStarted(WalkingState.java:49)
	at com.intellij.psi.PsiWalkingState.elementStarted(PsiWalkingState.java:76)
	at com.intellij.psi.PsiRecursiveElementWalkingVisitor.visitElement(PsiRecursiveElementWalkingVisitor.java:48)
	at fr.adrienbrault.idea.symfony2plugin.stubs.indexes.visitor.AnnotationRouteElementWalkingVisitor.visitElement(AnnotationRouteElementWalkingVisitor.java:56)
	at com.intellij.psi.PsiElementVisitor.visitFile(PsiElementVisitor.java:35)
	at com.intellij.psi.PsiRecursiveElementWalkingVisitor.visitFile(PsiRecursiveElementWalkingVisitor.java:70)
	at com.intellij.extapi.psi.PsiFileBase.accept(PsiFileBase.java:60)
	at com.jetbrains.php.lang.psi.PhpFileImpl.accept(PhpFileImpl.java:200)
	at fr.adrienbrault.idea.symfony2plugin.stubs.indexes.RoutesStubIndex.lambda$getIndexer$0(RoutesStubIndex.java:81)
	at com.intellij.util.indexing.impl.MapReduceIndex.mapByIndexer(MapReduceIndex.java:316)
	at com.intellij.util.indexing.impl.MapReduceIndex.mapInput(MapReduceIndex.java:306)
	at com.intellij.util.indexing.impl.storage.VfsAwareMapReduceIndex.mapInput(VfsAwareMapReduceIndex.java:168)
	at com.intellij.util.indexing.impl.storage.VfsAwareMapReduceIndex.mapInput(VfsAwareMapReduceIndex.java:39)
	at com.intellij.util.indexing.impl.MapReduceIndex.mapInputAndPrepareUpdate(MapReduceIndex.java:256)
	... 44 more

I use PhpStorm2021.1

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
shokhaacommented, Apr 12, 2021

@Alexandre-T I have the same error! plugin version: 0.22.207 PHPstorm version: 2021.1

2reactions
Haehnchencommented, Apr 17, 2021

duplicated and fixes

Read more comments on GitHub >

github_iconTop Results From Across the Web

App Manifest Attribute Reference | Cloud Foundry Docs
This topic describes manifest formatting and provides a full list of attributes available for app manifests. You can use it alongside Deploying ...
Read more >
repo.hu/projects/pcb-rnd/releases/changelog-1.2.0.txt
[ch] to the report plugin -Move: original rubberband code into a feature ... GUI -Fix: mark the PCB changed when the route style...
Read more >
Why I prefer a routing config file to Controller annotations : r/PHP
42 votes, 96 comments. I'm specifically going through a Symfony 5 test install, and while the Symfony devs state in the docs that...
Read more >
Navigation | Android Developers
0 's CreationExtras . Navigation SafeArgs. Navigation Safe Args has upgraded the Android Gradle Plugin dependency to rely on 7.0.4 , dropping ...
Read more >
Composability System · Backstage Software Catalog and ...
At the core is the concept of extensions, which are exported by plugins for use in the app. There is also a primitive...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found