3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Factory { private $Data = []; public function set($index, $data) { $this->Data[$index] = $data; } public function get($index) { return $this->Data[$index]; } } session_start(); $f = new Factory(); $f->set('Cookies', $_SESSION); $f->set('Check-Cookie', function() use ($f) { return $f->get('Cookies')['logged'] ? [true, $f->get('Cookies')['logged']] : [false, null]; }); $cookieArr = is_callable($f->get('Check-Cookie')) ? call_user_func($f->get('Check-Cookie')) : []; echo $cookieArr[0] ? $cookieArr[1] : 'Logged is not set';
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 31
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
2 jumps found. (Code = 43) Position 1 = 35, Position 2 = 38
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 38
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
2 jumps found. (Code = 43) Position 1 = 35, Position 2 = 38
Branch analysis from position: 35
Branch analysis from position: 38
filename:       /in/k5mk9
function name:  (null)
number of ops:  41
compiled vars:  !0 = $f, !1 = $cookieArr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   INIT_FCALL                                               'session_start'
          1        DO_ICALL                                                 
   15     2        NEW                                              $3      'Factory'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $3
   16     5        INIT_METHOD_CALL                                         !0, 'set'
          6        SEND_VAL_EX                                              'Cookies'
          7        CHECK_FUNC_ARG                                           
          8        FETCH_FUNC_ARG               global              $6      '_SESSION'
          9        SEND_FUNC_ARG                                            $6
         10        DO_FCALL                                      0          
   17    11        INIT_METHOD_CALL                                         !0, 'set'
         12        SEND_VAL_EX                                              'Check-Cookie'
         13        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fk5mk9%3A17%240'
         14        BIND_LEXICAL                                             ~8, !0
   19    15        SEND_VAL_EX                                              ~8
         16        DO_FCALL                                      0          
   21    17        INIT_FCALL                                               'is_callable'
         18        INIT_METHOD_CALL                                         !0, 'get'
         19        SEND_VAL_EX                                              'Check-Cookie'
         20        DO_FCALL                                      0  $10     
         21        SEND_VAR                                                 $10
         22        DO_ICALL                                         $11     
         23      > JMPZ                                                     $11, ->31
         24    >   INIT_METHOD_CALL                                         !0, 'get'
         25        SEND_VAL_EX                                              'Check-Cookie'
         26        DO_FCALL                                      0  $12     
         27        INIT_USER_CALL                                0          'call_user_func', $12
         28        DO_FCALL                                      0  $13     
         29        QM_ASSIGN                                        ~14     $13
         30      > JMP                                                      ->32
         31    >   QM_ASSIGN                                        ~14     <array>
         32    >   ASSIGN                                                   !1, ~14
   22    33        FETCH_DIM_R                                      ~16     !1, 0
         34      > JMPZ                                                     ~16, ->38
         35    >   FETCH_DIM_R                                      ~17     !1, 1
         36        QM_ASSIGN                                        ~18     ~17
         37      > JMP                                                      ->39
         38    >   QM_ASSIGN                                        ~18     'Logged+is+not+set'
         39    >   ECHO                                                     ~18
         40      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2Fk5mk9%3A17%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 14
Branch analysis from position: 6
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: 14
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/k5mk9
function name:  {closure}
number of ops:  17
compiled vars:  !0 = $f
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   BIND_STATIC                                              !0
   18     1        INIT_METHOD_CALL                                         !0, 'get'
          2        SEND_VAL_EX                                              'Cookies'
          3        DO_FCALL                                      0  $1      
          4        FETCH_DIM_R                                      ~2      $1, 'logged'
          5      > JMPZ                                                     ~2, ->14
          6    >   INIT_ARRAY                                       ~3      <true>
          7        INIT_METHOD_CALL                                         !0, 'get'
          8        SEND_VAL_EX                                              'Cookies'
          9        DO_FCALL                                      0  $4      
         10        FETCH_DIM_R                                      ~5      $4, 'logged'
         11        ADD_ARRAY_ELEMENT                                ~3      ~5
         12        QM_ASSIGN                                        ~6      ~3
         13      > JMP                                                      ->15
         14    >   QM_ASSIGN                                        ~6      <array>
         15    > > RETURN                                                   ~6
   19    16*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Fk5mk9%3A17%240

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

End of function set

Function get:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/k5mk9
function name:  get
number of ops:  5
compiled vars:  !0 = $index
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   10     1        FETCH_OBJ_R                                      ~1      'Data'
          2        FETCH_DIM_R                                      ~2      ~1, !0
          3      > RETURN                                                   ~2
   11     4*     > RETURN                                                   null

End of function get

End of class Factory.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
176.67 ms | 1404 KiB | 17 Q