コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function code(int $indentation = 0) : string
 {
     if ($this->isAbstract === true) {
         return $this->buildDefinition() . '(' . $this->buildArguments($this->arguments) . ');';
     } else {
         return parent::code($indentation);
     }
 }
コード例 #2
0
ファイル: Parser.php プロジェクト: nechutny/BP
 /**
  * Parse function declaration
  *
  * function name(args) { body }
  *
  * @throws EndOfFileException
  * @throws ParserError
  */
 protected function parse_function()
 {
     $functionGenerator = new FunctionGenerator();
     $this->check(T_FUNCTION);
     $token = $this->scanner->next();
     if ($token['code'] !== T_STRING) {
         throw new ParserError($token);
     }
     $functionGenerator->setFunctionName($token['value']);
     $varScope = new Scope();
     $codeGenerator = new CodeGenerator(1, $varScope);
     $functionGenerator->setCodeGenerator($codeGenerator);
     $this->check(T_LPARENTHESIS);
     $args = $this->parse_args();
     $functionGenerator->setArguments($args);
     $this->check(T_RPARENTHESIS);
     $this->check(T_LCURLY_PARENTHESIS);
     $this->parse_body($codeGenerator);
     $this->check(T_RCURLY_PARENTHESIS);
     $this->generator->addFunction($functionGenerator);
 }