3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait aTrait { public static function build($x) { return new static($x); } } class A { public function __construct($x) { $this->x = $x; } use aTrait; } class B { public function __construct($x) { $this->x = $x * 2; } use aTrait; } $a = A::build(2); $b = B::build(2); var_dump($a); var_dump($b);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BogSt
function name:  (null)
number of ops:  17
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   DECLARE_CLASS                                            'a'
   17     1        DECLARE_CLASS                                            'b'
   27     2        INIT_STATIC_METHOD_CALL                                  'A', 'build'
          3        SEND_VAL_EX                                              2
          4        DO_FCALL                                      0  $2      
          5        ASSIGN                                                   !0, $2
   28     6        INIT_STATIC_METHOD_CALL                                  'B', 'build'
          7        SEND_VAL_EX                                              2
          8        DO_FCALL                                      0  $4      
          9        ASSIGN                                                   !1, $4
   29    10        INIT_FCALL                                               'var_dump'
         11        SEND_VAR                                                 !0
         12        DO_ICALL                                                 
   30    13        INIT_FCALL                                               'var_dump'
         14        SEND_VAR                                                 !1
         15        DO_ICALL                                                 
         16      > RETURN                                                   1

Class aTrait:
Function build:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BogSt
function name:  build
number of ops:  6
compiled vars:  !0 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    5     1        NEW                          static              $1      
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
          4      > RETURN                                                   $1
    6     5*     > RETURN                                                   null

End of function build

End of class aTrait.

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

End of function __construct

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/BogSt
function name:  __construct
number of ops:  5
compiled vars:  !0 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
   20     1        MUL                                              ~2      !0, 2
          2        ASSIGN_OBJ                                               'x'
          3        OP_DATA                                                  ~2
   21     4      > RETURN                                                   null

End of function __construct

End of class B.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
246.97 ms | 1007 KiB | 14 Q