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::CLASS, Baz::getCalledClass(), Baz::getClass()], [Biz::CLASS, Biz::getCalledClass(), Biz::getClass()] );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9gtqN
function name:  (null)
number of ops:  21
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_ARRAY                                       ~0      'Foo%5CBar'
          4        INIT_STATIC_METHOD_CALL                                  'Foo%5CBar', 'getCalledClass'
          5        DO_FCALL                                      0  $1      
          6        ADD_ARRAY_ELEMENT                                ~0      $1
          7        INIT_STATIC_METHOD_CALL                                  'Foo%5CBar', 'getClass'
          8        DO_FCALL                                      0  $2      
          9        ADD_ARRAY_ELEMENT                                ~0      $2
         10        SEND_VAL_EX                                              ~0
   24    11        INIT_ARRAY                                       ~3      'Foo%5CBiz'
         12        INIT_STATIC_METHOD_CALL                                  'Foo%5CBiz', 'getCalledClass'
         13        DO_FCALL                                      0  $4      
         14        ADD_ARRAY_ELEMENT                                ~3      $4
         15        INIT_STATIC_METHOD_CALL                                  'Foo%5CBiz', 'getClass'
         16        DO_FCALL                                      0  $5      
         17        ADD_ARRAY_ELEMENT                                ~3      $5
         18        SEND_VAL_EX                                              ~3
         19        DO_FCALL                                      0          
   25    20      > 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/9gtqN
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/9gtqN
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:
149.93 ms | 1396 KiB | 17 Q