3v4l.org

run code in 500+ PHP versions simultaneously
<?php declare(strict_types=1); error_reporting(E_ALL); class base { public static function get1() { $className = static::class; return new $className(); } public static function get2() { return new self(); } } class foo extends base { } var_dump(foo::class . ' === ' . get_class(foo::get1()) . ' OK'); var_dump(foo::class . ' === ' . get_class(foo::get2()) . ' NOT OKAY');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9VDMR
function name:  (null)
number of ops:  20
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                                   'error_reporting'
          1        SEND_VAL                                                     30719
          2        DO_ICALL                                                     
   25     3        INIT_FCALL                                                   'var_dump'
          4        INIT_STATIC_METHOD_CALL                                      'foo', 'get1'
          5        DO_FCALL                                          0  $1      
          6        GET_CLASS                                            ~2      $1
          7        CONCAT                                               ~3      'foo+%3D%3D%3D+', ~2
          8        CONCAT                                               ~4      ~3, '+OK'
          9        SEND_VAL                                                     ~4
         10        DO_ICALL                                                     
   26    11        INIT_FCALL                                                   'var_dump'
         12        INIT_STATIC_METHOD_CALL                                      'foo', 'get2'
         13        DO_FCALL                                          0  $6      
         14        GET_CLASS                                            ~7      $6
         15        CONCAT                                               ~8      'foo+%3D%3D%3D+', ~7
         16        CONCAT                                               ~9      ~8, '+NOT+OKAY'
         17        SEND_VAL                                                     ~9
         18        DO_ICALL                                                     
         19      > RETURN                                                       1

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

End of function get1

Function get2:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9VDMR
function name:  get2
number of ops:  4
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   15     0  E >   NEW                              self                $0      
          1        DO_FCALL                                          0          
          2      > RETURN                                                       $0
   16     3*     > RETURN                                                       null

End of function get2

End of class base.

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

End of function get1

Function get2:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9VDMR
function name:  get2
number of ops:  4
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   15     0  E >   NEW                              self                $0      
          1        DO_FCALL                                          0          
          2      > RETURN                                                       $0
   16     3*     > RETURN                                                       null

End of function get2

End of class foo.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
154.92 ms | 492 KiB | 11 Q