3v4l.org

run code in 500+ PHP versions simultaneously
<?php #[Attribute(Attribute::TARGET_PROPERTY)] class NotSerializable {} class Foo { #[NotSerializable] protected $bar = 1; #[NotSerializable] protected $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); } return $data; } } class FooChild extends Foo { protected $bar; } var_dump(serialize(new FooChild()));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/N3fmO
function name:  (null)
number of ops:  9
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   24     0  E >   INIT_FCALL                                                   'var_dump'
          1        INIT_FCALL                                                   'serialize'
          2        NEW                                                  $0      'FooChild'
          3        DO_FCALL                                          0          
          4        SEND_VAR                                                     $0
          5        DO_ICALL                                             $2      
          6        SEND_VAR                                                     $2
          7        DO_ICALL                                                     
          8      > 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/N3fmO
function name:  __serialize
number of ops:  28
compiled vars:  !0 = $data, !1 = $property
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   11     0  E >   ASSIGN                                                       !0, <array>
   12     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
   13     9    >   INIT_METHOD_CALL                                             !1, 'getAttributes'
         10        SEND_VAL_EX                                                  'NotSerializable'
         11        DO_FCALL                                          0  $8      
         12      > JMPZ                                                         $8, ->14
   14    13    > > JMP                                                          ->8
   16    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
   12    22      > JMP                                                          ->8
         23    >   FE_FREE                                                      $7
   18    24        VERIFY_RETURN_TYPE                                           !0
         25      > RETURN                                                       !0
   19    26*       VERIFY_RETURN_TYPE                                           
         27*     > RETURN                                                       null

End of function __serialize

End of class Foo.

Class FooChild:
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/N3fmO
function name:  __serialize
number of ops:  28
compiled vars:  !0 = $data, !1 = $property
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   11     0  E >   ASSIGN                                                       !0, <array>
   12     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
   13     9    >   INIT_METHOD_CALL                                             !1, 'getAttributes'
         10        SEND_VAL_EX                                                  'NotSerializable'
         11        DO_FCALL                                          0  $8      
         12      > JMPZ                                                         $8, ->14
   14    13    > > JMP                                                          ->8
   16    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
   12    22      > JMP                                                          ->8
         23    >   FE_FREE                                                      $7
   18    24        VERIFY_RETURN_TYPE                                           !0
         25      > RETURN                                                       !0
   19    26*       VERIFY_RETURN_TYPE                                           
         27*     > RETURN                                                       null

End of function __serialize

End of class FooChild.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
158.9 ms | 1595 KiB | 15 Q