3v4l.org

run code in 500+ PHP versions simultaneously
<?php class A { readonly string $x; public function initFromA() { $this->x = 'a'; } } class B extends A { readonly string $x; public function initFromB() { $this->x = 'b'; } } $c = new B; $c->initFromB(); var_dump($c->x); $c->initFromA(); // Error: alredy initialized
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9AV4r
function name:  (null)
number of ops:  12
compiled vars:  !0 = $c
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   17     0  E >   NEW                                                  $1      'B'
          1        DO_FCALL                                          0          
          2        ASSIGN                                                       !0, $1
   18     3        INIT_METHOD_CALL                                             !0, 'initFromB'
          4        DO_FCALL                                          0          
   19     5        INIT_FCALL                                                   'var_dump'
          6        FETCH_OBJ_R                                          ~5      !0, 'x'
          7        SEND_VAL                                                     ~5
          8        DO_ICALL                                                     
   20     9        INIT_METHOD_CALL                                             !0, 'initFromA'
         10        DO_FCALL                                          0          
         11      > RETURN                                                       1

Class A:
Function initfroma:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9AV4r
function name:  initFromA
number of ops:  3
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    6     0  E >   ASSIGN_OBJ                                                   'x'
          1        OP_DATA                                                      'a'
    7     2      > RETURN                                                       null

End of function initfroma

End of class A.

Class B:
Function initfromb:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9AV4r
function name:  initFromB
number of ops:  3
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   13     0  E >   ASSIGN_OBJ                                                   'x'
          1        OP_DATA                                                      'b'
   14     2      > RETURN                                                       null

End of function initfromb

Function initfroma:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9AV4r
function name:  initFromA
number of ops:  3
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    6     0  E >   ASSIGN_OBJ                                                   'x'
          1        OP_DATA                                                      'a'
    7     2      > RETURN                                                       null

End of function initfroma

End of class B.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
155.85 ms | 1590 KiB | 14 Q