3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Context { private static $_context = []; public static function get($dependency) { return isset(self::$_context[$dependency]) ? self::$_context[$dependency] : null; } public static function register($dependencies) { if (!is_array($dependencies)) { throw new Exception("Неверное значение параметра для добавления зависимости в контекст"); } foreach ($dependencies as $key => $value) { self::$_context[$key] = $value instanceof Closure ? $value() : $value; } } } Context::register([ "test" => function() { return "callback"; } ]); echo Context::get("test");
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/keB3H
function name:  (null)
number of ops:  10
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   INIT_STATIC_METHOD_CALL                                  'Context', 'register'
          1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FkeB3H%3A22%240'
          2        INIT_ARRAY                                       ~1      ~0, 'test'
          3        SEND_VAL                                                 ~1
          4        DO_FCALL                                      0          
   24     5        INIT_STATIC_METHOD_CALL                                  'Context', 'get'
          6        SEND_VAL                                                 'test'
          7        DO_FCALL                                      0  $3      
          8        ECHO                                                     $3
          9      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FkeB3H%3A22%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/keB3H
function name:  {closure}
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E > > RETURN                                                   'callback'
          1*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FkeB3H%3A22%240

Class Context:
Function get:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 8
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/keB3H
function name:  get
number of ops:  11
compiled vars:  !0 = $dependency
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    7     1        FETCH_STATIC_PROP_IS                             ~1      '_context'
          2        ISSET_ISEMPTY_DIM_OBJ                         0          ~1, !0
          3      > JMPZ                                                     ~2, ->8
          4    >   FETCH_STATIC_PROP_R          unknown             ~3      '_context'
          5        FETCH_DIM_R                                      ~4      ~3, !0
          6        QM_ASSIGN                                        ~5      ~4
          7      > JMP                                                      ->9
          8    >   QM_ASSIGN                                        ~5      null
          9    > > RETURN                                                   ~5
    8    10*     > RETURN                                                   null

End of function get

Function register:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 8
Branch analysis from position: 4
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 22
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 22
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 17
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
filename:       /in/keB3H
function name:  register
number of ops:  24
compiled vars:  !0 = $dependencies, !1 = $value, !2 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
   11     1        TYPE_CHECK                                  128  ~3      !0
          2        BOOL_NOT                                         ~4      ~3
          3      > JMPZ                                                     ~4, ->8
   12     4    >   NEW                                              $5      'Exception'
          5        SEND_VAL_EX                                              '%D0%9D%D0%B5%D0%B2%D0%B5%D1%80%D0%BD%D0%BE%D0%B5+%D0%B7%D0%BD%D0%B0%D1%87%D0%B5%D0%BD%D0%B8%D0%B5+%D0%BF%D0%B0%D1%80%D0%B0%D0%BC%D0%B5%D1%82%D1%80%D0%B0+%D0%B4%D0%BB%D1%8F+%D0%B4%D0%BE%D0%B1%D0%B0%D0%B2%D0%BB%D0%B5%D0%BD%D0%B8%D1%8F+%D0%B7%D0%B0%D0%B2%D0%B8%D1%81%D0%B8%D0%BC%D0%BE%D1%81%D1%82%D0%B8+%D0%B2+%D0%BA%D0%BE%D0%BD%D1%82%D0%B5%D0%BA%D1%81%D1%82'
          6        DO_FCALL                                      0          
          7      > THROW                                         0          $5
   15     8    > > FE_RESET_R                                       $7      !0, ->22
          9    > > FE_FETCH_R                                       ~8      $7, !1, ->22
         10    >   ASSIGN                                                   !2, ~8
   16    11        INSTANCEOF                                               !1, 'Closure'
         12      > JMPZ                                                     ~12, ->17
         13    >   INIT_DYNAMIC_CALL                                        !1
         14        DO_FCALL                                      0  $13     
         15        QM_ASSIGN                                        ~14     $13
         16      > JMP                                                      ->18
         17    >   QM_ASSIGN                                        ~14     !1
         18    >   FETCH_STATIC_PROP_W          unknown             $10     '_context'
         19        ASSIGN_DIM                                               $10, !2
         20        OP_DATA                                                  ~14
   15    21      > JMP                                                      ->9
         22    >   FE_FREE                                                  $7
   18    23      > RETURN                                                   null

End of function register

End of class Context.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.82 ms | 1399 KiB | 13 Q