Intelephense show error like "unknown type" and "unknown function", but I have no clue how to fix them.
My project (a TYPO3 composer installation) has a "public" folder, which is, why I configured intelephense's intelephense.environment.documentRoot
option accordingly by setting it to ./public
.
The first screenshot shows the page tree of the project with a section opened, where the error occurs.
When I open "function.php", intelephense informs me about a "Undefined type 'Aimeos\Map'":
Map is defined right next to the function.php file in Map and ooks like this:
There are other places in the code, where intelephense informs me about a "Undefined function 'map'":
I had a look at intelephense's "function" template, but I do not know, what to put there. Neither, if I also have to define a class template and/or anything else.
This is my VSCode configuration for intelephense:
As can be seen, I tried to exclude "vendor/aimeos" files using the negator "!", but I assume this is not a known configuration value within intelephense.
What do I have to do to make intelephense work correctly? Thank you!
I was getting these warning even after adding appropriate use declarations. For me, I had to open the files where these types are declared from the vendor folder and then save the offending file. This somehow seems to trigger the intelephense type resolution mechanism and the warnings go away. Once intelephense recognizes them then you can safely close those files off of vendor folder. I tried closing the vs code and reopening it and still no warnings. Your mileage may vary.