3v4l.org

run code in 300+ 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 = 62, Position 2 = 81
Branch analysis from position: 62
2 jumps found. (Code = 78) Position 1 = 63, Position 2 = 81
Branch analysis from position: 63
1 jumps found. (Code = 42) Position 1 = 62
Branch analysis from position: 62
Branch analysis from position: 81
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 81
filename:       /in/DLh1U
function name:  (null)
number of ops:  83
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        INIT_FCALL                                               'strtr'
         20        SEND_VAR                                                 !0
         21        SEND_VAR                                                 !2
         22        DO_ICALL                                         $15     
         23        ASSIGN_DIM                                               !1, 'removing+double-quote'
         24        OP_DATA                                                  $15
   22    25        ASSIGN_DIM                                               !2, '%3B%7D'
         26        OP_DATA                                                  '%7D'
   23    27        ASSIGN_DIM                                               !2, '%3A%7B'
         28        OP_DATA                                                  '%7B'
   24    29        INIT_FCALL                                               'strtr'
         30        SEND_VAR                                                 !0
         31        SEND_VAR                                                 !2
         32        DO_ICALL                                         $19     
         33        ASSIGN_DIM                                               !1, 'removing+previous+and+array+leading+double-colon+and+trailing+semi-colon'
         34        OP_DATA                                                  $19
   25    35        ASSIGN_DIM                                               !2, 'O%3A'
         36        OP_DATA                                                  'O'
   26    37        ASSIGN_DIM                                               !2, 'a%3A'
         38        OP_DATA                                                  'a'
   27    39        ASSIGN_DIM                                               !2, 's%3A'
         40        OP_DATA                                                  's'
   28    41        ASSIGN_DIM                                               !2, 'E%3A'
         42        OP_DATA                                                  'E'
   29    43        INIT_FCALL                                               'strtr'
         44        SEND_VAR                                                 !0
         45        SEND_VAR                                                 !2
         46        DO_ICALL                                         $25     
         47        ASSIGN_DIM                                               !1, 'removing+previous+and+leading+double-colon+of+sized+types'
         48        OP_DATA                                                  $25
   30    49        ASSIGN_DIM                                               !2, 'i%3A'
         50        OP_DATA                                                  'i'
   31    51        ASSIGN_DIM                                               !2, 'd%3A'
         52        OP_DATA                                                  'd'
   32    53        ASSIGN_DIM                                               !2, 'b%3A'
         54        OP_DATA                                                  'b'
   33    55        INIT_FCALL                                               'strtr'
         56        SEND_VAR                                                 !0
         57        SEND_VAR                                                 !2
         58        DO_ICALL                                         $30     
         59        ASSIGN_DIM                                               !1, 'aggresive+removing+previous+and+some+double-colons'
         60        OP_DATA                                                  $30
   34    61      > FE_RESET_R                                       $31     !1, ->81
         62    > > FE_FETCH_R                                       ~32     $31, !3, ->81
         63    >   ASSIGN                                                   !4, ~32
   35    64        INIT_FCALL                                               'printf'
         65        ROPE_INIT                                     3  ~35     '%0ABy+'
         66        ROPE_ADD                                      1  ~35     ~35, !4
         67        ROPE_END                                      2  ~34     ~35, '+serialized+output+shrinks+by+%250.2f%25%25%0A'
         68        SEND_VAL                                                 ~34
         69        STRLEN                                           ~37     !0
         70        STRLEN                                           ~38     !3
         71        SUB                                              ~39     ~37, ~38
         72        STRLEN                                           ~40     !3
         73        DIV                                              ~41     ~39, ~40
         74        MUL                                              ~42     ~41, 100
         75        SEND_VAL                                                 ~42
         76        DO_ICALL                                                 
   36    77        INIT_FCALL                                               'var_dump'
         78        SEND_VAR                                                 !3
         79        DO_ICALL                                                 
   34    80      > JMP                                                      ->62
         81    >   FE_FREE                                                  $31
   37    82      > 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
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV_INIT                                        !3      <array>
          4        RECV_INIT                                        !4      <const ast>
          5        ASSIGN_OBJ                                               'date'
          6        OP_DATA                                                  !0
          7        ASSIGN_OBJ                                               'foo'
          8        OP_DATA                                                  !1
          9        ASSIGN_OBJ                                               'bar'
         10        OP_DATA                                                  !2
         11        ASSIGN_OBJ                                               'tbl'
         12        OP_DATA                                                  !3
         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.0.0


preferences:
141.4 ms | 1010 KiB | 17 Q