vimeo/psalm

Declaring stubs in directory

Open

#9,193 建立於 2023年1月27日

在 GitHub 查看
 (6 留言) (2 反應) (0 負責人)PHP (668 fork)batch import
Help wantedeasy problemsenhancementgood first issue

倉庫指標

Star
 (5,369 star)
PR 合併指標
 (平均合併 3天 12小時) (30 天內合併 5 個 PR)

描述

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.

貢獻者指南