public function postCloseCurlyBrace(BlockEvent $event)
 {
     $block = $event->getBlock();
     $token = $event->getToken();
     $nextToken = $this->parser->getTracker()->nextToken($token);
     // check new line before T_ELSE and T_ELSEIF
     if (in_array($block->type, [Block::TYPE_IF, Block::TYPE_ELSEIF]) && in_array($nextToken->type, [T_ELSE, T_ELSEIF])) {
         $this->newlineOrSpaceAfterCurly($this->config->getNewline('elseif_else'));
     } else {
         if ($this->nextToken->type == T_CATCH) {
             $this->newlineOrSpaceAfterCurly($this->config->getNewline('catch'));
         } else {
             if ($token->contents == 'finally') {
                 $this->newlineOrSpaceAfterCurly($this->config->getNewline('finally'));
             } else {
                 if ($block->type == Block::TYPE_DO && $nextToken->type == T_WHILE) {
                     $this->newlineOrSpaceAfterCurly($this->config->getNewline('do_while'));
                 } else {
                     $this->defaultFormatter->addPostWriteln();
                 }
             }
         }
     }
 }
예제 #2
0
 public function onBlockClosed(BlockEvent $event)
 {
     $block = $event->getBlock();
     if ($block->type == Block::TYPE_USE || $block->type == Block::TYPE_NAMESPACE) {
         $this->detectedUnit = $block->start;
         $this->detectedUnitType = $block->type;
         $this->flushDetection($event->getToken());
     }
 }