3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Distribution extends SPLFixedArray { private $keyMask; public function __construct(int $digits = 1) { parent::__construct(10 ** $digits); $this->keyMask = "%0{$digits}s"; } public function current(): int { return parent::current() ?? 0; } public function key(): string { return sprintf($this->keyMask, parent::key()); } public function addValue(string $key, int $value = 1) { $this->offsetSet((int) $key, $this->offsetGet((int) $key) + $value); } } $distribution = new Distribution(4); $distribution['8'] = ($distribution['8'] ?? 0) + 1; var_dump($distribution);

Abusive script

This script was stopped while abusing our resources

Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/28UL2
function name:  (null)
number of ops:  14
compiled vars:  !0 = $distribution
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   NEW                                              $1      'Distribution'
          1        SEND_VAL_EX                                              4
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $1
   25     4        FETCH_DIM_IS                                     ~5      !0, 8
          5        COALESCE                                         ~6      ~5
          6        QM_ASSIGN                                        ~6      0
          7        ADD                                              ~7      ~6, 1
          8        ASSIGN_DIM                                               !0, 8
          9        OP_DATA                                                  ~7
   27    10        INIT_FCALL                                               'var_dump'
         11        SEND_VAR                                                 !0
         12        DO_ICALL                                                 
         13      > RETURN                                                   1

Class Distribution:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/28UL2
function name:  __construct
number of ops:  11
compiled vars:  !0 = $digits
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV_INIT                                        !0      1
    7     1        INIT_STATIC_METHOD_CALL                                  
          2        POW                                              ~1      10, !0
          3        SEND_VAL_EX                                              ~1
          4        DO_FCALL                                      0          
    8     5        ROPE_INIT                                     3  ~5      '%250'
          6        ROPE_ADD                                      1  ~5      ~5, !0
          7        ROPE_END                                      2  ~4      ~5, 's'
          8        ASSIGN_OBJ                                               'keyMask'
          9        OP_DATA                                                  ~4
    9    10      > RETURN                                                   null

End of function __construct

Function current:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/28UL2
function name:  current
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   INIT_STATIC_METHOD_CALL                                  'current'
          1        DO_FCALL                                      0  $0      
          2        COALESCE                                         ~1      $0
          3        QM_ASSIGN                                        ~1      0
          4        VERIFY_RETURN_TYPE                                       ~1
          5      > RETURN                                                   ~1
   13     6*       VERIFY_RETURN_TYPE                                       
          7*     > RETURN                                                   null

End of function current

Function key:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/28UL2
function name:  key
number of ops:  11
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   INIT_FCALL                                               'sprintf'
          1        FETCH_OBJ_R                                      ~0      'keyMask'
          2        SEND_VAL                                                 ~0
          3        INIT_STATIC_METHOD_CALL                                  'key'
          4        DO_FCALL                                      0  $1      
          5        SEND_VAR                                                 $1
          6        DO_ICALL                                         $2      
          7        VERIFY_RETURN_TYPE                                       $2
          8      > RETURN                                                   $2
   17     9*       VERIFY_RETURN_TYPE                                       
         10*     > RETURN                                                   null

End of function key

Function addvalue:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/28UL2
function name:  addValue
number of ops:  13
compiled vars:  !0 = $key, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      1
   20     2        INIT_METHOD_CALL                                         'offsetSet'
          3        CAST                                          4  ~2      !0
          4        SEND_VAL_EX                                              ~2
          5        INIT_METHOD_CALL                                         'offsetGet'
          6        CAST                                          4  ~3      !0
          7        SEND_VAL_EX                                              ~3
          8        DO_FCALL                                      0  $4      
          9        ADD                                              ~5      $4, !1
         10        SEND_VAL_EX                                              ~5
         11        DO_FCALL                                      0          
   21    12      > RETURN                                                   null

End of function addvalue

End of class Distribution.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.94 ms | 1006 KiB | 15 Q