3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Example { private $label; public function __construct($label) { $this->label = $label; } public function __sleep() { echo "Attempt to serialize object with label $this->label\n"; return array('label'); } public function __destruct() { echo "Refcount reached zero for object with label $this->label\n"; } public function throwSomething($unused_parameter) { throw new Exception; } } echo "-- No object in stack trace --\n"; $target = new Example('Target of method call'); try { $target->throwSomething('irrelevant data'); } catch ( Exception $e ) { // Serialize exception, doesn't touch object var_dump(serialize($e)); // Destroy $target, as there are no other references to it unset($target); } echo "-- No object as argument captured in stack trace --\n"; $target = new Example('Target of method call'); $parameter = new Example('Parameter passed but never actually used'); try { $target->throwSomething($parameter); } catch ( Exception $e ) { // Serialize exception, will attempt to serialize $parameter var_dump(serialize($e)); // Destroy $target, as there are no other references to it unset($target); // Attempt to do the same for $parameter, Exception holds a reference unset($parameter); } echo "-- PHP process cleanup begins here --\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
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 = 42) Position 1 = 39
Branch analysis from position: 39
Found catch point at position: 30
Branch analysis from position: 30
2 jumps found. (Code = 107) Position 1 = 31, Position 2 = -2
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hOYb9
function name:  (null)
number of ops:  41
compiled vars:  !0 = $target, !1 = $e, !2 = $parameter
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   ECHO                                                     '--+No+object+in+stack+trace+--%0A'
   21     1        NEW                                              $3      'Example'
          2        SEND_VAL_EX                                              'Target+of+method+call'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $3
   23     5        INIT_METHOD_CALL                                         !0, 'throwSomething'
          6        SEND_VAL_EX                                              'irrelevant+data'
          7        DO_FCALL                                      0          
          8      > JMP                                                      ->17
   25     9  E > > CATCH                                       last         'Exception'
   27    10    >   INIT_FCALL                                               'var_dump'
         11        INIT_FCALL                                               'serialize'
         12        SEND_VAR                                                 !1
         13        DO_ICALL                                         $7      
         14        SEND_VAR                                                 $7
         15        DO_ICALL                                                 
   29    16        UNSET_CV                                                 !0
   32    17    >   ECHO                                                     '--+No+object+as+argument+captured+in+stack+trace+--%0A'
   33    18        NEW                                              $9      'Example'
         19        SEND_VAL_EX                                              'Target+of+method+call'
         20        DO_FCALL                                      0          
         21        ASSIGN                                                   !0, $9
   34    22        NEW                                              $12     'Example'
         23        SEND_VAL_EX                                              'Parameter+passed+but+never+actually+used'
         24        DO_FCALL                                      0          
         25        ASSIGN                                                   !2, $12
   36    26        INIT_METHOD_CALL                                         !0, 'throwSomething'
         27        SEND_VAR_EX                                              !2
         28        DO_FCALL                                      0          
         29      > JMP                                                      ->39
   38    30  E > > CATCH                                       last         'Exception'
   40    31    >   INIT_FCALL                                               'var_dump'
         32        INIT_FCALL                                               'serialize'
         33        SEND_VAR                                                 !1
         34        DO_ICALL                                         $16     
         35        SEND_VAR                                                 $16
         36        DO_ICALL                                                 
   42    37        UNSET_CV                                                 !0
   44    38        UNSET_CV                                                 !2
   47    39    >   ECHO                                                     '--+PHP+process+cleanup+begins+here+--%0A'
         40      > RETURN                                                   1

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

End of function __construct

Function __sleep:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hOYb9
function name:  __sleep
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   ROPE_INIT                                     3  ~2      'Attempt+to+serialize+object+with+label+'
          1        FETCH_OBJ_R                                      ~0      'label'
          2        ROPE_ADD                                      1  ~2      ~2, ~0
          3        ROPE_END                                      2  ~1      ~2, '%0A'
          4        ECHO                                                     ~1
   10     5      > RETURN                                                   <array>
   11     6*     > RETURN                                                   null

End of function __sleep

Function __destruct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hOYb9
function name:  __destruct
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   ROPE_INIT                                     3  ~2      'Refcount+reached+zero+for+object+with+label+'
          1        FETCH_OBJ_R                                      ~0      'label'
          2        ROPE_ADD                                      1  ~2      ~2, ~0
          3        ROPE_END                                      2  ~1      ~2, '%0A'
          4        ECHO                                                     ~1
   14     5      > RETURN                                                   null

End of function __destruct

Function throwsomething:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/hOYb9
function name:  throwSomething
number of ops:  5
compiled vars:  !0 = $unused_parameter
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
   16     1        NEW                                              $1      'Exception'
          2        DO_FCALL                                      0          
          3      > THROW                                         0          $1
   17     4*     > RETURN                                                   null

End of function throwsomething

End of class Example.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138.88 ms | 1006 KiB | 15 Q