mirror of
https://github.com/typecho/typecho.git
synced 2025-03-18 17:09:41 +01:00
remove func_get_args
This commit is contained in:
parent
4b97110087
commit
954e710013
@ -14,16 +14,17 @@ define('__TYPECHO_MB_SUPPORTED__', function_exists('mb_get_info') && function_ex
|
||||
/**
|
||||
* I18n function
|
||||
*
|
||||
* @param string $string 需要翻译的文字
|
||||
* @param ...$args 需要翻译的文字
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function _t($string)
|
||||
function _t(...$args)
|
||||
{
|
||||
if (func_num_args() <= 1) {
|
||||
[$string] = $args;
|
||||
|
||||
if (count($args) <= 1) {
|
||||
return Typecho_I18n::translate($string);
|
||||
} else {
|
||||
$args = func_get_args();
|
||||
array_shift($args);
|
||||
return vsprintf(Typecho_I18n::translate($string), $args);
|
||||
}
|
||||
@ -32,13 +33,12 @@ function _t($string)
|
||||
/**
|
||||
* I18n function, translate and echo
|
||||
*
|
||||
* @param string $string 需要翻译并输出的文字
|
||||
* @param ...$args 需要翻译的文字
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function _e()
|
||||
function _e(...$args)
|
||||
{
|
||||
$args = func_get_args();
|
||||
echo call_user_func_array('_t', $args);
|
||||
}
|
||||
|
||||
|
@ -277,20 +277,18 @@ class Typecho_Db_Query
|
||||
/**
|
||||
* OR条件查询语句
|
||||
*
|
||||
* @param string $condition 查询条件
|
||||
* @param mixed $param 条件值
|
||||
* @param ...$args
|
||||
* @return Typecho_Db_Query
|
||||
*/
|
||||
public function orWhere()
|
||||
public function orWhere(...$args)
|
||||
{
|
||||
$condition = func_get_arg(0);
|
||||
[$condition] = $args;
|
||||
$condition = str_replace('?', "%s", $this->filterColumn($condition));
|
||||
$operator = empty($this->_sqlPreBuild['where']) ? ' WHERE ' : ' OR';
|
||||
|
||||
if (func_num_args() <= 1) {
|
||||
$this->_sqlPreBuild['where'] .= $operator . ' (' . $condition . ')';
|
||||
} else {
|
||||
$args = func_get_args();
|
||||
array_shift($args);
|
||||
$this->_sqlPreBuild['where'] .= $operator . ' (' . vsprintf($condition, $this->quoteValues($args)) . ')';
|
||||
}
|
||||
@ -422,14 +420,12 @@ class Typecho_Db_Query
|
||||
/**
|
||||
* 选择查询字段
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $field 查询字段
|
||||
* @return Typecho_Db_Query
|
||||
* @param mixed ...$args 查询字段
|
||||
* @return $this
|
||||
*/
|
||||
public function select($field = '*')
|
||||
public function select(...$args): Typecho_Db_Query
|
||||
{
|
||||
$this->_sqlPreBuild['action'] = Typecho_Db::SELECT;
|
||||
$args = func_get_args();
|
||||
|
||||
$this->_sqlPreBuild['fields'] = $this->getColumnFromParameters($args);
|
||||
return $this;
|
||||
|
@ -290,13 +290,12 @@ abstract class Typecho_Widget
|
||||
/**
|
||||
* 根据余数输出
|
||||
*
|
||||
* @access public
|
||||
* @param mixed ...$args
|
||||
* @return void
|
||||
*/
|
||||
public function alt()
|
||||
public function alt(...$args)
|
||||
{
|
||||
$args = func_get_args();
|
||||
$num = func_num_args();
|
||||
$num = count($args);
|
||||
$split = $this->sequence % $num;
|
||||
echo $args[(0 == $split ? $num : $split) - 1];
|
||||
}
|
||||
|
@ -592,28 +592,26 @@ class Widget_Abstract_Contents extends Widget_Abstract
|
||||
/**
|
||||
* 输出文章评论数
|
||||
*
|
||||
* @access public
|
||||
* @param ...$args
|
||||
*/
|
||||
public function commentsNum()
|
||||
public function commentsNum(...$args)
|
||||
{
|
||||
$args = func_get_args();
|
||||
if (!$args) {
|
||||
if (empty($args)) {
|
||||
$args[] = '%d';
|
||||
}
|
||||
|
||||
$num = intval($this->commentsNum);
|
||||
|
||||
echo sprintf(isset($args[$num]) ? $args[$num] : array_pop($args), $num);
|
||||
echo sprintf($args[$num] ?? array_pop($args), $num);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文章权限
|
||||
*
|
||||
* @access public
|
||||
* @param ...$permissions
|
||||
*/
|
||||
public function allow()
|
||||
public function allow(...$permissions): bool
|
||||
{
|
||||
$permissions = func_get_args();
|
||||
$allow = true;
|
||||
|
||||
foreach ($permissions as $permission) {
|
||||
|
@ -350,14 +350,11 @@ class Widget_Comments_Archive extends Widget_Abstract_Comments
|
||||
/**
|
||||
* 根据深度余数输出
|
||||
*
|
||||
* @access public
|
||||
* @param string $param 需要输出的值
|
||||
* @return void
|
||||
* @param ...$args 需要输出的值
|
||||
*/
|
||||
public function levelsAlt()
|
||||
public function levelsAlt(...$args)
|
||||
{
|
||||
$args = func_get_args();
|
||||
$num = func_num_args();
|
||||
$num = count($args);
|
||||
$split = $this->levels % $num;
|
||||
echo $args[(0 == $split ? $num : $split) - 1];
|
||||
}
|
||||
@ -365,13 +362,11 @@ class Widget_Comments_Archive extends Widget_Abstract_Comments
|
||||
/**
|
||||
* 重载alt函数,以适应多级评论
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
* @param ...$args
|
||||
*/
|
||||
public function alt()
|
||||
public function alt(...$args)
|
||||
{
|
||||
$args = func_get_args();
|
||||
$num = func_num_args();
|
||||
$num = count($args);
|
||||
|
||||
$sequence = $this->levels <= 0 ? $this->sequence : $this->order;
|
||||
|
||||
|
@ -51,18 +51,15 @@ class Widget_Comments_Ping extends Widget_Abstract_Comments
|
||||
/**
|
||||
* 输出文章回响数
|
||||
*
|
||||
* @access public
|
||||
* @param string $string 评论数格式化数据
|
||||
* @return void
|
||||
* @param ...$args 评论数格式化数据
|
||||
*/
|
||||
public function num()
|
||||
public function num(...$args)
|
||||
{
|
||||
$args = func_get_args();
|
||||
if (!$args) {
|
||||
if (empty($args)) {
|
||||
$args[] = '%d';
|
||||
}
|
||||
|
||||
echo sprintf($args[$this->length] ?? array_pop($this->length), $this->length);
|
||||
echo sprintf($args[$this->length] ?? array_pop($args), $this->length);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -61,11 +61,12 @@ class Widget_Contents_Post_Edit extends Widget_Abstract_Contents implements Widg
|
||||
/**
|
||||
* 获取文章权限
|
||||
*
|
||||
* @param mixed ...$permissions
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function allow()
|
||||
public function allow(...$permissions): bool
|
||||
{
|
||||
$permissions = func_get_args();
|
||||
$allow = true;
|
||||
|
||||
foreach ($permissions as $permission) {
|
||||
|
@ -257,13 +257,11 @@ class Widget_Metas_Category_List extends Widget_Abstract_Metas
|
||||
/**
|
||||
* 根据深度余数输出
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
* @param ...$args
|
||||
*/
|
||||
public function levelsAlt()
|
||||
public function levelsAlt(...$args)
|
||||
{
|
||||
$args = func_get_args();
|
||||
$num = func_num_args();
|
||||
$num = count($args);
|
||||
$split = $this->levels % $num;
|
||||
echo $args[(0 == $split ? $num : $split) - 1];
|
||||
}
|
||||
|
@ -48,13 +48,10 @@ class Widget_Metas_Tag_Cloud extends Widget_Abstract_Metas
|
||||
/**
|
||||
* 按分割数输出字符串
|
||||
*
|
||||
* @access public
|
||||
* @param string $param 需要输出的值
|
||||
* @return void
|
||||
* @param ...$args 需要输出的值
|
||||
*/
|
||||
public function split()
|
||||
public function split(...$args)
|
||||
{
|
||||
$args = func_get_args();
|
||||
array_unshift($args, $this->count);
|
||||
echo call_user_func_array(['Typecho_Common', 'splitByCount'], $args);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user