community. I do not understand whether a bug, or feature.

// router.php public function match() { // other code foreach ($this->routes AS $route) { if (true)) { // other code // Если все нормально вернет Route и механизм отработает // Но в лог попадет второй return 3; echo 2; return true; } } return 3; } // далее в index.php $router->run($router->match(), $di); 

In error.log errors are poured

 PHP Fatal error: Uncaught TypeError: Argument 1 passed to system\\Router::run() must be an instance of system\\Route, boolean given, called in ... system\\Router->run(true, Object(system\\DependencyInjector))\n#1 {main} ... PHP Fatal error: Uncaught TypeError: Argument 1 passed to system\\Router::run() must be an instance of system\\Route, integer given, called in ... system\\Router->run(3, Object(system\\DependencyInjector))\n#1 {main} ... 

That is, both returns are performed and the string is printed. Any thoughts on that? The code is called only once, break will not work. UPD: If you remove the strict type of run ( Route $ route, Di $ di), the error disappears as it should be UPD: Tritely, the rule in htaccess is not processed for favicon.ico. The request does not find the picture and throws errors. Issue resolved

  • Of course, 2 returns mean 2 function calls - vp_arth
  • So my match is not used anywhere except for the start, I can not track this - ozornick
  • and if $router->match() to another which function is inserted as a parameter, will it also run 2 times? - TigerTV.ru
  • If you are using a framework of some kind, you may have subqueries within the application. There are clearly two calls to index.php - korytoff
  • We quickly queried the code above run (): function test(\system\Route $r){ debug($r); } test($router->match()); function test(\system\Route $r){ debug($r); } test($router->match()); Error log in test (NULL) - ozornick

0