3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* Function Argument Unpacking in PHP 5.6 complements Variadic Functions! */ class Foo { public function __construct($arg1, $arg2, $arg3) { /* Do stuff constructor with arguments */ $this->arg1 = $arg1; $this->arg2 = $arg2; $this->arg3 = $arg3; } } class Bar extends Foo { public function __construct(...$args) { /** * Before argument unpacking in 5.6 we would use * call_user_func_array + func_get_args to accomplish * the same thing. */ // The intent here is to call the parent constructor parent::__construct(...$args); // Looks much nicer in 5.6 } } $bar = new Bar(1,2,3); var_dump($bar);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6ibqf
function name:  (null)
number of ops:  10
compiled vars:  !0 = $bar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   NEW                                              $1      'Bar'
          1        SEND_VAL_EX                                              1
          2        SEND_VAL_EX                                              2
          3        SEND_VAL_EX                                              3
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !0, $1
   26     6        INIT_FCALL                                               'var_dump'
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                                 
          9      > RETURN                                                   1

Class Foo:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6ibqf
function name:  __construct
number of ops:  10
compiled vars:  !0 = $arg1, !1 = $arg2, !2 = $arg3
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
    6     3        ASSIGN_OBJ                                               'arg1'
          4        OP_DATA                                                  !0
    7     5        ASSIGN_OBJ                                               'arg2'
          6        OP_DATA                                                  !1
    8     7        ASSIGN_OBJ                                               'arg3'
          8        OP_DATA                                                  !2
    9     9      > RETURN                                                   null

End of function __construct

End of class Foo.

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

End of function __construct

End of class Bar.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.3 ms | 1396 KiB | 15 Q