3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php if (!function_exists('interface_exists')) { die('PHP version too old'); } $throwables = listThrowableClasses(); $throwablesPerParent = splitInParents($throwables); printTree($throwablesPerParent); if (count($throwablesPerParent) !== 0) { die('ERROR!!!'); } function listThrowableClasses() { $result = array(); if (interface_exists('Throwable')) { foreach (get_declared_classes() as $cn) { $implements = class_implements($cn); if (isset($implements['Throwable'])) { $result[] = $cn; } } } else { foreach (get_declared_classes() as $cn) { if ($cn === 'Exception' || is_subclass_of($cn, 'Exception')) { $result[] = $cn; } } } return $result; } function splitInParents($classes) { $result = array(); foreach ($classes as $cn) { $parent = (string) get_parent_class($cn); if (isset($result[$parent])) { $result[$parent][] = $cn; } else { $result[$parent] = array($cn); } } return $result; } function printTree(&$tree) { if (!isset($tree[''])) { die('No root classes!!!'); } printLeaves($tree, '', 0); } function printLeaves(&$tree, $parent, $level) { if (isset($tree[$parent])) { $leaves = $tree[$parent]; unset($tree[$parent]); natcasesort($leaves); $leaves = array_values($leaves); $count = count($leaves); for ($i = 0; $i < $count; $i++) { $leaf = $leaves[$i]; echo str_repeat(' ', $level), $leaf, "\n"; printLeaves($tree, $leaf, $level + 1); } } }
Finding entry points
Branch analysis from position: 0
Jump found. (Code = 43) Position 1 = 5, Position 2 = 6
Branch analysis from position: 5
Jump found. (Code = 79) Position 1 = -2
Branch analysis from position: 6
Jump found. (Code = 43) Position 1 = 21, Position 2 = 22
Branch analysis from position: 21
Jump found. (Code = 79) Position 1 = -2
Branch analysis from position: 22
Jump found. (Code = 62) Position 1 = -2
filename:       /in/sDMsv
function name:  (null)
number of ops:  27
compiled vars:  !0 = $throwables, !1 = $throwablesPerParent
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   3     0  E >   INIT_FCALL                                               'function_exists'
         1        SEND_VAL                                                 'interface_exists'
         2        DO_ICALL                                         $2      
         3        BOOL_NOT                                         ~3      $2
         4      > JMPZ                                                     ~3, ->6
   4     5    > > EXIT                                                     'PHP+version+too+old'
   6     6    >   INIT_FCALL_BY_NAME                                       'listThrowableClasses'
         7        DO_FCALL                                      0  $4      
         8        ASSIGN                                                   !0, $4
   7     9        INIT_FCALL_BY_NAME                                       'splitInParents'
        10        SEND_VAR_EX                                              !0
        11        DO_FCALL                                      0  $6      
        12        ASSIGN                                                   !1, $6
   8    13        INIT_FCALL_BY_NAME                                       'printTree'
        14        SEND_VAR_EX                                              !1
        15        DO_FCALL                                      0          
   9    16        INIT_FCALL                                               'count'
        17        SEND_VAR                                                 !1
        18        DO_ICALL                                         $9      
        19        IS_NOT_IDENTICAL                                 ~10     $9, 0
        20      > JMPZ                                                     ~10, ->22
  10    21    > > EXIT                                                     'ERROR%21%21%21'
  13    22    >   NOP                                                      
  33    23        NOP                                                      
  48    24        NOP                                                      
  55    25        NOP                                                      
  69    26      > RETURN                                                   1

