3v4l.org

run code in 300+ PHP versions simultaneously
<?php define('MAX_ATTEMPTS', 5); class NetworkException extends Exception { } class FetchDataException extends Exception { private $surpressed = []; public function addSuppressed(Throwable $e): void { $this->surpressed[] = $e; } public function getSuppressed(): array { return $this->surpressed; } } function fetchDataOverNetwork() { $networkExceptions = []; for ($i = 0; $i < MAX_ATTEMPTS; $i++) { try { // Some operation that may throw throw new NetworkException(); } catch (NetworkException $ne) { $networkExceptions[] = $ne; } } $fdException = new FetchDataException("Failed to get data"); foreach ($networkExceptions as $networkException) { $fdException->addSuppressed($networkException); } throw $fdException; } try { fetchDataOverNetwork(); } catch(FetchDataException $fde) { var_dump($fde->getSuppressed()); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 7
Branch analysis from position: 7
2 jumps found. (Code = 107) Position 1 = 8, Position 2 = -2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cboHF
function name:  (null)
number of ops:  14
compiled vars:  !0 = $fde
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'define'
          1        SEND_VAL                                                 'MAX_ATTEMPTS'
          2        SEND_VAL                                                 5
          3        DO_ICALL                                                 
   43     4        INIT_FCALL                                               'fetchdataovernetwork'
          5        DO_FCALL                                      0          
          6      > JMP                                                      ->13
   45     7  E > > CATCH                                       last         'FetchDataException'
   46     8    >   INIT_FCALL                                               'var_dump'
          9        INIT_METHOD_CALL                                         !0, 'getSuppressed'
         10        DO_FCALL                                      0  $3      
         11        SEND_VAR                                                 $3
         12        DO_ICALL                                                 
   47    13    > > RETURN                                                   1

Function fetchdataovernetwork:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 3
Branch analysis from position: 14
2 jumps found. (Code = 77) Position 1 = 19, Position 2 = 24
Branch analysis from position: 19
2 jumps found. (Code = 78) Position 1 = 20, Position 2 = 24
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 24
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 24
Branch analysis from position: 3
1 jumps found. (Code = 108) Position 1 = -2
Found catch point at position: 7
Branch analysis from position: 7
2 jumps found. (Code = 107) Position 1 = 8, Position 2 = -2
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 3
Branch analysis from position: 14
Branch analysis from position: 3
filename:       /in/cboHF
function name:  fetchDataOverNetwork
number of ops:  27
compiled vars:  !0 = $networkExceptions, !1 = $i, !2 = $ne, !3 = $fdException, !4 = $networkException
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   ASSIGN                                                   !0, <array>
   23     1        ASSIGN                                                   !1, 0
          2      > JMP                                                      ->11
   26     3    >   NEW                                              $7      'NetworkException'
          4        DO_FCALL                                      0          
          5      > THROW                                         0          $7
          6*       JMP                                                      ->10
   28     7  E > > CATCH                                       last         'NetworkException'
   29     8    >   ASSIGN_DIM                                               !0
          9        OP_DATA                                                  !2
   23    10        PRE_INC                                                  !1
         11    >   FETCH_CONSTANT                                   ~11     'MAX_ATTEMPTS'
         12        IS_SMALLER                                               !1, ~11
         13      > JMPNZ                                                    ~12, ->3
   33    14    >   NEW                                              $13     'FetchDataException'
         15        SEND_VAL_EX                                              'Failed+to+get+data'
         16        DO_FCALL                                      0          
         17        ASSIGN                                                   !3, $13
   35    18      > FE_RESET_R                                       $16     !0, ->24
         19    > > FE_FETCH_R                                               $16, !4, ->24
   36    20    >   INIT_METHOD_CALL                                         !3, 'addSuppressed'
         21        SEND_VAR_EX                                              !4
         22        DO_FCALL                                      0          
   35    23      > JMP                                                      ->19
         24    >   FE_FREE                                                  $16
   39    25      > THROW                                         0          !3
   40    26*     > RETURN                                                   null

End of function fetchdataovernetwork

Class NetworkException: [no user functions]
Class FetchDataException:
Function addsuppressed:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cboHF
function name:  addSuppressed
number of ops:  5
compiled vars:  !0 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
   11     1        FETCH_OBJ_W                                      $1      'surpressed'
          2        ASSIGN_DIM                                               $1
          3        OP_DATA                                                  !0
   12     4      > RETURN                                                   null

End of function addsuppressed

Function getsuppressed:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cboHF
function name:  getSuppressed
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   FETCH_OBJ_R                                      ~0      'surpressed'
          1        VERIFY_RETURN_TYPE                                       ~0
          2      > RETURN                                                   ~0
   16     3*       VERIFY_RETURN_TYPE                                       
          4*     > RETURN                                                   null

End of function getsuppressed

End of class FetchDataException.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
144.58 ms | 1006 KiB | 16 Q