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]; $a=3; $b=4; $obj = new Wrapper(); #all parameter must be variables here because there are by ref now $count = $obj->foo($a,$b, $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/9ivmL
function name:  (null)
number of ops:  20
compiled vars:  !0 = $values, !1 = $a, !2 = $b, !3 = $obj, !4 = $count
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   ASSIGN                                                   !0, <array>
   19     1        ASSIGN                                                   !1, 3
   20     2        ASSIGN                                                   !2, 4
   21     3        NEW                                              $8      'Wrapper'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !3, $8
   23     6        INIT_METHOD_CALL                                         !3, 'foo'
          7        SEND_VAR_EX                                              !1
          8        SEND_VAR_EX                                              !2
          9        SEND_VAR_EX                                              !0
         10        DO_FCALL                                      0  $11     
         11        ASSIGN                                                   !4, $11
   25    12        ROPE_INIT                                     3  ~14     'Elements+count%3A+'
         13        ROPE_ADD                                      1  ~14     ~14, !4
         14        ROPE_END                                      2  ~13     ~14, '%0D%0A'
         15        ECHO                                                     ~13
   26    16        INIT_FCALL                                               'print_r'
         17        SEND_VAR                                                 !0
         18        DO_ICALL                                                 
         19      > RETURN                                                   1

Class Wrapper:
Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9ivmL
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/9ivmL
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:
144.96 ms | 1010 KiB | 14 Q