Function listthrowableclasses:
Finding entry points
Branch analysis from position: 0
Jump found. (Code = 43) Position 1 = 5, Position 2 = 20
Branch analysis from position: 5
Jump found. (Code = 77) Position 1 = 8, Position 2 = 18
Branch analysis from position: 8
Jump found. (Code = 78) Position 1 = 9, Position 2 = 18
Branch analysis from position: 9
Jump found. (Code = 43) Position 1 = 15, Position 2 = 17
Branch analysis from position: 15
Jump found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 17
Branch analysis from position: 18
Jump found. (Code = 42) Position 1 = 36
Branch analysis from position: 36
Jump found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
Branch analysis from position: 20
Jump found. (Code = 77) Position 1 = 23, Position 2 = 35
Branch analysis from position: 23
Jump found. (Code = 78) Position 1 = 24, Position 2 = 35
Branch analysis from position: 24
Jump found. (Code = 47) Position 1 = 26, Position 2 = 31
Branch analysis from position: 26
Jump found. (Code = 43) Position 1 = 32, Position 2 = 34
Branch analysis from position: 32
Jump found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
Branch analysis from position: 34
Branch analysis from position: 31
Branch analysis from position: 35
Jump found. (Code = 62) Position 1 = -2
Branch analysis from position: 35
filename:       /in/sDMsv
function name:  listThrowableClasses
number of ops:  38
compiled vars:  !0 = $result, !1 = $cn, !2 = $implements
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  15     0  E >   ASSIGN                                                   !0, <array>
  16     1        INIT_FCALL                                               'interface_exists'
         2        SEND_VAL                                                 'Throwable'
         3        DO_ICALL                                         $4      
         4      > JMPZ                                                     $4, ->20
  17     5    >   INIT_FCALL                                               'get_declared_classes'
         6        DO_ICALL                                         $5      
         7      > FE_RESET_R                                       $6      $5, ->18
         8    > > FE_FETCH_R                                               $6, !1, ->18
  18     9    >   INIT_FCALL                                               'class_implements'
        10        SEND_VAR                                                 !1
        11        DO_ICALL                                         $7      
        12        ASSIGN                                                   !2, $7
  19    13        ISSET_ISEMPTY_DIM_OBJ                       33554432  ~9      !2, 'Throwable'
        14      > JMPZ                                                     ~9, ->17
  20    15    >   ASSIGN_DIM                                               !0
        16        OP_DATA                                                  !1
        17    > > JMP                                                      ->8
        18    >   FE_FREE                                                  $6
        19      > JMP                                                      ->36
  24    20    >   INIT_FCALL                                               'get_declared_classes'
        21        DO_ICALL                                         $11     
        22      > FE_RESET_R                                       $12     $11, ->35
        23    > > FE_FETCH_R                                               $12, !1, ->35
  25    24    >   IS_IDENTICAL                                     ~13     !1, 'Exception'
        25      > JMPNZ_EX                                         ~13     ~13, ->31
        26    >   INIT_FCALL                                               'is_subclass_of'
        27        SEND_VAR                                                 !1
        28        SEND_VAL                                                 'Exception'
        29        DO_ICALL                                         $14     
        30        BOOL                                             ~13     $14
        31    > > JMPZ                                                     ~13, ->34
  26    32    >   ASSIGN_DIM                                               !0
        33        OP_DATA                                                  !1
        34    > > JMP                                                      ->23
        35    >   FE_FREE                                                  $12
  30    36    > > RETURN                                                   !0
  31    37*     > RETURN                                                   null

End of function listthrowableclasses

Function splitinparents:
Finding entry points
Branch analysis from position: 0
Jump found. (Code = 77) Position 1 = 3, Position 2 = 19
Branch analysis from position: 3
Jump found. (Code = 78) Position 1 = 4, Position 2 = 19
Branch analysis from position: 4
Jump found. (Code = 43) Position 1 = 11, Position 2 = 15
Branch analysis from position: 11
Jump found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
Jump found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 15
Jump found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 19
Jump found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
filename:       /in/sDMsv
function name:  splitInParents
number of ops:  22
compiled vars:  !0 = $classes, !1 = $result, !2 = $cn, !3 = $parent
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  33     0  E >   RECV                                             !0      
  35     1        ASSIGN                                                   !1, <array>
  36     2      > FE_RESET_R                                       $5      !0, ->19
         3    > > FE_FETCH_R                                               $5, !2, ->19
  37     4    >   INIT_FCALL                                               'get_parent_class'
         5        SEND_VAR                                                 !2
         6        DO_ICALL                                         $6      
         7        CAST                                          6  ~7      $6
         8        ASSIGN                                                   !3, ~7
  38     9        ISSET_ISEMPTY_DIM_OBJ                       33554432  ~9      !1, !3
        10      > JMPZ                                                     ~9, ->15
  39    11    >   FETCH_DIM_W                                      $10     !1, !3
        12        ASSIGN_DIM                                               $10
        13        OP_DATA                                                  !2
        14      > JMP                                                      ->18
  41    15    >   INIT_ARRAY                                       ~13     !2
        16        ASSIGN_DIM                                               !1, !3
        17        OP_DATA                                                  ~13
        18    > > JMP                                                      ->3
        19    >   FE_FREE                                                  $5
  45    20      > RETURN                                                   !1
  46    21*     > RETURN                                                   null

