3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test{ const OFF = -2147483647; // Logging is turned Off const OFF_STR = 'OFF'; const FATAL = -1; // Identical to Emergency const FATAL_STR = 'FATAL'; const EMERGENCY = 0; // System is unusable const EMERGENCY_STR = 'EMERGENCY'; const ALERT = 100; // Action Must be Taken Immediately const ALERT_STR = 'ALERT'; const CRITICAL = 200; // Critical Conditions const CRITICAL_STR = 'CRITICAL'; const ERROR = 300; // Error Conditions const ERROR_STR = 'ERROR'; const WARNING = 400; // Warning Conditions const WARNING_STR = 'WARNING'; const NOTICE = 500; // Normal, but significant conditions const NOTICE_STR = 'NOTICE'; const INFO = 600; // Informational messages const INFO_STR = 'INFO'; const DEBUG = 700; // Debug Level Messages const DEBUG_STR = 'DEBUG'; const TRACE = 800; // Trace Level Messages const TRACE_STR = 'TRACE'; const ALL = 2147483647; // Every Possible Log Level const ALL_STR = 'ALL'; private function Test($level, $levelStr){ $this->level = $level; $this->levelStr = $levelStr; } public static function getSomething(){ $cName = 'SOMETHING'; $sName = 'something'; self::setMap($cName,$sName); return self::$someMap[constant('Test::'.$cName)]; } public static function initLevelMap(){ $oClass = new ReflectionClass (__CLASS__); $constants = $oClass->getConstants(); foreach ($constants as $constant){ if (is_int($constant) && array_key_exists($constant.'_STR', $constants)){ print "$constant looks good.\n"; } } //var_dump($constants); } public static function setMap($cName,$sName){ if(!isset(self::$someMap[constant('Test::'.$cName)])) { print "setting it"; self::$someMap[constant('Test::'.$cName)] = new Test(constant('Test::'.$cName), $sName); } return self::$someMap; } } Test::initLevelMap();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bUuhM
function name:  (null)
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   76     0  E >   INIT_STATIC_METHOD_CALL                                  'Test', 'initLevelMap'
          1        DO_FCALL                                      0          
          2      > RETURN                                                   1

Class Test:
Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bUuhM
function name:  Test
number of ops:  7
compiled vars:  !0 = $level, !1 = $levelStr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   42     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   43     2        ASSIGN_OBJ                                               'level'
          3        OP_DATA                                                  !0
   44     4        ASSIGN_OBJ                                               'levelStr'
          5        OP_DATA                                                  !1
   45     6      > RETURN                                                   null

End of function test

Function getsomething:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bUuhM
function name:  getSomething
number of ops:  14
compiled vars:  !0 = $cName, !1 = $sName
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   48     0  E >   ASSIGN                                                   !0, 'SOMETHING'
   49     1        ASSIGN                                                   !1, 'something'
   50     2        INIT_STATIC_METHOD_CALL                                  'setMap'
          3        SEND_VAR_EX                                              !0
          4        SEND_VAR_EX                                              !1
          5        DO_FCALL                                      0          
   51     6        INIT_FCALL                                               'constant'
          7        CONCAT                                           ~6      'Test%3A%3A', !0
          8        SEND_VAL                                                 ~6
          9        DO_ICALL                                         $7      
         10        FETCH_STATIC_PROP_R          unknown             ~5      'someMap'
         11        FETCH_DIM_R                                      ~8      ~5, $7
         12      > RETURN                                                   ~8
   52    13*     > RETURN                                                   null

End of function getsomething

Function initlevelmap:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 19
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 19
Branch analysis from position: 9
2 jumps found. (Code = 46) Position 1 = 11, Position 2 = 14
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 18
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 18
Branch analysis from position: 14
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
filename:       /in/bUuhM
function name:  initLevelMap
number of ops:  21
compiled vars:  !0 = $oClass, !1 = $constants, !2 = $constant
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   55     0  E >   NEW                                              $3      'ReflectionClass'
          1        SEND_VAL_EX                                              'Test'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $3
   56     4        INIT_METHOD_CALL                                         !0, 'getConstants'
          5        DO_FCALL                                      0  $6      
          6        ASSIGN                                                   !1, $6
   57     7      > FE_RESET_R                                       $8      !1, ->19
          8    > > FE_FETCH_R                                               $8, !2, ->19
   58     9    >   TYPE_CHECK                                   16  ~9      !2
         10      > JMPZ_EX                                          ~9      ~9, ->14
         11    >   CONCAT                                           ~10     !2, '_STR'
         12        ARRAY_KEY_EXISTS                                 ~11     ~10, !1
         13        BOOL                                             ~9      ~11
         14    > > JMPZ                                                     ~9, ->18
   59    15    >   NOP                                                      
         16        FAST_CONCAT                                      ~12     !2, '+looks+good.%0A'
         17        ECHO                                                     ~12
   57    18    > > JMP                                                      ->8
         19    >   FE_FREE                                                  $8
   64    20      > RETURN                                                   null

End of function initlevelmap

Function setmap:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 26
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
filename:       /in/bUuhM
function name:  setMap
number of ops:  29
compiled vars:  !0 = $cName, !1 = $sName
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   66     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   67     2        INIT_FCALL                                               'constant'
          3        CONCAT                                           ~3      'Test%3A%3A', !0
          4        SEND_VAL                                                 ~3
          5        DO_ICALL                                         $4      
          6        FETCH_STATIC_PROP_IS                             ~2      'someMap'
          7        ISSET_ISEMPTY_DIM_OBJ                         0  ~5      ~2, $4
          8        BOOL_NOT                                         ~6      ~5
          9      > JMPZ                                                     ~6, ->26
   68    10    >   ECHO                                                     'setting+it'
   69    11        INIT_FCALL                                               'constant'
         12        CONCAT                                           ~8      'Test%3A%3A', !0
         13        SEND_VAL                                                 ~8
         14        DO_ICALL                                         $9      
         15        NEW                                              $11     'Test'
         16        INIT_FCALL                                               'constant'
         17        CONCAT                                           ~12     'Test%3A%3A', !0
         18        SEND_VAL                                                 ~12
         19        DO_ICALL                                         $13     
         20        SEND_VAR_NO_REF_EX                                       $13
         21        SEND_VAR_EX                                              !1
         22        DO_FCALL                                      0          
         23        FETCH_STATIC_PROP_W          unknown             $7      'someMap'
         24        ASSIGN_DIM                                               $7, $9
         25        OP_DATA                                                  $11
   71    26    >   FETCH_STATIC_PROP_R          unknown             ~15     'someMap'
         27      > RETURN                                                   ~15
   72    28*     > RETURN                                                   null

End of function setmap

End of class Test.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
141.93 ms | 1404 KiB | 15 Q