Jump to content
Fórum Script Brasil
  • 0

function rum not work after upgrade from php5 to 7.3


Question

abstract class Bootstrap
{

    public function __construct(){
        $this->initRoutes();
        $this->rum($this->getUrl());
    }
    private $routes;

    abstract protected function initRoutes();

    protected function rum($url){
        array_walk($this->routes,function ($route) use($url) {
            if($url == $route['route']){
                $class = "App\\Controllers\\".ucfirst($route['controller']);
                $controller = new $class;
                $controllers = $controller->$route['action'];
                $controllers(); // Will not work on PHP7.
            }
        });
    }

    protected function setRoutes(array $routes){
        $this->routes = $routes;
    }

    protected function getUrl(){
        return parse_url($_SERVER['REQUEST_URI'],PHP_URL_PATH);
    }

}

Essa function rum funcionava na versão php 5.6 e não funciona na versão 7.3 (da erro de Array to string conversion) quando o array_walk está tentando construir uma função nomeada pelo argumento funcname (nome da rota) em cada elemento de array que é utilizada no controller para renderizar a views após instanciado a classname controller.

 

Alguém sabe como converter esse código para o php 7.3?

Link to post
Share on other sites

1 answer to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      149264
    • Total Posts
      645605
×
×
  • Create New...