All functions show unused even it is being used
Hello, JetBrains community,
I'm encountering an issue with PhpStorm, where all my functions are flagged as "unused" even though they are being called and used in my code. I'm hoping someone here can help me resolve this issue, as it's affecting my ability to use the IDE effectively.
Description of the issue:
- I've created several functions in my PHP project, all used in various places within the code.
- However, PhpStorm is showing a warning for each function, stating that the function is "unused."
- This is causing unnecessary clutter in the editor and making it difficult to identify genuine issues in the code.
Environment details:
- PhpStorm version: 2023.1.1
- PHP version: 8.4.1
- Operating System: macOS Ventura 13.3.1 (22E261)
Steps to reproduce:
- Create a new PHP file with a function.
- Then, use the function in the same or another PHP file in the project.
- Notice that PhpStorm flags the function as "unused" even though it's being called.
What I've tried so far:
- I've checked the PhpStorm settings for code inspection and ensured that "Unused" is not disabled or misconfigured.
- I've invalidated the PhpStorm cache and restarted the IDE multiple times.
- I've updated PhpStorm to the latest version and tried it on a different machine with a fresh installation.
None of the above solutions have resolved the issue.
I've searched the forum and online resources for a solution but haven't found any relevant threads or articles addressing this issue. Please let me know if anyone has experienced a similar problem or has any suggestions. I appreciate your assistance!
Many thanks for considering my request.
Best regards,
Jatin Soni
请先登录再写评论。
Hey Jatin,
I was not able to quickly reproduce it on PhpStorm 2023.1.1:

Usually, a caches invalidates may help but as far as I see, you have tried it already.
Is it reproducible for you on a fresh new project as well? Do you have any custom plugins?
For what it’s worth, I experience this constantly. Here is a screenshot of the IDE being undecided. The grayed-out color and the inlay hint suggest no usages, but the „find usages” popup has results
I have been experiencing a similar issue.
I have 2 public static methods in the same controller;
numberOfPurchases
&numberOfUses
, each running a query returning a count.Each method is called once from a Blade template, literally one right after the other and the
numberOfUses
method also called from another controller.The code is working fine but the
numberOfUses
method was showing unused although, as above, find usage shows the 2 calld.Whilst looking at it I created a call to
numberOfUses
from within the previous method, just to ensure it was ‘used’.$timesUsed = self::numberOfUses($couponCouponId);
Immediately the method name turned from grey to green as it was now seens as being used.
I deleted
$timesUsed = self::numberOfUses($couponCouponId);
expeting the method name to turn back to grey. It didn't.Looks like, for some reason, the IDE has the method flagged as unused, even though it's not, and forcing the issue corrected that.