3v4l.org

run code in 500+ 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 = 31
Branch analysis from position: 31
2 jumps found. (Code = 44) Position 1 = 33, Position 2 = 7
Branch analysis from position: 33
2 jumps found. (Code = 43) Position 1 = 34, Position 2 = 54
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 54
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 30
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 23
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
2 jumps found. (Code = 44) Position 1 = 33, Position 2 = 7
Branch analysis from position: 33
Branch analysis from position: 7
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 28
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 33, Position 2 = 7
Branch analysis from position: 33
Branch analysis from position: 7
Branch analysis from position: 30
filename:       /in/FgUuP
function name:  __invoke
number of ops:  57
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                                                          ->31
   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        FETCH_OBJ_R                                          ~12     'pattern'
         14        FRAMELESS_ICALL_2                preg_match          ~13     ~12, !3
         15        ASSIGN                                                       !4, ~13
   24    16        BOOL_NOT                                             ~15     !4
         17      > JMPZ                                                         ~15, ->30
   25    18    >   IS_IDENTICAL                                                 !3, '+'
         19      > JMPZ                                                         ~16, ->23
   26    20    >   ASSIGN_DIM                                                   !5
         21        OP_DATA                                                      '%D0%BF%D1%80%D0%BE%D0%B1%D0%B5%D0%BB'
   25    22      > JMP                                                          ->30
   27    23    >   IS_IDENTICAL                                                 !3, '%2C'
         24      > JMPZ                                                         ~18, ->28
   28    25    >   ASSIGN_DIM                                                   !5
         26        OP_DATA                                                      '%D0%B7%D0%B0%D0%BF%D1%8F%D1%82%D0%B0%D1%8F'
   27    27      > JMP                                                          ->30
   30    28    >   ASSIGN_DIM                                                   !5
         29        OP_DATA                                                      !3
   21    30    >   PRE_INC                                                      !2
         31    >   IS_SMALLER                                                   !2, !1
         32      > JMPNZ                                                        ~22, ->7
   34    33    > > JMPZ                                                         !5, ->54
   35    34    >   INIT_FCALL                                                   'array_unique'
         35        SEND_VAR                                                     !5
         36        DO_ICALL                                             $23     
         37        ASSIGN                                                       !5, $23
   36    38        FRAMELESS_ICALL_2                implode             ~25     '%2C+', !5
         39        ASSIGN                                                       !5, ~25
   37    40        INIT_FCALL                                                   'sprintf'
   38    41        FETCH_OBJ_R                                          ~27     'format'
         42        SEND_VAL                                                     ~27
   39    43        FETCH_OBJ_R                                          ~28     'verbalDescriptionOfPattern'
         44        SEND_VAL                                                     ~28
   40    45        SEND_VAR                                                     !5
   37    46        DO_ICALL                                             $29     
         47        ASSIGN                                                       !6, $29
   42    48        NEW                                                  $31     'ValidationError'
         49        SEND_VAR_EX                                                  !6
         50        DO_FCALL                                          0          
         51        VERIFY_RETURN_TYPE                                           $31
         52      > RETURN                                                       $31
   34    53*       JMP                                                          ->55
   44    54    > > RETURN                                                       null
   46    55*       VERIFY_RETURN_TYPE                                           
         56*     > RETURN                                                       null

End of function __invoke

End of class ValidSymbolValidator.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
161.99 ms | 1617 KiB | 16 Q