Open susannemoog opened 8 years ago
Hi @psychomieze Please try new build 1.3.1, it should help. If not - could you send me reproducible example
I just got the same exception with PhpStorm 9.0.2 and phpuaca-1.3.1
String index out of range: -46
java.lang.StringIndexOutOfBoundsException: String index out of range: -46
at java.lang.String.substring(String.java:1911)
at com.phpuaca.completion.ProphecyTypeProvider.getTypeForReveal(ProphecyTypeProvider.java:96)
at com.phpuaca.completion.ProphecyTypeProvider.getType(ProphecyTypeProvider.java:62)
at com.jetbrains.php.lang.psi.resolve.types.PhpTypeInfo$1.internalCompute(PhpTypeInfo.java:43)
at com.jetbrains.php.lang.psi.resolve.types.PhpTypeInfo$1.internalCompute(PhpTypeInfo.java:37)
at com.intellij.openapi.util.Computable$NotNullCachedComputable.compute(Computable.java:52)
at com.intellij.openapi.util.RecursionManager$2.doPreventingRecursion(RecursionManager.java:112)
at com.intellij.openapi.util.RecursionManager.doPreventingRecursion(RecursionManager.java:68)
at com.jetbrains.php.lang.psi.resolve.types.PhpTypeInfo.getType(PhpTypeInfo.java:37)
at com.jetbrains.php.lang.psi.elements.impl.PhpReferenceImpl.getType(PhpReferenceImpl.java:153)
at com.jetbrains.php.lang.inspections.PhpVoidFunctionResultUsedInspection.analyzeCall(PhpVoidFunctionResultUsedInspection.java:47)
at com.jetbrains.php.lang.inspections.PhpVoidFunctionResultUsedInspection.access$000(PhpVoidFunctionResultUsedInspection.java:21)
at com.jetbrains.php.lang.inspections.PhpVoidFunctionResultUsedInspection$1.visitPhpMethodReference(PhpVoidFunctionResultUsedInspection.java:39)
at com.jetbrains.php.lang.psi.elements.impl.MethodReferenceImpl.accept(MethodReferenceImpl.java:30)
at com.intellij.codeInspection.InspectionEngine.acceptElements(InspectionEngine.java:80)
at com.intellij.codeInspection.InspectionEngine.createVisitorAndAcceptElements(InspectionEngine.java:69)
at com.intellij.codeInsight.daemon.impl.LocalInspectionsPass.a(LocalInspectionsPass.java:285)
at com.intellij.codeInsight.daemon.impl.LocalInspectionsPass.access$200(LocalInspectionsPass.java:75)
at com.intellij.codeInsight.daemon.impl.LocalInspectionsPass$2.process(LocalInspectionsPass.java:254)
at com.intellij.codeInsight.daemon.impl.LocalInspectionsPass$2.process(LocalInspectionsPass.java:251)
at com.intellij.concurrency.ApplierCompleter.a(ApplierCompleter.java:122)
at com.intellij.concurrency.ApplierCompleter.access$000(ApplierCompleter.java:44)
at com.intellij.concurrency.ApplierCompleter$1.run(ApplierCompleter.java:85)
at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1098)
at com.intellij.concurrency.ApplierCompleter$2.run(ApplierCompleter.java:94)
at com.intellij.openapi.progress.impl.CoreProgressManager.a(CoreProgressManager.java:452)
at com.intellij.openapi.progress.impl.CoreProgressManager.a(CoreProgressManager.java:449)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:402)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:54)
at com.intellij.concurrency.ApplierCompleter.a(ApplierCompleter.java:106)
at com.intellij.concurrency.ApplierCompleter.compute(ApplierCompleter.java:82)
at jsr166e.CountedCompleter.exec(CountedCompleter.java:684)
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:109)
@jdreesen could you send me a code example please to reproduce this exception
I have the same error (PhpStorm 10, 1.3.1). I would like to give you sample of code, but i don't know where exactly error occurs.
@maxfilatov, i've found what causes errors. This happens when you get mock by some method without @return statement in bockblock, for example:
private function getEntityManager()
{
$em = $this->prophesize(EntityManager::class);
$connection = $this->prophesize(Connection::class);
$em->getConnection()->shouldBeCalled()->willReturn($connection);
return $em;
}
Adding bockblock stopped errors genration:
/**
* @return EntityManager|ObjectProphecy
*/
private function getEntityManager()
{
$em = $this->prophesize(EntityManager::class);
$connection = $this->prophesize(Connection::class);
$em->getConnection()->shouldBeCalled()->willReturn($connection);
return $em;
}
PhpStorm 11 EAP (PS-144.4199.11) and phpuaca-1.3.0-unstable-5.jar throws the following Exception:
String index out of range: -46 java.lang.StringIndexOutOfBoundsException: String index out of range: -46 at java.lang.String.substring(String.java:1967) at com.phpuaca.completion.ProphecyTypeProvider.getTypeForReveal(ProphecyTypeProvider.java:96) at com.phpuaca.completion.ProphecyTypeProvider.getType(ProphecyTypeProvider.java:62) at com.jetbrains.php.lang.psi.resolve.types.PhpTypeInfo$1.internalCompute(PhpTypeInfo.java:43) at com.jetbrains.php.lang.psi.resolve.types.PhpTypeInfo$1.internalCompute(PhpTypeInfo.java:37) at com.intellij.openapi.util.Computable$NotNullCachedComputable.compute(Computable.java:52) at com.intellij.openapi.util.RecursionManager$2.doPreventingRecursion(RecursionManager.java:112) at com.intellij.openapi.util.RecursionManager.doPreventingRecursion(RecursionManager.java:68) at com.jetbrains.php.lang.psi.resolve.types.PhpTypeInfo.getType(PhpTypeInfo.java:37) at com.jetbrains.php.lang.psi.elements.impl.PhpReferenceImpl.getType(PhpReferenceImpl.java:207) at com.jetbrains.php.lang.psi.resolve.types.PhpType.add(PhpType.java:150) at com.jetbrains.php.lang.inspections.PhpParamsInspection.checkCall(PhpParamsInspection.java:91) at com.jetbrains.php.lang.inspections.PhpParamsInspection.access$000(PhpParamsInspection.java:25) at com.jetbrains.php.lang.inspections.PhpParamsInspection$2.visitPhpMethodReference(PhpParamsInspection.java:59) at com.jetbrains.php.lang.psi.elements.impl.MethodReferenceImpl.accept(MethodReferenceImpl.java:29) at com.intellij.codeInspection.InspectionEngine.acceptElements(InspectionEngine.java:81) at com.intellij.codeInsight.daemon.impl.LocalInspectionsPass$4.process(LocalInspectionsPass.java:320) at com.intellij.codeInsight.daemon.impl.LocalInspectionsPass$4.process(LocalInspectionsPass.java:315) at com.intellij.concurrency.ApplierCompleter.b(ApplierCompleter.java:128) at com.intellij.concurrency.ApplierCompleter.a(ApplierCompleter.java:217) at com.intellij.concurrency.ApplierCompleter.b(ApplierCompleter.java:146) at com.intellij.concurrency.ApplierCompleter.a(ApplierCompleter.java:217) at com.intellij.concurrency.ApplierCompleter.b(ApplierCompleter.java:146) at com.intellij.concurrency.ApplierCompleter.access$000(ApplierCompleter.java:44) at com.intellij.concurrency.ApplierCompleter$1.run(ApplierCompleter.java:91) at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1178) at com.intellij.concurrency.ApplierCompleter$2.run(ApplierCompleter.java:100) at com.intellij.openapi.progress.impl.CoreProgressManager.a(CoreProgressManager.java:446) at com.intellij.openapi.progress.impl.CoreProgressManager.a(CoreProgressManager.java:443) 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.concurrency.ApplierCompleter.a(ApplierCompleter.java:112) at com.intellij.concurrency.ApplierCompleter.compute(ApplierCompleter.java:88) at jsr166e.CountedCompleter.exec(CountedCompleter.java:684) 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)
Thanks for your work :)