3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); class Test { function __toInt() { return 10; } function __toFloat() { return 10.00; } function __toString() { return "10"; } } var_dump((int) new Test, (float) new Test, (string) new Test);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IXYG7
function name:  (null)
number of ops:  16
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   DECLARE_CLASS                                            'test'
   19     1        INIT_FCALL                                               'var_dump'
          2        NEW                                              $0      'Test'
          3        DO_FCALL                                      0          
          4        CAST                                          4  ~2      $0
          5        SEND_VAL                                                 ~2
          6        NEW                                              $3      'Test'
          7        DO_FCALL                                      0          
          8        CAST                                          5  ~5      $3
          9        SEND_VAL                                                 ~5
         10        NEW                                              $6      'Test'
         11        DO_FCALL                                      0          
         12        CAST                                          6  ~8      $6
         13        SEND_VAL                                                 ~8
         14        DO_ICALL                                                 
         15      > RETURN                                                   1

Class Test:
Function __toint:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IXYG7
function name:  __toInt
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E > > RETURN                                                   10
    8     1*     > RETURN                                                   null

End of function __toint

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

End of function __tofloat

Function __tostring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IXYG7
function name:  __toString
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E > > RETURN                                                   '10'
   16     1*       VERIFY_RETURN_TYPE                                       
          2*     > RETURN                                                   null

End of function __tostring

End of class Test.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.19 ms | 1396 KiB | 15 Q