3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Authenticator { protected $isloggedin; protected $session; public function __construct(Session $session) { $this->session = $session; // if ( ! empty($session->get('isloggedin')) && $session->get('isloggedin') == true) { $isl = $session->get('isloggedin'); if ( ! empty($isl) && $isl == true) { $this->isloggedin = true; } } } interface Session { public function set($key, $val=true); public function get($key); } class BasicSession implements Session { protected $session = array(); public function __construct() { if ( ! session_start() ) { throw new Exception('Could not initiate web session'); } $this->session = $_SESSION; } public function set($key, $val=true) { $this->session[$key] = $val; } public function get($key) { if (isset($this->session[$key])) { return $this->session[$key]; } return false; } } try { $sess = new BasicSession(); $auth = new Authenticator($sess); } catch (Exception $e) { die('System go KA-BOOM! ' . $e->getMessage()); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 9
Branch analysis from position: 9
2 jumps found. (Code = 107) Position 1 = 10, Position 2 = -2
Branch analysis from position: 10
1 jumps found. (Code = 79) Position 1 = -2
filename:       /in/VrOYF
function name:  (null)
number of ops:  15
compiled vars:  !0 = $sess, !1 = $auth, !2 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   DECLARE_CLASS                                            'basicsession'
   46     1        NEW                                              $3      'BasicSession'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $3
   47     4        NEW                                              $6      'Authenticator'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !1, $6
          8      > JMP                                                      ->14
   48     9  E > > CATCH                                       last         'Exception'
   49    10    >   INIT_METHOD_CALL                                         !2, 'getMessage'
         11        DO_FCALL                                      0  $9      
         12        CONCAT                                           ~10     'System+go+KA-BOOM%21+', $9
         13      > EXIT                                                     ~10
   50    14    > > RETURN                                                   1

Class Authenticator:
Function __construct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 10, Position 2 = 12
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 15
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
Branch analysis from position: 12
filename:       /in/VrOYF
function name:  __construct
number of ops:  16
compiled vars:  !0 = $session, !1 = $isl
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    8     1        ASSIGN_OBJ                                               'session'
          2        OP_DATA                                                  !0
   11     3        INIT_METHOD_CALL                                         !0, 'get'
          4        SEND_VAL_EX                                              'isloggedin'
          5        DO_FCALL                                      0  $3      
          6        ASSIGN                                                   !1, $3
   12     7        ISSET_ISEMPTY_CV                                 ~5      !1
          8        BOOL_NOT                                         ~6      ~5
          9      > JMPZ_EX                                          ~6      ~6, ->12
         10    >   BOOL                                             ~7      !1
         11        BOOL                                             ~6      ~7
         12    > > JMPZ                                                     ~6, ->15
   13    13    >   ASSIGN_OBJ                                               'isloggedin'
         14        OP_DATA                                                  <true>
   15    15    > > RETURN                                                   null

End of function __construct

End of class Authenticator.

Class Session:
Function set:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VrOYF
function name:  set
number of ops:  3
compiled vars:  !0 = $key, !1 = $val
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <true>
          2      > 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/VrOYF
function name:  get
number of ops:  2
compiled vars:  !0 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
          1      > RETURN                                                   null

End of function get

End of class Session.

Class BasicSession:
Function __construct:
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
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VrOYF
function name:  __construct
number of ops:  12
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   INIT_FCALL                                               'session_start'
          1        DO_ICALL                                         $0      
          2        BOOL_NOT                                         ~1      $0
          3      > JMPZ                                                     ~1, ->8
   28     4    >   NEW                                              $2      'Exception'
          5        SEND_VAL_EX                                              'Could+not+initiate+web+session'
          6        DO_FCALL                                      0          
          7      > THROW                                         0          $2
   30     8    >   FETCH_R                      global              ~5      '_SESSION'
          9        ASSIGN_OBJ                                               'session'
         10        OP_DATA                                                  ~5
   31    11      > 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/VrOYF
function name:  set
number of ops:  6
compiled vars:  !0 = $key, !1 = $val
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <true>
   34     2        FETCH_OBJ_W                                      $2      'session'
          3        ASSIGN_DIM                                               $2, !0
          4        OP_DATA                                                  !1
   35     5      > RETURN                                                   null

End of function set

Function get:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 7
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VrOYF
function name:  get
number of ops:  9
compiled vars:  !0 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   37     0  E >   RECV                                             !0      
   38     1        FETCH_OBJ_IS                                     ~1      'session'
          2        ISSET_ISEMPTY_DIM_OBJ                         0          ~1, !0
          3      > JMPZ                                                     ~2, ->7
   39     4    >   FETCH_OBJ_R                                      ~3      'session'
          5        FETCH_DIM_R                                      ~4      ~3, !0
          6      > RETURN                                                   ~4
   41     7    > > RETURN                                                   <false>
   42     8*     > RETURN                                                   null

End of function get

End of class BasicSession.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.88 ms | 1404 KiB | 15 Q