openScope() public method

public openScope ( )
示例#1
0
文件: TryStmt.php 项目: quack/quack
 public function format(Parser $parser)
 {
     $source = 'try';
     $source .= PHP_EOL;
     $parser->openScope();
     $source .= $this->try->format($parser);
     $parser->closeScope();
     foreach ($this->rescues as $rescue) {
         $obj = (object) $rescue;
         $source .= $parser->indent();
         $source .= 'rescue (';
         $source .= implode('.', $obj->exception_class);
         $source .= ' ';
         $source .= $obj->variable;
         $source .= ')';
         $source .= PHP_EOL;
         $parser->openScope();
         $source .= $obj->body->format($parser);
         $parser->closeScope();
     }
     if (null !== $this->finally) {
         $source .= $parser->indent();
         $source .= 'finally ';
         $source .= PHP_EOL;
         $parser->openScope();
         $source .= $this->finally->format($parser);
         $parser->closeScope();
     }
     $source .= $parser->indent();
     $source .= 'end';
     $source .= PHP_EOL;
     return $source;
 }
示例#2
0
文件: WhenExpr.php 项目: quack/quack
 public function format(Parser $parser)
 {
     $source = 'when';
     $source .= PHP_EOL;
     $parser->openScope();
     for ($i = 0, $l = sizeof($this->cases); $i < $l; $i++) {
         $obj = $this->cases[$i];
         $source .= $parser->indent();
         $source .= '| ';
         if (null !== $obj->condition) {
             $source .= $obj->condition->format($parser);
             $source .= ' -> ';
         } else {
             $source .= 'else ';
         }
         $source .= $obj->action->format($parser);
         if ($i + 1 !== $l) {
             $source .= ';';
             $source .= PHP_EOL;
         }
     }
     $parser->closeScope();
     $source .= PHP_EOL;
     $source .= $parser->indent();
     $source .= 'end';
     return $this->parenthesize($source);
 }
示例#3
0
文件: BlockExpr.php 项目: quack/quack
 public function format(Parser $parser)
 {
     $source = '&{';
     if (sizeof($this->body->stmt_list) > 0) {
         $source .= PHP_EOL;
         $parser->openScope();
         $source .= $this->body->format($parser);
         $parser->closeScope();
         $source .= $parser->indent();
     }
     $source .= '}';
     return $this->parenthesize($source);
 }
示例#4
0
文件: BlockStmt.php 项目: quack/quack
 public function format(Parser $parser)
 {
     $source = 'begin';
     $source .= PHP_EOL;
     $parser->openScope();
     foreach ($this->stmt_list as $stmt) {
         $source .= $parser->indent();
         $source .= $stmt->format($parser);
     }
     $parser->closeScope();
     $source .= $parser->indent();
     $source .= 'end';
     $source .= PHP_EOL;
     return $source;
 }
示例#5
0
文件: ShapeStmt.php 项目: quack/quack
 public function format(Parser $parser)
 {
     $source = 'shape ';
     $source .= $this->name;
     $source .= PHP_EOL;
     $parser->openScope();
     foreach ($this->members as $member) {
         $source .= $parser->indent();
         $source .= $member;
         $source .= PHP_EOL;
     }
     $parser->closeScope();
     $source .= $parser->indent();
     $source .= 'end';
     $source .= PHP_EOL;
     return $source;
 }
示例#6
0
文件: EnumStmt.php 项目: quack/quack
 public function format(Parser $parser)
 {
     $source = 'enum ';
     $source .= $this->name;
     $source .= PHP_EOL;
     $parser->openScope();
     foreach ($this->entries as $entry) {
         $source .= $parser->indent();
         $source .= $entry;
         $source .= PHP_EOL;
     }
     $parser->closeScope();
     $source .= $parser->indent();
     $source .= 'end';
     $source .= PHP_EOL;
     return $source;
 }
示例#7
0
文件: ImplStmt.php 项目: quack/quack
 public function format(Parser $parser)
 {
     $source = 'impl ';
     $source .= $this->formatQualifiedName($this->class_or_shape);
     if (Tag::T_CLASS === $this->type) {
         $source .= ' for ';
         $source .= $this->formatQualifiedName($this->class_for);
     }
     $source .= PHP_EOL;
     $parser->openScope();
     $source .= $this->body->format($parser);
     $parser->closeScope();
     $source .= $parser->indent();
     $source .= 'end';
     $source .= PHP_EOL;
     return $source;
 }
示例#8
0
 public function format(Parser $parser)
 {
     $source = '@{';
     $keys =& $this->keys;
     $values =& $this->values;
     if (sizeof($this->keys) > 0) {
         $source .= PHP_EOL;
         $parser->openScope();
         // Iterate based on index
         $source .= implode(';' . PHP_EOL, array_map(function ($index) use(&$keys, &$values, $parser) {
             $subsource = $parser->indent();
             $subsource .= $keys[$index];
             $subsource .= ' -> ';
             $subsource .= $values[$index]->format($parser);
             return $subsource;
         }, range(0, sizeof($keys) - 1)));
         $parser->closeScope();
         $source .= PHP_EOL;
         $source .= $parser->indent();
     }
     $source .= '}';
     return $this->parenthesize($source);
 }