3v4l.org

run code in 300+ PHP versions simultaneously
<?php class UserService { public function userFactory() { $user=new User(); $user->id='test_id'; return $user; } } class Conversation { public $participants=array(); public function getParticipants() { return $this->participants; } } class User { public $id; } $u1=new User(); $u2=new User(); $conversation=new Conversation(); $conversation->participants[]=$u1; $conversation->participants[]=$u2; $userService=new UserService(); foreach($conversation->getParticipants() as &$participant) { $participant=$userService->userFactory(); } print_r($conversation);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 22, Position 2 = 27
Branch analysis from position: 22
2 jumps found. (Code = 126) Position 1 = 23, Position 2 = 27
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
filename:       /in/pYSHj
function name:  (null)
number of ops:  32
compiled vars:  !0 = $u1, !1 = $u2, !2 = $conversation, !3 = $userService, !4 = $participant
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   NEW                                              $5      'User'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $5
   24     3        NEW                                              $8      'User'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $8
   26     6        NEW                                              $11     'Conversation'
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !2, $11
   27     9        FETCH_OBJ_W                                      $14     !2, 'participants'
         10        ASSIGN_DIM                                               $14
         11        OP_DATA                                                  !0
   28    12        FETCH_OBJ_W                                      $16     !2, 'participants'
         13        ASSIGN_DIM                                               $16
         14        OP_DATA                                                  !1
   30    15        NEW                                              $18     'UserService'
         16        DO_FCALL                                      0          
         17        ASSIGN                                                   !3, $18
   32    18        INIT_METHOD_CALL                                         !2, 'getParticipants'
         19        DO_FCALL                                      0  $21     
         20        SEPARATE                                         $21     $21
         21      > FE_RESET_RW                                      $22     $21, ->27
         22    > > FE_FETCH_RW                                              $22, !4, ->27
   33    23    >   INIT_METHOD_CALL                                         !3, 'userFactory'
         24        DO_FCALL                                      0  $23     
         25        ASSIGN                                                   !4, $23
   32    26      > JMP                                                      ->22
         27    >   FE_FREE                                                  $22
   36    28        INIT_FCALL                                               'print_r'
         29        SEND_VAR                                                 !2
         30        DO_ICALL                                                 
         31      > RETURN                                                   1

Class UserService:
Function userfactory:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pYSHj
function name:  userFactory
number of ops:  7
compiled vars:  !0 = $user
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   NEW                                              $1      'User'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
    6     3        ASSIGN_OBJ                                               !0, 'id'
          4        OP_DATA                                                  'test_id'
    7     5      > RETURN                                                   !0
    8     6*     > RETURN                                                   null

End of function userfactory

End of class UserService.

Class Conversation:
Function getparticipants:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pYSHj
function name:  getParticipants
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   FETCH_OBJ_R                                      ~0      'participants'
          1      > RETURN                                                   ~0
   16     2*     > RETURN                                                   null

End of function getparticipants

End of class Conversation.

Class User: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.3 ms | 1400 KiB | 15 Q