vimeo/psalm

Declaring stubs in directory

Open

#9,193 opened on Jan 27, 2023

View on GitHub
 (6 comments) (2 reactions) (0 assignees)PHP (668 forks)batch import
Help wantedeasy problemsenhancementgood first issue

Repository metrics

Stars
 (5,369 stars)
PR merge metrics
 (Avg merge 3d 12h) (5 merged PRs in 30d)

Description

Right now, the <stubs> configuration node only supports the <file> node as a child.

This is problematic when:

  • there are multiple files
  • stubs files are generated dynamically

Having experienced both of the above, I think it would be nice if Psalm would support <directory> as <stubs>'s child node. Similar to how <projectFiles> already does.

Alternatively, the <file> node could support a pattern attribute to be used instead of <name>, so instead of

    <stubs>
        <file name="path/to/my/stubs/file1.php" />
        <file name="path/to/my/stubs/file2.php" />
        <file name="path/to/my/stubs/file3.php" />
        <file name="path/to/my/stubs/file4.php" />
    </stubs>

one could do either:

    <stubs>
        <directory name="path/to/my/stubs/" />
    </stubs>

or:

    <stubs>
        <file pattern="path/to/my/stubs/*.php" />
    </stubs>

Both approaches would solve this issue. The pattern attribute available for the StubsAttributeType XML type will enable it for any other usage of the <file> node in configuration.

Contributor guide