3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types = 1); class A { function f(): string { return (string) (new A()); } function __toString() { return "5"; } } echo (new A())->f(); echo "\n\r"; echo ((new A())->f()) + "2";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2KdVU
function name:  (null)
number of ops:  14
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   DECLARE_CLASS                                            'a'
   14     1        NEW                                              $0      'A'
          2        DO_FCALL                                      0          
          3        INIT_METHOD_CALL                                         $0, 'f'
          4        DO_FCALL                                      0  $2      
          5        ECHO                                                     $2
   15     6        ECHO                                                     '%0A%0D'
   16     7        NEW                                              $3      'A'
          8        DO_FCALL                                      0          
          9        INIT_METHOD_CALL                                         $3, 'f'
         10        DO_FCALL                                      0  $5      
         11        ADD                                              ~6      $5, '2'
         12        ECHO                                                     ~6
         13      > RETURN                                                   1

Class A:
Function f:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2KdVU
function name:  f
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   NEW                                              $0      'A'
          1        DO_FCALL                                      0          
          2        CAST                                          6  ~2      $0
          3        VERIFY_RETURN_TYPE                                       ~2
          4      > RETURN                                                   ~2
    7     5*       VERIFY_RETURN_TYPE                                       
          6*     > RETURN                                                   null

End of function f

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

End of function __tostring

End of class A.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.63 ms | 1449 KiB | 13 Q