3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace One { class Request { public function getResponse() { return new Response(); } } class Response { public function __construct() { $debug = debug_backtrace(); if (count($debug) < 2 || !isset($debug[1]['class']) || strpos($debug[1]['class'], __NAMESPACE__ . '\\') !== 0) { die('Invalid context'); } echo 'Created' . PHP_EOL; } } } namespace Two { $request = new \One\Request(); $response = $request->getResponse(); // Should work $wrongResponse = new \One\Response(); // Should NOT work }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/g0dnG
function name:  (null)
number of ops:  10
compiled vars:  !0 = $request, !1 = $response, !2 = $wrongResponse
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   NEW                                              $3      'One%5CRequest'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
   36     3        INIT_METHOD_CALL                                         !0, 'getResponse'
          4        DO_FCALL                                      0  $6      
          5        ASSIGN                                                   !1, $6
   37     6        NEW                                              $8      'One%5CResponse'
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !2, $8
   38     9      > RETURN                                                   1

Class One\Request:
Function getresponse:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/g0dnG
function name:  getResponse
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   NEW                                              $0      'One%5CResponse'
          1        DO_FCALL                                      0          
          2      > RETURN                                                   $0
   12     3*     > RETURN                                                   null

End of function getresponse

End of class One\Request.

Class One\Response:
Function __construct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 8, Position 2 = 12
Branch analysis from position: 8
2 jumps found. (Code = 47) Position 1 = 13, Position 2 = 22
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 24
Branch analysis from position: 23
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
Branch analysis from position: 12
filename:       /in/g0dnG
function name:  __construct
number of ops:  28
compiled vars:  !0 = $debug
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   INIT_NS_FCALL_BY_NAME                                    'One%5Cdebug_backtrace'
          1        DO_FCALL                                      0  $1      
          2        ASSIGN                                                   !0, $1
   22     3        INIT_NS_FCALL_BY_NAME                                    'One%5Ccount'
          4        SEND_VAR_EX                                              !0
          5        DO_FCALL                                      0  $3      
          6        IS_SMALLER                                       ~4      $3, 2
          7      > JMPNZ_EX                                         ~4      ~4, ->12
          8    >   FETCH_DIM_IS                                     ~5      !0, 1
          9        ISSET_ISEMPTY_DIM_OBJ                         0  ~6      ~5, 'class'
         10        BOOL_NOT                                         ~7      ~6
         11        BOOL                                             ~4      ~7
         12    > > JMPNZ_EX                                         ~4      ~4, ->22
         13    >   INIT_NS_FCALL_BY_NAME                                    'One%5Cstrpos'
         14        CHECK_FUNC_ARG                                           
         15        FETCH_DIM_FUNC_ARG                               $8      !0, 1
         16        FETCH_DIM_FUNC_ARG                               $9      $8, 'class'
         17        SEND_FUNC_ARG                                            $9
         18        SEND_VAL_EX                                              'One%5C'
         19        DO_FCALL                                      0  $10     
         20        IS_NOT_IDENTICAL                                 ~11     $10, 0
         21        BOOL                                             ~4      ~11
         22    > > JMPZ                                                     ~4, ->24
   24    23    > > EXIT                                                     'Invalid+context'
   26    24    >   FETCH_CONSTANT                                   ~12     'One%5CPHP_EOL'
         25        CONCAT                                           ~13     'Created', ~12
         26        ECHO                                                     ~13
   27    27      > RETURN                                                   null

End of function __construct

End of class One\Response.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.33 ms | 1400 KiB | 19 Q