3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ValidSymbolValidator implements ValidatorRuleInterface { private string $format = 'В этом поле можно использовать следующие символы: %s. Вы использовали символ(ы), который не входит в этот список, а именно - %s.'; private string $pattern; private string $verbalDescriptionOfPattern; public function __construct(string $pattern, string $verbalDescriptionOfPattern) { $this->pattern = $pattern; $this->verbalDescriptionOfPattern = $verbalDescriptionOfPattern; } public function __invoke(mixed $value): ?ValidationError { $numberOfCharacters = iconv_strlen($value); for($i = 0; $i < $numberOfCharacters; $i++) { $letter = mb_substr($value, $i, 1); $result = preg_match($this->pattern, $letter); if (!$result) { if ($letter === " ") { $invalidSymbols [] = "пробел"; } elseif ($letter === ",") { $invalidSymbols [] = "запятая"; } else { $invalidSymbols [] = $letter; } } } if ($invalidSymbols) { $invalidSymbols = array_unique($invalidSymbols); $invalidSymbols = implode(", ", $invalidSymbols); $errorText = sprintf( $this->format, $this->verbalDescriptionOfPattern, $invalidSymbols ); return new ValidationError($errorText); } else { return null; } } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FgUuP
function name:  (null)
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'validsymbolvalidator'
   47     1      > RETURN                                                   1

Class ValidSymbolValidator:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FgUuP
function name:  __construct
number of ops:  7
compiled vars:  !0 = $pattern, !1 = $verbalDescriptionOfPattern
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   13     2        ASSIGN_OBJ                                               'pattern'
          3        OP_DATA                                                  !0
   14     4        ASSIGN_OBJ                                               'verbalDescriptionOfPattern'
          5        OP_DATA                                                  !1
   15     6      > RETURN                                                   null

End of function __construct

Function __invoke:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
2 jumps found. (Code = 44) Position 1 = 36, Position 2 = 7
Branch analysis from position: 36
2 jumps found. (Code = 43) Position 1 = 37, Position 2 = 60
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 60
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 33
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 26
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
2 jumps found. (Code = 44) Position 1 = 36, Position 2 = 7
Branch analysis from position: 36
Branch analysis from position: 7
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 31
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
Branch analysis from position: 31
2 jumps found. (Code = 44) Position 1 = 36, Position 2 = 7
Branch analysis from position: 36
Branch analysis from position: 7
Branch analysis from position: 33
filename:       /in/FgUuP
function name:  __invoke
number of ops:  63
compiled vars:  !0 = $value, !1 = $numberOfCharacters, !2 = $i, !3 = $letter, !4 = $result, !5 = $invalidSymbols, !6 = $errorText
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
   19     1        INIT_FCALL_BY_NAME                                       'iconv_strlen'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0  $7      
          4        ASSIGN                                                   !1, $7
   21     5        ASSIGN                                                   !2, 0
          6      > JMP                                                      ->34
   22     7    >   INIT_FCALL                                               'mb_substr'
          8        SEND_VAR                                                 !0
          9        SEND_VAR                                                 !2
         10        SEND_VAL                                                 1
         11        DO_ICALL                                         $10     
         12        ASSIGN                                                   !3, $10
   23    13        INIT_FCALL                                               'preg_match'
         14        FETCH_OBJ_R                                      ~12     'pattern'
         15        SEND_VAL                                                 ~12
         16        SEND_VAR                                                 !3
         17        DO_ICALL                                         $13     
         18        ASSIGN                                                   !4, $13
   24    19        BOOL_NOT                                         ~15     !4
         20      > JMPZ                                                     ~15, ->33
   25    21    >   IS_IDENTICAL                                             !3, '+'
         22      > JMPZ                                                     ~16, ->26
   26    23    >   ASSIGN_DIM                                               !5
         24        OP_DATA                                                  '%D0%BF%D1%80%D0%BE%D0%B1%D0%B5%D0%BB'
   25    25      > JMP                                                      ->33
   27    26    >   IS_IDENTICAL                                             !3, '%2C'
         27      > JMPZ                                                     ~18, ->31
   28    28    >   ASSIGN_DIM                                               !5
         29        OP_DATA                                                  '%D0%B7%D0%B0%D0%BF%D1%8F%D1%82%D0%B0%D1%8F'
   27    30      > JMP                                                      ->33
   30    31    >   ASSIGN_DIM                                               !5
         32        OP_DATA                                                  !3
   21    33    >   PRE_INC                                                  !2
         34    >   IS_SMALLER                                               !2, !1
         35      > JMPNZ                                                    ~22, ->7
   34    36    > > JMPZ                                                     !5, ->60
   35    37    >   INIT_FCALL                                               'array_unique'
         38        SEND_VAR                                                 !5
         39        DO_ICALL                                         $23     
         40        ASSIGN                                                   !5, $23
   36    41        INIT_FCALL                                               'implode'
         42        SEND_VAL                                                 '%2C+'
         43        SEND_VAR                                                 !5
         44        DO_ICALL                                         $25     
         45        ASSIGN                                                   !5, $25
   37    46        INIT_FCALL                                               'sprintf'
   38    47        FETCH_OBJ_R                                      ~27     'format'
         48        SEND_VAL                                                 ~27
   39    49        FETCH_OBJ_R                                      ~28     'verbalDescriptionOfPattern'
         50        SEND_VAL                                                 ~28
   40    51        SEND_VAR                                                 !5
   37    52        DO_ICALL                                         $29     
         53        ASSIGN                                                   !6, $29
   42    54        NEW                                              $31     'ValidationError'
         55        SEND_VAR_EX                                              !6
         56        DO_FCALL                                      0          
         57        VERIFY_RETURN_TYPE                                       $31
         58      > RETURN                                                   $31
   34    59*       JMP                                                      ->61
   44    60    > > RETURN                                                   null
   46    61*       VERIFY_RETURN_TYPE                                       
         62*     > RETURN                                                   null

End of function __invoke

End of class ValidSymbolValidator.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
141.22 ms | 1011 KiB | 18 Q