Skip to content

Psalm should load extensions based on composer.json instead of local configuration #5482

@AndrolGenhald

Description

@AndrolGenhald

I was thinking about this recently although it hasn't directly affected me yet, but I saw it pop up for someone else so I thought I'd create an issue.

one of the purposes of the stubs is to enable the static analysis of the code that depends on an extension that is unavailable at runtime.

Oh, in that case you should instead provide your own stubs. If Psalm were to stub all classes it might miss situations where you're missing an extension.

Originally posted by @muglug in #5477 (comment)

With docker it's possible and probably even common for the local php configuration to be different from what's being used to run the code. If I have the PDO extension enabled locally, but composer doesn't require "ext-pdo" then psalm shouldn't load the PDO extension in case my local docker (or production!) environment doesn't use that extension.

It might also be a good idea to add a configuration option to enable or disable specific extensions in psalm.xml.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions