pub struct FunctionLikeMetadata {Show 22 fields
pub kind: FunctionLikeKind,
pub span: Span,
pub name: Word,
pub original_name: Word,
pub name_span: Option<Span>,
pub parameters: Vec<FunctionLikeParameterMetadata>,
pub return_type_declaration_metadata: Option<TypeMetadata>,
pub return_type_metadata: Option<TypeMetadata>,
pub template_types: TemplateTypes,
pub attributes: Vec<AttributeMetadata>,
pub method_metadata: Option<MethodMetadata>,
pub type_resolution_context: Option<TypeResolutionContext>,
pub thrown_types: Vec<TypeMetadata>,
pub issues: Vec<Issue>,
pub assertions: BTreeMap<Word, Vec<Assertion>>,
pub if_true_assertions: BTreeMap<Word, Vec<Assertion>>,
pub if_false_assertions: BTreeMap<Word, Vec<Assertion>>,
pub assertions_inferred: bool,
pub globals_accessed: WordSet,
pub has_docblock: bool,
pub flags: MetadataFlags,
pub version_constraint: VersionConstraint,
}Fields§
§kind: FunctionLikeKindThe kind of function-like structure this metadata represents.
span: SpanThe source code location (span) covering the entire function/method/closure definition.
For closures/arrow functions, this covers the function(...) { ... } or fn(...) => ... part.
name: WordThe lookup name of the function or method. For named functions and
methods this is the lowercased identifier (PHP-style case-insensitive
lookup); for closures and arrow functions it is the synthetic
{closure:path:line:col} word produced by
crate::build_synthetic_name. Always set.
Example: processrequest, __construct, my_global_func,
{closure:src/foo.php:12:5}.
original_name: WordThe original-case name. Matches the source identifier for named
functions/methods, and matches Self::name verbatim for closures.
name_span: Option<Span>The specific source code location (span) of the function or method name identifier.
None if the function/method has no name (closures/arrow functions).
parameters: Vec<FunctionLikeParameterMetadata>Ordered list of metadata for each parameter defined in the signature.
return_type_declaration_metadata: Option<TypeMetadata>The explicit return type declaration (type hint).
Example: For function getName(): string, this holds metadata for string.
None if no return type is specified.
return_type_metadata: Option<TypeMetadata>The explicit return type declaration (type hint) or docblock type (@return).
Example: For function getName(): string, this holds metadata for string,
or for /** @return string */ function getName() { .. }, this holds metadata for string.
None if neither is specified.
template_types: TemplateTypesGeneric type parameters (templates) defined for the function/method (e.g., @template T).
Stores the template name and its constraint (defining entity and bound type).
Example: { "T" => (GenericParent::FunctionLike(("funcName", "")), TUnion::object()) }
attributes: Vec<AttributeMetadata>Attributes attached to the function/method/closure declaration (#[Attribute] function foo() {}).
method_metadata: Option<MethodMetadata>Specific metadata relevant only to methods (visibility, final, static, etc.).
This is Some if kind is FunctionLikeKind::Method, None otherwise.
type_resolution_context: Option<TypeResolutionContext>Contains context information needed for resolving types within this function’s scope
(e.g., use statements, current namespace, class context). Often populated during analysis.
thrown_types: Vec<TypeMetadata>A list of types that this function/method might throw, derived from @throws docblock tags
or inferred from throw statements within the body.
issues: Vec<Issue>List of issues specifically related to parsing or interpreting this function’s docblock.
assertions: BTreeMap<Word, Vec<Assertion>>Assertions about parameter types or variable types that are guaranteed to be true
after this function/method returns normally. From @psalm-assert, @phpstan-assert, etc.
Maps variable/parameter name to a list of type assertions.
if_true_assertions: BTreeMap<Word, Vec<Assertion>>Assertions about parameter/variable types that are guaranteed to be true if this
function/method returns true. From @psalm-assert-if-true, etc.
if_false_assertions: BTreeMap<Word, Vec<Assertion>>Assertions about parameter/variable types that are guaranteed to be true if this
function/method returns false. From @psalm-assert-if-false, etc.
assertions_inferred: boolSet when the assertions in if_true_assertions / if_false_assertions were
auto-inferred from the body rather than declared explicitly via docblock. The
populator uses this to know it can safely override them with assertions
inherited from a parent method, so explicit contracts on a parent always win.
globals_accessed: WordSetNames of variables this function/method imports from the global scope via a
global $x; statement anywhere in its body. Used by the invocation post-processor
to invalidate caller-side narrowings of those globals on every call, since the
callee can reassign them behind the caller’s back.
has_docblock: boolTracks whether this function/method has a docblock comment. Used to determine if docblock inheritance should occur implicitly.
flags: MetadataFlags§version_constraint: VersionConstraintPHP version range in which this function-like is available, derived
from Mago\AvailableSince / Mago\AvailableUntil attributes during
scanning.
Implementations§
Source§impl FunctionLikeMetadata
Contains comprehensive metadata for any function-like structure in PHP.
impl FunctionLikeMetadata
Contains comprehensive metadata for any function-like structure in PHP.
Sourcepub fn new(
kind: FunctionLikeKind,
name: Word,
original_name: Word,
span: Span,
flags: MetadataFlags,
) -> Self
pub fn new( kind: FunctionLikeKind, name: Word, original_name: Word, span: Span, flags: MetadataFlags, ) -> Self
Creates new FunctionLikeMetadata with basic information and default flags.
Pass the lookup name (lowercased identifier for named functions/methods,
synthetic {closure:...} word for closures) and original_name (source
casing for named items, identical to name for closures).
Sourcepub fn is_available_in_version(&self, version: PHPVersion) -> bool
pub fn is_available_in_version(&self, version: PHPVersion) -> bool
Returns true when this function-like is available in the given PHP
version.
Sourcepub fn is_available_in_version_range(&self, range: PHPVersionRange) -> bool
pub fn is_available_in_version_range(&self, range: PHPVersionRange) -> bool
Returns true when this function-like is available across the entire
supplied PHPVersionRange.
Sourcepub fn get_kind(&self) -> FunctionLikeKind
pub fn get_kind(&self) -> FunctionLikeKind
Returns the kind of function-like (Function, Method, Closure, ArrowFunction).
Sourcepub fn get_parameters_mut(&mut self) -> &mut [FunctionLikeParameterMetadata]
pub fn get_parameters_mut(&mut self) -> &mut [FunctionLikeParameterMetadata]
Returns a mutable slice of the parameter metadata.
Sourcepub fn get_parameter(
&self,
name: Word,
) -> Option<&FunctionLikeParameterMetadata>
pub fn get_parameter( &self, name: Word, ) -> Option<&FunctionLikeParameterMetadata>
Returns a reference to specific parameter metadata by name, if it exists.
Sourcepub fn get_parameter_mut(
&mut self,
name: Word,
) -> Option<&mut FunctionLikeParameterMetadata>
pub fn get_parameter_mut( &mut self, name: Word, ) -> Option<&mut FunctionLikeParameterMetadata>
Returns a mutable reference to specific parameter metadata by name, if it exists.
Sourcepub fn get_template_types_mut(&mut self) -> &mut TemplateTypes
pub fn get_template_types_mut(&mut self) -> &mut TemplateTypes
Returns a mutable reference to the template type parameters.
Sourcepub fn get_attributes(&self) -> &[AttributeMetadata]
pub fn get_attributes(&self) -> &[AttributeMetadata]
Returns a slice of the attributes.
Sourcepub fn get_method_metadata_mut(&mut self) -> Option<&mut MethodMetadata>
pub fn get_method_metadata_mut(&mut self) -> Option<&mut MethodMetadata>
Returns a mutable reference to the method-specific info, if this is a method.
Sourcepub fn take_issues(&mut self) -> Vec<Issue>
pub fn take_issues(&mut self) -> Vec<Issue>
Returns a mutable slice of docblock issues.
Sourcepub fn set_parameters(
&mut self,
parameters: impl IntoIterator<Item = FunctionLikeParameterMetadata>,
)
pub fn set_parameters( &mut self, parameters: impl IntoIterator<Item = FunctionLikeParameterMetadata>, )
Sets the parameters, replacing existing ones.
Sourcepub fn with_parameters(
self,
parameters: impl IntoIterator<Item = FunctionLikeParameterMetadata>,
) -> Self
pub fn with_parameters( self, parameters: impl IntoIterator<Item = FunctionLikeParameterMetadata>, ) -> Self
Returns a new instance with the parameters replaced.
pub fn set_return_type_metadata(&mut self, return_type: Option<TypeMetadata>)
pub fn set_return_type_declaration_metadata( &mut self, return_type: Option<TypeMetadata>, )
Sourcepub fn add_template_type(&mut self, name: Word, constraint: GenericTemplate)
pub fn add_template_type(&mut self, name: Word, constraint: GenericTemplate)
Adds a single template type definition.
Sourcepub fn apply_patch(&mut self, patch: &mut FunctionLikeMetadata)
pub fn apply_patch(&mut self, patch: &mut FunctionLikeMetadata)
Applies a patch to this entry in place, refining type information only.
Refined fields — return type, per-parameter types, @param-out, default-value types,
@throws, @template, and assertions — are each copied only when the patch specifies
them, so a sparsely-typed patch never erases richer existing information. Structural
identity (span, file, kind, parameter count, visibility) is left to whichever non-patch
source declared the symbol. Diagnostics are appended to patch.issues; the full set of
patching rules is documented in the [source] patching guide.
Trait Implementations§
Source§impl Clone for FunctionLikeMetadata
impl Clone for FunctionLikeMetadata
Source§fn clone(&self) -> FunctionLikeMetadata
fn clone(&self) -> FunctionLikeMetadata
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for FunctionLikeMetadata
impl Debug for FunctionLikeMetadata
impl Eq for FunctionLikeMetadata
Source§impl PartialEq for FunctionLikeMetadata
impl PartialEq for FunctionLikeMetadata
Source§fn eq(&self, other: &FunctionLikeMetadata) -> bool
fn eq(&self, other: &FunctionLikeMetadata) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for FunctionLikeMetadata
Auto Trait Implementations§
impl Freeze for FunctionLikeMetadata
impl RefUnwindSafe for FunctionLikeMetadata
impl Send for FunctionLikeMetadata
impl Sync for FunctionLikeMetadata
impl Unpin for FunctionLikeMetadata
impl UnsafeUnpin for FunctionLikeMetadata
impl UnwindSafe for FunctionLikeMetadata
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);