3v4l.org

run code in 500+ PHP versions simultaneously
<?php $db_mock = array( 'token' => 'jfdfdkfldkhvmxhfuf', 'scope' => 'User.Profile' ); class API { private static $Token; public static function setToken($token) { self::$Token = $token; } public static function getToken() { return self::$Token; } } class Endpoint { public function __construct() { if(empty(API::getToken())) { throw new Exception('Invalid or undefined token.'); } } public function isToken($db_mock) { // replace with database logic if(in_array(API::getToken(), $db_mock)) { // run the logic for returning response for scope return true; } else { return false; } } } API::setToken('jfdfdkfldkhvmxhfuf'); $e = new Endpoint(); echo (int)$e->isToken($db_mock);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/i20oX
function name:  (null)
number of ops:  13
compiled vars:  !0 = $db_mock, !1 = $e
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   35     1        INIT_STATIC_METHOD_CALL                                      'API', 'setToken'
          2        SEND_VAL                                                     'jfdfdkfldkhvmxhfuf'
          3        DO_FCALL                                          0          
   36     4        NEW                                                  $4      'Endpoint'
          5        DO_FCALL                                          0          
          6        ASSIGN                                                       !1, $4
   37     7        INIT_METHOD_CALL                                             !1, 'isToken'
          8        SEND_VAR_EX                                                  !0
          9        DO_FCALL                                          0  $7      
         10        CAST                                              4  ~8      $7
         11        ECHO                                                         ~8
         12      > RETURN                                                       1

Class API:
Function settoken:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/i20oX
function name:  setToken
number of ops:  4
compiled vars:  !0 = $token
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   10     0  E >   RECV                                                 !0      
   11     1        ASSIGN_STATIC_PROP                                           'Token'
          2        OP_DATA                                                      !0
   12     3      > RETURN                                                       null

End of function settoken

Function gettoken:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/i20oX
function name:  getToken
number of ops:  3
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   14     0  E >   FETCH_STATIC_PROP_R              unknown             ~0      'Token'
          1      > RETURN                                                       ~0
   15     2*     > RETURN                                                       null

End of function gettoken

End of class API.

Class Endpoint:
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/i20oX
function name:  __construct
number of ops:  9
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   20     0  E >   INIT_STATIC_METHOD_CALL                                      'API', 'getToken'
          1        DO_FCALL                                          0  $0      
          2        BOOL_NOT                                             ~1      $0
          3      > JMPZ                                                         ~1, ->8
   21     4    >   NEW                                                  $2      'Exception'
          5        SEND_VAL_EX                                                  'Invalid+or+undefined+token.'
          6        DO_FCALL                                          0          
          7      > THROW                                             0          $2
   23     8    > > RETURN                                                       null

End of function __construct

Function istoken:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 7
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/i20oX
function name:  isToken
number of ops:  9
compiled vars:  !0 = $db_mock
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   25     0  E >   RECV                                                 !0      
   26     1        INIT_STATIC_METHOD_CALL                                      'API', 'getToken'
          2        DO_FCALL                                          0  $1      
          3        FRAMELESS_ICALL_2                in_array            ~2      $1, !0
          4      > JMPZ                                                         ~2, ->7
   28     5    > > RETURN                                                       <true>
   26     6*       JMP                                                          ->8
   30     7    > > RETURN                                                       <false>
   32     8*     > RETURN                                                       null

End of function istoken

End of class Endpoint.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
158.7 ms | 2561 KiB | 13 Q