vimeo/psalm

Declaring stubs in directory

Open

#9,193 opened on 2023年1月27日

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
 (平均マージ 3d 12h) (30d で 5 merged PRs)

説明

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.

コントリビューターガイド