3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php trait foo { protected $foo; protected function foo() { return $this->foo; } } trait bar { use foo; protected function bar() { return $this->foo().'bar'; } } class A { use foo; public function __construct($foo) { $this->foo = $foo; } } class B extends A { use bar; } $b = new B('foo'); $b->bar();
based on XM9CC
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/T1CSG
function name:  (null)
number of ops:  18
compiled vars:  !0 = $b
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   3     0  E >   NOP                                                      
  13     1        DECLARE_CLASS                                    $2      '%00bar%2Fin%2FT1CSG0x7fd708d340dd', 'bar'
  15     2        ADD_TRAIT                                                $2, 'foo'
  13     3        BIND_TRAITS                                              $2
  23     4        DECLARE_CLASS                                    $3      '%00a%2Fin%2FT1CSG0x7fd708d34149', 'a'
  25     5        ADD_TRAIT                                                $3, 'foo'
  23     6        BIND_TRAITS                                              $3
  33     7        FETCH_CLASS                                   0  :4      'A'
         8        DECLARE_INHERITED_CLASS                                  '%00b%2Fin%2FT1CSG0x7fd708d3416d', 'b'
  35     9        ADD_TRAIT                                                $5, 'bar'
  33    10        BIND_TRAITS                                              $5
  38    11        NEW                                              $6      :8
        12        SEND_VAL_EX                                              'foo'
        13        DO_FCALL                                      0          
        14        ASSIGN                                                   !0, $6
  39    15        INIT_METHOD_CALL                                         !0, 'bar'
        16        DO_FCALL                                      0          
        17      > RETURN                                                   1

Class foo:
Function foo:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/T1CSG
function name:  foo
number of ops:  3
compiled vars:  none
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   9     0  E >   FETCH_OBJ_R                                      $0      'foo'
         1      > RETURN                                                   $0
  10     2*     > RETURN                                                   null

End of function foo

End of class foo.

Class bar:
Function bar:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/T1CSG
function name:  bar
number of ops:  5
compiled vars:  none
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  19     0  E >   INIT_METHOD_CALL                                         'foo'
         1        DO_FCALL                                      0  $0      
         2        CONCAT                                           ~1      $0, 'bar'
         3      > RETURN                                                   ~1
  20     4*     > RETURN                                                   null

End of function bar

End of class bar.

Class A:
Function __construct:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/T1CSG
function name:  __construct
number of ops:  4
compiled vars:  !0 = $foo
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  27     0  E >   RECV                                             !0      
  29     1        ASSIGN_OBJ                                               'foo'
         2        OP_DATA                                                  !0
  30     3      > RETURN                                                   null

End of function __construct

End of class A.

Class B: [no user functions]

Generated using Vulcan Logic Dumper, using php 7.1.0