/** * @param mixed $v * @param bool $allow0 [optional] * @return int * @throws DFE */ function df_nat($v, $allow0 = false) { /** @var int $result */ $result = df_int($v, $allow0); if ($allow0) { df_assert_ge(0, $result); } else { df_assert_gt0($result); } return $result; }
/** @return void */ public static function restore() { array_pop(self::$_stack); df_assert_gt0(count(self::$_stack)); }
/** * @param mixed[] $args * @return string */ function df_format(...$args) { $args = df_args($args); /** @var string $result */ $result = null; /** @var int $count */ $count = count($args); df_assert_gt0($count); switch ($count) { case 1: $result = $args[0]; break; case 2: /** @var mixed $params */ $params = $args[1]; if (is_array($params)) { $result = strtr($args[0], $params); } break; } return !is_null($result) ? $result : df_sprintf($args); }