3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Character { protected $symbol; public function __construct($symbol) { $this->symbol = $symbol; } public function display($pointSize) { echo $this->symbol." (size ".$pointSize.")"; } } class CharacterFactory { private $characters = array(); public function getCharacter($key) { if (!array_key_exists($key, $this->characters)) $this->characters[$key] = new Character($key); return $this->characters[$key]; } } $document = "Барабан"; $chars = str_split($document); $factory = new CharacterFactory(); $debug = array(); $pointSize = 0; foreach ($chars as $key) { $pointSize++; $character = $factory->getCharacter($key); $character->display($pointSize); $debug[] = $character; } var_dump($debug);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 23
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 23
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
filename:       /in/DQnsB
function name:  (null)
number of ops:  28
compiled vars:  !0 = $document, !1 = $chars, !2 = $factory, !3 = $debug, !4 = $pointSize, !5 = $key, !6 = $character
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   ASSIGN                                                   !0, '%D0%91%D0%B0%D1%80%D0%B0%D0%B1%D0%B0%D0%BD'
   32     1        INIT_FCALL                                               'str_split'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $8      
          4        ASSIGN                                                   !1, $8
   34     5        NEW                                              $10     'CharacterFactory'
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !2, $10
   36     8        ASSIGN                                                   !3, <array>
   38     9        ASSIGN                                                   !4, 0
   39    10      > FE_RESET_R                                       $15     !1, ->23
         11    > > FE_FETCH_R                                               $15, !5, ->23
   41    12    >   PRE_INC                                                  !4
   42    13        INIT_METHOD_CALL                                         !2, 'getCharacter'
         14        SEND_VAR_EX                                              !5
         15        DO_FCALL                                      0  $17     
         16        ASSIGN                                                   !6, $17
   43    17        INIT_METHOD_CALL                                         !6, 'display'
         18        SEND_VAR_EX                                              !4
         19        DO_FCALL                                      0          
   45    20        ASSIGN_DIM                                               !3
         21        OP_DATA                                                  !6
   39    22      > JMP                                                      ->11
         23    >   FE_FREE                                                  $15
   48    24        INIT_FCALL                                               'var_dump'
         25        SEND_VAR                                                 !3
         26        DO_ICALL                                                 
         27      > RETURN                                                   1

Class Character:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DQnsB
function name:  __construct
number of ops:  4
compiled vars:  !0 = $symbol
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    9     1        ASSIGN_OBJ                                               'symbol'
          2        OP_DATA                                                  !0
   10     3      > RETURN                                                   null

End of function __construct

Function display:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DQnsB
function name:  display
number of ops:  7
compiled vars:  !0 = $pointSize
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   14     1        FETCH_OBJ_R                                      ~1      'symbol'
          2        CONCAT                                           ~2      ~1, '+%28size+'
          3        CONCAT                                           ~3      ~2, !0
          4        CONCAT                                           ~4      ~3, '%29'
          5        ECHO                                                     ~4
   15     6      > RETURN                                                   null

End of function display

End of class Character.

Class CharacterFactory:
Function getcharacter:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 11
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/DQnsB
function name:  getCharacter
number of ops:  15
compiled vars:  !0 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   RECV                                             !0      
   24     1        FETCH_OBJ_R                                      ~1      'characters'
          2        ARRAY_KEY_EXISTS                                 ~2      !0, ~1
          3        BOOL_NOT                                         ~3      ~2
          4      > JMPZ                                                     ~3, ->11
   25     5    >   NEW                                              $6      'Character'
          6        SEND_VAR_EX                                              !0
          7        DO_FCALL                                      0          
          8        FETCH_OBJ_W                                      $4      'characters'
          9        ASSIGN_DIM                                               $4, !0
         10        OP_DATA                                                  $6
   27    11    >   FETCH_OBJ_R                                      ~8      'characters'
         12        FETCH_DIM_R                                      ~9      ~8, !0
         13      > RETURN                                                   ~9
   28    14*     > RETURN                                                   null

End of function getcharacter

End of class CharacterFactory.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.71 ms | 1400 KiB | 17 Q