3v4l.org

run code in 500+ PHP versions simultaneously
<?php class Foo { public function __toString() { return '42'; } public function asInt(): int { return $this; } } var_dump((new Foo)->asInt());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UeRYn
function name:  (null)
number of ops:  9
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                                'foo'
   16     1        INIT_FCALL                                                   'var_dump'
          2        NEW                                                  $0      'Foo'
          3        DO_FCALL                                          0          
          4        INIT_METHOD_CALL                                             $0, 'asInt'
          5        DO_FCALL                                          0  $2      
          6        SEND_VAR                                                     $2
          7        DO_ICALL                                                     
          8      > RETURN                                                       1

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

End of function __tostring

Function asint:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UeRYn
function name:  asInt
number of ops:  5
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   12     0  E >   FETCH_THIS                                           ~0      
          1        VERIFY_RETURN_TYPE                                           ~0
          2      > RETURN                                                       ~0
   13     3*       VERIFY_RETURN_TYPE                                           
          4*     > RETURN                                                       null

End of function asint

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
161.1 ms | 2290 KiB | 14 Q