__toString() public méthode

public __toString ( ) : string
Résultat string PHP code
Exemple #1
0
 /**
  * @return string
  */
 public function __toString()
 {
     $this->setBody('');
     if (strtolower($this->getName()) === '__construct') {
         $this->addParameter('_kdyby_aopContainer')->setTypeHint('\\Nette\\DI\\Container');
         $this->addBody('$this->_kdyby_aopContainer = $_kdyby_aopContainer;');
     }
     $this->addBody('$__arguments = func_get_args(); $__exception = $__result = NULL;');
     if ($this->before) {
         foreach ($this->before as $before) {
             $this->addBody($before);
         }
     }
     if ($this->afterThrowing || $this->after) {
         $this->addBody('try {');
     }
     if (!$this->around) {
         $parentCall = Code\Helpers::format('$__result = call_user_func_array("parent::?", $__arguments);', $this->getName());
     } else {
         $parentCall = Code\Helpers::format('$__around = new \\Kdyby\\Aop\\JoinPoint\\AroundMethod($this, __FUNCTION__, $__arguments);');
         foreach ($this->around as $around) {
             $parentCall .= "\n" . $around;
         }
         $parentCall .= "\n" . Code\Helpers::format('$__result = $__around->proceed();');
     }
     $this->addBody($this->afterThrowing || $this->after ? Nette\Utils\Strings::indent($parentCall) : $parentCall);
     if ($this->afterThrowing || $this->after) {
         $this->addBody('} catch (\\Exception $__exception) {');
     }
     if ($this->afterThrowing) {
         foreach ($this->afterThrowing as $afterThrowing) {
             $this->addBody(Nette\Utils\Strings::indent($afterThrowing));
         }
     }
     if ($this->afterThrowing || $this->after) {
         $this->addBody('}');
     }
     if ($this->afterReturning) {
         if ($this->afterThrowing || $this->after) {
             $this->addBody('if (empty($__exception)) {');
         }
         foreach ($this->afterReturning as $afterReturning) {
             $this->addBody($this->afterThrowing || $this->after ? Nette\Utils\Strings::indent($afterReturning) : $afterReturning);
         }
         if ($this->afterThrowing || $this->after) {
             $this->addBody('}');
         }
     }
     if ($this->after) {
         foreach ($this->after as $after) {
             $this->addBody($after);
         }
     }
     if ($this->afterThrowing || $this->after) {
         $this->addBody('if ($__exception) { throw $__exception; }');
     }
     $this->addBody('return $__result;');
     return parent::__toString();
 }