3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait Traitor { public function cloneMutated($settings) { $object = clone $this; foreach ($settings as $name => $val) { $object->$name = $val; } return $object; } } class Q { use Traitor; private $foo; protected $bar; public function __construct($foo, $bar) { $this->foo = $foo; $this->bar = $bar; } } class Z extends Q { private $asd; } $a = new Z(1, 2); $b = $a->cloneMutated(["bar" => 3]); var_dump($b); $c = $a->cloneMutated(["asd" => 4]); var_dump($c);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jP1bu
function name:  (null)
number of ops:  22
compiled vars:  !0 = $a, !1 = $b, !2 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   DECLARE_CLASS                                            'q'
   25     1        DECLARE_CLASS                                            'z', 'q'
   29     2        NEW                                              $3      'Z'
          3        SEND_VAL_EX                                              1
          4        SEND_VAL_EX                                              2
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !0, $3
   30     7        INIT_METHOD_CALL                                         !0, 'cloneMutated'
          8        SEND_VAL_EX                                              <array>
          9        DO_FCALL                                      0  $6      
         10        ASSIGN                                                   !1, $6
   31    11        INIT_FCALL                                               'var_dump'
         12        SEND_VAR                                                 !1
         13        DO_ICALL                                                 
   33    14        INIT_METHOD_CALL                                         !0, 'cloneMutated'
         15        SEND_VAL_EX                                              <array>
         16        DO_FCALL                                      0  $9      
         17        ASSIGN                                                   !2, $9
   34    18        INIT_FCALL                                               'var_dump'
         19        SEND_VAR                                                 !2
         20        DO_ICALL                                                 
         21      > RETURN                                                   1

Class Traitor:
Function clonemutated:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 10
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 10
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
filename:       /in/jP1bu
function name:  cloneMutated
number of ops:  13
compiled vars:  !0 = $settings, !1 = $object, !2 = $val, !3 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    6     1        FETCH_THIS                                       ~4      
          2        CLONE                                            ~5      ~4
          3        ASSIGN                                                   !1, ~5
    7     4      > FE_RESET_R                                       $7      !0, ->10
          5    > > FE_FETCH_R                                       ~8      $7, !2, ->10
          6    >   ASSIGN                                                   !3, ~8
    8     7        ASSIGN_OBJ                                               !1, !3
          8        OP_DATA                                                  !2
    7     9      > JMP                                                      ->5
         10    >   FE_FREE                                                  $7
   11    11      > RETURN                                                   !1
   12    12*     > RETURN                                                   null

End of function clonemutated

End of class Traitor.

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

End of function __construct

End of class Q.

Class Z: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.8 ms | 1400 KiB | 15 Q