MCPcopy Create free account
hub / github.com/PHPantom-dev/phpantom_lsp / extract_template_params

Function extract_template_params

src/docblock/templates.rs:32–37  ·  view source on GitHub ↗

Extract template parameter names from `@template` tags in a docblock. Handles the common PHPStan / Psalm variants: - `@template T` - `@template TKey of array-key` - `@template-covariant TValue` - `@template-contravariant TValue` - `@phpstan-template T` - `@phpstan-template-covariant TValue` Returns a list of template parameter names (e.g. `["T", "TKey"]`).

(docblock: &str)

Source from the content-addressed store, hash-verified

30///
31/// Returns a list of template parameter names (e.g. `["T", "TKey"]`).
32pub fn extract_template_params(docblock: &str) -> Vec<String> {
33 extract_template_params_full(docblock)
34 .into_iter()
35 .map(|(name, _, _, _)| name)
36 .collect()
37}
38
39/// Like [`extract_template_params`], but operates on a pre-parsed [`DocblockInfo`].
40pub fn extract_template_params_from_info(info: &DocblockInfo) -> Vec<String> {

Callers 1

Calls 3

into_iterMethod · 0.80
mapMethod · 0.45

Tested by 1