mirror of
https://github.com/danog/parser.git
synced 2024-11-27 04:14:55 +01:00
parser: add special Type::Void case
This commit is contained in:
parent
c4fdc85d64
commit
9953be3ab1
@ -10,6 +10,7 @@ pub enum Type {
|
||||
Nullable(String),
|
||||
Union(Vec<String>),
|
||||
Intersection(Vec<String>),
|
||||
Void,
|
||||
}
|
||||
|
||||
#[derive(Debug, Eq, PartialEq, Clone, Serialize)]
|
||||
|
@ -159,7 +159,10 @@ impl Parser {
|
||||
return Ok(Type::Intersection(types));
|
||||
}
|
||||
|
||||
Ok(Type::Plain(id))
|
||||
Ok(match id.as_str() {
|
||||
"void" => Type::Void,
|
||||
_ => Type::Plain(id),
|
||||
})
|
||||
}
|
||||
|
||||
fn statement(&mut self) -> ParseResult<Statement> {
|
||||
@ -2929,6 +2932,16 @@ mod tests {
|
||||
return_type: Some(Type::Plain("string".into())),
|
||||
}],
|
||||
);
|
||||
|
||||
assert_ast(
|
||||
"<?php function foo(): void {}",
|
||||
&[Statement::Function {
|
||||
name: "foo".to_string().into(),
|
||||
params: vec![],
|
||||
body: vec![],
|
||||
return_type: Some(Type::Void),
|
||||
}],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
Loading…
Reference in New Issue
Block a user