3v4l.org

run code in 300+ PHP versions simultaneously
<?php function castToString(Stringable|string $variable): string { try { $value = (string) $variable; } catch(\Throwable) { var_dump("Error thrown during string-conversion!"); $value = ''; } return $value; } class MyString { public function __toString(): never { throw new \Exception(); } } castToString(new MyString());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Ze7r6
function name:  (null)
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   DECLARE_CLASS                                            'mystring'
   20     1        INIT_FCALL                                               'casttostring'
          2        NEW                                              $0      'MyString'
          3        DO_FCALL                                      0          
          4        SEND_VAR                                                 $0
          5        DO_FCALL                                      0          
          6      > RETURN                                                   1

Function casttostring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 4
Branch analysis from position: 4
2 jumps found. (Code = 107) Position 1 = 5, Position 2 = -2
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Ze7r6
function name:  castToString
number of ops:  13
compiled vars:  !0 = $variable, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        CAST                                          6  ~2      !0
          2        ASSIGN                                                   !1, ~2
          3      > JMP                                                      ->9
    6     4  E > > CATCH                                       last         'Throwable'
    7     5    >   INIT_FCALL                                               'var_dump'
          6        SEND_VAL                                                 'Error+thrown+during+string-conversion%21'
          7        DO_ICALL                                                 
    8     8        ASSIGN                                                   !1, ''
   11     9    >   VERIFY_RETURN_TYPE                                       !1
         10      > RETURN                                                   !1
   12    11*       VERIFY_RETURN_TYPE                                       
         12*     > RETURN                                                   null

End of function casttostring

Class MyString:
Function __tostring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/Ze7r6
function name:  __toString
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   NEW                                              $0      'Exception'
          1        DO_FCALL                                      0          
          2      > THROW                                         0          $0
   17     3*     > VERIFY_NEVER_TYPE                                        

End of function __tostring

End of class MyString.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148 ms | 1008 KiB | 15 Q