3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Router { private $routeList; public function addRoute($url, $callback){ $this->routeList[$url] = $callback; } public function route($url){ $this->routeList[$url]->call($this, $url); } } class HomeController { public function __construct($router){ $router->addRoute('/', function(){ return $this->doHomePage(); }); } private function doHomePage(){ $quote = $this->getRandomQuote(); return new Response('home.html', ['quote' => $quote]); } private function getRandomQuote(){ $quotes = ['You can do anything, but not everything.—David Allen', ' The richest man is not he who has the most, but he who needs the least. —Unknown Author','You miss 100 percent of the shots you never take.—Wayne Gretzky']; return $quotes[array_rand($quotes)]; } } class Response { public function __construct($template, $data){ } } $router = new Router(); $controller = new HomeController($router); $router->route('/');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/WlsRe
function name:  (null)
number of ops:  11
compiled vars:  !0 = $router, !1 = $controller
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   38     0  E >   NEW                                              $2      'Router'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   39     3        NEW                                              $5      'HomeController'
          4        SEND_VAR_EX                                              !0
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !1, $5
   41     7        INIT_METHOD_CALL                                         !0, 'route'
          8        SEND_VAL_EX                                              '%2F'
          9        DO_FCALL                                      0          
         10      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FWlsRe%3A16%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/WlsRe
function name:  {closure}
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   FETCH_THIS                                       $0      
          1        INIT_METHOD_CALL                                         $0, 'doHomePage'
          2        DO_FCALL                                      0  $1      
          3      > RETURN                                                   $1
   18     4*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FWlsRe%3A16%240

Class Router:
Function addroute:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/WlsRe
function name:  addRoute
number of ops:  6
compiled vars:  !0 = $url, !1 = $callback
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    6     2        FETCH_OBJ_W                                      $2      'routeList'
          3        ASSIGN_DIM                                               $2, !0
          4        OP_DATA                                                  !1
    7     5      > RETURN                                                   null

End of function addroute

Function route:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/WlsRe
function name:  route
number of ops:  9
compiled vars:  !0 = $url
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   10     1        FETCH_OBJ_R                                      ~1      'routeList'
          2        FETCH_DIM_R                                      ~2      ~1, !0
          3        INIT_METHOD_CALL                                         ~2, 'call'
          4        FETCH_THIS                                       $3      
          5        SEND_VAR_EX                                              $3
          6        SEND_VAR_EX                                              !0
          7        DO_FCALL                                      0          
   11     8      > RETURN                                                   null

End of function route

End of class Router.

Class HomeController:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/WlsRe
function name:  __construct
number of ops:  7
compiled vars:  !0 = $router
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
   16     1        INIT_METHOD_CALL                                         !0, 'addRoute'
          2        SEND_VAL_EX                                              '%2F'
          3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FWlsRe%3A16%240'
   18     4        SEND_VAL_EX                                              ~1
          5        DO_FCALL                                      0          
   19     6      > RETURN                                                   null

End of function __construct

Function dohomepage:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/WlsRe
function name:  doHomePage
number of ops:  10
compiled vars:  !0 = $quote
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   INIT_METHOD_CALL                                         'getRandomQuote'
          1        DO_FCALL                                      0  $1      
          2        ASSIGN                                                   !0, $1
   23     3        NEW                                              $3      'Response'
          4        SEND_VAL_EX                                              'home.html'
          5        INIT_ARRAY                                       ~4      !0, 'quote'
          6        SEND_VAL_EX                                              ~4
          7        DO_FCALL                                      0          
          8      > RETURN                                                   $3
   24     9*     > RETURN                                                   null

End of function dohomepage

Function getrandomquote:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/WlsRe
function name:  getRandomQuote
number of ops:  7
compiled vars:  !0 = $quotes
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   ASSIGN                                                   !0, <array>
   28     1        INIT_FCALL                                               'array_rand'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $2      
          4        FETCH_DIM_R                                      ~3      !0, $2
          5      > RETURN                                                   ~3
   29     6*     > RETURN                                                   null

End of function getrandomquote

End of class HomeController.

Class Response:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/WlsRe
function name:  __construct
number of ops:  3
compiled vars:  !0 = $template, !1 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   35     2      > RETURN                                                   null

End of function __construct

End of class Response.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
134.46 ms | 1409 KiB | 15 Q