3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { public $x; public $y; public function __construct($x, $y) { $this->x = sha1($x); $this->y = $y; } public function __clone() { return new A($this->x, $this->y); } } class B extends A { public $z; public function __construct($z, $parent_obj) { $this->z = $z; parent::__construct($parent_obj->x, $parent_obj->y); } public function doSomeThing() { $parent_a_array = (array) parent::__clone(); var_dump($parent_a_array); $child_a_array = array_diff_assoc((array) $this, $parent_a_array); var_dump($child_a_array); echo "Parent Array Printing :\n"; foreach ($parent_a_array as $key => $value) { echo "Key: $key; Value: $value\n"; } echo "\nChild Array Printing: \n"; foreach ($child_a_array as $key => $value) { echo "Key: $key; Value: $value\n"; } } } $t = new B('C', new A("A", "B")); $t->doSomeThing();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/L6IAP
function name:  (null)
number of ops:  12
compiled vars:  !0 = $t
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   40     0  E >   NEW                                              $1      'B'
          1        SEND_VAL_EX                                              'C'
          2        NEW                                              $2      'A'
          3        SEND_VAL_EX                                              'A'
          4        SEND_VAL_EX                                              'B'
          5        DO_FCALL                                      0          
          6        SEND_VAR_NO_REF_EX                                       $2
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !0, $1
   41     9        INIT_METHOD_CALL                                         !0, 'doSomeThing'
         10        DO_FCALL                                      0          
         11      > RETURN                                                   1

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

End of function __construct

Function __clone:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/L6IAP
function name:  __clone
number of ops:  10
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   NEW                                              $0      'A'
          1        CHECK_FUNC_ARG                                           
          2        FETCH_OBJ_FUNC_ARG                               $1      'x'
          3        SEND_FUNC_ARG                                            $1
          4        CHECK_FUNC_ARG                                           
          5        FETCH_OBJ_FUNC_ARG                               $2      'y'
          6        SEND_FUNC_ARG                                            $2
          7        DO_FCALL                                      0          
          8      > RETURN                                                   $0
   12     9*     > RETURN                                                   null

End of function __clone

End of class A.

Class B:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/L6IAP
function name:  __construct
number of ops:  13
compiled vars:  !0 = $z, !1 = $parent_obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   19     2        ASSIGN_OBJ                                               'z'
          3        OP_DATA                                                  !0
   20     4        INIT_STATIC_METHOD_CALL                                  
          5        CHECK_FUNC_ARG                                           
          6        FETCH_OBJ_FUNC_ARG                               $3      !1, 'x'
          7        SEND_FUNC_ARG                                            $3
          8        CHECK_FUNC_ARG                                           
          9        FETCH_OBJ_FUNC_ARG                               $4      !1, 'y'
         10        SEND_FUNC_ARG                                            $4
         11        DO_FCALL                                      0          
   21    12      > RETURN                                                   null

End of function __construct

Function dosomething:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 19, Position 2 = 28
Branch analysis from position: 19
2 jumps found. (Code = 78) Position 1 = 20, Position 2 = 28
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 28
2 jumps found. (Code = 77) Position 1 = 31, Position 2 = 40
Branch analysis from position: 31
2 jumps found. (Code = 78) Position 1 = 32, Position 2 = 40
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 40
Branch analysis from position: 28
filename:       /in/L6IAP
function name:  doSomeThing
number of ops:  42
compiled vars:  !0 = $parent_a_array, !1 = $child_a_array, !2 = $value, !3 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   INIT_STATIC_METHOD_CALL                                  '__clone'
          1        DO_FCALL                                      0  $4      
          2        CAST                                          7  ~5      $4
          3        ASSIGN                                                   !0, ~5
   24     4        INIT_FCALL                                               'var_dump'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                                 
   25     7        INIT_FCALL                                               'array_diff_assoc'
          8        FETCH_THIS                                       ~8      
          9        CAST                                          7  ~9      ~8
         10        SEND_VAL                                                 ~9
         11        SEND_VAR                                                 !0
         12        DO_ICALL                                         $10     
         13        ASSIGN                                                   !1, $10
   26    14        INIT_FCALL                                               'var_dump'
         15        SEND_VAR                                                 !1
         16        DO_ICALL                                                 
   27    17        ECHO                                                     'Parent+Array+Printing+%3A%0A'
   28    18      > FE_RESET_R                                       $13     !0, ->28
         19    > > FE_FETCH_R                                       ~14     $13, !2, ->28
         20    >   ASSIGN                                                   !3, ~14
   29    21        ROPE_INIT                                     5  ~17     'Key%3A+'
         22        ROPE_ADD                                      1  ~17     ~17, !3
         23        ROPE_ADD                                      2  ~17     ~17, '%3B+Value%3A+'
         24        ROPE_ADD                                      3  ~17     ~17, !2
         25        ROPE_END                                      4  ~16     ~17, '%0A'
         26        ECHO                                                     ~16
   28    27      > JMP                                                      ->19
         28    >   FE_FREE                                                  $13
   31    29        ECHO                                                     '%0AChild+Array+Printing%3A+%0A'
   32    30      > FE_RESET_R                                       $20     !1, ->40
         31    > > FE_FETCH_R                                       ~21     $20, !2, ->40
         32    >   ASSIGN                                                   !3, ~21
   33    33        ROPE_INIT                                     5  ~24     'Key%3A+'
         34        ROPE_ADD                                      1  ~24     ~24, !3
         35        ROPE_ADD                                      2  ~24     ~24, '%3B+Value%3A+'
         36        ROPE_ADD                                      3  ~24     ~24, !2
         37        ROPE_END                                      4  ~23     ~24, '%0A'
         38        ECHO                                                     ~23
   32    39      > JMP                                                      ->31
         40    >   FE_FREE                                                  $20
   37    41      > RETURN                                                   null

End of function dosomething

Function __clone:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/L6IAP
function name:  __clone
number of ops:  10
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   NEW                                              $0      'A'
          1        CHECK_FUNC_ARG                                           
          2        FETCH_OBJ_FUNC_ARG                               $1      'x'
          3        SEND_FUNC_ARG                                            $1
          4        CHECK_FUNC_ARG                                           
          5        FETCH_OBJ_FUNC_ARG                               $2      'y'
          6        SEND_FUNC_ARG                                            $2
          7        DO_FCALL                                      0          
          8      > RETURN                                                   $0
   12     9*     > RETURN                                                   null

End of function __clone

End of class B.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
198.76 ms | 1409 KiB | 19 Q