Throwable var showing redundant function suggestions

Is this normal?

I'm working with PHP 7, and we just changed all of our `\Exception` instances to `\Throwable`, and the redundant suggestions started popping up.

I suppose one is coming from the Exception class and the other is from the Error class, but it doesn't distinguish, and the methods are identical anyway (Throwable is just an interface).

There's gotta be a better way to show suggestions for implemented classes that by definition are required to have methods of the same names.

0
6 comments

It looks like the indexes might be broken. Seen a different report on our tracker recently.
I also think this might be the reason for this other problem you're having.

Could you please check if File | Invalidate Caches | Invalidate and Restart helps?

0

Which options should I select?

0

Notice on `getCode`, it's showing different inputs, like `int` for one and `int|mixed` for another. That means it's seeing two definitions, but I'm not seeing how to see which definition it's referring to.

0

That means it's seeing two definitions, but I'm not seeing how to see which definition it's referring to.

Invoke "View | Quick Documentation" while the code completion popup is active -- it will display the doc popup next to the item (it displays the source for the doc text which should give you the clues).

1

Thanks.

I noticed that it only happens when I'm editing the PHP 7 version of the app (I have to edit it at other times in PHP 5 for other reasons right now), Here's the difference:

So for whatever reason, the `Throwable $e` when Language Level is PHP 7.4 shows duplicate calls, where one is `final public function Exception` and the other is `public function Throwable`...

I suppose this is normal for PHP 7? I mean... I know Exception implements Throwable... but showing both seems redundant... and no matter which I select, how could PHPStorm know which one I meant to be using as far as validation based on parameters I do or don't enter?

Is this unavoidable, or can PHPStorm maybe handle this more intelligently? 

0

So the source is the same but one instance comes from the Exception class and another one is from the Throwable interface.

This one looks similar to me: https://youtrack.jetbrains.com/issue/WI-66800

I'm not super sure... but I think I saw a ticket that was related and supposed to be fixed for the next 2022.2 version (although I may have been confused by some keywords and it's a different one). Anyway, can you try the EAP build (it can be installed and run alongside the current stable version) and check it there? https://www.jetbrains.com/phpstorm/nextversion/

If it's still the same: you know your code (where and how those 2 mentioned classes/interfaces are used), do you think you can make a simple code sample that could illustrate the issue (just one or few files in the brand new empty project)?

0

Please sign in to leave a comment.