3v4l.org

run code in 300+ PHP versions simultaneously
<?php class C { public function getThis(): self { return $this; } public function getThat(): self { // Fails. return new stdClass; } } var_dump((new C)->getThis()); var_dump((new C)->getThat());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9UU6T
function name:  (null)
number of ops:  15
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   INIT_FCALL                                               'var_dump'
          1        NEW                                              $0      'C'
          2        DO_FCALL                                      0          
          3        INIT_METHOD_CALL                                         $0, 'getThis'
          4        DO_FCALL                                      0  $2      
          5        SEND_VAR                                                 $2
          6        DO_ICALL                                                 
   15     7        INIT_FCALL                                               'var_dump'
          8        NEW                                              $4      'C'
          9        DO_FCALL                                      0          
         10        INIT_METHOD_CALL                                         $4, 'getThat'
         11        DO_FCALL                                      0  $6      
         12        SEND_VAR                                                 $6
         13        DO_ICALL                                                 
         14      > RETURN                                                   1

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

End of function getthis

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

End of function getthat

End of class C.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
171.08 ms | 1396 KiB | 15 Q