3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace Foo; use Foo\Bar as Baz; trait getClass { public static function getClass() { return __CLASS__; } public static function getCalledClass() { return get_called_class(); } } class Bar { use GetClass; } class Biz extends Bar {} var_dump( [Baz::getCalledClass(), Baz::getClass()], [Biz::getCalledClass(), Biz::getClass()] );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dn9Iv
function name:  (null)
number of ops:  19
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   DECLARE_CLASS                                            'foo%5Cbar'
   20     1        DECLARE_CLASS                                            'foo%5Cbiz', 'foo%5Cbar'
   22     2        INIT_NS_FCALL_BY_NAME                                    'Foo%5Cvar_dump'
   23     3        INIT_STATIC_METHOD_CALL                                  'Foo%5CBar', 'getCalledClass'
          4        DO_FCALL                                      0  $0      
          5        INIT_ARRAY                                       ~1      $0
          6        INIT_STATIC_METHOD_CALL                                  'Foo%5CBar', 'getClass'
          7        DO_FCALL                                      0  $2      
          8        ADD_ARRAY_ELEMENT                                ~1      $2
          9        SEND_VAL_EX                                              ~1
   24    10        INIT_STATIC_METHOD_CALL                                  'Foo%5CBiz', 'getCalledClass'
         11        DO_FCALL                                      0  $3      
         12        INIT_ARRAY                                       ~4      $3
         13        INIT_STATIC_METHOD_CALL                                  'Foo%5CBiz', 'getClass'
         14        DO_FCALL                                      0  $5      
         15        ADD_ARRAY_ELEMENT                                ~4      $5
         16        SEND_VAL_EX                                              ~4
         17        DO_FCALL                                      0          
   25    18      > RETURN                                                   1

Class Foo\getClass:
Function getclass:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dn9Iv
function name:  getClass
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   FETCH_CLASS_NAME                                 ~0      
          1      > RETURN                                                   ~0
    9     2*     > RETURN                                                   null

End of function getclass

Function getcalledclass:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dn9Iv
function name:  getCalledClass
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   INIT_NS_FCALL_BY_NAME                                    'Foo%5Cget_called_class'
          1        DO_FCALL                                      0  $0      
          2      > RETURN                                                   $0
   12     3*     > RETURN                                                   null

End of function getcalledclass

End of class Foo\getClass.

Class Foo\Bar: [no user functions]
Class Foo\Biz: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.36 ms | 1401 KiB | 17 Q