pub struct FunctionLikeMetadata {Show 18 fields
pub kind: FunctionLikeKind,
pub span: Span,
pub name: Option<Atom>,
pub original_name: Option<Atom>,
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: Vec<TemplateTuple>,
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<Atom, Vec<Assertion>>,
pub if_true_assertions: BTreeMap<Atom, Vec<Assertion>>,
pub if_false_assertions: BTreeMap<Atom, Vec<Assertion>>,
pub flags: MetadataFlags,
}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: Option<Atom>The name of the function or method, lowercased, if applicable.
None for closures and arrow functions unless assigned to a variable later.
Example: processRequest, __construct, my_global_func.
original_name: Option<Atom>The original name of the function or method, in its original case.
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: Vec<TemplateTuple>Generic type parameters (templates) defined for the function/method (e.g., @template T).
Stores the template name and its constraints (parent type and bound type).
Example: [("T", [(GenericParent::Function("funcName"), Arc<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<Atom, 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<Atom, 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<Atom, 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.
flags: MetadataFlagsImplementations§
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, span: Span, flags: MetadataFlags) -> Self
pub fn new(kind: FunctionLikeKind, span: Span, flags: MetadataFlags) -> Self
Creates new FunctionLikeMetadata with basic information and default flags.
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: Atom,
) -> Option<&FunctionLikeParameterMetadata>
pub fn get_parameter( &self, name: Atom, ) -> Option<&FunctionLikeParameterMetadata>
Returns a reference to specific parameter metadata by name, if it exists.
Sourcepub fn get_parameter_mut(
&mut self,
name: Atom,
) -> Option<&mut FunctionLikeParameterMetadata>
pub fn get_parameter_mut( &mut self, name: Atom, ) -> 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 [TemplateTuple] ⓘ
pub fn get_template_types_mut(&mut self) -> &mut [TemplateTuple] ⓘ
Returns a mutable slice of 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, template: TemplateTuple)
pub fn add_template_type(&mut self, template: TemplateTuple)
Adds a single template type definition.
Trait Implementations§
Source§impl Clone for FunctionLikeMetadata
impl Clone for FunctionLikeMetadata
Source§fn clone(&self) -> FunctionLikeMetadata
fn clone(&self) -> FunctionLikeMetadata
1.0.0 · 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
Source§impl<'de> Deserialize<'de> for FunctionLikeMetadata
impl<'de> Deserialize<'de> for FunctionLikeMetadata
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for FunctionLikeMetadata
impl PartialEq for FunctionLikeMetadata
Source§impl Serialize for FunctionLikeMetadata
impl Serialize for FunctionLikeMetadata
impl Eq for FunctionLikeMetadata
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 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§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>
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);