You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was just trying to run my linting locally and the fact that i have certain extensions not installed made it very hard.
Docblock-defined class, interface or enum named Memcache does not exist
Class, interface or enum named Memcached does not exist
Docblock-defined class, interface or enum named Redis does not exist
Docblock-defined class, interface or enum named APCUIterator does not exist
So after investigating a bit into the matter i found that redis as well as apcu seem to be a special cases as there are literally extension_loaded checks in place which enable the subs:
I played a little around with the code base but haven been able to find the location which determines to only load this callmap if the extension is installed.
It seems that eventually extension support will get better in psalm 5 #7107 but i assume - as i wasnt able to specify memcache as enableExtensions in 5.x - the same problem exists there for now as well, until the extensions are migrated to stub files?
I don't believe that Psalm 4 or 5 have stub files for the memcache/memcached classes so it relies on reflection to populate them.
You could add your own stub file to your project to give Psalm the information it needs when the extension is not installed.
If you also want to contribute that back to Psalm I'm sure it would be welcome, as it can then be used for anyone requiring ext-memcache(d) in their composer.json.
Yes there are no stubs. But im wondering what the callmap file is for, which declares the memcache extension's classes correctly, and why it doesnt seem to work? Maybe its obsolete and reflection is always used?
I was just trying to run my linting locally and the fact that i have certain extensions not installed made it very hard.
In my case i rely on
APCUIterator
Memcache
Memcached
andRedis
.(My usecase is like the one another user had (unanswered): https://stackoverflow.com/questions/73703563/psalm-how-to-deal-with-optional-classes)
So after investigating a bit into the matter i found that
redis
as well asapcu
seem to be a special cases as there are literallyextension_loaded
checks in place which enable the subs:psalm/src/Psalm/Config.php
Line 2079 in f630a0d
But for
memcache
i couldnt find such logic, only that theCallMap
correctly specifies the class:https://github.com/vimeo/psalm/blob/4.x/dictionaries/CallMap.php#L7349
I played a little around with the code base but haven been able to find the location which determines to only load this callmap if the extension is installed.
It seems that eventually extension support will get better in psalm 5 #7107 but i assume - as i wasnt able to specify
memcache
asenableExtensions
in 5.x - the same problem exists there for now as well, until the extensions are migrated to stub files?Related #7982 which also highlighted:
Tested with
vimeo/psalm: 4.30.0
The text was updated successfully, but these errors were encountered: