Multiple definitions exist for class 'Collection'
When using Laravel Idea with code generation, PhpStorm warns me that multiple definitions exist for class 'Collection' for example in my Lumen 10 project, one in _ide_helper_macro and one in _ide_helper_macro_static. Is this intended behavior?
It seems there is no Collection class in the project, but some library added a macro method to it...
So, Lumen framework doesn't contain the Collection class by default?
It does, https://github.com/laravel/lumen-framework/blob/10.x/composer.json#L24
Looks like PhpStorm forgot about the original Collection class. Could you make main menu > File > Invalidate Caches...?
Didn't help. 😟 Wondering if it's because of Laravel Scout because _ide_helper_macro_static.php and _ide_helper_macro.php both contain:
...
namespace Illuminate\Support {
/**
* @method static void searchable()
* @method static void unsearchable()
*/
class Collection {}
}
So, there is Illuminate\Support\Collection in this project, but PhpStorm sees only these two from helper files? Looks like a PhpStorm bug...
OK this is weird, I now moved the path of the generated files to <root>/vendor/_laravel_idea (previously had them in <root>/.laravel_idea) and now I see 3 hits, one for Illuminate\Support\Collection and the two aforementioned by Laravel Idea.
But is it expected that every occurance of use Illuminate\Support\Collection; now triggers the warning? I was hoping that PhpStorm knows that they all belong to the same namespace and class.
This happens to me after the latest update...
We did some fixes in 11.5, and they can fix this issue too. Could you update and check?