3v4l.org

run code in 300+ PHP versions simultaneously
<?php class foo { public static function getInstance() { $className = __CLASS__; return new $className(); } } class bar extends foo { public static function getInstance() { return parent::getInstance(); } } $obj = bar::getInstance(); var_dump($obj);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Srd4I
function name:  (null)
number of ops:  7
compiled vars:  !0 = $obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   INIT_STATIC_METHOD_CALL                                  'bar', 'getInstance'
          1        DO_FCALL                                      0  $1      
          2        ASSIGN                                                   !0, $1
   17     3        INIT_FCALL                                               'var_dump'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                                 
          6      > RETURN                                                   1

Class foo:
Function getinstance:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Srd4I
function name:  getInstance
number of ops:  6
compiled vars:  !0 = $className
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                   !0, 'foo'
    5     1        FETCH_CLASS                                   0  $2      !0
          2        NEW                                              $3      $2
          3        DO_FCALL                                      0          
          4      > RETURN                                                   $3
    6     5*     > RETURN                                                   null

End of function getinstance

End of class foo.

Class bar:
Function getinstance:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Srd4I
function name:  getInstance
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   INIT_STATIC_METHOD_CALL                                  'getInstance'
          1        DO_FCALL                                      0  $0      
          2      > RETURN                                                   $0
   12     3*     > RETURN                                                   null

End of function getinstance

End of class bar.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.73 ms | 1395 KiB | 15 Q