Nette\Utils\Callback::toString PHP Method

toString() public static method

public static toString ( $callable ) : string
return string
    public static function toString($callable)
    {
        if ($callable instanceof \Closure) {
            $inner = self::unwrap($callable);
            return '{closure' . ($inner instanceof \Closure ? '}' : ' ' . self::toString($inner) . '}');
        } elseif (is_string($callable) && $callable[0] === "") {
            return '{lambda}';
        } else {
            is_callable($callable, TRUE, $textual);
            return $textual;
        }
    }

Usage Example

コード例 #1
0
ファイル: Helpers.php プロジェクト: rostenkowski/nette
 /**
  * @return array
  */
 public static function exportRules(Rules $rules, $json = TRUE)
 {
     $payload = array();
     foreach ($rules as $rule) {
         if (!is_string($op = $rule->validator)) {
             if (!Nette\Utils\Callback::isStatic($op)) {
                 continue;
             }
             $op = Nette\Utils\Callback::toString($op);
         }
         if ($rule->branch) {
             $item = array('op' => ($rule->isNegative ? '~' : '') . $op, 'rules' => static::exportRules($rule->branch, FALSE), 'control' => $rule->control->getHtmlName());
             if ($rule->branch->getToggles()) {
                 $item['toggle'] = $rule->branch->getToggles();
             }
         } else {
             $item = array('op' => ($rule->isNegative ? '~' : '') . $op, 'msg' => Validator::formatMessage($rule, FALSE));
         }
         if (is_array($rule->arg)) {
             foreach ($rule->arg as $key => $value) {
                 $item['arg'][$key] = $value instanceof IControl ? array('control' => $value->getHtmlName()) : $value;
             }
         } elseif ($rule->arg !== NULL) {
             $item['arg'] = $rule->arg instanceof IControl ? array('control' => $rule->arg->getHtmlName()) : $rule->arg;
         }
         $payload[] = $item;
     }
     return $json ? $payload ? Nette\Utils\Json::encode($payload) : NULL : $payload;
 }
All Usage Examples Of Nette\Utils\Callback::toString