3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Lock { function __destruct() { echo "***lock released now***\n"; } } class LockedFile { private $lock; function __construct(string $path) { $this->lock = new Lock(); } } class LineReader { function __construct(private LockedFile $file) {} function readLines() { } } function process_lines(LineReader $reader) { throw new Exception("readLines"); } function process_file(string $path): string { try { $file = new LockedFile($path); $reader = new LineReader($file); process_lines($reader); } catch (Exception $e) { // release file echo "unsetting \$file, \$reader...\n"; unset($file, $reader); // $file is still referenced via $e->getTrace()[0]['args'][0]->file throw new Exception('Processing failed', previous: $e); } return $content; } process_file('/some/file.txt');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lsicN
function name:  (null)
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   44     0  E >   INIT_FCALL                                               'process_file'
          1        SEND_VAL                                                 '%2Fsome%2Ffile.txt'
          2        DO_FCALL                                      0          
          3      > RETURN                                                   1

Function process_lines:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/lsicN
function name:  process_lines
number of ops:  6
compiled vars:  !0 = $reader
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   RECV                                             !0      
   23     1        NEW                                              $1      'Exception'
          2        SEND_VAL_EX                                              'readLines'
          3        DO_FCALL                                      0          
          4      > THROW                                         0          $1
   24     5*     > RETURN                                                   null

End of function process_lines

Function process_file:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 13
Branch analysis from position: 13
2 jumps found. (Code = 107) Position 1 = 14, Position 2 = -2
Branch analysis from position: 14
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/lsicN
function name:  process_file
number of ops:  27
compiled vars:  !0 = $path, !1 = $file, !2 = $reader, !3 = $e, !4 = $content
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   RECV                                             !0      
   28     1        NEW                                              $5      'LockedFile'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !1, $5
   29     5        NEW                                              $8      'LineReader'
          6        SEND_VAR_EX                                              !1
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !2, $8
   30     9        INIT_FCALL                                               'process_lines'
         10        SEND_VAR                                                 !2
         11        DO_FCALL                                      0          
         12      > JMP                                                      ->23
   31    13  E > > CATCH                                       last         'Exception'
   33    14    >   ECHO                                                     'unsetting+%24file%2C+%24reader...%0A'
   34    15        UNSET_CV                                                 !1
         16        UNSET_CV                                                 !2
   38    17        NEW                                              $12     'Exception'
         18        SEND_VAL_EX                                              'Processing+failed'
         19        SEND_VAR_EX                                              !3, 'previous'
         20        CHECK_UNDEF_ARGS                                         
         21        DO_FCALL                                      1          
         22      > THROW                                         0          $12
   41    23    >   VERIFY_RETURN_TYPE                                       !4
         24      > RETURN                                                   !4
   42    25*       VERIFY_RETURN_TYPE                                       
         26*     > RETURN                                                   null

End of function process_file

Class Lock:
Function __destruct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lsicN
function name:  __destruct
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   ECHO                                                     '%2A%2A%2Alock+released+now%2A%2A%2A%0A'
    6     1      > RETURN                                                   null

End of function __destruct

End of class Lock.

Class LockedFile:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lsicN
function name:  __construct
number of ops:  6
compiled vars:  !0 = $path
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
   12     1        NEW                                              $2      'Lock'
          2        DO_FCALL                                      0          
          3        ASSIGN_OBJ                                               'lock'
          4        OP_DATA                                                  $2
   13     5      > RETURN                                                   null

End of function __construct

End of class LockedFile.

Class LineReader:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lsicN
function name:  __construct
number of ops:  4
compiled vars:  !0 = $file
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
          1        ASSIGN_OBJ                                               'file'
          2        OP_DATA                                                  !0
          3      > RETURN                                                   null

End of function __construct

Function readlines:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lsicN
function name:  readLines
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E > > RETURN                                                   null

End of function readlines

End of class LineReader.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.49 ms | 1010 KiB | 15 Q