Enum php_parser_rs::parser::ast::modifiers::MethodModifier
source · pub enum MethodModifier {
Final(Span),
Static(Span),
Abstract(Span),
Public(Span),
Protected(Span),
Private(Span),
}
Variants§
Implementations§
source§impl MethodModifier
impl MethodModifier
sourcepub fn span(&self) -> Span
pub fn span(&self) -> Span
Examples found in repository?
src/parser/internal/classes.rs (line 197)
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225
fn member(state: &mut State, abstract_class: bool, class_name: &str) -> ParseResult<ClassMember> {
let has_attributes = attributes::gather_attributes(state)?;
if !has_attributes && state.stream.current().kind == TokenKind::Use {
return traits::usage(state).map(ClassMember::TraitUsage);
}
if state.stream.current().kind == TokenKind::Var {
return properties::parse_var(state, class_name).map(ClassMember::VariableProperty);
}
let modifiers = modifiers::collect(state)?;
if state.stream.current().kind == TokenKind::Const {
return classish(state, modifiers::constant_group(modifiers)?).map(ClassMember::Constant);
}
if state.stream.current().kind == TokenKind::Function {
let method = method(
state,
MethodType::DependingOnModifiers,
modifiers::method_group(modifiers)?,
class_name,
)?;
match method {
Method::Abstract(method) => {
if !abstract_class {
return Err(ParseError::AbstractModifierOnNonAbstractClassMethod(
method.modifiers.get_abstract().unwrap().span(),
));
}
return Ok(ClassMember::AbstractMethod(method));
}
Method::Concrete(method) => {
return Ok(ClassMember::ConcreteMethod(method));
}
Method::AbstractConstructor(ctor) => {
if !abstract_class {
return Err(ParseError::AbstractModifierOnNonAbstractClassMethod(
ctor.modifiers.get_abstract().unwrap().span(),
));
}
return Ok(ClassMember::AbstractConstructor(ctor));
}
Method::ConcreteConstructor(ctor) => {
return Ok(ClassMember::ConcreteConstructor(ctor));
}
}
}
// e.g: public static
let modifiers = modifiers::property_group(modifiers)?;
properties::parse(state, class_name, modifiers).map(ClassMember::Property)
}
Trait Implementations§
source§impl Clone for MethodModifier
impl Clone for MethodModifier
source§fn clone(&self) -> MethodModifier
fn clone(&self) -> MethodModifier
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for MethodModifier
impl Debug for MethodModifier
source§impl<'de> Deserialize<'de> for MethodModifier
impl<'de> Deserialize<'de> for MethodModifier
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>,
Deserialize this value from the given Serde deserializer. Read more
source§impl JsonSchema for MethodModifier
impl JsonSchema for MethodModifier
source§fn schema_name() -> String
fn schema_name() -> String
The name of the generated JSON Schema. Read more
source§fn json_schema(gen: &mut SchemaGenerator) -> Schema
fn json_schema(gen: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
Whether JSON Schemas generated for this type should be re-used where possible using the
$ref
keyword. Read moresource§impl PartialEq<MethodModifier> for MethodModifier
impl PartialEq<MethodModifier> for MethodModifier
source§fn eq(&self, other: &MethodModifier) -> bool
fn eq(&self, other: &MethodModifier) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.