vimeo / psalm

A static analysis tool for finding errors in PHP applications
https://psalm.dev
MIT License
5.54k stars 659 forks source link

Why is enableExtensions/disableExtensions list completely arbitrary? #9892

Open kkmuffme opened 1 year ago

kkmuffme commented 1 year ago

I have a psalm config with phpVersion 7.4. JSON is not a default enabled extension in PHP 7.

However psalm doesn't complain about json being used: https://psalm.dev/r/b342017802

Using disableExtensions doesn't work either, since the selection of extensions that support this config is seemingly arbitrary? This won't work:

    <disableExtensions>
        <extension name="json"/>
    </disableExtensions>

But disabling simplexml (which has been part of PHP since forever) is possible?!

psalm-github-bot[bot] commented 1 year ago

I found these snippets:

https://psalm.dev/r/b342017802 ```php
orklah commented 1 year ago

It supports what contributors have worked on for now

The list of stubbed extensions is here: https://github.com/vimeo/psalm/tree/a6016e307261a9fa054e028d04bec12c920f66bf/stubs/extensions

So if you want for json to be supported, you start by removing json functions in the callmap, stub them and conditionally load the stub depending on whether the extension is loaded or in the config