vimeo/psalm

Declaring stubs in directory

Open

#9193 aperta il 27 gen 2023

Vedi su GitHub
 (6 commenti) (2 reazioni) (0 assegnatari)PHP (668 fork)batch import
Help wantedeasy problemsenhancementgood first issue

Metriche repository

Star
 (5369 star)
Metriche merge PR
 (Merge medio 3g 12h) (5 PR mergiate in 30 g)

Descrizione

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.

Guida contributor