Kaynağa Gözat

Fixed: warning

朱金辉 2 ay önce
ebeveyn
işleme
d424b20e50

+ 1 - 1
src/Application.php

@@ -197,7 +197,7 @@ class Application
      * 静态文件目录不做处理,直接返回404
      *
      * @param array $path
-     * @return void
+     * @return $this
      */
     public function setStaticPath($path) {
         if(!is_array($path)) {

+ 5 - 2
src/Base/Route.php

@@ -298,12 +298,15 @@ class Route
                         $firstMatch = $index;
                     }
                     $key = str_replace(array("{", "}"), "", $val);
-                    $value = $uriArray[$index];
+                    $value = "";
+                    if (isset($uriArray[$index])) {
+                        $value = $uriArray[$index];
+                    }
                     //如果key未xx:yy则yy表示xx的值类型,会做强制转换,支持的类型为number、string、bool、float
                     if(strpos($key, ":") > 0) {
                         $keyArr = explode(":", $key);
                         $key = $keyArr[0];
-                        $value =  $this->convertValueTo($uriArray[$index], $keyArr[1]);
+                        $value =  $this->convertValueTo($value, $keyArr[1]);
                     }
                     $args[$key] = $value;
                 }

+ 8 - 4
src/Router/Parse.php

@@ -6,6 +6,7 @@ use \Qii\Autoloader\Import;
 use \Qii\Config\Register;
 use \Qii\Config\Consts;
 use Qii\Exceptions\ClassNotFound;
+use Qii\Exceptions\Variable;
 
 /**
  * 路由规则类
@@ -20,16 +21,19 @@ class Parse
     /**
      * 路由转发, 转发对应的规则中xx不能为*
      *
-     * @param String $controller
-     * @param String $action
-     * @param Array $router
-     * @return Array ($controller, $action);
+     * @param string $url
+     * @param string $controller
+     * @param string $action
+     * @param string $thirdParam
+     * @return array ($controller, $action);
      *
      * *:* => *:yyy 所有controller和action都转发到 *->yyy
      * *:* => yy:* 所有转发到xxx->*, 这里的*,前边对应的是什么,后边就对应转发到什么,比如: *:xxx => yy:yyy
      * xx:* => yy:* xx中对应的方法转发到yy对应的方法
      * xx:* => yy:yyy xxx Controller转发到 yy->yyy
      * *:xxx => yy:yyy 所有Controller转发到 yy->yyy
+     * @throws ClassNotFound
+     * @throws Variable
      */
     public static function get($url, $controller, $action = '', $thirdParam = '')
     {

+ 1 - 1
src/Router/Parse/Normal.php

@@ -177,7 +177,7 @@ class Normal
                 $replacements[$key] = isset($dirInfo[$index]) && $dirInfo[$index] != '' ? $dirInfo[$index] : Register::get("APP_DEFAULT_ACTION");
                 $rulesVal = preg_replace("/\{[\d]{1,}\}/", $replacements[$key], $rulesVal, 1);
             }else if($val == '*'){
-                $replacements[$key] = $dirInfo[$maxIndex] ? $dirInfo[$maxIndex] : 'index';
+                $replacements[$key] = isset($dirInfo[$maxIndex]) ? $dirInfo[$maxIndex] : 'index';
                 //一次只替换一个,用于匹配多次
                 $rulesVal = preg_replace("/[\*]{1}/", $replacements[$key], $rulesVal, 1);
                 $maxIndex++;