3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Baz { protected $data; function __construct($d) { $this->data = $d; } function getData() { return $this->data; } } trait A { public $a; function run() { echo $this->a->getData(); } } class Foo { use A; function __construct() { $this->a = new Baz('Hello '); } } class Bar { use A; function __construct() { $this->a = (new Foo())->a; } } (new Foo)->run(); (new Bar)->run();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9BcqB
function name:  (null)
number of ops:  11
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   DECLARE_CLASS                                            'foo'
   30     1        DECLARE_CLASS                                            'bar'
   38     2        NEW                                              $0      'Foo'
          3        DO_FCALL                                      0          
          4        INIT_METHOD_CALL                                         $0, 'run'
          5        DO_FCALL                                      0          
   39     6        NEW                                              $3      'Bar'
          7        DO_FCALL                                      0          
          8        INIT_METHOD_CALL                                         $3, 'run'
          9        DO_FCALL                                      0          
         10      > RETURN                                                   1

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

End of function __construct

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

End of function getdata

End of class Baz.

Class A:
Function run:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9BcqB
function name:  run
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   FETCH_OBJ_R                                      ~0      'a'
          1        INIT_METHOD_CALL                                         ~0, 'getData'
          2        DO_FCALL                                      0  $1      
          3        ECHO                                                     $1
   19     4      > RETURN                                                   null

End of function run

End of class A.

Class Foo:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9BcqB
function name:  __construct
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   NEW                                              $1      'Baz'
          1        SEND_VAL_EX                                              'Hello+'
          2        DO_FCALL                                      0          
          3        ASSIGN_OBJ                                               'a'
          4        OP_DATA                                                  $1
   27     5      > RETURN                                                   null

End of function __construct

End of class Foo.

Class Bar:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9BcqB
function name:  __construct
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   NEW                                              $1      'Foo'
          1        DO_FCALL                                      0          
          2        FETCH_OBJ_R                                      ~3      $1, 'a'
          3        ASSIGN_OBJ                                               'a'
          4        OP_DATA                                                  ~3
   35     5      > RETURN                                                   null

End of function __construct

End of class Bar.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.45 ms | 1390 KiB | 13 Q