3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A {} class B {} class C { public function __construct( protected A|B $b ) { if ($this->b instanceof A) { trigger_error('A is deprecated, pass B instead', E_USER_DEPRECATED); $this->b = new B(); } var_dump($this->b); } } new C(new A()); new C(new B());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CLnhZ
function name:  (null)
number of ops:  13
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   NEW                                              $0      'C'
          1        NEW                                              $1      'A'
          2        DO_FCALL                                      0          
          3        SEND_VAR_NO_REF_EX                                       $1
          4        DO_FCALL                                      0          
          5        FREE                                                     $0
   19     6        NEW                                              $4      'C'
          7        NEW                                              $5      'B'
          8        DO_FCALL                                      0          
          9        SEND_VAR_NO_REF_EX                                       $5
         10        DO_FCALL                                      0          
         11        FREE                                                     $4
         12      > RETURN                                                   1

Class A: [no user functions]
Class B: [no user functions]
Class C:
Function __construct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 14
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
filename:       /in/CLnhZ
function name:  __construct
number of ops:  19
compiled vars:  !0 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        ASSIGN_OBJ                                               'b'
          2        OP_DATA                                                  !0
   10     3        FETCH_OBJ_R                                      ~1      'b'
          4        INSTANCEOF                                               ~1, 'A'
          5      > JMPZ                                                     ~2, ->14
   11     6    >   INIT_FCALL                                               'trigger_error'
          7        SEND_VAL                                                 'A+is+deprecated%2C+pass+B+instead'
          8        SEND_VAL                                                 16384
          9        DO_ICALL                                                 
   12    10        NEW                                              $5      'B'
         11        DO_FCALL                                      0          
         12        ASSIGN_OBJ                                               'b'
         13        OP_DATA                                                  $5
   14    14    >   INIT_FCALL                                               'var_dump'
         15        FETCH_OBJ_R                                      ~7      'b'
         16        SEND_VAL                                                 ~7
         17        DO_ICALL                                                 
   15    18      > RETURN                                                   null

End of function __construct

End of class C.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.54 ms | 1438 KiB | 15 Q