3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Wrapper { public function foo (...$args) { return $this->dostuff(...$args); } public function dostuff($param1, $param2, &$arr) { $arr[] = $param1; $arr[] = $param2; return count($arr); } } $values = [1,2]; $obj = new Wrapper(); $count = $obj->foo(3,4, $values); echo "Elements count: $count\r\n"; print_r($values); //Expected [1,2,3,4]
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1GKCh
function name:  (null)
number of ops:  18
compiled vars:  !0 = $values, !1 = $obj, !2 = $count
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   ASSIGN                                                   !0, <array>
   20     1        NEW                                              $4      'Wrapper'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $4
   21     4        INIT_METHOD_CALL                                         !1, 'foo'
          5        SEND_VAL_EX                                              3
          6        SEND_VAL_EX                                              4
          7        SEND_VAR_EX                                              !0
          8        DO_FCALL                                      0  $7      
          9        ASSIGN                                                   !2, $7
   23    10        ROPE_INIT                                     3  ~10     'Elements+count%3A+'
         11        ROPE_ADD                                      1  ~10     ~10, !2
         12        ROPE_END                                      2  ~9      ~10, '%0D%0A'
         13        ECHO                                                     ~9
   24    14        INIT_FCALL                                               'print_r'
         15        SEND_VAR                                                 !0
         16        DO_ICALL                                                 
         17      > RETURN                                                   1

Class Wrapper:
Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1GKCh
function name:  foo
number of ops:  7
compiled vars:  !0 = $args
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV_VARIADIC                                    !0      
    6     1        INIT_METHOD_CALL                                         'dostuff'
          2        SEND_UNPACK                                              !0
          3        CHECK_UNDEF_ARGS                                         
          4        DO_FCALL                                      1  $1      
          5      > RETURN                                                   $1
    7     6*     > RETURN                                                   null

End of function foo

Function dostuff:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1GKCh
function name:  dostuff
number of ops:  10
compiled vars:  !0 = $param1, !1 = $param2, !2 = $arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   10     3        ASSIGN_DIM                                               !2
          4        OP_DATA                                                  !0
   11     5        ASSIGN_DIM                                               !2
          6        OP_DATA                                                  !1
   13     7        COUNT                                            ~5      !2
          8      > RETURN                                                   ~5
   14     9*     > RETURN                                                   null

End of function dostuff

End of class Wrapper.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.26 ms | 1015 KiB | 14 Q