function Parser::parseClassElement
Parses a class elements
Return value
Node\MethodDefinition|Node\PropertyDefinition|Node\StaticBlock|bool|null
1 call to Parser::parseClassElement()
- Parser::parseClassElementList in vendor/
mck89/ peast/ lib/ Peast/ Syntax/ Parser.php - Parses class elements list
File
-
vendor/
mck89/ peast/ lib/ Peast/ Syntax/ Parser.php, line 1789
Class
- Parser
- Parser class
Namespace
Peast\SyntaxCode
protected function parseClassElement() {
if ($this->scanner
->consume(";")) {
return true;
}
if ($this->features->classStaticBlock && $this->scanner
->isBefore(array(
array(
"static",
"{",
),
), true)) {
return $this->parseClassStaticBlock();
}
$staticToken = null;
$state = $this->scanner
->getState();
//This code handles the case where "static" is the method name
if (!$this->scanner
->isBefore(array(
array(
"static",
"(",
),
), true)) {
$staticToken = $this->scanner
->consume("static");
}
if ($def = $this->parseMethodDefinition()) {
if ($staticToken) {
$def->setStatic(true);
$def->location->start = $staticToken->location->start;
}
return $def;
}
else {
if ($this->features->classFields) {
if ($field = $this->parseFieldDefinition()) {
if ($staticToken) {
$field->setStatic(true);
$field->location->start = $staticToken->location->start;
}
}
elseif ($staticToken) {
//Handle the case when "static" is the field name
$this->scanner
->setState($state);
$field = $this->parseFieldDefinition();
}
return $field;
}
elseif ($staticToken) {
$this->error();
}
}
return null;
}