From 4b9711008731286b613dd324f63968a16134e338 Mon Sep 17 00:00:00 2001 From: joyqi Date: Wed, 18 Aug 2021 22:55:32 +0800 Subject: [PATCH] fix stack --- var/Typecho/Validate.php | 4 ++-- var/Typecho/Widget.php | 8 ++++++-- var/Widget/Comments/Archive.php | 9 +++------ 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/var/Typecho/Validate.php b/var/Typecho/Validate.php index 3b967208..9fcf269c 100644 --- a/var/Typecho/Validate.php +++ b/var/Typecho/Validate.php @@ -239,12 +239,12 @@ class Typecho_Validate * @access public * * @param string $key 数值键值 - * @param string $rule 规则名称 + * @param string|array $rule 规则名称 * @param string $message 错误字符串 * * @return $this */ - public function addRule(string $key, string $rule, string $message): Typecho_Validate + public function addRule(string $key, $rule, string $message): Typecho_Validate { if (func_num_args() <= 3) { $this->_rules[$key][] = [$rule, $message]; diff --git a/var/Typecho/Widget.php b/var/Typecho/Widget.php index ad036df9..3defa99f 100644 --- a/var/Typecho/Widget.php +++ b/var/Typecho/Widget.php @@ -255,10 +255,14 @@ abstract class Typecho_Widget */ public function next() { - if ($this->sequence < count($this->stack)) { - $this->row = $this->stack[$this->sequence]; + $key = key($this->stack); + + if ($key !== null && isset($this->stack[$key])) { + $this->row = current($this->stack); + next($this->stack); $this->sequence ++; } else { + reset($this->stack); $this->sequence = 0; return false; } diff --git a/var/Widget/Comments/Archive.php b/var/Widget/Comments/Archive.php index 25c481e1..5618a459 100644 --- a/var/Widget/Comments/Archive.php +++ b/var/Widget/Comments/Archive.php @@ -70,14 +70,11 @@ class Widget_Comments_Archive 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'; }