3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ImmutableClass { public function __construct( public readonly OtherClass $readonly_property, ) {} } class OtherClass { public function __construct( public int $foo = 0, public ?string $bar = null, ) {} } $object = new OtherClass(); $object->foo = 500; $immutable_object = new ImmutableClass(readonly_property: $object); var_dump($immutable_object->readonly_property); $immutable_object->readonly_property->foo = 100; $immutable_object->readonly_property->bar = 'oops'; var_dump($immutable_object->readonly_property);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/I5phk
function name:  (null)
number of ops:  25
compiled vars:  !0 = $object, !1 = $immutable_object
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   NEW                                              $2      'OtherClass'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   17     3        ASSIGN_OBJ                                               !0, 'foo'
          4        OP_DATA                                                  500
   19     5        NEW                                              $6      'ImmutableClass'
          6        SEND_VAR_EX                                              !0, 'readonly_property'
          7        CHECK_UNDEF_ARGS                                         
          8        DO_FCALL                                      1          
          9        ASSIGN                                                   !1, $6
   21    10        INIT_FCALL                                               'var_dump'
         11        FETCH_OBJ_R                                      ~9      !1, 'readonly_property'
         12        SEND_VAL                                                 ~9
         13        DO_ICALL                                                 
   23    14        FETCH_OBJ_W                                      $11     !1, 'readonly_property'
         15        ASSIGN_OBJ                                               $11, 'foo'
         16        OP_DATA                                                  100
   24    17        FETCH_OBJ_W                                      $13     !1, 'readonly_property'
         18        ASSIGN_OBJ                                               $13, 'bar'
         19        OP_DATA                                                  'oops'
   26    20        INIT_FCALL                                               'var_dump'
         21        FETCH_OBJ_R                                      ~15     !1, 'readonly_property'
         22        SEND_VAL                                                 ~15
         23        DO_ICALL                                                 
         24      > RETURN                                                   1

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

End of function __construct

End of class ImmutableClass.

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

End of function __construct

End of class OtherClass.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
139.38 ms | 1003 KiB | 14 Q