use mago_span::HasSpan;
use mago_span::Span;
use mago_word::Word;
use crate::metadata::attribute::AttributeMetadata;
use crate::metadata::flags::MetadataFlags;
use crate::metadata::version_constraint::VersionConstraint;
use crate::ttype::atomic::TAtomic;
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[non_exhaustive]
pub struct EnumCaseMetadata {
pub attributes: Vec<AttributeMetadata>,
pub name: Word,
pub name_span: Span,
pub span: Span,
pub value_type: Option<TAtomic>,
pub flags: MetadataFlags,
pub version_constraint: VersionConstraint,
}
impl EnumCaseMetadata {
#[inline]
#[must_use]
pub fn new(name: Word, name_span: Span, span: Span, flags: MetadataFlags) -> Self {
Self {
attributes: Vec::new(),
name,
name_span,
span,
flags,
value_type: None,
version_constraint: VersionConstraint::unconstrained(),
}
}
#[inline]
#[must_use]
pub fn is_available_in_version(&self, version: mago_php_version::PHPVersion) -> bool {
self.version_constraint.allows_version(version)
}
#[inline]
#[must_use]
pub fn is_available_in_version_range(&self, range: mago_php_version::PHPVersionRange) -> bool {
self.version_constraint.allows_version_range(range)
}
}
impl HasSpan for EnumCaseMetadata {
fn span(&self) -> Span {
self.span
}
}