3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class foo { public static function who(){ return __CLASS__; } static public function create($params = array()){ $class = self::who(); return new $class($params); } } class bar extends foo {} print_r(foo::create()); print_r(bar::create());
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/TUZ1p
function name:  (null)
number of ops:  14
compiled vars:  none
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   2     0  E >   NOP                                                      
  12     1        NOP                                                      
         2        NOP                                                      
  14     3        INIT_FCALL                                               'print_r'
         4        INIT_STATIC_METHOD_CALL                                  'foo', 'create'
         5        DO_FCALL                                      0  $3      
         6        SEND_VAR                                                 $3
         7        DO_ICALL                                                 
  15     8        INIT_FCALL                                               'print_r'
         9        INIT_STATIC_METHOD_CALL                                  'bar', 'create'
        10        DO_FCALL                                      0  $5      
        11        SEND_VAR                                                 $5
        12        DO_ICALL                                                 
        13      > RETURN                                                   1

Class foo:
Function who:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/TUZ1p
function name:  who
number of ops:  2
compiled vars:  none
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   4     0  E > > RETURN                                                   'foo'
   5     1*     > RETURN                                                   null

End of function who

Function create:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/TUZ1p
function name:  create
number of ops:  11
compiled vars:  !0 = $params, !1 = $class
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   6     0  E >   RECV_INIT                                        !0      <array>
   7     1        FETCH_CLASS                                 513  :2      
         2        INIT_STATIC_METHOD_CALL                                  $2, 'who'
         3        DO_FCALL                                      0  $3      
         4        ASSIGN                                                   !1, $3
   8     5        FETCH_CLASS                                 512  :5      !1
         6        NEW                                              $6      :5
         7        SEND_VAR_EX                                              !0
         8        DO_FCALL                                      0          
         9      > RETURN                                                   $6
   9    10*     > RETURN                                                   null

End of function create

End of class foo.

Class bar:
Function who:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/TUZ1p
function name:  who
number of ops:  2
compiled vars:  none
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   4     0  E > > RETURN                                                   'foo'
   5     1*     > RETURN                                                   null

End of function who

Function create:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/TUZ1p
function name:  create
number of ops:  11
compiled vars:  !0 = $params, !1 = $class
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   6     0  E >   RECV_INIT                                        !0      <array>
   7     1        FETCH_CLASS                                 513  :2      
         2        INIT_STATIC_METHOD_CALL                                  $2, 'who'
         3        DO_FCALL                                      0  $3      
         4        ASSIGN                                                   !1, $3
   8     5        FETCH_CLASS                                 512  :5      !1
         6        NEW                                              $6      :5
         7        SEND_VAR_EX                                              !0
         8        DO_FCALL                                      0          
         9      > RETURN                                                   $6
   9    10*     > RETURN                                                   null

End of function create

End of class bar.

Generated using Vulcan Logic Dumper, using php 7.2.0