3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Services { protected $services = []; public function getService($id, callback $creator) { // Нет в кэше? Берём из creator'а // Возвращаем кэш } } class Framework extends Services { protected $instance = null; public function __construct() { // Что-то } public static function getInstance() { if (is_null(static::$instance)) { throw new \Exception('Не инициализировано'); } return static::$instance; } public static function getRouter() { return static::getInstance()->getService('framework.router', function() use ($something) { return new Router($something); }); } public static function init() { static::$instance = new self(); } public function run() { // Маршрутизация => Контроллер => Выполнение Response } } class CMS extends Framework { public static function getModulesManager() { return static::getInstance()->getService('cms.modulesmanager', function() use ($a, $b, $c) { return new ModulesManager($a, $b, $c); }); } public function run() { // Маршрутизация => Встроенные контроллеры/Модули => Выполнение Response } } // based on framework Framework::init() && Framework::run(); // где-то в компоненте: var_dump(Framework::getRouter()); // based on CMS CMS::init() && CMS::run(); // где-то в модуле: var_dump(CMS::getRouter()); var_dump(CMS::getModulesManager());
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 3, Position 2 = 6
Branch analysis from position: 3
2 jumps found. (Code = 46) Position 1 = 14, Position 2 = 17
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
Branch analysis from position: 6
filename:       /in/uD0CD
function name:  (null)
number of ops:  28
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   67     0  E >   INIT_STATIC_METHOD_CALL                                  'Framework', 'init'
          1        DO_FCALL                                      0  $0      
          2      > JMPZ_EX                                          ~1      $0, ->6
          3    >   INIT_STATIC_METHOD_CALL                                  'Framework', 'run'
          4        DO_FCALL                                      0  $2      
          5        BOOL                                             ~1      $2
   69     6    >   INIT_FCALL                                               'var_dump'
          7        INIT_STATIC_METHOD_CALL                                  'Framework', 'getRouter'
          8        DO_FCALL                                      0  $3      
          9        SEND_VAR                                                 $3
         10        DO_ICALL                                                 
   72    11        INIT_STATIC_METHOD_CALL                                  'CMS', 'init'
         12        DO_FCALL                                      0  $5      
         13      > JMPZ_EX                                          ~6      $5, ->17
         14    >   INIT_STATIC_METHOD_CALL                                  'CMS', 'run'
         15        DO_FCALL                                      0  $7      
         16        BOOL                                             ~6      $7
   74    17    >   INIT_FCALL                                               'var_dump'
         18        INIT_STATIC_METHOD_CALL                                  'CMS', 'getRouter'
         19        DO_FCALL                                      0  $8      
         20        SEND_VAR                                                 $8
         21        DO_ICALL                                                 
   75    22        INIT_FCALL                                               'var_dump'
         23        INIT_STATIC_METHOD_CALL                                  'CMS', 'getModulesManager'
         24        DO_FCALL                                      0  $10     
         25        SEND_VAR                                                 $10
         26        DO_ICALL                                                 
         27      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FuD0CD%3A35%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uD0CD
function name:  {closure}
number of ops:  6
compiled vars:  !0 = $something
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   BIND_STATIC                                              !0
   36     1        NEW                                              $1      'Router'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
          4      > RETURN                                                   $1
   37     5*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FuD0CD%3A35%240

Function %00%7Bclosure%7D%2Fin%2FuD0CD%3A55%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uD0CD
function name:  {closure}
number of ops:  10
compiled vars:  !0 = $a, !1 = $b, !2 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   55     0  E >   BIND_STATIC                                              !0
          1        BIND_STATIC                                              !1
          2        BIND_STATIC                                              !2
   56     3        NEW                                              $3      'ModulesManager'
          4        SEND_VAR_EX                                              !0
          5        SEND_VAR_EX                                              !1
          6        SEND_VAR_EX                                              !2
          7        DO_FCALL                                      0          
          8      > RETURN                                                   $3
   57     9*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FuD0CD%3A55%241

Class Services:
Function getservice:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uD0CD
function name:  getService
number of ops:  3
compiled vars:  !0 = $id, !1 = $creator
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   12     2      > RETURN                                                   null

End of function getservice

End of class Services.

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

End of function __construct

Function getinstance:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 7
Branch analysis from position: 3
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uD0CD
function name:  getInstance
number of ops:  10
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   FETCH_STATIC_PROP_R          unknown             ~0      'instance'
          1        TYPE_CHECK                                    2          ~0
          2      > JMPZ                                                     ~1, ->7
   27     3    >   NEW                                              $2      'Exception'
          4        SEND_VAL_EX                                              '%D0%9D%D0%B5+%D0%B8%D0%BD%D0%B8%D1%86%D0%B8%D0%B0%D0%BB%D0%B8%D0%B7%D0%B8%D1%80%D0%BE%D0%B2%D0%B0%D0%BD%D0%BE'
          5        DO_FCALL                                      0          
          6      > THROW                                         0          $2
   30     7    >   FETCH_STATIC_PROP_R          unknown             ~4      'instance'
          8      > RETURN                                                   ~4
   31     9*     > RETURN                                                   null

End of function getinstance

Function getrouter:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uD0CD
function name:  getRouter
number of ops:  10
compiled vars:  !0 = $something
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   INIT_STATIC_METHOD_CALL                                  'getInstance'
          1        DO_FCALL                                      0  $1      
          2        INIT_METHOD_CALL                                         $1, 'getService'
          3        SEND_VAL_EX                                              'framework.router'
          4        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FuD0CD%3A35%240'
          5        BIND_LEXICAL                                             ~2, !0
   37     6        SEND_VAL_EX                                              ~2
          7        DO_FCALL                                      0  $3      
          8      > RETURN                                                   $3
   38     9*     > RETURN                                                   null

End of function getrouter

Function init:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uD0CD
function name:  init
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   42     0  E >   NEW                          self                $1      
          1        DO_FCALL                                      0          
          2        ASSIGN_STATIC_PROP                                       'instance'
          3        OP_DATA                                                  $1
   43     4      > RETURN                                                   null

End of function init

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

End of function run

Function getservice:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uD0CD
function name:  getService
number of ops:  3
compiled vars:  !0 = $id, !1 = $creator
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   12     2      > RETURN                                                   null

End of function getservice

End of class Framework.

Class CMS:
Function getmodulesmanager:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uD0CD
function name:  getModulesManager
number of ops:  12
compiled vars:  !0 = $a, !1 = $b, !2 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   55     0  E >   INIT_STATIC_METHOD_CALL                                  'getInstance'
          1        DO_FCALL                                      0  $3      
          2        INIT_METHOD_CALL                                         $3, 'getService'
          3        SEND_VAL_EX                                              'cms.modulesmanager'
          4        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FuD0CD%3A55%241'
          5        BIND_LEXICAL                                             ~4, !0
          6        BIND_LEXICAL                                             ~4, !1
          7        BIND_LEXICAL                                             ~4, !2
   57     8        SEND_VAL_EX                                              ~4
          9        DO_FCALL                                      0  $5      
         10      > RETURN                                                   $5
   58    11*     > RETURN                                                   null

End of function getmodulesmanager

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

End of function run

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

End of function __construct

Function getinstance:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 7
Branch analysis from position: 3
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uD0CD
function name:  getInstance
number of ops:  10
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   FETCH_STATIC_PROP_R          unknown             ~0      'instance'
          1        TYPE_CHECK                                    2          ~0
          2      > JMPZ                                                     ~1, ->7
   27     3    >   NEW                                              $2      'Exception'
          4        SEND_VAL_EX                                              '%D0%9D%D0%B5+%D0%B8%D0%BD%D0%B8%D1%86%D0%B8%D0%B0%D0%BB%D0%B8%D0%B7%D0%B8%D1%80%D0%BE%D0%B2%D0%B0%D0%BD%D0%BE'
          5        DO_FCALL                                      0          
          6      > THROW                                         0          $2
   30     7    >   FETCH_STATIC_PROP_R          unknown             ~4      'instance'
          8      > RETURN                                                   ~4
   31     9*     > RETURN                                                   null

End of function getinstance

Function getrouter:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uD0CD
function name:  getRouter
number of ops:  10
compiled vars:  !0 = $something
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   INIT_STATIC_METHOD_CALL                                  'getInstance'
          1        DO_FCALL                                      0  $1      
          2        INIT_METHOD_CALL                                         $1, 'getService'
          3        SEND_VAL_EX                                              'framework.router'
          4        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FuD0CD%3A35%240'
          5        BIND_LEXICAL                                             ~2, !0
   37     6        SEND_VAL_EX                                              ~2
          7        DO_FCALL                                      0  $3      
          8      > RETURN                                                   $3
   38     9*     > RETURN                                                   null

End of function getrouter

Function init:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uD0CD
function name:  init
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   42     0  E >   NEW                          self                $1      
          1        DO_FCALL                                      0          
          2        ASSIGN_STATIC_PROP                                       'instance'
          3        OP_DATA                                                  $1
   43     4      > RETURN                                                   null

End of function init

Function getservice:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uD0CD
function name:  getService
number of ops:  3
compiled vars:  !0 = $id, !1 = $creator
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   12     2      > RETURN                                                   null

End of function getservice

End of class CMS.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.02 ms | 1412 KiB | 15 Q