3v4l.org

run code in 500+ PHP versions simultaneously
<?php class RegexValidator implements ValidatorRuleInterface { private array $reviewResources = [ "formatForSymbols" => 'В этом поле можно использовать следующие символы: %s. Вы использовали символ(ы), который не входит в этот список, а именно - %s', "formatForString" => 'Поле должно иметь следующий вид: %s. Вы написали - %s', ]; public function __construct(string $patternForSymbol, string $patternForString, array $verbalDescriptionOfPatterns) { $this->reviewResources["patternForSymbol"] = $patternForSymbol; $this->reviewResources["patternForString"] = $patternForString; $this->reviewResources["verbalDescriptionOfPatterns"] = $verbalDescriptionOfPatterns; } private function checkSymbols (mixed $value): ?array { $numberOfCharacters = iconv_strlen($value); for ($i=0; $i<$numberOfCharacters; $i++) { $letter = $value[$i]; $result = preg_match($this->reviewResources["patternForSymbol"]); if (!$result) { $invalidSymbols [] = $letter; } } return ($invalidSymbols) ? $invalidSymbols : null; } private function checkString (mixed $value): bool { return preg_match($this->reviewResources["patternForString"], $value); } public function __invoke (mixed $value): ?ValidationError { $resultForSymbol = $this->checkSymbols($value); $resultForString = $this->checkString($value); if ($resultForSymbol) { $result .= sprintf( $this->reviewResources["formatForSymbols"], $this->reviewResources["verbalDescriptionOfPatterns"]["symbols"], implode(", ", $resultForSymbol) ); } if (!$resultForString) { $result .= sprintf( $this->reviewResources["formatForString"], $this->reviewResources["verbalDescriptionOfPatterns"]["string"], $value ); } ($result) ? new ValidationError($result) : null; } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/of0e9
function name:  (null)
number of ops:  2
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                                'regexvalidator'
   62     1      > RETURN                                                       1

Class RegexValidator:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/of0e9
function name:  __construct
number of ops:  13
compiled vars:  !0 = $patternForSymbol, !1 = $patternForString, !2 = $verbalDescriptionOfPatterns
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   10     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
          2        RECV                                                 !2      
   12     3        FETCH_OBJ_W                                          $3      'reviewResources'
          4        ASSIGN_DIM                                                   $3, 'patternForSymbol'
          5        OP_DATA                                                      !0
   13     6        FETCH_OBJ_W                                          $5      'reviewResources'
          7        ASSIGN_DIM                                                   $5, 'patternForString'
          8        OP_DATA                                                      !1
   14     9        FETCH_OBJ_W                                          $7      'reviewResources'
         10        ASSIGN_DIM                                                   $7, 'verbalDescriptionOfPatterns'
         11        OP_DATA                                                      !2
   15    12      > RETURN                                                       null

End of function __construct

Function checksymbols:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 7
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 25
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 19
Branch analysis from position: 17
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 7
Branch analysis from position: 22
Branch analysis from position: 7
Branch analysis from position: 19
filename:       /in/of0e9
function name:  checkSymbols
number of ops:  30
compiled vars:  !0 = $value, !1 = $numberOfCharacters, !2 = $i, !3 = $letter, !4 = $result, !5 = $invalidSymbols
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  $6      
          4        ASSIGN                                                       !1, $6
   21     5        ASSIGN                                                       !2, 0
          6      > JMP                                                          ->20
   23     7    >   FETCH_DIM_R                                          ~9      !0, !2
          8        ASSIGN                                                       !3, ~9
   24     9        INIT_FCALL                                                   'preg_match'
         10        FETCH_OBJ_R                                          ~11     'reviewResources'
         11        FETCH_DIM_R                                          ~12     ~11, 'patternForSymbol'
         12        SEND_VAL                                                     ~12
         13        DO_ICALL                                             $13     
         14        ASSIGN                                                       !4, $13
   25    15        BOOL_NOT                                             ~15     !4
         16      > JMPZ                                                         ~15, ->19
   27    17    >   ASSIGN_DIM                                                   !5
         18        OP_DATA                                                      !3
   21    19    >   PRE_INC                                                      !2
         20    >   IS_SMALLER                                                   !2, !1
         21      > JMPNZ                                                        ~18, ->7
   30    22    > > JMPZ                                                         !5, ->25
         23    >   QM_ASSIGN                                            ~19     !5
         24      > JMP                                                          ->26
         25    >   QM_ASSIGN                                            ~19     null
         26    >   VERIFY_RETURN_TYPE                                           ~19
         27      > RETURN                                                       ~19
   31    28*       VERIFY_RETURN_TYPE                                           
         29*     > RETURN                                                       null

End of function checksymbols

Function checkstring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/of0e9
function name:  checkString
number of ops:  8
compiled vars:  !0 = $value
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   33     0  E >   RECV                                                 !0      
   35     1        FETCH_OBJ_R                                          ~1      'reviewResources'
          2        FETCH_DIM_R                                          ~2      ~1, 'patternForString'
          3        FRAMELESS_ICALL_2                preg_match          ~3      ~2, !0
          4        VERIFY_RETURN_TYPE                                           ~3
          5      > RETURN                                                       ~3
   36     6*       VERIFY_RETURN_TYPE                                           
          7*     > RETURN                                                       null

End of function checkstring

Function __invoke:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 22
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 35
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 36, Position 2 = 41
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 41
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 35
Branch analysis from position: 22
filename:       /in/of0e9
function name:  __invoke
number of ops:  45
compiled vars:  !0 = $value, !1 = $resultForSymbol, !2 = $resultForString, !3 = $result
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   38     0  E >   RECV                                                 !0      
   40     1        INIT_METHOD_CALL                                             'checkSymbols'
          2        SEND_VAR                                                     !0
          3        DO_FCALL                                          0  $4      
          4        ASSIGN                                                       !1, $4
   41     5        INIT_METHOD_CALL                                             'checkString'
          6        SEND_VAR                                                     !0
          7        DO_FCALL                                          0  $6      
          8        ASSIGN                                                       !2, $6
   42     9      > JMPZ                                                         !1, ->22
   44    10    >   INIT_FCALL                                                   'sprintf'
   45    11        FETCH_OBJ_R                                          ~8      'reviewResources'
         12        FETCH_DIM_R                                          ~9      ~8, 'formatForSymbols'
         13        SEND_VAL                                                     ~9
   46    14        FETCH_OBJ_R                                          ~10     'reviewResources'
         15        FETCH_DIM_R                                          ~11     ~10, 'verbalDescriptionOfPatterns'
         16        FETCH_DIM_R                                          ~12     ~11, 'symbols'
         17        SEND_VAL                                                     ~12
   47    18        FRAMELESS_ICALL_2                implode             ~13     '%2C+', !1
         19        SEND_VAL                                                     ~13
   44    20        DO_ICALL                                             $14     
   47    21        ASSIGN_OP                                         8          !3, $14
   51    22    >   BOOL_NOT                                             ~16     !2
         23      > JMPZ                                                         ~16, ->35
   53    24    >   INIT_FCALL                                                   'sprintf'
   54    25        FETCH_OBJ_R                                          ~17     'reviewResources'
         26        FETCH_DIM_R                                          ~18     ~17, 'formatForString'
         27        SEND_VAL                                                     ~18
   55    28        FETCH_OBJ_R                                          ~19     'reviewResources'
         29        FETCH_DIM_R                                          ~20     ~19, 'verbalDescriptionOfPatterns'
         30        FETCH_DIM_R                                          ~21     ~20, 'string'
         31        SEND_VAL                                                     ~21
   56    32        SEND_VAR                                                     !0
   53    33        DO_ICALL                                             $22     
   56    34        ASSIGN_OP                                         8          !3, $22
   60    35    > > JMPZ                                                         !3, ->41
         36    >   NEW                                                  $24     'ValidationError'
         37        SEND_VAR_EX                                                  !3
         38        DO_FCALL                                          0          
         39        QM_ASSIGN                                            ~26     $24
         40      > JMP                                                          ->42
         41    >   QM_ASSIGN                                            ~26     null
         42    >   FREE                                                         ~26
   61    43        VERIFY_RETURN_TYPE                                           
         44      > RETURN                                                       null

End of function __invoke

End of class RegexValidator.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
159.96 ms | 1617 KiB | 17 Q