3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ImmutableClass { public function __construct( public readonly stdClass $readonly_property, ) {} } $object = new stdClass(); $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/9rlfW
function name:  (null)
number of ops:  25
compiled vars:  !0 = $object, !1 = $immutable_object
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   NEW                                              $2      'stdClass'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   10     3        ASSIGN_OBJ                                               !0, 'foo'
          4        OP_DATA                                                  500
   12     5        NEW                                              $6      'ImmutableClass'
          6        SEND_VAR_EX                                              !0, 'readonly_property'
          7        CHECK_UNDEF_ARGS                                         
          8        DO_FCALL                                      1          
          9        ASSIGN                                                   !1, $6
   14    10        INIT_FCALL                                               'var_dump'
         11        FETCH_OBJ_R                                      ~9      !1, 'readonly_property'
         12        SEND_VAL                                                 ~9
         13        DO_ICALL                                                 
   16    14        FETCH_OBJ_W                                      $11     !1, 'readonly_property'
         15        ASSIGN_OBJ                                               $11, 'foo'
         16        OP_DATA                                                  100
   17    17        FETCH_OBJ_W                                      $13     !1, 'readonly_property'
         18        ASSIGN_OBJ                                               $13, 'bar'
         19        OP_DATA                                                  'oops'
   19    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/9rlfW
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.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.76 ms | 1068 KiB | 14 Q