Browse code

Fix on deprecated trim(null).

RafaƂ Szklarczyk authored on 25/01/2024 11:25:44
Showing 2 changed files
... ...
@@ -181,7 +181,8 @@ class Application{
181 181
                 return $this->handle404($this->request);
182 182
             }
183 183
 
184
-            $this->module = trim($module, '\\');
184
+            if(!is_null($module))
185
+                $this->module = trim($module, '\\');
185 186
             $this->controller = $controller;
186 187
             $this->action = $controller_action;
187 188
             // prepare args and start the action
... ...
@@ -112,7 +112,12 @@ class Router{
112 112
 
113 113
     public function match($request){
114 114
 
115
-        $auri = explode('/', trim($request->path, "/ \t\n\r\0\x0B"));
115
+        if(is_null($request->path)){
116
+            $auri = array();
117
+        }
118
+        else{
119
+            $auri = explode('/', trim($request->path, "/ \t\n\r\0\x0B"));
120
+        }
116 121
         $curi = count($auri);
117 122
 			
118 123
         foreach ($this->routes as $routeInfo) {
... ...
@@ -120,7 +125,13 @@ class Router{
120 125
                 $route = $routeInfo->path;
121 126
                 $method = $routeInfo->method;
122 127
                 if($method=='ANY' || strpos($request->method,$method)!==false){
123
-                    $aroute = explode('/', trim($route, "/ \t\n\r\0\x0B"));
128
+                    if(is_null($route)){
129
+                        $aroute = array();
130
+                    }
131
+                    else{
132
+                        $aroute = explode('/', trim($route, "/ \t\n\r\0\x0B"));
133
+                    }
134
+                    
124 135
                     //print_r($aroute);
125 136
                     if($curi==count($aroute)){ //compare path element count
126 137
                         //optimistic assumption :)
... ...
@@ -177,6 +188,7 @@ class Router{
177 188
     }
178 189
 
179 190
     public function calculateRequestDepth($request){
191
+        if(is_null($request->path)) return 0;
180 192
         return count(explode('/',trim($request->path, "/ \t\n\r\0\x0B")));
181 193
     }
182 194