3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace Foo { class App { const SOME_CONST = 5; public function __construct($a) { echo __METHOD__ . " $a\n"; } } } namespace Foo\Api { class Api { private $var = 2; public function __construct($a) { echo __METHOD__ . " " . get_class($a) . "\n"; } public function run() { echo __METHOD__; } } } namespace Whatever { use Foo\Api\Api; use Foo\App as Foo; // require __DIR__ . '/path/to/vendor/autoload.php'; var_dump( Api::class, // "Foo\Api\Api" class_exists(Api::class), // bool(true) Foo::class, // "Foo\App" class_exists(Foo::class) // bool(true) ); $api = new Api( new Foo(Foo::SOME_CONST) // Fatal Error: Class "Foo\Api\Foo" not found ... ); $api->run(); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YCrEp
function name:  (null)
number of ops:  22
compiled vars:  !0 = $api
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   INIT_NS_FCALL_BY_NAME                                    'Whatever%5Cvar_dump'
   33     1        SEND_VAL_EX                                              'Foo%5CApi%5CApi'
   34     2        INIT_NS_FCALL_BY_NAME                                    'Whatever%5Cclass_exists'
          3        SEND_VAL_EX                                              'Foo%5CApi%5CApi'
          4        DO_FCALL                                      0  $1      
          5        SEND_VAR_NO_REF_EX                                       $1
   35     6        SEND_VAL_EX                                              'Foo%5CApp'
   36     7        INIT_NS_FCALL_BY_NAME                                    'Whatever%5Cclass_exists'
          8        SEND_VAL_EX                                              'Foo%5CApp'
          9        DO_FCALL                                      0  $2      
         10        SEND_VAR_NO_REF_EX                                       $2
         11        DO_FCALL                                      0          
   38    12        NEW                                              $4      'Foo%5CApi%5CApi'
   39    13        NEW                                              $5      'Foo%5CApp'
         14        SEND_VAL_EX                                              5
         15        DO_FCALL                                      0          
         16        SEND_VAR_NO_REF_EX                                       $5
         17        DO_FCALL                                      0          
   38    18        ASSIGN                                                   !0, $4
   41    19        INIT_METHOD_CALL                                         !0, 'run'
         20        DO_FCALL                                      0          
   42    21      > RETURN                                                   1

Class Foo\App:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YCrEp
function name:  __construct
number of ops:  7
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    7     1        ROPE_INIT                                     3  ~2      '+'
          2        ROPE_ADD                                      1  ~2      ~2, !0
          3        ROPE_END                                      2  ~1      ~2, '%0A'
          4        CONCAT                                           ~4      'Foo%5CApp%3A%3A__construct', ~1
          5        ECHO                                                     ~4
    8     6      > RETURN                                                   null

End of function __construct

End of class Foo\App.

Class Foo\Api\Api:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YCrEp
function name:  __construct
number of ops:  8
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
   17     1        INIT_NS_FCALL_BY_NAME                                    'Foo%5CApi%5Cget_class'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0  $1      
          4        CONCAT                                           ~2      'Foo%5CApi%5CApi%3A%3A__construct+', $1
          5        CONCAT                                           ~3      ~2, '%0A'
          6        ECHO                                                     ~3
   18     7      > RETURN                                                   null

End of function __construct

Function run:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YCrEp
function name:  run
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   ECHO                                                     'Foo%5CApi%5CApi%3A%3Arun'
   22     1      > RETURN                                                   null

End of function run

End of class Foo\Api\Api.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
176.84 ms | 1400 KiB | 19 Q