| Subject | Details |
| :------------- | :---------------------------------------------------------------------------- |
| Plugin | Php Inspections (EA Extended) |
| Language level | PHP 7.1 |
Throw a false positive error
Nothing
How to reproduce:
$validationErrors = [];
if (count($validationErrors)) {}
Hi,
I can't reproduce the issue with your example.
Could you give further details or a larger example who could show the issue?
Thank you for reporting @florianajir, I also could not reproduce. Would you please share an extended code fragment, please?
It seems to be an ide init bug or I don't know what but the error did not thrown today.
However that was not the first time I seen this false positive error.
But you can close the issue because I'm not able to reproduce anymore.
Ok, it would be great to get a reproducible sample if you run into the issue again. meanwhile closing,
It happens again


I can see now, looks like a correctly reported case: $validationErrors is overridden and not being used between the declaration and the override. In this case, renaming the local variable is recommended.
$validationErrors is a parameter of your method. You change its value without using it once. That's why Kalessil recommanded to use a different name for your variable, to avoid confusion between the value passed in parameter and the changed value.
Ok I didn't notice the parameter of the method, my bad. Thank you!
@florianajir, just a second =) I'm thinking if warning message needs to be adjusted, perhaps you can propose how it can be improved?
Indeed reading the message i supposed the problem come after the declaration.
Maybe something like "This variable name has already been declared previously without being used"
@florianajir: updated!
Most helpful comment
@florianajir: updated!