3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface Router { public function serve($uri); } class FlatRouter implements Router { public function serve($uri) { // send()s instance of HTTP\Request, no return value echo 'Serving request: ', $uri, ' using ', __CLASS__; } } class NestedRouter implements Router { public function serve($uri) { // send()s instance of HTTP\Request, no return value echo 'Serving request: ', $uri, ' using ', __CLASS__; } } abstract class Application { protected static $instances = array(); private $properties = array(); protected static function getInstance() { return isset(self::$instances[$className = get_called_class()]) ? self::$instances[$className] : self::$instances[$className] = new static(); } private function __construct() { } public function __set($propertyName, $value) { $this->properties[$propertyName] = $value; } public function __get($propertyName) { return is_callable($this->properties[$propertyName]) ? $this->properties[$propertyName] = $this->properties[$propertyName]($this) : $this->properties[$propertyName]; } } abstract class WebApplication extends Application { protected $routerClassName = 'FlatRouter'; private function __construct() { $this->router = function ($application) { $routerClassName = $application->routerClassName; return new $routerClassName(); }; } public static function serve($uri) { $instance = static::getInstance(); $instance->router->serve($uri); } } final class FooBarWebApplication extends WebApplication { protected $routerClassName = 'NestedRouter'; } FooBarWebApplication::serve('http://foo.bar/path/to/resource');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HAgvq
function name:  (null)
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   DECLARE_CLASS                                            'flatrouter'
   14     1        DECLARE_CLASS                                            'nestedrouter'
   66     2        INIT_STATIC_METHOD_CALL                                  'FooBarWebApplication', 'serve'
          3        SEND_VAL                                                 'http%3A%2F%2Ffoo.bar%2Fpath%2Fto%2Fresource'
          4        DO_FCALL                                      0          
          5      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FHAgvq%3A48%242:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HAgvq
function name:  {closure}
number of ops:  8
compiled vars:  !0 = $application, !1 = $routerClassName
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   48     0  E >   RECV                                             !0      
   49     1        FETCH_OBJ_R                                      ~2      !0, 'routerClassName'
          2        ASSIGN                                                   !1, ~2
   50     3        FETCH_CLASS                                   0  $4      !1
          4        NEW                                              $5      $4
          5        DO_FCALL                                      0          
          6      > RETURN                                                   $5
   51     7*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FHAgvq%3A48%242

Class Router:
Function serve:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HAgvq
function name:  serve
number of ops:  2
compiled vars:  !0 = $uri
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1      > RETURN                                                   null

End of function serve

End of class Router.

Class FlatRouter:
Function serve:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HAgvq
function name:  serve
number of ops:  6
compiled vars:  !0 = $uri
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
   10     1        ECHO                                                     'Serving+request%3A+'
          2        ECHO                                                     !0
          3        ECHO                                                     '+using+'
          4        ECHO                                                     'FlatRouter'
   11     5      > RETURN                                                   null

End of function serve

End of class FlatRouter.

Class NestedRouter:
Function serve:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HAgvq
function name:  serve
number of ops:  6
compiled vars:  !0 = $uri
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
   17     1        ECHO                                                     'Serving+request%3A+'
          2        ECHO                                                     !0
          3        ECHO                                                     '+using+'
          4        ECHO                                                     'NestedRouter'
   18     5      > RETURN                                                   null

End of function serve

End of class NestedRouter.

Class Application:
Function getinstance:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 9
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HAgvq
function name:  getInstance
number of ops:  17
compiled vars:  !0 = $className
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   GET_CALLED_CLASS                                 ~2      
          1        ASSIGN                                           ~3      !0, ~2
          2        FETCH_STATIC_PROP_IS                             ~1      'instances'
          3        ISSET_ISEMPTY_DIM_OBJ                         0          ~1, ~3
          4      > JMPZ                                                     ~4, ->9
          5    >   FETCH_STATIC_PROP_R          unknown             ~5      'instances'
          6        FETCH_DIM_R                                      ~6      ~5, !0
          7        QM_ASSIGN                                        ~7      ~6
          8      > JMP                                                      ->15
          9    >   NEW                          static              $10     
         10        DO_FCALL                                      0          
         11        FETCH_STATIC_PROP_W          unknown             $8      'instances'
         12        ASSIGN_DIM                                       ~9      $8, !0
         13        OP_DATA                                                  $10
         14        QM_ASSIGN                                        ~7      ~9
         15    > > RETURN                                                   ~7
   29    16*     > RETURN                                                   null

End of function getinstance

Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HAgvq
function name:  __construct
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E > > RETURN                                                   null

End of function __construct

Function __set:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HAgvq
function name:  __set
number of ops:  6
compiled vars:  !0 = $propertyName, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   35     2        FETCH_OBJ_W                                      $2      'properties'
          3        ASSIGN_DIM                                               $2, !0
          4        OP_DATA                                                  !1
   36     5      > RETURN                                                   null

End of function __set

Function __get:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 18
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HAgvq
function name:  __get
number of ops:  23
compiled vars:  !0 = $propertyName
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   38     0  E >   RECV                                             !0      
   39     1        INIT_FCALL                                               'is_callable'
          2        FETCH_OBJ_R                                      ~1      'properties'
          3        FETCH_DIM_R                                      ~2      ~1, !0
          4        SEND_VAL                                                 ~2
          5        DO_ICALL                                         $3      
          6      > JMPZ                                                     $3, ->18
          7    >   FETCH_OBJ_R                                      ~6      'properties'
          8        FETCH_DIM_R                                      ~7      ~6, !0
          9        INIT_DYNAMIC_CALL                                        ~7
         10        FETCH_THIS                                       $8      
         11        SEND_VAR_EX                                              $8
         12        DO_FCALL                                      0  $9      
         13        FETCH_OBJ_W                                      $4      'properties'
         14        ASSIGN_DIM                                       ~5      $4, !0
         15        OP_DATA                                                  $9
         16        QM_ASSIGN                                        ~10     ~5
         17      > JMP                                                      ->21
         18    >   FETCH_OBJ_R                                      ~11     'properties'
         19        FETCH_DIM_R                                      ~12     ~11, !0
         20        QM_ASSIGN                                        ~10     ~12
         21    > > RETURN                                                   ~10
   40    22*     > RETURN                                                   null

End of function __get

End of class Application.

Class WebApplication:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HAgvq
function name:  __construct
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   48     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FHAgvq%3A48%242'
          1        ASSIGN_OBJ                                               'router'
   51     2        OP_DATA                                                  ~1
   52     3      > RETURN                                                   null

End of function __construct

Function serve:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HAgvq
function name:  serve
number of ops:  9
compiled vars:  !0 = $uri, !1 = $instance
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   54     0  E >   RECV                                             !0      
   55     1        INIT_STATIC_METHOD_CALL                                  'getInstance'
          2        DO_FCALL                                      0  $2      
          3        ASSIGN                                                   !1, $2
   56     4        FETCH_OBJ_R                                      ~4      !1, 'router'
          5        INIT_METHOD_CALL                                         ~4, 'serve'
          6        SEND_VAR_EX                                              !0
          7        DO_FCALL                                      0          
   57     8      > RETURN                                                   null

End of function serve

Function getinstance:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 9
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HAgvq
function name:  getInstance
number of ops:  17
compiled vars:  !0 = $className
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   GET_CALLED_CLASS                                 ~2      
          1        ASSIGN                                           ~3      !0, ~2
          2        FETCH_STATIC_PROP_IS                             ~1      'instances'
          3        ISSET_ISEMPTY_DIM_OBJ                         0          ~1, ~3
          4      > JMPZ                                                     ~4, ->9
          5    >   FETCH_STATIC_PROP_R          unknown             ~5      'instances'
          6        FETCH_DIM_R                                      ~6      ~5, !0
          7        QM_ASSIGN                                        ~7      ~6
          8      > JMP                                                      ->15
          9    >   NEW                          static              $10     
         10        DO_FCALL                                      0          
         11        FETCH_STATIC_PROP_W          unknown             $8      'instances'
         12        ASSIGN_DIM                                       ~9      $8, !0
         13        OP_DATA                                                  $10
         14        QM_ASSIGN                                        ~7      ~9
         15    > > RETURN                                                   ~7
   29    16*     > RETURN                                                   null

End of function getinstance

Function __set:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HAgvq
function name:  __set
number of ops:  6
compiled vars:  !0 = $propertyName, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   35     2        FETCH_OBJ_W                                      $2      'properties'
          3        ASSIGN_DIM                                               $2, !0
          4        OP_DATA                                                  !1
   36     5      > RETURN                                                   null

End of function __set

Function __get:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 18
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HAgvq
function name:  __get
number of ops:  23
compiled vars:  !0 = $propertyName
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   38     0  E >   RECV                                             !0      
   39     1        INIT_FCALL                                               'is_callable'
          2        FETCH_OBJ_R                                      ~1      'properties'
          3        FETCH_DIM_R                                      ~2      ~1, !0
          4        SEND_VAL                                                 ~2
          5        DO_ICALL                                         $3      
          6      > JMPZ                                                     $3, ->18
          7    >   FETCH_OBJ_R                                      ~6      'properties'
          8        FETCH_DIM_R                                      ~7      ~6, !0
          9        INIT_DYNAMIC_CALL                                        ~7
         10        FETCH_THIS                                       $8      
         11        SEND_VAR_EX                                              $8
         12        DO_FCALL                                      0  $9      
         13        FETCH_OBJ_W                                      $4      'properties'
         14        ASSIGN_DIM                                       ~5      $4, !0
         15        OP_DATA                                                  $9
         16        QM_ASSIGN                                        ~10     ~5
         17      > JMP                                                      ->21
         18    >   FETCH_OBJ_R                                      ~11     'properties'
         19        FETCH_DIM_R                                      ~12     ~11, !0
         20        QM_ASSIGN                                        ~10     ~12
         21    > > RETURN                                                   ~10
   40    22*     > RETURN                                                   null

End of function __get

End of class WebApplication.

Class FooBarWebApplication:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HAgvq
function name:  __construct
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   48     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FHAgvq%3A48%242'
          1        ASSIGN_OBJ                                               'router'
   51     2        OP_DATA                                                  ~1
   52     3      > RETURN                                                   null

End of function __construct

Function serve:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HAgvq
function name:  serve
number of ops:  9
compiled vars:  !0 = $uri, !1 = $instance
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   54     0  E >   RECV                                             !0      
   55     1        INIT_STATIC_METHOD_CALL                                  'getInstance'
          2        DO_FCALL                                      0  $2      
          3        ASSIGN                                                   !1, $2
   56     4        FETCH_OBJ_R                                      ~4      !1, 'router'
          5        INIT_METHOD_CALL                                         ~4, 'serve'
          6        SEND_VAR_EX                                              !0
          7        DO_FCALL                                      0          
   57     8      > RETURN                                                   null

End of function serve

Function getinstance:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 9
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HAgvq
function name:  getInstance
number of ops:  17
compiled vars:  !0 = $className
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   GET_CALLED_CLASS                                 ~2      
          1        ASSIGN                                           ~3      !0, ~2
          2        FETCH_STATIC_PROP_IS                             ~1      'instances'
          3        ISSET_ISEMPTY_DIM_OBJ                         0          ~1, ~3
          4      > JMPZ                                                     ~4, ->9
          5    >   FETCH_STATIC_PROP_R          unknown             ~5      'instances'
          6        FETCH_DIM_R                                      ~6      ~5, !0
          7        QM_ASSIGN                                        ~7      ~6
          8      > JMP                                                      ->15
          9    >   NEW                          static              $10     
         10        DO_FCALL                                      0          
         11        FETCH_STATIC_PROP_W          unknown             $8      'instances'
         12        ASSIGN_DIM                                       ~9      $8, !0
         13        OP_DATA                                                  $10
         14        QM_ASSIGN                                        ~7      ~9
         15    > > RETURN                                                   ~7
   29    16*     > RETURN                                                   null

End of function getinstance

Function __set:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HAgvq
function name:  __set
number of ops:  6
compiled vars:  !0 = $propertyName, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   35     2        FETCH_OBJ_W                                      $2      'properties'
          3        ASSIGN_DIM                                               $2, !0
          4        OP_DATA                                                  !1
   36     5      > RETURN                                                   null

End of function __set

Function __get:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 18
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HAgvq
function name:  __get
number of ops:  23
compiled vars:  !0 = $propertyName
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   38     0  E >   RECV                                             !0      
   39     1        INIT_FCALL                                               'is_callable'
          2        FETCH_OBJ_R                                      ~1      'properties'
          3        FETCH_DIM_R                                      ~2      ~1, !0
          4        SEND_VAL                                                 ~2
          5        DO_ICALL                                         $3      
          6      > JMPZ                                                     $3, ->18
          7    >   FETCH_OBJ_R                                      ~6      'properties'
          8        FETCH_DIM_R                                      ~7      ~6, !0
          9        INIT_DYNAMIC_CALL                                        ~7
         10        FETCH_THIS                                       $8      
         11        SEND_VAR_EX                                              $8
         12        DO_FCALL                                      0  $9      
         13        FETCH_OBJ_W                                      $4      'properties'
         14        ASSIGN_DIM                                       ~5      $4, !0
         15        OP_DATA                                                  $9
         16        QM_ASSIGN                                        ~10     ~5
         17      > JMP                                                      ->21
         18    >   FETCH_OBJ_R                                      ~11     'properties'
         19        FETCH_DIM_R                                      ~12     ~11, !0
         20        QM_ASSIGN                                        ~10     ~12
         21    > > RETURN                                                   ~10
   40    22*     > RETURN                                                   null

End of function __get

End of class FooBarWebApplication.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.81 ms | 1412 KiB | 15 Q