pub struct PropertyMetadata {Show 18 fields
pub name: VariableIdentifier,
pub name_span: Option<Span>,
pub span: Option<Span>,
pub read_visibility: Visibility,
pub write_visibility: Visibility,
pub type_declaration_metadata: Option<TypeMetadata>,
pub type_metadata: Option<TypeMetadata>,
pub default_type_metadata: Option<TypeMetadata>,
pub is_readonly: bool,
pub has_default: bool,
pub is_promoted: bool,
pub is_internal: bool,
pub is_static: bool,
pub is_abstract: bool,
pub is_deprecated: bool,
pub is_virtual: bool,
pub is_asymmetric: bool,
pub allow_private_mutation: bool,
}Expand description
Contains metadata associated with a declared class property in PHP.
This includes information about its name, location, visibility (potentially asymmetric),
type hints, default values, and various modifiers (static, readonly, abstract, etc.).
Fields§
§name: VariableIdentifierThe identifier (name) of the property, including the leading ‘$’.
name_span: Option<Span>The specific source code location (span) of the property’s name identifier itself.
None if the location is unknown or not relevant (e.g., for synthetic properties).
span: Option<Span>The source code location (span) covering the entire property declaration statement.
None if the location is unknown or not relevant.
read_visibility: VisibilityThe visibility level required for reading the property’s value.
In PHP, this corresponds to the primary visibility keyword specified
(e.g., the public in public private(set) string $prop;).
If no asymmetric visibility is specified (e.g., public string $prop),
this level applies to both reading and writing. Defaults to Public.
write_visibility: VisibilityThe visibility level required for writing/modifying the property’s value.
In PHP, this can differ from read_visibility using asymmetric visibility syntax
like private(set) (e.g., public private(set) string $prop;).
If asymmetric visibility is not used, this implicitly matches read_visibility.
Defaults to Public.
type_declaration_metadata: Option<TypeMetadata>The explicit type declaration (type hint) associated with the property, if any.
e.g., for public string $name;, this would contain the metadata for string.
type_metadata: Option<TypeMetadata>The type metadata for the property’s type, if any.
This is either the same as type_declaration_metadata or the type provided
in a docblock comment (e.g., @var string).
default_type_metadata: Option<TypeMetadata>The type inferred from the property’s default value, if it has one.
e.g., for public $count = 0;, this would contain the metadata for int(0).
This can be used to compare against type_signature for consistency checks.
is_readonly: booltrue if the property is declared with the readonly modifier.
has_default: booltrue if the property is declared with a default value (e.g., = null, = 10).
is_promoted: booltrue if this property originates from constructor property promotion.
is_internal: booltrue if the property is marked as internal, typically via a docblock tag like @internal.
Indicates it’s not intended for use outside the defining class or library.
is_static: booltrue if the property is declared with the static modifier.
is_abstract: booltrue if this property represents an abstract property requirement.
is_deprecated: booltrue if the property is marked as deprecated, typically via @deprecated docblock tag.
is_virtual: booltrue if the property uses PHP’s Property Hooks feature.
Such properties have custom get and/or set logic instead of direct storage,
making them behave like “virtual” properties.
Note: Properties with hooks cannot have asymmetric visibility (is_asymmetric must be false).
is_asymmetric: booltrue if read_visibility and write_visibility are different,
indicating that PHP’s asymmetric visibility syntax (e.g., public private(set)) was used.
Must be false if is_virtual is true.
allow_private_mutation: booltrue if the property allows private mutation.
Implementations§
Source§impl PropertyMetadata
impl PropertyMetadata
Sourcepub fn new(name: VariableIdentifier) -> Self
pub fn new(name: VariableIdentifier) -> Self
Creates new PropertyMetadata with basic defaults (public, non-static, non-readonly, etc.).
Name is mandatory. Spans, types, and flags can be set using modifier methods.
pub fn set_default_type_metadata( &mut self, default_type_metadata: Option<TypeMetadata>, )
pub fn set_type_declaration_metadata( &mut self, type_declaration_metadata: Option<TypeMetadata>, )
pub fn set_type_metadata(&mut self, type_metadata: Option<TypeMetadata>)
Sourcepub fn get_name(&self) -> &VariableIdentifier
pub fn get_name(&self) -> &VariableIdentifier
Returns a reference to the property’s name identifier.
Sourcepub fn has_default(&self) -> bool
pub fn has_default(&self) -> bool
Checks if the property is declared with a default value.
Sourcepub fn is_final(&self) -> bool
pub fn is_final(&self) -> bool
Checks if the property is effectively final (private read or write access).
Sourcepub fn set_name_span(&mut self, name_span: Option<Span>)
pub fn set_name_span(&mut self, name_span: Option<Span>)
Sets the span for the property name identifier.
Sourcepub fn set_span(&mut self, span: Option<Span>)
pub fn set_span(&mut self, span: Option<Span>)
Sets the overall span for the property declaration.
Sourcepub fn set_visibility(&mut self, read: Visibility, write: Visibility)
pub fn set_visibility(&mut self, read: Visibility, write: Visibility)
Sets both read and write visibility levels. Updates is_asymmetric. Ensures virtual properties remain symmetric.
Sourcepub fn set_is_readonly(&mut self, is_readonly: bool)
pub fn set_is_readonly(&mut self, is_readonly: bool)
Sets whether the property is readonly.
Sourcepub fn set_allow_private_mutation(&mut self, allow_private_mutation: bool)
pub fn set_allow_private_mutation(&mut self, allow_private_mutation: bool)
Sets whether the property allows private mutation.
Sourcepub fn set_has_default(&mut self, has_default: bool)
pub fn set_has_default(&mut self, has_default: bool)
Sets whether the property has a default value.
Sourcepub fn set_is_promoted(&mut self, is_promoted: bool)
pub fn set_is_promoted(&mut self, is_promoted: bool)
Sets whether the property originates from constructor promotion.
Sourcepub fn set_is_internal(&mut self, is_internal: bool)
pub fn set_is_internal(&mut self, is_internal: bool)
Sets whether the property is marked @internal.
Sourcepub fn set_is_static(&mut self, is_static: bool)
pub fn set_is_static(&mut self, is_static: bool)
Sets whether the property is static.
Sourcepub fn set_is_abstract(&mut self, is_abstract: bool)
pub fn set_is_abstract(&mut self, is_abstract: bool)
Sets whether the property represents an abstract requirement.
Sourcepub fn set_is_deprecated(&mut self, is_deprecated: bool)
pub fn set_is_deprecated(&mut self, is_deprecated: bool)
Sets whether the property is marked @deprecated.
Sourcepub fn set_is_virtual(&mut self, is_virtual: bool)
pub fn set_is_virtual(&mut self, is_virtual: bool)
Sets whether the property uses property hooks. Updates is_asymmetric.
Trait Implementations§
Source§impl Clone for PropertyMetadata
impl Clone for PropertyMetadata
Source§fn clone(&self) -> PropertyMetadata
fn clone(&self) -> PropertyMetadata
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PropertyMetadata
impl Debug for PropertyMetadata
Source§impl<'de> Deserialize<'de> for PropertyMetadata
impl<'de> Deserialize<'de> for PropertyMetadata
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 Hash for PropertyMetadata
impl Hash for PropertyMetadata
Source§impl PartialEq for PropertyMetadata
impl PartialEq for PropertyMetadata
Source§impl Serialize for PropertyMetadata
impl Serialize for PropertyMetadata
impl Eq for PropertyMetadata
impl StructuralPartialEq for PropertyMetadata
Auto Trait Implementations§
impl Freeze for PropertyMetadata
impl RefUnwindSafe for PropertyMetadata
impl Send for PropertyMetadata
impl Sync for PropertyMetadata
impl Unpin for PropertyMetadata
impl UnwindSafe for PropertyMetadata
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§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);