示例#1
0
文件: array.php 项目: mage2pro/core
/**
 * 2016-09-02
 * @uses array_flip() корректно работает с пустыми массивами.
 * @param array(string => mixed) $a
 * @param string[] ...$keys
 * @return array(string => mixed)
 */
function dfa_unset(array $a, ...$keys)
{
    return array_diff_key($a, array_flip(df_args($keys)));
}
示例#2
0
文件: Method.php 项目: mage2pro/core
 /**
  * 2016-09-01
  * @param string[] $a
  * @return void
  */
 public function iiaSetTRR(...$a)
 {
     $a = df_args($a);
     dfp_set_transaction_info($this->ii(), df_clean(['Request' => $a[0], 'Response' => $a[1]]));
 }
示例#3
0
文件: state.php 项目: mage2pro/core
/**
 * 2016-01-07
 * @param string|string[] $name
 * @return string|bool
 */
function df_action_is($name)
{
    /** @var string $actionName */
    $actionName = df_action_name();
    return 1 === func_num_args() ? $actionName === $name : in_array($name, df_args(func_get_args()));
}
示例#4
0
文件: Method.php 项目: mage2pro/core
 /**
  * 2016-08-31
  * @used-by \Df\Payment\R\Refund::url()
  * @param string $url
  * @param bool $test [optional]
  * @param string[] $stageNames
  * @param mixed[] ...$params [optional]
  * @return string
  */
 public final function url2($url, $test = null, array $stageNames, ...$params)
 {
     $test = !is_null($test) ? $test : $this->s()->test();
     /** @var string $stage */
     $stage = call_user_func($test ? 'df_first' : 'df_last', $stageNames);
     return vsprintf(str_replace('{stage}', $stage, $url), df_args($params));
 }
示例#5
0
文件: text.php 项目: mage2pro/core
/**
 * @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);
}