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.

ClassCastException after opening a Twig template

See original GitHub issue

I’ve encountered the following error: when I open a Twig template and switch back to a PHP file within the same session, after that whenever I click in that file, I get a ClassCastException.

Q A
PhpStorm version 10.0.2 build: PS-143.1184
JRE 1.8.0_51-b16 amd64
Plugin version 0.11.106
Project type Symfony fullstack
PhpStorm EAP channel no

This issue is probably related to #592

After I restart PhpStorm, the issue is gone until I open another Twig file.

Stacktrace:

com.intellij.lang.javascript.psi.impl.JSFunctionExpressionImpl cannot be cast to com.jetbrains.php.lang.psi.elements.PhpNamespace
java.lang.ClassCastException: com.intellij.lang.javascript.psi.impl.JSFunctionExpressionImpl cannot be cast to com.jetbrains.php.lang.psi.elements.PhpNamespace
    at fr.adrienbrault.idea.symfony2plugin.util.PhpIndexUtil$1.process(PhpIndexUtil.java:39)
    at com.intellij.psi.stubs.StubProcessingHelperBase.processStubsInFile(StubProcessingHelperBase.java:165)
    at com.intellij.psi.stubs.StubProcessingHelperBase.processStubsInFile(StubProcessingHelperBase.java:52)
    at com.intellij.psi.stubs.StubIndexImpl$1.process(StubIndexImpl.java:231)
    at com.intellij.psi.stubs.StubIndexImpl$StubIdListContainerAction.perform(StubIndexImpl.java:582)
    at com.intellij.psi.stubs.StubIndexImpl$StubIdListContainerAction.perform(StubIndexImpl.java:570)
    at com.intellij.util.indexing.ValueContainer.forEach(ValueContainer.java:81)
    at com.intellij.psi.stubs.StubIndexImpl.a(StubIndexImpl.java:252)
    at com.intellij.psi.stubs.StubIndexImpl.processElements(StubIndexImpl.java:223)
    at com.intellij.psi.stubs.StubIndexImpl.processElements(StubIndexImpl.java:212)
    at com.intellij.psi.stubs.StubIndex.process(StubIndex.java:77)
    at fr.adrienbrault.idea.symfony2plugin.util.PhpIndexUtil.getPhpClassInsideNamespace(PhpIndexUtil.java:39)
    at fr.adrienbrault.idea.symfony2plugin.util.PhpIndexUtil.getPhpClassInsideNamespace(PhpIndexUtil.java:27)
    at fr.adrienbrault.idea.symfony2plugin.doctrine.EntityHelper.getModelClasses(EntityHelper.java:789)
    at fr.adrienbrault.idea.symfony2plugin.doctrine.EntityHelper.getModelClasses(EntityHelper.java:754)
    at fr.adrienbrault.idea.symfony2plugin.config.ServiceLineMarkerProvider.entityClassMarker(ServiceLineMarkerProvider.java:151)
    at fr.adrienbrault.idea.symfony2plugin.config.ServiceLineMarkerProvider.collectSlowLineMarkers(ServiceLineMarkerProvider.java:69)
    at com.intellij.codeInsight.daemon.impl.SlowLineMarkersPass.addLineMarkers(SlowLineMarkersPass.java:78)
    at com.intellij.codeInsight.daemon.impl.SlowLineMarkersPass.doCollectInformation(SlowLineMarkersPass.java:65)
    at com.intellij.codeHighlighting.TextEditorHighlightingPass.collectInformation(TextEditorHighlightingPass.java:67)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass$1$1.run(PassExecutorService.java:444)
    at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1169)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass$1.run(PassExecutorService.java:435)
    at com.intellij.openapi.progress.impl.CoreProgressManager.a(CoreProgressManager.java:446)
    at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:392)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:54)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.a(PassExecutorService.java:432)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.run(PassExecutorService.java:408)
    at com.intellij.concurrency.JobLauncherImpl$VoidForkJoinTask$1.exec(JobLauncherImpl.java:206)
    at jsr166e.ForkJoinTask.doExec(ForkJoinTask.java:260)
    at jsr166e.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:858)
    at jsr166e.ForkJoinPool.scan(ForkJoinPool.java:1687)
    at jsr166e.ForkJoinPool.runWorker(ForkJoinPool.java:1642)
    at jsr166e.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:108)

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
Haehnchencommented, May 5, 2016

fixed by #670

0reactions
Haehnchencommented, Jan 24, 2016

maybe also related to #670 reported by phpstorm core dev

Read more comments on GitHub >

github_iconTop Results From Across the Web

java.lang.NoClassDefFoundError: com/jetbrains/twig/TwigFile
I get this error multiple times per day. It doesn't bother me, interrupt my work or otherwise cause any issues. I'm just getting...
Read more >
com.sun.org.apache.xerces.internal.dom.ElementImpl cannot ...
This problem appears as result of editing which leads to merging schema2beans model. There is no way to fix it on client side....
Read more >
ClassCastException when casting to the same class
During the lifecycle of the Form project, I call validator.validate() which loads the previously created bean object from the session (I'm ...
Read more >
include - The flexible, fast, and secure PHP template engine
The include statement includes a template and outputs the rendered content of ... You can add additional variables by passing them after the...
Read more >
Discovering and Inspecting Variables in Twig Templates
When working with a Twig template file most variables are ... Microsoft's VSCode is a free open-source IDE with plugins that will do...
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