3v4l.org

run code in 300+ PHP versions simultaneously
<?php final readonly class Client { public function __construct( private string $a, private string $very, private string $long, private string $list, private string $of, private string $constructor, private string $argument, private string $userAgent, ) { } public function fetch(int $id): array { var_dump("fetching user $id"); // Simulate fetching from remote service $this->userAgent; return [ 'id' => $id, 'name' => 'John Doe', ]; } public function getName(): string { return 'The Super API Client'; } } final readonly class UserRepository { public function __construct( public Client $client, ) { } public function find(int $id): array { return $this->client->fetch($id); } } $reflector = new ReflectionClass(Client::class); $client = $reflector->newLazyProxy(function ($x) { var_dump("init"); return new Client( 'a', 'very', 'long', 'list', 'of', 'constructor', 'argument', 'Mozilla/5.0', ); }); $repository = new UserRepository($client); var_dump($repository->client->getName()); var_dump($repository->find(42));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/S6B46
function name:  (null)
number of ops:  26
compiled vars:  !0 = $reflector, !1 = $client, !2 = $repository
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   49     0  E >   NEW                                              $3      'ReflectionClass'
          1        SEND_VAL_EX                                              'Client'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $3
   50     4        INIT_METHOD_CALL                                         !0, 'newLazyProxy'
          5        DECLARE_LAMBDA_FUNCTION                          ~6      [0]
   62     6        SEND_VAL_EX                                              ~6
   50     7        DO_FCALL                                      0  $7      
          8        ASSIGN                                                   !1, $7
   64     9        NEW                                              $9      'UserRepository'
         10        SEND_VAR_EX                                              !1
         11        DO_FCALL                                      0          
         12        ASSIGN                                                   !2, $9
   66    13        INIT_FCALL                                               'var_dump'
         14        FETCH_OBJ_R                                      ~12     !2, 'client'
         15        INIT_METHOD_CALL                                         ~12, 'getName'
         16        DO_FCALL                                      0  $13     
         17        SEND_VAR                                                 $13
         18        DO_ICALL                                                 
   68    19        INIT_FCALL                                               'var_dump'
         20        INIT_METHOD_CALL                                         !2, 'find'
         21        SEND_VAL_EX                                              42
         22        DO_FCALL                                      0  $15     
         23        SEND_VAR                                                 $15
         24        DO_ICALL                                                 
         25      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/S6B46
function name:  {closure}
number of ops:  16
compiled vars:  !0 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   50     0  E >   RECV                                             !0      
   51     1        INIT_FCALL                                               'var_dump'
          2        SEND_VAL                                                 'init'
          3        DO_ICALL                                                 
   52     4        NEW                                              $2      'Client'
   53     5        SEND_VAL_EX                                              'a'
   54     6        SEND_VAL_EX                                              'very'
   55     7        SEND_VAL_EX                                              'long'
   56     8        SEND_VAL_EX                                              'list'
   57     9        SEND_VAL_EX                                              'of'
   58    10        SEND_VAL_EX                                              'constructor'
   59    11        SEND_VAL_EX                                              'argument'
   60    12        SEND_VAL_EX                                              'Mozilla%2F5.0'
   52    13        DO_FCALL                                      0          
   60    14      > RETURN                                                   $2
   62    15*     > RETURN                                                   null

End of Dynamic Function 0

Class Client:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/S6B46
function name:  __construct
number of ops:  25
compiled vars:  !0 = $a, !1 = $very, !2 = $long, !3 = $list, !4 = $of, !5 = $constructor, !6 = $argument, !7 = $userAgent
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
          4        RECV                                             !4      
          5        RECV                                             !5      
          6        RECV                                             !6      
          7        RECV                                             !7      
          8        ASSIGN_OBJ                                               'a'
          9        OP_DATA                                                  !0
         10        ASSIGN_OBJ                                               'very'
         11        OP_DATA                                                  !1
         12        ASSIGN_OBJ                                               'long'
         13        OP_DATA                                                  !2
         14        ASSIGN_OBJ                                               'list'
         15        OP_DATA                                                  !3
         16        ASSIGN_OBJ                                               'of'
         17        OP_DATA                                                  !4
         18        ASSIGN_OBJ                                               'constructor'
         19        OP_DATA                                                  !5
         20        ASSIGN_OBJ                                               'argument'
         21        OP_DATA                                                  !6
         22        ASSIGN_OBJ                                               'userAgent'
         23        OP_DATA                                                  !7
   15    24      > RETURN                                                   null

End of function __construct

Function fetch:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/S6B46
function name:  fetch
number of ops:  14
compiled vars:  !0 = $id
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
   19     1        INIT_FCALL                                               'var_dump'
          2        NOP                                                      
          3        FAST_CONCAT                                      ~1      'fetching+user+', !0
          4        SEND_VAL                                                 ~1
          5        DO_ICALL                                                 
   22     6        FETCH_OBJ_R                                      ~3      'userAgent'
          7        FREE                                                     ~3
   25     8        INIT_ARRAY                                       ~4      !0, 'id'
   26     9        ADD_ARRAY_ELEMENT                                ~4      'John+Doe', 'name'
         10        VERIFY_RETURN_TYPE                                       ~4
         11      > RETURN                                                   ~4
   28    12*       VERIFY_RETURN_TYPE                                       
         13*     > RETURN                                                   null

End of function fetch

Function getname:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/S6B46
function name:  getName
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E > > RETURN                                                   'The+Super+API+Client'
   33     1*       VERIFY_RETURN_TYPE                                       
          2*     > RETURN                                                   null

End of function getname

End of class Client.

Class UserRepository:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/S6B46
function name:  __construct
number of ops:  4
compiled vars:  !0 = $client
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   38     0  E >   RECV                                             !0      
          1        ASSIGN_OBJ                                               'client'
          2        OP_DATA                                                  !0
   41     3      > RETURN                                                   null

End of function __construct

Function find:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/S6B46
function name:  find
number of ops:  9
compiled vars:  !0 = $id
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   43     0  E >   RECV                                             !0      
   45     1        FETCH_OBJ_R                                      ~1      'client'
          2        INIT_METHOD_CALL                                         ~1, 'fetch'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0  $2      
          5        VERIFY_RETURN_TYPE                                       $2
          6      > RETURN                                                   $2
   46     7*       VERIFY_RETURN_TYPE                                       
          8*     > RETURN                                                   null

End of function find

End of class UserRepository.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.51 ms | 1014 KiB | 14 Q