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

Function is_available_for_version

src/parser/mod.rs:130–141  ·  view source on GitHub ↗

Check whether a function or method is available for the given PHP version based on its `#[PhpStormStubsElementAvailable]` attributes. Returns `true` when: - The element has no `PhpStormStubsElementAvailable` attribute (always available). - The element has the attribute and the version falls within its range. Returns `false` when the attribute is present and the version is outside the range.

(
    attribute_lists: &Sequence<'_, attribute::AttributeList<'_>>,
    ctx: &DocblockCtx<'_>,
    php_version: PhpVersion,
)

Source from the content-addressed store, hash-verified

128///
129/// Returns `false` when the attribute is present and the version is outside the range.
130pub(crate) fn is_available_for_version(
131 attribute_lists: &Sequence<'_, attribute::AttributeList<'_>>,
132 ctx: &DocblockCtx<'_>,
133 php_version: PhpVersion,
134) -> bool {
135 if let Some(avail) = extract_version_availability(attribute_lists, ctx) {
136 php_version.matches_range(avail.from, avail.to)
137 } else {
138 // No version attribute → always available.
139 true
140 }
141}
142
143/// Check whether a function, method, or class has been removed in the
144/// target PHP version based on a `@removed X.Y` docblock tag.

Calls 2

matches_rangeMethod · 0.80

Tested by

no test coverage detected