3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait one { public function setOne($data) { $this->{__TRAIT__ . '\data'} = $data; } public function getOne() { return $this->{__TRAIT__ . '\data'}; } } trait two { public function setTwo($data) { $this->{__TRAIT__ . '\data'} = $data; } public function getTwo() { return $this->{__TRAIT__ . '\data'}; } } class Bar { use one; use two; } $bar = new Bar; $bar->setOne(1); $bar->setTwo(2); print_r($bar); echo "Bar getOne: " . $bar->getOne() . '<br>' . PHP_EOL; // echoes 2 instead of wanted 1 echo "Bar getTwo: " . $bar->getTwo() . '<br>' . PHP_EOL; // overwrites $this->data = 1 with 2
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oHcn9
function name:  (null)
number of ops:  26
compiled vars:  !0 = $bar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   DECLARE_CLASS                                            'bar'
   35     1        NEW                                              $1      'Bar'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $1
   37     4        INIT_METHOD_CALL                                         !0, 'setOne'
          5        SEND_VAL_EX                                              1
          6        DO_FCALL                                      0          
   38     7        INIT_METHOD_CALL                                         !0, 'setTwo'
          8        SEND_VAL_EX                                              2
          9        DO_FCALL                                      0          
   40    10        INIT_FCALL                                               'print_r'
         11        SEND_VAR                                                 !0
         12        DO_ICALL                                                 
   42    13        INIT_METHOD_CALL                                         !0, 'getOne'
         14        DO_FCALL                                      0  $7      
         15        CONCAT                                           ~8      'Bar+getOne%3A+', $7
         16        CONCAT                                           ~9      ~8, '%3Cbr%3E'
         17        CONCAT                                           ~10     ~9, '%0A'
         18        ECHO                                                     ~10
   43    19        INIT_METHOD_CALL                                         !0, 'getTwo'
         20        DO_FCALL                                      0  $11     
         21        CONCAT                                           ~12     'Bar+getTwo%3A+', $11
         22        CONCAT                                           ~13     ~12, '%3Cbr%3E'
         23        CONCAT                                           ~14     ~13, '%0A'
         24        ECHO                                                     ~14
         25      > RETURN                                                   1

Class one:
Function setone:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oHcn9
function name:  setOne
number of ops:  4
compiled vars:  !0 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    7     1        ASSIGN_OBJ                                               'one%5Cdata'
          2        OP_DATA                                                  !0
    8     3      > RETURN                                                   null

End of function setone

Function getone:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oHcn9
function name:  getOne
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   FETCH_OBJ_R                                      ~0      'one%5Cdata'
          1      > RETURN                                                   ~0
   13     2*     > RETURN                                                   null

End of function getone

End of class one.

Class two:
Function settwo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oHcn9
function name:  setTwo
number of ops:  4
compiled vars:  !0 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
   20     1        ASSIGN_OBJ                                               'two%5Cdata'
          2        OP_DATA                                                  !0
   21     3      > RETURN                                                   null

End of function settwo

Function gettwo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oHcn9
function name:  getTwo
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   FETCH_OBJ_R                                      ~0      'two%5Cdata'
          1      > RETURN                                                   ~0
   26     2*     > RETURN                                                   null

End of function gettwo

End of class two.

Class Bar: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.93 ms | 1015 KiB | 14 Q