|
@@ -13,6 +13,8 @@
|
|
|
// | github 仓库地址 :https://github.com/zoujingli/ThinkLibrary
|
|
|
// +----------------------------------------------------------------------
|
|
|
|
|
|
+declare (strict_types=1);
|
|
|
+
|
|
|
namespace think\admin;
|
|
|
|
|
|
use think\admin\helper\DeleteHelper;
|
|
@@ -98,7 +100,7 @@ abstract class Controller extends \stdClass
|
|
|
* @param mixed $data 返回数据
|
|
|
* @param integer $code 返回代码
|
|
|
*/
|
|
|
- public function error($info, $data = '{-null-}', $code = 0)
|
|
|
+ public function error($info, $data = '{-null-}', $code = 0): void
|
|
|
{
|
|
|
if ($data === '{-null-}') $data = new \stdClass();
|
|
|
throw new HttpResponseException(json([
|
|
@@ -112,7 +114,7 @@ abstract class Controller extends \stdClass
|
|
|
* @param mixed $data 返回数据
|
|
|
* @param integer $code 返回代码
|
|
|
*/
|
|
|
- public function success($info, $data = '{-null-}', $code = 1)
|
|
|
+ public function success($info, $data = '{-null-}', $code = 1): void
|
|
|
{
|
|
|
if ($this->csrf_state) {
|
|
|
TokenHelper::instance()->clear();
|
|
@@ -128,7 +130,7 @@ abstract class Controller extends \stdClass
|
|
|
* @param string $url 跳转链接
|
|
|
* @param integer $code 跳转代码
|
|
|
*/
|
|
|
- public function redirect($url, $code = 301)
|
|
|
+ public function redirect(string $url, $code = 301): void
|
|
|
{
|
|
|
throw new HttpResponseException(redirect($url, $code));
|
|
|
}
|
|
@@ -137,9 +139,9 @@ abstract class Controller extends \stdClass
|
|
|
* 返回视图内容
|
|
|
* @param string $tpl 模板名称
|
|
|
* @param array $vars 模板变量
|
|
|
- * @param string $node CSRF授权节点
|
|
|
+ * @param mixed $node CSRF授权节点
|
|
|
*/
|
|
|
- public function fetch($tpl = '', $vars = [], $node = null)
|
|
|
+ public function fetch($tpl = '', $vars = [], $node = null): void
|
|
|
{
|
|
|
foreach ($this as $name => $value) $vars[$name] = $value;
|
|
|
if ($this->csrf_state) {
|
|
@@ -174,7 +176,7 @@ abstract class Controller extends \stdClass
|
|
|
* @param mixed $two 回调引用参数2
|
|
|
* @return boolean
|
|
|
*/
|
|
|
- public function callback($name, &$one = [], &$two = [])
|
|
|
+ public function callback(string $name, &$one = [], &$two = []): bool
|
|
|
{
|
|
|
if (is_callable($name)) return call_user_func($name, $this, $one, $two);
|
|
|
foreach (["_{$this->app->request->action()}{$name}", $name] as $method) {
|
|
@@ -209,7 +211,7 @@ abstract class Controller extends \stdClass
|
|
|
* @throws DbException
|
|
|
* @throws ModelNotFoundException
|
|
|
*/
|
|
|
- protected function _page($dbQuery, $page = true, $display = true, $total = false, $limit = 0, $template = '')
|
|
|
+ protected function _page($dbQuery, bool $page = true, bool $display = true, $total = false, int $limit = 0, string $template = '')
|
|
|
{
|
|
|
return PageHelper::instance()->init($dbQuery, $page, $display, $total, $limit, $template);
|
|
|
}
|
|
@@ -226,7 +228,7 @@ abstract class Controller extends \stdClass
|
|
|
* @throws DbException
|
|
|
* @throws ModelNotFoundException
|
|
|
*/
|
|
|
- protected function _form($dbQuery, $template = '', $field = '', $where = [], $data = [])
|
|
|
+ protected function _form($dbQuery, string $template = '', string $field = '', array $where = [], array $data = [])
|
|
|
{
|
|
|
return FormHelper::instance()->init($dbQuery, $template, $field, $where, $data);
|
|
|
}
|
|
@@ -237,7 +239,7 @@ abstract class Controller extends \stdClass
|
|
|
* @param string $type 输入方式 ( post. 或 get. )
|
|
|
* @return array
|
|
|
*/
|
|
|
- protected function _vali(array $rules, $type = '')
|
|
|
+ protected function _vali(array $rules, string $type = '')
|
|
|
{
|
|
|
return ValidateHelper::instance()->init($rules, $type);
|
|
|
}
|
|
@@ -251,7 +253,7 @@ abstract class Controller extends \stdClass
|
|
|
* @return boolean
|
|
|
* @throws DbException
|
|
|
*/
|
|
|
- protected function _save($dbQuery, $data = [], $field = '', $where = [])
|
|
|
+ protected function _save($dbQuery, array $data = [], string $field = '', array $where = [])
|
|
|
{
|
|
|
return SaveHelper::instance()->init($dbQuery, $data, $field, $where);
|
|
|
}
|
|
@@ -264,7 +266,7 @@ abstract class Controller extends \stdClass
|
|
|
* @return boolean|null
|
|
|
* @throws DbException
|
|
|
*/
|
|
|
- protected function _delete($dbQuery, $field = '', $where = [])
|
|
|
+ protected function _delete($dbQuery, string $field = '', array $where = [])
|
|
|
{
|
|
|
return DeleteHelper::instance()->init($dbQuery, $field, $where);
|
|
|
}
|
|
@@ -274,7 +276,7 @@ abstract class Controller extends \stdClass
|
|
|
* @param boolean $return 是否返回结果
|
|
|
* @return boolean
|
|
|
*/
|
|
|
- protected function _applyFormToken($return = false)
|
|
|
+ protected function _applyFormToken(bool $return = false)
|
|
|
{
|
|
|
return TokenHelper::instance()->init($return);
|
|
|
}
|
|
@@ -288,7 +290,7 @@ abstract class Controller extends \stdClass
|
|
|
* @param integer $rscript 任务类型(0单例,1多例)
|
|
|
* @param integer $loops 循环等待时间
|
|
|
*/
|
|
|
- protected function _queue($title, $command, $later = 0, $data = [], $rscript = 0, $loops = 0)
|
|
|
+ protected function _queue(string $title, string $command, int $later = 0, array $data = [], int $rscript = 0, int $loops = 0)
|
|
|
{
|
|
|
try {
|
|
|
$queue = QueueService::instance()->register($title, $command, $later, $data, $rscript, $loops);
|