3v4l.org

run code in 500+ PHP versions simultaneously
<?php class Point { public function __construct(private int $x, private int $y) {} protected function modClone(...$args): static { $new = clone($this); foreach ($args as $k => $v) { $new->$k = $v; } return $new; } public function moveUp(int $amt) { return $this->modClone(y: $this->y + $amt); } } $p1 = new Point(3, 5); $p2 = $p1->moveUp(4); var_dump($p2);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lg4Ac
function name:  (null)
number of ops:  13
compiled vars:  !0 = $p1, !1 = $p2
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   17     0  E >   NEW                                                  $2      'Point'
          1        SEND_VAL_EX                                                  3
          2        SEND_VAL_EX                                                  5
          3        DO_FCALL                                          0          
          4        ASSIGN                                                       !0, $2
   19     5        INIT_METHOD_CALL                                             !0, 'moveUp'
          6        SEND_VAL_EX                                                  4
          7        DO_FCALL                                          0  $5      
          8        ASSIGN                                                       !1, $5
   21     9        INIT_FCALL                                                   'var_dump'
         10        SEND_VAR                                                     !1
         11        DO_ICALL                                                     
         12      > RETURN                                                       1

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

End of function __construct

Function modclone:
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/lg4Ac
function name:  modClone
number of ops:  15
compiled vars:  !0 = $args, !1 = $new, !2 = $v, !3 = $k
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    6     0  E >   RECV_VARIADIC                                        !0      
    7     1        FETCH_THIS                                           ~4      
          2        CLONE                                                ~5      ~4
          3        ASSIGN                                                       !1, ~5
    8     4      > FE_RESET_R                                           $7      !0, ->10
          5    > > FE_FETCH_R                                           ~8      $7, !2, ->10
          6    >   ASSIGN                                                       !3, ~8
    9     7        ASSIGN_OBJ                                                   !1, !3
          8        OP_DATA                                                      !2
    8     9      > JMP                                                          ->5
         10    >   FE_FREE                                                      $7
   11    11        VERIFY_RETURN_TYPE                                           !1
         12      > RETURN                                                       !1
   12    13*       VERIFY_RETURN_TYPE                                           
         14*     > RETURN                                                       null

End of function modclone

Function moveup:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lg4Ac
function name:  moveUp
number of ops:  9
compiled vars:  !0 = $amt
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   14     0  E >   RECV                                                 !0      
          1        INIT_METHOD_CALL                                             'modClone'
          2        FETCH_OBJ_R                                          ~1      'y'
          3        ADD                                                  ~2      ~1, !0
          4        SEND_VAL_EX                                                  ~2, 'y'
          5        CHECK_UNDEF_ARGS                                             
          6        DO_FCALL                                          1  $3      
          7      > RETURN                                                       $3
          8*     > RETURN                                                       null

End of function moveup

End of class Point.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
161.39 ms | 1783 KiB | 14 Q