3v4l.org

run code in 500+ PHP versions simultaneously
<?php #[Attribute(Attribute::TARGET_PROPERTY)] class NotSerializable {} class Foo { #[NotSerializable] public $bar = 1; public $baz = 2; public function __serialize(): array { $data = []; foreach ((new ReflectionObject($this))->getProperties() as $property) { if ($property->getAttributes(NotSerializable::class)) { continue; } $data[$property->getName()] = $property->getValue($this); } var_dump($data); return $data; } } var_dump(unserialize(serialize(new Foo())));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6b1Y6
function name:  (null)
number of ops:  12
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   21     0  E >   INIT_FCALL                                                   'var_dump'
          1        INIT_FCALL                                                   'unserialize'
          2        INIT_FCALL                                                   'serialize'
          3        NEW                                                  $0      'Foo'
          4        DO_FCALL                                          0          
          5        SEND_VAR                                                     $0
          6        DO_ICALL                                             $2      
          7        SEND_VAR                                                     $2
          8        DO_ICALL                                             $3      
          9        SEND_VAR                                                     $3
         10        DO_ICALL                                                     
         11      > RETURN                                                       1

Class NotSerializable: [no user functions]
Class Foo:
Function __serialize:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 23
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 23
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 14
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
filename:       /in/6b1Y6
function name:  __serialize
number of ops:  31
compiled vars:  !0 = $data, !1 = $property
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   10     0  E >   ASSIGN                                                       !0, <array>
   11     1        NEW                                                  $3      'ReflectionObject'
          2        FETCH_THIS                                           $4      
          3        SEND_VAR_EX                                                  $4
          4        DO_FCALL                                          0          
          5        INIT_METHOD_CALL                                             $3, 'getProperties'
          6        DO_FCALL                                          0  $6      
          7      > FE_RESET_R                                           $7      $6, ->23
          8    > > FE_FETCH_R                                                   $7, !1, ->23
   12     9    >   INIT_METHOD_CALL                                             !1, 'getAttributes'
         10        SEND_VAL_EX                                                  'NotSerializable'
         11        DO_FCALL                                          0  $8      
         12      > JMPZ                                                         $8, ->14
   13    13    > > JMP                                                          ->8
   15    14    >   INIT_METHOD_CALL                                             !1, 'getName'
         15        DO_FCALL                                          0  $9      
         16        INIT_METHOD_CALL                                             !1, 'getValue'
         17        FETCH_THIS                                           $11     
         18        SEND_VAR_EX                                                  $11
         19        DO_FCALL                                          0  $12     
         20        ASSIGN_DIM                                                   !0, $9
         21        OP_DATA                                                      $12
   11    22      > JMP                                                          ->8
         23    >   FE_FREE                                                      $7
   17    24        INIT_FCALL                                                   'var_dump'
         25        SEND_VAR                                                     !0
         26        DO_ICALL                                                     
   18    27        VERIFY_RETURN_TYPE                                           !0
         28      > RETURN                                                       !0
   19    29*       VERIFY_RETURN_TYPE                                           
         30*     > RETURN                                                       null

End of function __serialize

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
156.78 ms | 1602 KiB | 16 Q