3v4l.org

run code in 500+ PHP versions simultaneously
<?php declare(strict_types=1); enum Color: string { case Yellow = 'yw'; } class Foo { public function __construct( public DateTimeImmutable $date, protected string $foo, private int $bar, public array $tbl = [123, true, 1.1, 'baz'], protected Color $color = Color::Yellow, ) {} } $current = serialize(new Foo(new DateTimeImmutable('now'), "Foo bar\nbaz", 123456789)); var_dump($current); echo "\nReducing by potentially unnecessary chars...\n"; $reductions = []; $replacements = ['"' => '']; $reductions['removing double-quote'] = strtr($current, $replacements); $replacements[';}'] = '}'; $replacements[':{'] = '{'; $reductions['removing previous and array leading double-colon and trailing semi-colon'] = strtr($current, $replacements); $replacements['O:'] = 'O'; $replacements['a:'] = 'a'; $replacements['s:'] = 's'; $replacements['E:'] = 'E'; $reductions['removing previous and leading double-colon of sized types'] = strtr($current, $replacements); $replacements['i:'] = 'i'; $replacements['d:'] = 'd'; $replacements['b:'] = 'b'; $reductions['aggresive removing previous and some double-colons'] = strtr($current, $replacements); foreach ($reductions as $name => $serialized) { printf("\nBy {$name} serialized output shrinks by %0.2f%%\n", (strlen($current) - strlen($serialized)) / strlen($serialized) * 100); var_dump($serialized); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 50, Position 2 = 69
Branch analysis from position: 50
2 jumps found. (Code = 78) Position 1 = 51, Position 2 = 69
Branch analysis from position: 51
1 jumps found. (Code = 42) Position 1 = 50
Branch analysis from position: 50
Branch analysis from position: 69
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 69
filename:       /in/DLh1U
function name:  (null)
number of ops:  71
compiled vars:  !0 = $current, !1 = $reductions, !2 = $replacements, !3 = $serialized, !4 = $name
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                                'color'
   16     1        INIT_FCALL                                                   'serialize'
          2        NEW                                                  $5      'Foo'
          3        NEW                                                  $6      'DateTimeImmutable'
          4        SEND_VAL_EX                                                  'now'
          5        DO_FCALL                                          0          
          6        SEND_VAR_NO_REF_EX                                           $6
          7        SEND_VAL_EX                                                  'Foo+bar%0Abaz'
          8        SEND_VAL_EX                                                  123456789
          9        DO_FCALL                                          0          
         10        SEND_VAR                                                     $5
         11        DO_ICALL                                             $9      
         12        ASSIGN                                                       !0, $9
   17    13        INIT_FCALL                                                   'var_dump'
         14        SEND_VAR                                                     !0
         15        DO_ICALL                                                     
   18    16        ECHO                                                         '%0AReducing+by+potentially+unnecessary+chars...%0A'
   19    17        ASSIGN                                                       !1, <array>
   20    18        ASSIGN                                                       !2, <array>
   21    19        FRAMELESS_ICALL_2                strtr               ~15     !0, !2
         20        ASSIGN_DIM                                                   !1, 'removing+double-quote'
         21        OP_DATA                                                      ~15
   22    22        ASSIGN_DIM                                                   !2, '%3B%7D'
         23        OP_DATA                                                      '%7D'
   23    24        ASSIGN_DIM                                                   !2, '%3A%7B'
         25        OP_DATA                                                      '%7B'
   24    26        FRAMELESS_ICALL_2                strtr               ~19     !0, !2
         27        ASSIGN_DIM                                                   !1, 'removing+previous+and+array+leading+double-colon+and+trailing+semi-colon'
         28        OP_DATA                                                      ~19
   25    29        ASSIGN_DIM                                                   !2, 'O%3A'
         30        OP_DATA                                                      'O'
   26    31        ASSIGN_DIM                                                   !2, 'a%3A'
         32        OP_DATA                                                      'a'
   27    33        ASSIGN_DIM                                                   !2, 's%3A'
         34        OP_DATA                                                      's'
   28    35        ASSIGN_DIM                                                   !2, 'E%3A'
         36        OP_DATA                                                      'E'
   29    37        FRAMELESS_ICALL_2                strtr               ~25     !0, !2
         38        ASSIGN_DIM                                                   !1, 'removing+previous+and+leading+double-colon+of+sized+types'
         39        OP_DATA                                                      ~25
   30    40        ASSIGN_DIM                                                   !2, 'i%3A'
         41        OP_DATA                                                      'i'
   31    42        ASSIGN_DIM                                                   !2, 'd%3A'
         43        OP_DATA                                                      'd'
   32    44        ASSIGN_DIM                                                   !2, 'b%3A'
         45        OP_DATA                                                      'b'
   33    46        FRAMELESS_ICALL_2                strtr               ~30     !0, !2
         47        ASSIGN_DIM                                                   !1, 'aggresive+removing+previous+and+some+double-colons'
         48        OP_DATA                                                      ~30
   34    49      > FE_RESET_R                                           $31     !1, ->69
         50    > > FE_FETCH_R                                           ~32     $31, !3, ->69
         51    >   ASSIGN                                                       !4, ~32
   35    52        INIT_FCALL                                                   'printf'
         53        ROPE_INIT                                         3  ~35     '%0ABy+'
         54        ROPE_ADD                                          1  ~35     ~35, !4
         55        ROPE_END                                          2  ~34     ~35, '+serialized+output+shrinks+by+%250.2f%25%25%0A'
         56        SEND_VAL                                                     ~34
         57        STRLEN                                               ~37     !0
         58        STRLEN                                               ~38     !3
         59        SUB                                                  ~39     ~37, ~38
         60        STRLEN                                               ~40     !3
         61        DIV                                                  ~41     ~39, ~40
         62        MUL                                                  ~42     ~41, 100
         63        SEND_VAL                                                     ~42
         64        DO_ICALL                                                     
   36    65        INIT_FCALL                                                   'var_dump'
         66        SEND_VAR                                                     !3
         67        DO_ICALL                                                     
   34    68      > JMP                                                          ->50
         69    >   FE_FREE                                                      $31
   37    70      > RETURN                                                       1

Class Color: [no user functions]
Class Foo:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DLh1U
function name:  __construct
number of ops:  16
compiled vars:  !0 = $date, !1 = $foo, !2 = $bar, !3 = $tbl, !4 = $color
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    9     0  E >   RECV                                                 !0      
   10     1        RECV                                                 !1      
   11     2        RECV                                                 !2      
   12     3        RECV_INIT                                            !3      <array>
   13     4        RECV_INIT                                            !4      <const ast>
    9     5        ASSIGN_OBJ                                                   'date'
          6        OP_DATA                                                      !0
   10     7        ASSIGN_OBJ                                                   'foo'
          8        OP_DATA                                                      !1
   11     9        ASSIGN_OBJ                                                   'bar'
         10        OP_DATA                                                      !2
   12    11        ASSIGN_OBJ                                                   'tbl'
         12        OP_DATA                                                      !3
   13    13        ASSIGN_OBJ                                                   'color'
         14        OP_DATA                                                      !4
   14    15      > RETURN                                                       null

End of function __construct

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
200.47 ms | 1771 KiB | 16 Q