3v4l.org

run code in 500+ 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 = 27
Branch analysis from position: 13
2 jumps found. (Code = 208) Position 1 = 14, Position 2 = 22
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 31
Branch analysis from position: 28
1 jumps found. (Code = 61) Position 1 = -2
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 31
Branch analysis from position: 28
Branch analysis from position: 31
Branch analysis from position: 27
Branch analysis from position: 12
filename:       /in/g0dnG
function name:  __construct
number of ops:  35
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, ->27
         13    > > JMP_FRAMELESS                                   s24          'one%5Cstrpos', ->22
         14    >   INIT_NS_FCALL_BY_NAME                                        'One%5Cstrpos'
         15        CHECK_FUNC_ARG                                               
         16        FETCH_DIM_FUNC_ARG                                   $8      !0, 1
         17        FETCH_DIM_FUNC_ARG                                   $9      $8, 'class'
         18        SEND_FUNC_ARG                                                $9
         19        SEND_VAL_EX                                                  'One%5C'
         20        DO_FCALL                                          0  $10     
         21      > JMP                                                          ->25
         22    >   FETCH_DIM_R                                          ~11     !0, 1
         23        FETCH_DIM_R                                          ~12     ~11, 'class'
         24        FRAMELESS_ICALL_2                strpos              $10     ~12, 'One%5C'
         25    >   IS_NOT_IDENTICAL                                     ~13     $10, 0
         26        BOOL                                                 ~4      ~13
         27    > > JMPZ                                                         ~4, ->31
   24    28    > > INIT_FCALL                                                   'exit'
         29*       SEND_VAL                                                     'Invalid+context'
         30*       DO_ICALL                                                     
   26    31    >   FETCH_CONSTANT                                       ~15     'One%5CPHP_EOL'
         32        CONCAT                                               ~16     'Created', ~15
         33        ECHO                                                         ~16
   27    34      > RETURN                                                       null

End of function __construct

End of class One\Response.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
231.79 ms | 2650 KiB | 17 Q