@@ -4,10 +4,10 @@ |
||
| 4 | 4 | |
| 5 | 5 | class TLD extends Warning |
| 6 | 6 | { |
| 7 | - const CODE = 9; |
|
| 7 | + const CODE = 9; |
|
| 8 | 8 | |
| 9 | - public function __construct() |
|
| 10 | - { |
|
| 11 | - $this->message = "RFC5321, TLD"; |
|
| 12 | - } |
|
| 9 | + public function __construct() |
|
| 10 | + { |
|
| 11 | + $this->message = "RFC5321, TLD"; |
|
| 12 | + } |
|
| 13 | 13 | } |
@@ -4,11 +4,11 @@ |
||
| 4 | 4 | |
| 5 | 5 | class IPV6MaxGroups extends Warning |
| 6 | 6 | { |
| 7 | - const CODE = 75; |
|
| 7 | + const CODE = 75; |
|
| 8 | 8 | |
| 9 | - public function __construct() |
|
| 10 | - { |
|
| 11 | - $this->message = 'Reached the maximum number of IPV6 groups allowed'; |
|
| 12 | - $this->rfcNumber = 5321; |
|
| 13 | - } |
|
| 9 | + public function __construct() |
|
| 10 | + { |
|
| 11 | + $this->message = 'Reached the maximum number of IPV6 groups allowed'; |
|
| 12 | + $this->rfcNumber = 5321; |
|
| 13 | + } |
|
| 14 | 14 | } |
@@ -4,11 +4,11 @@ |
||
| 4 | 4 | |
| 5 | 5 | class AddressLiteral extends Warning |
| 6 | 6 | { |
| 7 | - const CODE = 12; |
|
| 7 | + const CODE = 12; |
|
| 8 | 8 | |
| 9 | - public function __construct() |
|
| 10 | - { |
|
| 11 | - $this->message = 'Address literal in domain part'; |
|
| 12 | - $this->rfcNumber = 5321; |
|
| 13 | - } |
|
| 9 | + public function __construct() |
|
| 10 | + { |
|
| 11 | + $this->message = 'Address literal in domain part'; |
|
| 12 | + $this->rfcNumber = 5321; |
|
| 13 | + } |
|
| 14 | 14 | } |
@@ -4,11 +4,11 @@ |
||
| 4 | 4 | |
| 5 | 5 | class IPV6GroupCount extends Warning |
| 6 | 6 | { |
| 7 | - const CODE = 72; |
|
| 7 | + const CODE = 72; |
|
| 8 | 8 | |
| 9 | - public function __construct() |
|
| 10 | - { |
|
| 11 | - $this->message = 'Group count is not IPV6 valid'; |
|
| 12 | - $this->rfcNumber = 5322; |
|
| 13 | - } |
|
| 9 | + public function __construct() |
|
| 10 | + { |
|
| 11 | + $this->message = 'Group count is not IPV6 valid'; |
|
| 12 | + $this->rfcNumber = 5322; |
|
| 13 | + } |
|
| 14 | 14 | } |
@@ -4,11 +4,11 @@ |
||
| 4 | 4 | |
| 5 | 5 | class LabelTooLong extends Warning |
| 6 | 6 | { |
| 7 | - const CODE = 63; |
|
| 7 | + const CODE = 63; |
|
| 8 | 8 | |
| 9 | - public function __construct() |
|
| 10 | - { |
|
| 11 | - $this->message = 'Label too long'; |
|
| 12 | - $this->rfcNumber = 5322; |
|
| 13 | - } |
|
| 9 | + public function __construct() |
|
| 10 | + { |
|
| 11 | + $this->message = 'Label too long'; |
|
| 12 | + $this->rfcNumber = 5322; |
|
| 13 | + } |
|
| 14 | 14 | } |
@@ -4,44 +4,44 @@ |
||
| 4 | 4 | |
| 5 | 5 | abstract class Warning |
| 6 | 6 | { |
| 7 | - const CODE = 0; |
|
| 8 | - |
|
| 9 | - /** |
|
| 10 | - * @var string |
|
| 11 | - */ |
|
| 12 | - protected $message = ''; |
|
| 13 | - |
|
| 14 | - /** |
|
| 15 | - * @var int |
|
| 16 | - */ |
|
| 17 | - protected $rfcNumber = 0; |
|
| 18 | - |
|
| 19 | - /** |
|
| 20 | - * @return string |
|
| 21 | - */ |
|
| 22 | - public function message() |
|
| 23 | - { |
|
| 24 | - return $this->message; |
|
| 25 | - } |
|
| 26 | - |
|
| 27 | - /** |
|
| 28 | - * @return int |
|
| 29 | - */ |
|
| 30 | - public function code() |
|
| 31 | - { |
|
| 32 | - return static::CODE; |
|
| 33 | - } |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * @return int |
|
| 37 | - */ |
|
| 38 | - public function RFCNumber() |
|
| 39 | - { |
|
| 40 | - return $this->rfcNumber; |
|
| 41 | - } |
|
| 42 | - |
|
| 43 | - public function __toString() |
|
| 44 | - { |
|
| 45 | - return $this->message() . " rfc: " . $this->rfcNumber . "interal code: " . static::CODE; |
|
| 46 | - } |
|
| 7 | + const CODE = 0; |
|
| 8 | + |
|
| 9 | + /** |
|
| 10 | + * @var string |
|
| 11 | + */ |
|
| 12 | + protected $message = ''; |
|
| 13 | + |
|
| 14 | + /** |
|
| 15 | + * @var int |
|
| 16 | + */ |
|
| 17 | + protected $rfcNumber = 0; |
|
| 18 | + |
|
| 19 | + /** |
|
| 20 | + * @return string |
|
| 21 | + */ |
|
| 22 | + public function message() |
|
| 23 | + { |
|
| 24 | + return $this->message; |
|
| 25 | + } |
|
| 26 | + |
|
| 27 | + /** |
|
| 28 | + * @return int |
|
| 29 | + */ |
|
| 30 | + public function code() |
|
| 31 | + { |
|
| 32 | + return static::CODE; |
|
| 33 | + } |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * @return int |
|
| 37 | + */ |
|
| 38 | + public function RFCNumber() |
|
| 39 | + { |
|
| 40 | + return $this->rfcNumber; |
|
| 41 | + } |
|
| 42 | + |
|
| 43 | + public function __toString() |
|
| 44 | + { |
|
| 45 | + return $this->message() . " rfc: " . $this->rfcNumber . "interal code: " . static::CODE; |
|
| 46 | + } |
|
| 47 | 47 | } |
@@ -42,6 +42,6 @@ |
||
| 42 | 42 | |
| 43 | 43 | public function __toString() |
| 44 | 44 | { |
| 45 | - return $this->message() . " rfc: " . $this->rfcNumber . "interal code: " . static::CODE; |
|
| 45 | + return $this->message()." rfc: ".$this->rfcNumber."interal code: ".static::CODE; |
|
| 46 | 46 | } |
| 47 | 47 | } |
@@ -6,278 +6,278 @@ |
||
| 6 | 6 | |
| 7 | 7 | class EmailLexer extends AbstractLexer |
| 8 | 8 | { |
| 9 | - //ASCII values |
|
| 10 | - const C_DEL = 127; |
|
| 11 | - const C_NUL = 0; |
|
| 12 | - const S_AT = 64; |
|
| 13 | - const S_BACKSLASH = 92; |
|
| 14 | - const S_DOT = 46; |
|
| 15 | - const S_DQUOTE = 34; |
|
| 16 | - const S_SQUOTE = 39; |
|
| 17 | - const S_BACKTICK = 96; |
|
| 18 | - const S_OPENPARENTHESIS = 49; |
|
| 19 | - const S_CLOSEPARENTHESIS = 261; |
|
| 20 | - const S_OPENBRACKET = 262; |
|
| 21 | - const S_CLOSEBRACKET = 263; |
|
| 22 | - const S_HYPHEN = 264; |
|
| 23 | - const S_COLON = 265; |
|
| 24 | - const S_DOUBLECOLON = 266; |
|
| 25 | - const S_SP = 267; |
|
| 26 | - const S_HTAB = 268; |
|
| 27 | - const S_CR = 269; |
|
| 28 | - const S_LF = 270; |
|
| 29 | - const S_IPV6TAG = 271; |
|
| 30 | - const S_LOWERTHAN = 272; |
|
| 31 | - const S_GREATERTHAN = 273; |
|
| 32 | - const S_COMMA = 274; |
|
| 33 | - const S_SEMICOLON = 275; |
|
| 34 | - const S_OPENQBRACKET = 276; |
|
| 35 | - const S_CLOSEQBRACKET = 277; |
|
| 36 | - const S_SLASH = 278; |
|
| 37 | - const S_EMPTY = null; |
|
| 38 | - const GENERIC = 300; |
|
| 39 | - const CRLF = 301; |
|
| 40 | - const INVALID = 302; |
|
| 41 | - const ASCII_INVALID_FROM = 127; |
|
| 42 | - const ASCII_INVALID_TO = 199; |
|
| 9 | + //ASCII values |
|
| 10 | + const C_DEL = 127; |
|
| 11 | + const C_NUL = 0; |
|
| 12 | + const S_AT = 64; |
|
| 13 | + const S_BACKSLASH = 92; |
|
| 14 | + const S_DOT = 46; |
|
| 15 | + const S_DQUOTE = 34; |
|
| 16 | + const S_SQUOTE = 39; |
|
| 17 | + const S_BACKTICK = 96; |
|
| 18 | + const S_OPENPARENTHESIS = 49; |
|
| 19 | + const S_CLOSEPARENTHESIS = 261; |
|
| 20 | + const S_OPENBRACKET = 262; |
|
| 21 | + const S_CLOSEBRACKET = 263; |
|
| 22 | + const S_HYPHEN = 264; |
|
| 23 | + const S_COLON = 265; |
|
| 24 | + const S_DOUBLECOLON = 266; |
|
| 25 | + const S_SP = 267; |
|
| 26 | + const S_HTAB = 268; |
|
| 27 | + const S_CR = 269; |
|
| 28 | + const S_LF = 270; |
|
| 29 | + const S_IPV6TAG = 271; |
|
| 30 | + const S_LOWERTHAN = 272; |
|
| 31 | + const S_GREATERTHAN = 273; |
|
| 32 | + const S_COMMA = 274; |
|
| 33 | + const S_SEMICOLON = 275; |
|
| 34 | + const S_OPENQBRACKET = 276; |
|
| 35 | + const S_CLOSEQBRACKET = 277; |
|
| 36 | + const S_SLASH = 278; |
|
| 37 | + const S_EMPTY = null; |
|
| 38 | + const GENERIC = 300; |
|
| 39 | + const CRLF = 301; |
|
| 40 | + const INVALID = 302; |
|
| 41 | + const ASCII_INVALID_FROM = 127; |
|
| 42 | + const ASCII_INVALID_TO = 199; |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * US-ASCII visible characters not valid for atext (@link http://tools.ietf.org/html/rfc5322#section-3.2.3) |
|
| 46 | - * |
|
| 47 | - * @var array |
|
| 48 | - */ |
|
| 49 | - protected $charValue = array( |
|
| 50 | - '(' => self::S_OPENPARENTHESIS, |
|
| 51 | - ')' => self::S_CLOSEPARENTHESIS, |
|
| 52 | - '<' => self::S_LOWERTHAN, |
|
| 53 | - '>' => self::S_GREATERTHAN, |
|
| 54 | - '[' => self::S_OPENBRACKET, |
|
| 55 | - ']' => self::S_CLOSEBRACKET, |
|
| 56 | - ':' => self::S_COLON, |
|
| 57 | - ';' => self::S_SEMICOLON, |
|
| 58 | - '@' => self::S_AT, |
|
| 59 | - '\\' => self::S_BACKSLASH, |
|
| 60 | - '/' => self::S_SLASH, |
|
| 61 | - ',' => self::S_COMMA, |
|
| 62 | - '.' => self::S_DOT, |
|
| 63 | - "'" => self::S_SQUOTE, |
|
| 64 | - "`" => self::S_BACKTICK, |
|
| 65 | - '"' => self::S_DQUOTE, |
|
| 66 | - '-' => self::S_HYPHEN, |
|
| 67 | - '::' => self::S_DOUBLECOLON, |
|
| 68 | - ' ' => self::S_SP, |
|
| 69 | - "\t" => self::S_HTAB, |
|
| 70 | - "\r" => self::S_CR, |
|
| 71 | - "\n" => self::S_LF, |
|
| 72 | - "\r\n" => self::CRLF, |
|
| 73 | - 'IPv6' => self::S_IPV6TAG, |
|
| 74 | - '{' => self::S_OPENQBRACKET, |
|
| 75 | - '}' => self::S_CLOSEQBRACKET, |
|
| 76 | - '' => self::S_EMPTY, |
|
| 77 | - '\0' => self::C_NUL, |
|
| 78 | - ); |
|
| 44 | + /** |
|
| 45 | + * US-ASCII visible characters not valid for atext (@link http://tools.ietf.org/html/rfc5322#section-3.2.3) |
|
| 46 | + * |
|
| 47 | + * @var array |
|
| 48 | + */ |
|
| 49 | + protected $charValue = array( |
|
| 50 | + '(' => self::S_OPENPARENTHESIS, |
|
| 51 | + ')' => self::S_CLOSEPARENTHESIS, |
|
| 52 | + '<' => self::S_LOWERTHAN, |
|
| 53 | + '>' => self::S_GREATERTHAN, |
|
| 54 | + '[' => self::S_OPENBRACKET, |
|
| 55 | + ']' => self::S_CLOSEBRACKET, |
|
| 56 | + ':' => self::S_COLON, |
|
| 57 | + ';' => self::S_SEMICOLON, |
|
| 58 | + '@' => self::S_AT, |
|
| 59 | + '\\' => self::S_BACKSLASH, |
|
| 60 | + '/' => self::S_SLASH, |
|
| 61 | + ',' => self::S_COMMA, |
|
| 62 | + '.' => self::S_DOT, |
|
| 63 | + "'" => self::S_SQUOTE, |
|
| 64 | + "`" => self::S_BACKTICK, |
|
| 65 | + '"' => self::S_DQUOTE, |
|
| 66 | + '-' => self::S_HYPHEN, |
|
| 67 | + '::' => self::S_DOUBLECOLON, |
|
| 68 | + ' ' => self::S_SP, |
|
| 69 | + "\t" => self::S_HTAB, |
|
| 70 | + "\r" => self::S_CR, |
|
| 71 | + "\n" => self::S_LF, |
|
| 72 | + "\r\n" => self::CRLF, |
|
| 73 | + 'IPv6' => self::S_IPV6TAG, |
|
| 74 | + '{' => self::S_OPENQBRACKET, |
|
| 75 | + '}' => self::S_CLOSEQBRACKET, |
|
| 76 | + '' => self::S_EMPTY, |
|
| 77 | + '\0' => self::C_NUL, |
|
| 78 | + ); |
|
| 79 | 79 | |
| 80 | - /** |
|
| 81 | - * @var bool |
|
| 82 | - */ |
|
| 83 | - protected $hasInvalidTokens = false; |
|
| 80 | + /** |
|
| 81 | + * @var bool |
|
| 82 | + */ |
|
| 83 | + protected $hasInvalidTokens = false; |
|
| 84 | 84 | |
| 85 | - /** |
|
| 86 | - * @var array |
|
| 87 | - * |
|
| 88 | - * @psalm-var array{value:string, type:null|int, position:int}|array<empty, empty> |
|
| 89 | - */ |
|
| 90 | - protected $previous = []; |
|
| 85 | + /** |
|
| 86 | + * @var array |
|
| 87 | + * |
|
| 88 | + * @psalm-var array{value:string, type:null|int, position:int}|array<empty, empty> |
|
| 89 | + */ |
|
| 90 | + protected $previous = []; |
|
| 91 | 91 | |
| 92 | - /** |
|
| 93 | - * The last matched/seen token. |
|
| 94 | - * |
|
| 95 | - * @var array |
|
| 96 | - * |
|
| 97 | - * @psalm-var array{value:string, type:null|int, position:int} |
|
| 98 | - */ |
|
| 99 | - public $token; |
|
| 92 | + /** |
|
| 93 | + * The last matched/seen token. |
|
| 94 | + * |
|
| 95 | + * @var array |
|
| 96 | + * |
|
| 97 | + * @psalm-var array{value:string, type:null|int, position:int} |
|
| 98 | + */ |
|
| 99 | + public $token; |
|
| 100 | 100 | |
| 101 | - /** |
|
| 102 | - * The next token in the input. |
|
| 103 | - * |
|
| 104 | - * @var array|null |
|
| 105 | - */ |
|
| 106 | - public $lookahead; |
|
| 101 | + /** |
|
| 102 | + * The next token in the input. |
|
| 103 | + * |
|
| 104 | + * @var array|null |
|
| 105 | + */ |
|
| 106 | + public $lookahead; |
|
| 107 | 107 | |
| 108 | - /** |
|
| 109 | - * @psalm-var array{value:'', type:null, position:0} |
|
| 110 | - */ |
|
| 111 | - private static $nullToken = [ |
|
| 112 | - 'value' => '', |
|
| 113 | - 'type' => null, |
|
| 114 | - 'position' => 0, |
|
| 115 | - ]; |
|
| 108 | + /** |
|
| 109 | + * @psalm-var array{value:'', type:null, position:0} |
|
| 110 | + */ |
|
| 111 | + private static $nullToken = [ |
|
| 112 | + 'value' => '', |
|
| 113 | + 'type' => null, |
|
| 114 | + 'position' => 0, |
|
| 115 | + ]; |
|
| 116 | 116 | |
| 117 | - public function __construct() |
|
| 118 | - { |
|
| 119 | - $this->previous = $this->token = self::$nullToken; |
|
| 120 | - $this->lookahead = null; |
|
| 121 | - } |
|
| 117 | + public function __construct() |
|
| 118 | + { |
|
| 119 | + $this->previous = $this->token = self::$nullToken; |
|
| 120 | + $this->lookahead = null; |
|
| 121 | + } |
|
| 122 | 122 | |
| 123 | - /** |
|
| 124 | - * @return void |
|
| 125 | - */ |
|
| 126 | - public function reset() |
|
| 127 | - { |
|
| 128 | - $this->hasInvalidTokens = false; |
|
| 129 | - parent::reset(); |
|
| 130 | - $this->previous = $this->token = self::$nullToken; |
|
| 131 | - } |
|
| 123 | + /** |
|
| 124 | + * @return void |
|
| 125 | + */ |
|
| 126 | + public function reset() |
|
| 127 | + { |
|
| 128 | + $this->hasInvalidTokens = false; |
|
| 129 | + parent::reset(); |
|
| 130 | + $this->previous = $this->token = self::$nullToken; |
|
| 131 | + } |
|
| 132 | 132 | |
| 133 | - /** |
|
| 134 | - * @return bool |
|
| 135 | - */ |
|
| 136 | - public function hasInvalidTokens() |
|
| 137 | - { |
|
| 138 | - return $this->hasInvalidTokens; |
|
| 139 | - } |
|
| 133 | + /** |
|
| 134 | + * @return bool |
|
| 135 | + */ |
|
| 136 | + public function hasInvalidTokens() |
|
| 137 | + { |
|
| 138 | + return $this->hasInvalidTokens; |
|
| 139 | + } |
|
| 140 | 140 | |
| 141 | - /** |
|
| 142 | - * @param int $type |
|
| 143 | - * @throws \UnexpectedValueException |
|
| 144 | - * @return boolean |
|
| 145 | - * |
|
| 146 | - * @psalm-suppress InvalidScalarArgument |
|
| 147 | - */ |
|
| 148 | - public function find($type) |
|
| 149 | - { |
|
| 150 | - $search = clone $this; |
|
| 151 | - $search->skipUntil($type); |
|
| 141 | + /** |
|
| 142 | + * @param int $type |
|
| 143 | + * @throws \UnexpectedValueException |
|
| 144 | + * @return boolean |
|
| 145 | + * |
|
| 146 | + * @psalm-suppress InvalidScalarArgument |
|
| 147 | + */ |
|
| 148 | + public function find($type) |
|
| 149 | + { |
|
| 150 | + $search = clone $this; |
|
| 151 | + $search->skipUntil($type); |
|
| 152 | 152 | |
| 153 | - if (!$search->lookahead) { |
|
| 154 | - throw new \UnexpectedValueException($type . ' not found'); |
|
| 155 | - } |
|
| 156 | - return true; |
|
| 157 | - } |
|
| 153 | + if (!$search->lookahead) { |
|
| 154 | + throw new \UnexpectedValueException($type . ' not found'); |
|
| 155 | + } |
|
| 156 | + return true; |
|
| 157 | + } |
|
| 158 | 158 | |
| 159 | - /** |
|
| 160 | - * getPrevious |
|
| 161 | - * |
|
| 162 | - * @return array |
|
| 163 | - */ |
|
| 164 | - public function getPrevious() |
|
| 165 | - { |
|
| 166 | - return $this->previous; |
|
| 167 | - } |
|
| 159 | + /** |
|
| 160 | + * getPrevious |
|
| 161 | + * |
|
| 162 | + * @return array |
|
| 163 | + */ |
|
| 164 | + public function getPrevious() |
|
| 165 | + { |
|
| 166 | + return $this->previous; |
|
| 167 | + } |
|
| 168 | 168 | |
| 169 | - /** |
|
| 170 | - * moveNext |
|
| 171 | - * |
|
| 172 | - * @return boolean |
|
| 173 | - */ |
|
| 174 | - public function moveNext() |
|
| 175 | - { |
|
| 176 | - $this->previous = $this->token; |
|
| 177 | - $hasNext = parent::moveNext(); |
|
| 178 | - $this->token = $this->token ?: self::$nullToken; |
|
| 169 | + /** |
|
| 170 | + * moveNext |
|
| 171 | + * |
|
| 172 | + * @return boolean |
|
| 173 | + */ |
|
| 174 | + public function moveNext() |
|
| 175 | + { |
|
| 176 | + $this->previous = $this->token; |
|
| 177 | + $hasNext = parent::moveNext(); |
|
| 178 | + $this->token = $this->token ?: self::$nullToken; |
|
| 179 | 179 | |
| 180 | - return $hasNext; |
|
| 181 | - } |
|
| 180 | + return $hasNext; |
|
| 181 | + } |
|
| 182 | 182 | |
| 183 | - /** |
|
| 184 | - * Lexical catchable patterns. |
|
| 185 | - * |
|
| 186 | - * @return string[] |
|
| 187 | - */ |
|
| 188 | - protected function getCatchablePatterns() |
|
| 189 | - { |
|
| 190 | - return array( |
|
| 191 | - '[a-zA-Z_]+[46]?', //ASCII and domain literal |
|
| 192 | - '[^\x00-\x7F]', //UTF-8 |
|
| 193 | - '[0-9]+', |
|
| 194 | - '\r\n', |
|
| 195 | - '::', |
|
| 196 | - '\s+?', |
|
| 197 | - '.', |
|
| 198 | - ); |
|
| 199 | - } |
|
| 183 | + /** |
|
| 184 | + * Lexical catchable patterns. |
|
| 185 | + * |
|
| 186 | + * @return string[] |
|
| 187 | + */ |
|
| 188 | + protected function getCatchablePatterns() |
|
| 189 | + { |
|
| 190 | + return array( |
|
| 191 | + '[a-zA-Z_]+[46]?', //ASCII and domain literal |
|
| 192 | + '[^\x00-\x7F]', //UTF-8 |
|
| 193 | + '[0-9]+', |
|
| 194 | + '\r\n', |
|
| 195 | + '::', |
|
| 196 | + '\s+?', |
|
| 197 | + '.', |
|
| 198 | + ); |
|
| 199 | + } |
|
| 200 | 200 | |
| 201 | - /** |
|
| 202 | - * Lexical non-catchable patterns. |
|
| 203 | - * |
|
| 204 | - * @return string[] |
|
| 205 | - */ |
|
| 206 | - protected function getNonCatchablePatterns() |
|
| 207 | - { |
|
| 208 | - return array('[\xA0-\xff]+'); |
|
| 209 | - } |
|
| 201 | + /** |
|
| 202 | + * Lexical non-catchable patterns. |
|
| 203 | + * |
|
| 204 | + * @return string[] |
|
| 205 | + */ |
|
| 206 | + protected function getNonCatchablePatterns() |
|
| 207 | + { |
|
| 208 | + return array('[\xA0-\xff]+'); |
|
| 209 | + } |
|
| 210 | 210 | |
| 211 | - /** |
|
| 212 | - * Retrieve token type. Also processes the token value if necessary. |
|
| 213 | - * |
|
| 214 | - * @param string $value |
|
| 215 | - * @throws \InvalidArgumentException |
|
| 216 | - * @return integer |
|
| 217 | - */ |
|
| 218 | - protected function getType(&$value) |
|
| 219 | - { |
|
| 220 | - if ($this->isNullType($value)) { |
|
| 221 | - return self::C_NUL; |
|
| 222 | - } |
|
| 211 | + /** |
|
| 212 | + * Retrieve token type. Also processes the token value if necessary. |
|
| 213 | + * |
|
| 214 | + * @param string $value |
|
| 215 | + * @throws \InvalidArgumentException |
|
| 216 | + * @return integer |
|
| 217 | + */ |
|
| 218 | + protected function getType(&$value) |
|
| 219 | + { |
|
| 220 | + if ($this->isNullType($value)) { |
|
| 221 | + return self::C_NUL; |
|
| 222 | + } |
|
| 223 | 223 | |
| 224 | - if ($this->isValid($value)) { |
|
| 225 | - return $this->charValue[$value]; |
|
| 226 | - } |
|
| 224 | + if ($this->isValid($value)) { |
|
| 225 | + return $this->charValue[$value]; |
|
| 226 | + } |
|
| 227 | 227 | |
| 228 | - if ($this->isUTF8Invalid($value)) { |
|
| 229 | - $this->hasInvalidTokens = true; |
|
| 230 | - return self::INVALID; |
|
| 231 | - } |
|
| 228 | + if ($this->isUTF8Invalid($value)) { |
|
| 229 | + $this->hasInvalidTokens = true; |
|
| 230 | + return self::INVALID; |
|
| 231 | + } |
|
| 232 | 232 | |
| 233 | - return self::GENERIC; |
|
| 234 | - } |
|
| 233 | + return self::GENERIC; |
|
| 234 | + } |
|
| 235 | 235 | |
| 236 | - /** |
|
| 237 | - * @param string $value |
|
| 238 | - * |
|
| 239 | - * @return bool |
|
| 240 | - */ |
|
| 241 | - protected function isValid($value) |
|
| 242 | - { |
|
| 243 | - if (isset($this->charValue[$value])) { |
|
| 244 | - return true; |
|
| 245 | - } |
|
| 236 | + /** |
|
| 237 | + * @param string $value |
|
| 238 | + * |
|
| 239 | + * @return bool |
|
| 240 | + */ |
|
| 241 | + protected function isValid($value) |
|
| 242 | + { |
|
| 243 | + if (isset($this->charValue[$value])) { |
|
| 244 | + return true; |
|
| 245 | + } |
|
| 246 | 246 | |
| 247 | - return false; |
|
| 248 | - } |
|
| 247 | + return false; |
|
| 248 | + } |
|
| 249 | 249 | |
| 250 | - /** |
|
| 251 | - * @param string $value |
|
| 252 | - * @return bool |
|
| 253 | - */ |
|
| 254 | - protected function isNullType($value) |
|
| 255 | - { |
|
| 256 | - if ($value === "\0") { |
|
| 257 | - return true; |
|
| 258 | - } |
|
| 250 | + /** |
|
| 251 | + * @param string $value |
|
| 252 | + * @return bool |
|
| 253 | + */ |
|
| 254 | + protected function isNullType($value) |
|
| 255 | + { |
|
| 256 | + if ($value === "\0") { |
|
| 257 | + return true; |
|
| 258 | + } |
|
| 259 | 259 | |
| 260 | - return false; |
|
| 261 | - } |
|
| 260 | + return false; |
|
| 261 | + } |
|
| 262 | 262 | |
| 263 | - /** |
|
| 264 | - * @param string $value |
|
| 265 | - * @return bool |
|
| 266 | - */ |
|
| 267 | - protected function isUTF8Invalid($value) |
|
| 268 | - { |
|
| 269 | - if (preg_match('/\p{Cc}+/u', $value)) { |
|
| 270 | - return true; |
|
| 271 | - } |
|
| 263 | + /** |
|
| 264 | + * @param string $value |
|
| 265 | + * @return bool |
|
| 266 | + */ |
|
| 267 | + protected function isUTF8Invalid($value) |
|
| 268 | + { |
|
| 269 | + if (preg_match('/\p{Cc}+/u', $value)) { |
|
| 270 | + return true; |
|
| 271 | + } |
|
| 272 | 272 | |
| 273 | - return false; |
|
| 274 | - } |
|
| 273 | + return false; |
|
| 274 | + } |
|
| 275 | 275 | |
| 276 | - /** |
|
| 277 | - * @return string |
|
| 278 | - */ |
|
| 279 | - protected function getModifiers() |
|
| 280 | - { |
|
| 281 | - return 'iu'; |
|
| 282 | - } |
|
| 276 | + /** |
|
| 277 | + * @return string |
|
| 278 | + */ |
|
| 279 | + protected function getModifiers() |
|
| 280 | + { |
|
| 281 | + return 'iu'; |
|
| 282 | + } |
|
| 283 | 283 | } |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | $search->skipUntil($type); |
| 152 | 152 | |
| 153 | 153 | if (!$search->lookahead) { |
| 154 | - throw new \UnexpectedValueException($type . ' not found'); |
|
| 154 | + throw new \UnexpectedValueException($type.' not found'); |
|
| 155 | 155 | } |
| 156 | 156 | return true; |
| 157 | 157 | } |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | { |
| 190 | 190 | return array( |
| 191 | 191 | '[a-zA-Z_]+[46]?', //ASCII and domain literal |
| 192 | - '[^\x00-\x7F]', //UTF-8 |
|
| 192 | + '[^\x00-\x7F]', //UTF-8 |
|
| 193 | 193 | '[0-9]+', |
| 194 | 194 | '\r\n', |
| 195 | 195 | '::', |
@@ -4,6 +4,6 @@ |
||
| 4 | 4 | |
| 5 | 5 | class ExpectingQPair extends InvalidEmail |
| 6 | 6 | { |
| 7 | - const CODE = 136; |
|
| 8 | - const REASON = "Expecting QPAIR"; |
|
| 7 | + const CODE = 136; |
|
| 8 | + const REASON = "Expecting QPAIR"; |
|
| 9 | 9 | } |
@@ -4,6 +4,6 @@ |
||
| 4 | 4 | |
| 5 | 5 | class NoDomainPart extends InvalidEmail |
| 6 | 6 | { |
| 7 | - const CODE = 131; |
|
| 8 | - const REASON = "No Domain part"; |
|
| 7 | + const CODE = 131; |
|
| 8 | + const REASON = "No Domain part"; |
|
| 9 | 9 | } |