3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait Foo { private $traitProperty = 'blah'; public function getTraitProperty() { return $this->traitProperty; } public function getClassPropertyFromTrait() { return $this->classProperty; } } class MyClass { use Foo; private $classProperty = 'meh'; public function getTraitPropertyFromClass() { return $this->traitProperty; } public function getClassProperty() { return $this->classProperty; } } $x = new MyClass(); var_dump($x->getTraitProperty()); var_dump($x->getTraitPropertyFromClass()); var_dump($x->getClassProperty()); var_dump($x->getClassPropertyFromTrait());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/M80Zl
function name:  (null)
number of ops:  25
compiled vars:  !0 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   DECLARE_CLASS                                            'myclass'
   36     1        NEW                                              $1      'MyClass'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $1
   37     4        INIT_FCALL                                               'var_dump'
          5        INIT_METHOD_CALL                                         !0, 'getTraitProperty'
          6        DO_FCALL                                      0  $4      
          7        SEND_VAR                                                 $4
          8        DO_ICALL                                                 
   38     9        INIT_FCALL                                               'var_dump'
         10        INIT_METHOD_CALL                                         !0, 'getTraitPropertyFromClass'
         11        DO_FCALL                                      0  $6      
         12        SEND_VAR                                                 $6
         13        DO_ICALL                                                 
   39    14        INIT_FCALL                                               'var_dump'
         15        INIT_METHOD_CALL                                         !0, 'getClassProperty'
         16        DO_FCALL                                      0  $8      
         17        SEND_VAR                                                 $8
         18        DO_ICALL                                                 
   40    19        INIT_FCALL                                               'var_dump'
         20        INIT_METHOD_CALL                                         !0, 'getClassPropertyFromTrait'
         21        DO_FCALL                                      0  $10     
         22        SEND_VAR                                                 $10
         23        DO_ICALL                                                 
         24      > RETURN                                                   1

Class Foo:
Function gettraitproperty:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/M80Zl
function name:  getTraitProperty
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   FETCH_OBJ_R                                      ~0      'traitProperty'
          1      > RETURN                                                   ~0
   11     2*     > RETURN                                                   null

End of function gettraitproperty

Function getclasspropertyfromtrait:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/M80Zl
function name:  getClassPropertyFromTrait
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   FETCH_OBJ_R                                      ~0      'classProperty'
          1      > RETURN                                                   ~0
   16     2*     > RETURN                                                   null

End of function getclasspropertyfromtrait

End of class Foo.

Class MyClass:
Function gettraitpropertyfromclass:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/M80Zl
function name:  getTraitPropertyFromClass
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   FETCH_OBJ_R                                      ~0      'traitProperty'
          1      > RETURN                                                   ~0
   28     2*     > RETURN                                                   null

End of function gettraitpropertyfromclass

Function getclassproperty:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/M80Zl
function name:  getClassProperty
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   FETCH_OBJ_R                                      ~0      'classProperty'
          1      > RETURN                                                   ~0
   33     2*     > RETURN                                                   null

End of function getclassproperty

End of class MyClass.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
134.86 ms | 1450 KiB | 14 Q