3v4l.org

run code in 500+ PHP versions simultaneously
<?php class CustomException extends Exception { public $object; public $wantedValue; public $changedValue; public function __construct( string $msg, SomeClass $object, int $wantedValue, int $changedValue ) { parent::__construct($msg); $this->object = $object; $this->wantedValue = $wantedValue; $this->changedValue = $changedValue; } } class SomeClass { private $value; public function __construct(int $value) { $this->value = $value; if($value > 10) { throw new CustomException( sprintf("Value %d is larger than the max 10 setting to 10!", $value), $this, $value, $this->value = 10 ); } } } $valid = new SomeClass(9); var_dump($valid); try { $invalid = new SomeClass(20); } catch (CustomException $e) { echo PHP_EOL, $e->getMessage(), PHP_EOL, PHP_EOL; $invalid = $e->object; // I can still access the invalid object var_dump($invalid); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 12
Branch analysis from position: 12
2 jumps found. (Code = 107) Position 1 = 13, Position 2 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZUtkn
function name:  (null)
number of ops:  25
compiled vars:  !0 = $valid, !1 = $invalid, !2 = $e
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   40     0  E >   NEW                                                  $3      'SomeClass'
          1        SEND_VAL_EX                                                  9
          2        DO_FCALL                                          0          
          3        ASSIGN                                                       !0, $3
   41     4        INIT_FCALL                                                   'var_dump'
          5        SEND_VAR                                                     !0
          6        DO_ICALL                                                     
   44     7        NEW                                                  $7      'SomeClass'
          8        SEND_VAL_EX                                                  20
          9        DO_FCALL                                          0          
         10        ASSIGN                                                       !1, $7
         11      > JMP                                                          ->24
   45    12  E > > CATCH                                           last         'CustomException'
   46    13    >   ECHO                                                         '%0A'
         14        INIT_METHOD_CALL                                             !2, 'getMessage'
         15        DO_FCALL                                          0  $10     
         16        ECHO                                                         $10
         17        ECHO                                                         '%0A'
         18        ECHO                                                         '%0A'
   47    19        FETCH_OBJ_R                                          ~11     !2, 'object'
         20        ASSIGN                                                       !1, ~11
   48    21        INIT_FCALL                                                   'var_dump'
         22        SEND_VAR                                                     !1
         23        DO_ICALL                                                     
   49    24    > > RETURN                                                       1

Class CustomException:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZUtkn
function name:  __construct
number of ops:  14
compiled vars:  !0 = $msg, !1 = $object, !2 = $wantedValue, !3 = $changedValue
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   10     0  E >   RECV                                                 !0      
   11     1        RECV                                                 !1      
   12     2        RECV                                                 !2      
   13     3        RECV                                                 !3      
   15     4        INIT_STATIC_METHOD_CALL                                      
          5        SEND_VAR_EX                                                  !0
          6        DO_FCALL                                          0          
   17     7        ASSIGN_OBJ                                                   'object'
          8        OP_DATA                                                      !1
   18     9        ASSIGN_OBJ                                                   'wantedValue'
         10        OP_DATA                                                      !2
   19    11        ASSIGN_OBJ                                                   'changedValue'
         12        OP_DATA                                                      !3
   20    13      > RETURN                                                       null

End of function __construct

End of class CustomException.

Class SomeClass:
Function __construct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 19
Branch analysis from position: 5
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZUtkn
function name:  __construct
number of ops:  20
compiled vars:  !0 = $value
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   27     0  E >   RECV                                                 !0      
   29     1        ASSIGN_OBJ                                                   'value'
          2        OP_DATA                                                      !0
   31     3        IS_SMALLER                                                   10, !0
          4      > JMPZ                                                         ~2, ->19
   32     5    >   NEW                                                  $3      'CustomException'
   33     6        ROPE_INIT                                         3  ~6      'Value+'
          7        CAST                                              4  ~4      !0
          8        ROPE_ADD                                          1  ~6      ~6, ~4
          9        ROPE_END                                          2  ~5      ~6, '+is+larger+than+the+max+10+setting+to+10%21'
         10        SEND_VAL_EX                                                  ~5
         11        FETCH_THIS                                           $8      
         12        SEND_VAR_EX                                                  $8
         13        SEND_VAR_EX                                                  !0
   34    14        ASSIGN_OBJ                                           ~9      'value'
         15        OP_DATA                                                      10
         16        SEND_VAL_EX                                                  ~9
   32    17        DO_FCALL                                          0          
   34    18      > THROW                                             0          $3
   37    19    > > RETURN                                                       null

End of function __construct

End of class SomeClass.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
127.56 ms | 483 KiB | 8 Q