3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); final class Foo { public readonly ?int $id; } $object = new Foo(); $reflection = new ReflectionClass($object); $instance = $reflection->newInstanceWithoutConstructor(); $reflectionProperty = $reflection->getProperty('id'); $reflectionProperty->setValue($instance, 42); $reflectionProperty->setValue($instance, null); var_dump($reflectionProperty->getValue($instance));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FrhLN
function name:  (null)
number of ops:  29
compiled vars:  !0 = $object, !1 = $reflection, !2 = $instance, !3 = $reflectionProperty
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   NEW                                              $4      'Foo'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $4
   11     3        NEW                                              $7      'ReflectionClass'
          4        SEND_VAR_EX                                              !0
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !1, $7
   12     7        INIT_METHOD_CALL                                         !1, 'newInstanceWithoutConstructor'
          8        DO_FCALL                                      0  $10     
          9        ASSIGN                                                   !2, $10
   13    10        INIT_METHOD_CALL                                         !1, 'getProperty'
         11        SEND_VAL_EX                                              'id'
         12        DO_FCALL                                      0  $12     
         13        ASSIGN                                                   !3, $12
   14    14        INIT_METHOD_CALL                                         !3, 'setValue'
         15        SEND_VAR_EX                                              !2
         16        SEND_VAL_EX                                              42
         17        DO_FCALL                                      0          
   15    18        INIT_METHOD_CALL                                         !3, 'setValue'
         19        SEND_VAR_EX                                              !2
         20        SEND_VAL_EX                                              null
         21        DO_FCALL                                      0          
   17    22        INIT_FCALL                                               'var_dump'
         23        INIT_METHOD_CALL                                         !3, 'getValue'
         24        SEND_VAR_EX                                              !2
         25        DO_FCALL                                      0  $16     
         26        SEND_VAR                                                 $16
         27        DO_ICALL                                                 
         28      > RETURN                                                   1

Class Foo: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
178.76 ms | 1004 KiB | 14 Q