3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public string $bar = 'a'; public ?string $baz = null; public function __construct(public readonly ?string $x = null) { } } $foo = new Foo(); $fooSerialized = 'O:3:"Foo":1:{s:3:"bar";s:1:"a";}a'; $fooUnserialized = unserialize($fooSerialized); var_dump($fooUnserialized->bar); // works because exists in serialized string var_dump($fooUnserialized->baz); // works because regular typed property, even if not existing in serialized string var_dump($fooUnserialized->x); // Doesn't work
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4d6XG
function name:  (null)
number of ops:  21
compiled vars:  !0 = $foo, !1 = $fooSerialized, !2 = $fooUnserialized
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   NEW                                              $3      'Foo'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
   13     3        ASSIGN                                                   !1, 'O%3A3%3A%22Foo%22%3A1%3A%7Bs%3A3%3A%22bar%22%3Bs%3A1%3A%22a%22%3B%7Da'
   14     4        INIT_FCALL                                               'unserialize'
          5        SEND_VAR                                                 !1
          6        DO_ICALL                                         $7      
          7        ASSIGN                                                   !2, $7
   16     8        INIT_FCALL                                               'var_dump'
          9        FETCH_OBJ_R                                      ~9      !2, 'bar'
         10        SEND_VAL                                                 ~9
         11        DO_ICALL                                                 
   17    12        INIT_FCALL                                               'var_dump'
         13        FETCH_OBJ_R                                      ~11     !2, 'baz'
         14        SEND_VAL                                                 ~11
         15        DO_ICALL                                                 
   18    16        INIT_FCALL                                               'var_dump'
         17        FETCH_OBJ_R                                      ~13     !2, 'x'
         18        SEND_VAL                                                 ~13
         19        DO_ICALL                                                 
         20      > RETURN                                                   1

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

End of function __construct

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.42 ms | 1003 KiB | 15 Q