Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecation: Psalm stubs for ext-apcu loaded using legacy way. #8958

Closed
michnovka opened this issue Dec 20, 2022 · 9 comments · Fixed by #9291
Closed

Deprecation: Psalm stubs for ext-apcu loaded using legacy way. #8958

michnovka opened this issue Dec 20, 2022 · 9 comments · Fixed by #9291

Comments

@michnovka
Copy link
Contributor

I have lot of these warnings in my psalm output:

Target PHP version: 8.2 (inferred from current PHP version) Extensions enabled: decimal (unsupported extensions: ctype, curl, gd, iconv, intl, json, mbstring)
Scanning files...
Deprecation: Psalm stubs for ext-apcu loaded using legacy way. Instead, please declare ext-apcu as dependency in composer.json or use directive in Psalm config.
Deprecation: Psalm stubs for ext-random loaded using legacy way. Instead, please declare ext-random as dependency in composer.json or use directive in Psalm config.
Deprecation: Psalm stubs for ext-redis loaded using legacy way. Instead, please declare ext-redis as dependency in composer.json or use directive in Psalm config.

My project does not use apcu, nor redis. It is not inside psalm.xml nor inside composer.json.

Why are these extensions even loaded?

@psalm-github-bot
Copy link

Hey @michnovka, can you reproduce the issue on https://psalm.dev ?

@michnovka
Copy link
Contributor Author

This is unreproducible with psalm.dev

@orklah
Copy link
Collaborator

orklah commented Dec 20, 2022

Those are extensions that are loaded in your current PHP installation (we retrieve those through extension_loaded:

if (! $is_stub_already_loaded && extension_loaded($ext_name)) {

Historically, Psalm used to have every extension symbol automatically known. This was having weird effects when users declared those symbol but did not have that specific extension. We're changing things in order to have a better workflow here

We created separate stubs for extensions and we only load them when we detect an extension;

  • Either because it is loaded at runtime
  • Or because it is in composer.json
  • Or because it is in psalm.xml

We wish to deprecate the first possibility, but for better migration, we're warning users that they will have to migrate extensions to one of the other possibility. If you don't wish to enable the extensions we warn about, just ignore the deprecation, we'll disable those when we finish the migration. Otherwise, please add them in composer or in config.

Ref: #8885
(ping @lptn )

@michnovka
Copy link
Contributor Author

@orklah maybe we can introduce some psalm.xml config option to suppress these messages? I keep all my requirements correctly included in composer.json. Still, my PHP installation has maybe few extra extensions. But this does not mean I need to load their stubs for my project.

So while I get the reason for the warning, if a user sees it, they decide its OK, adding an option into psalm.xml to suppress them would be welcome. WDYT?

@alies-dev
Copy link
Contributor

I think the ideal option for this case will be to use disableExtensions config key: https://psalm.dev/docs/running_psalm/configuration/#disableextensions

However, I haven't tested how they works in this combination. I'll test it this week, if doesn't work - I'll create a PR

@ThomasLandauer
Copy link
Contributor

I have the same issue with ext-random in PHP 8.2.

According to https://php.watch/versions/8.2/ext-random, the random extension is loaded automatically in 8.2, so in this case the deprecation message might be false.

@alies-dev
Copy link
Contributor

alies-dev commented Jan 10, 2023

the fixed version is on master branch.

As for issue raised by @ThomasLandauer, we need to find another solution. I will try to find something not complex to solve this (different PHP versions have different bundled/core php ext, it's also possible to compile PHP with/without some of them, it's possible to disable some ext in .ini, we can write a comprehensive solution for this, but I don't think we should increase complexity of the project on such non-major functionality).

UPD: There is a PR for that: https://github.com/vimeo/psalm/pull/9099/files

UPD 2: It's fixed and merged. The fix on master and will be shipped within next release (next after 5.4.0)

@iquito
Copy link

iquito commented Feb 5, 2023

I tried to get rid of these deprecation messages, unfortunately disableExtensions does not make these go away in my project - the deprecation messages still occur when I add this to my psalm.xml:

    <disableExtensions>
        <extension name="apcu"/>
        <extension name="redis"/>
        <extension name="random"/>
    </disableExtensions>

@stramunin
Copy link

@iquito
I got the same message. Something is broken.

$ psalm --version
Psalm 5.6.0@e784128902dfe01d489c4123d69918a9f3c1eac5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants