3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Cart { public function save(object $repo = null) { if ($repo === null || !$repo instanceof CartRepository) { throw new Exception('Save the cart using the CartRepository' . "\n"); } $repo->save($this); } } class CartRepository { public function save(Cart $cart) { return 'saved!'; } } $repo = new CartRepository(); $cart = new Cart(); try { $cart->save(); } catch (Exception $e) { echo $e->getMessage(); } echo $repo->save($cart);
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: 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 = 62) Position 1 = -2
filename:       /in/uHW1e
function name:  (null)
number of ops:  18
compiled vars:  !0 = $repo, !1 = $cart, !2 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   NEW                                              $3      'CartRepository'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
   24     3        NEW                                              $6      'Cart'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $6
   27     6        INIT_METHOD_CALL                                         !1, 'save'
          7        DO_FCALL                                      0          
          8      > JMP                                                      ->13
   28     9  E > > CATCH                                       last         'Exception'
   29    10    >   INIT_METHOD_CALL                                         !2, 'getMessage'
         11        DO_FCALL                                      0  $10     
         12        ECHO                                                     $10
   32    13    >   INIT_METHOD_CALL                                         !0, 'save'
         14        SEND_VAR_EX                                              !1
         15        DO_FCALL                                      0  $11     
         16        ECHO                                                     $11
         17      > RETURN                                                   1

Class Cart:
Function save:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 3, Position 2 = 6
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 11
Branch analysis from position: 7
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
filename:       /in/uHW1e
function name:  save
number of ops:  16
compiled vars:  !0 = $repo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV_INIT                                        !0      null
    7     1        TYPE_CHECK                                    2  ~1      !0
          2      > JMPNZ_EX                                         ~1      ~1, ->6
          3    >   INSTANCEOF                                       ~2      !0, 'CartRepository'
          4        BOOL_NOT                                         ~3      ~2
          5        BOOL                                             ~1      ~3
          6    > > JMPZ                                                     ~1, ->11
    8     7    >   NEW                                              $4      'Exception'
          8        SEND_VAL_EX                                              'Save+the+cart+using+the+CartRepository%0A'
          9        DO_FCALL                                      0          
         10      > THROW                                         0          $4
   11    11    >   INIT_METHOD_CALL                                         !0, 'save'
         12        FETCH_THIS                                       $6      
         13        SEND_VAR_EX                                              $6
         14        DO_FCALL                                      0          
   12    15      > RETURN                                                   null

End of function save

End of class Cart.

Class CartRepository:
Function save:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uHW1e
function name:  save
number of ops:  3
compiled vars:  !0 = $cart
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
   19     1      > RETURN                                                   'saved%21'
   20     2*     > RETURN                                                   null

End of function save

End of class CartRepository.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.37 ms | 1012 KiB | 13 Q