End of function splitinparents

Function printtree:
Finding entry points
Branch analysis from position: 0
Jump found. (Code = 43) Position 1 = 4, Position 2 = 5
Branch analysis from position: 4
Jump found. (Code = 79) Position 1 = -2
Branch analysis from position: 5
Jump found. (Code = 62) Position 1 = -2
filename:       /in/sDMsv
function name:  printTree
number of ops:  11
compiled vars:  !0 = $tree
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  48     0  E >   RECV                                             !0      
  50     1        ISSET_ISEMPTY_DIM_OBJ                       33554432  ~1      !0, ''
         2        BOOL_NOT                                         ~2      ~1
         3      > JMPZ                                                     ~2, ->5
  51     4    > > EXIT                                                     'No+root+classes%21%21%21'
  53     5    >   INIT_FCALL_BY_NAME                                       'printLeaves'
         6        SEND_VAR_EX                                              !0
         7        SEND_VAL_EX                                              ''
         8        SEND_VAL_EX                                              0
         9        DO_FCALL                                      0          
  54    10      > RETURN                                                   null

End of function printtree

Function printleaves:
Finding entry points
Branch analysis from position: 0
Jump found. (Code = 43) Position 1 = 5, Position 2 = 40
Branch analysis from position: 5
Jump found. (Code = 42) Position 1 = 38
Branch analysis from position: 38
Jump found. (Code = 44) Position 1 = 40, Position 2 = 21
Branch analysis from position: 40
Jump found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
Jump found. (Code = 44) Position 1 = 40, Position 2 = 21
Branch analysis from position: 40
Branch analysis from position: 21
Branch analysis from position: 40
filename:       /in/sDMsv
function name:  printLeaves
number of ops:  41
compiled vars:  !0 = $tree, !1 = $parent, !2 = $level, !3 = $leaves, !4 = $count, !5 = $i, !6 = $leaf
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  55     0  E >   RECV                                             !0      
         1        RECV                                             !1      
         2        RECV                                             !2      
  57     3        ISSET_ISEMPTY_DIM_OBJ                       33554432  ~7      !0, !1
         4      > JMPZ                                                     ~7, ->40
  58     5    >   FETCH_DIM_R                                      $8      !0, !1
         6        ASSIGN                                                   !3, $8
  59     7        UNSET_DIM                                                !0, !1
  60     8        INIT_FCALL                                               'natcasesort'
         9        SEND_REF                                                 !3
        10        DO_ICALL                                                 
  61    11        INIT_FCALL                                               'array_values'
        12        SEND_VAR                                                 !3
        13        DO_ICALL                                         $11     
        14        ASSIGN                                                   !3, $11
  62    15        INIT_FCALL                                               'count'
        16        SEND_VAR                                                 !3
        17        DO_ICALL                                         $13     
        18        ASSIGN                                                   !4, $13
  63    19        ASSIGN                                                   !5, 0
        20      > JMP                                                      ->38
  64    21    >   FETCH_DIM_R                                      $16     !3, !5
        22        ASSIGN                                                   !6, $16
  65    23        INIT_FCALL                                               'str_repeat'
        24        SEND_VAL                                                 '++'
        25        SEND_VAR                                                 !2
        26        DO_ICALL                                         $18     
        27        ECHO                                                     $18
        28        ECHO                                                     !6
        29        ECHO                                                     '%0A'
  66    30        INIT_FCALL_BY_NAME                                       'printLeaves'
        31        SEND_VAR_EX                                              !0
        32        SEND_VAR_EX                                              !6
        33        ADD                                              ~19     !2, 1
        34        SEND_VAL_EX                                              ~19
        35        DO_FCALL                                      0          
  63    36        POST_INC                                         ~21     !5
        37        FREE                                                     ~21
        38    >   IS_SMALLER                                       ~22     !5, !4
        39      > JMPNZ                                                    ~22, ->21
  69    40    > > RETURN                                                   null

End of function printleaves

Generated using Vulcan Logic Dumper, using php 7.1.0