@@ -152,16 +152,16 @@ discard block |
||
| 152 | 152 | */ |
| 153 | 153 | public $Timelimit = 300; |
| 154 | 154 | |
| 155 | - /** |
|
| 156 | - * @var array patterns to extract smtp transaction id from smtp reply |
|
| 157 | - * Only first capture group will be use, use non-capturing group to deal with it |
|
| 158 | - * Extend this class to override this property to fulfil your needs. |
|
| 159 | - */ |
|
| 160 | - protected $smtp_transaction_id_patterns = array( |
|
| 161 | - 'exim' => '/[0-9]{3} OK id=(.*)/', |
|
| 162 | - 'sendmail' => '/[0-9]{3} 2.0.0 (.*) Message/', |
|
| 163 | - 'postfix' => '/[0-9]{3} 2.0.0 Ok: queued as (.*)/' |
|
| 164 | - ); |
|
| 155 | + /** |
|
| 156 | + * @var array patterns to extract smtp transaction id from smtp reply |
|
| 157 | + * Only first capture group will be use, use non-capturing group to deal with it |
|
| 158 | + * Extend this class to override this property to fulfil your needs. |
|
| 159 | + */ |
|
| 160 | + protected $smtp_transaction_id_patterns = array( |
|
| 161 | + 'exim' => '/[0-9]{3} OK id=(.*)/', |
|
| 162 | + 'sendmail' => '/[0-9]{3} 2.0.0 (.*) Message/', |
|
| 163 | + 'postfix' => '/[0-9]{3} 2.0.0 Ok: queued as (.*)/' |
|
| 164 | + ); |
|
| 165 | 165 | |
| 166 | 166 | /** |
| 167 | 167 | * The socket for the server connection. |
@@ -1225,27 +1225,27 @@ discard block |
||
| 1225 | 1225 | ); |
| 1226 | 1226 | } |
| 1227 | 1227 | |
| 1228 | - /** |
|
| 1229 | - * Will return the ID of the last smtp transaction based on a list of patterns provided |
|
| 1230 | - * in SMTP::$smtp_transaction_id_patterns. |
|
| 1231 | - * If no reply has been received yet, it will return null. |
|
| 1232 | - * If no pattern has been matched, it will return false. |
|
| 1233 | - * @return bool|null|string |
|
| 1234 | - */ |
|
| 1235 | - public function getLastTransactionID() |
|
| 1236 | - { |
|
| 1237 | - $reply = $this->getLastReply(); |
|
| 1238 | - |
|
| 1239 | - if (empty($reply)) { |
|
| 1240 | - return null; |
|
| 1241 | - } |
|
| 1242 | - |
|
| 1243 | - foreach($this->smtp_transaction_id_patterns as $smtp_transaction_id_pattern) { |
|
| 1244 | - if(preg_match($smtp_transaction_id_pattern, $reply, $matches)) { |
|
| 1245 | - return $matches[1]; |
|
| 1246 | - } |
|
| 1247 | - } |
|
| 1248 | - |
|
| 1249 | - return false; |
|
| 1228 | + /** |
|
| 1229 | + * Will return the ID of the last smtp transaction based on a list of patterns provided |
|
| 1230 | + * in SMTP::$smtp_transaction_id_patterns. |
|
| 1231 | + * If no reply has been received yet, it will return null. |
|
| 1232 | + * If no pattern has been matched, it will return false. |
|
| 1233 | + * @return bool|null|string |
|
| 1234 | + */ |
|
| 1235 | + public function getLastTransactionID() |
|
| 1236 | + { |
|
| 1237 | + $reply = $this->getLastReply(); |
|
| 1238 | + |
|
| 1239 | + if (empty($reply)) { |
|
| 1240 | + return null; |
|
| 1241 | + } |
|
| 1242 | + |
|
| 1243 | + foreach($this->smtp_transaction_id_patterns as $smtp_transaction_id_pattern) { |
|
| 1244 | + if(preg_match($smtp_transaction_id_pattern, $reply, $matches)) { |
|
| 1245 | + return $matches[1]; |
|
| 1246 | + } |
|
| 1247 | + } |
|
| 1248 | + |
|
| 1249 | + return false; |
|
| 1250 | 1250 | } |
| 1251 | 1251 | } |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | "\n", |
| 245 | 245 | "\n \t ", |
| 246 | 246 | trim($str) |
| 247 | - )."\n"; |
|
| 247 | + ) . "\n"; |
|
| 248 | 248 | } |
| 249 | 249 | } |
| 250 | 250 | |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | } |
| 279 | 279 | // Connect to the SMTP server |
| 280 | 280 | $this->edebug( |
| 281 | - "Connection: opening to $host:$port, timeout=$timeout, options=".var_export($options, true), |
|
| 281 | + "Connection: opening to $host:$port, timeout=$timeout, options=" . var_export($options, true), |
|
| 282 | 282 | self::DEBUG_CONNECTION |
| 283 | 283 | ); |
| 284 | 284 | $errno = 0; |
@@ -426,7 +426,7 @@ discard block |
||
| 426 | 426 | $this->setError('No supported authentication methods found'); |
| 427 | 427 | return false; |
| 428 | 428 | } |
| 429 | - self::edebug('Auth method selected: '.$authtype, self::DEBUG_LOWLEVEL); |
|
| 429 | + self::edebug('Auth method selected: ' . $authtype, self::DEBUG_LOWLEVEL); |
|
| 430 | 430 | } |
| 431 | 431 | |
| 432 | 432 | if (!in_array($authtype, $this->server_caps['AUTH'])) { |
@@ -895,7 +895,7 @@ discard block |
||
| 895 | 895 | $code_ex = (count($matches) > 2 ? $matches[2] : null); |
| 896 | 896 | // Cut off error code from each response line |
| 897 | 897 | $detail = preg_replace( |
| 898 | - "/{$code}[ -]".($code_ex ? str_replace('.', '\\.', $code_ex).' ' : '')."/m", |
|
| 898 | + "/{$code}[ -]" . ($code_ex ? str_replace('.', '\\.', $code_ex) . ' ' : '') . "/m", |
|
| 899 | 899 | '', |
| 900 | 900 | $this->last_reply |
| 901 | 901 | ); |
@@ -1107,7 +1107,7 @@ discard block |
||
| 1107 | 1107 | // Now check if reads took too long |
| 1108 | 1108 | if ($endtime and time() > $endtime) { |
| 1109 | 1109 | $this->edebug( |
| 1110 | - 'SMTP -> get_lines(): timelimit reached ('. |
|
| 1110 | + 'SMTP -> get_lines(): timelimit reached (' . |
|
| 1111 | 1111 | $this->Timelimit . ' sec)', |
| 1112 | 1112 | self::DEBUG_LOWLEVEL |
| 1113 | 1113 | ); |
@@ -1240,8 +1240,8 @@ discard block |
||
| 1240 | 1240 | return null; |
| 1241 | 1241 | } |
| 1242 | 1242 | |
| 1243 | - foreach($this->smtp_transaction_id_patterns as $smtp_transaction_id_pattern) { |
|
| 1244 | - if(preg_match($smtp_transaction_id_pattern, $reply, $matches)) { |
|
| 1243 | + foreach ($this->smtp_transaction_id_patterns as $smtp_transaction_id_pattern) { |
|
| 1244 | + if (preg_match($smtp_transaction_id_pattern, $reply, $matches)) { |
|
| 1245 | 1245 | return $matches[1]; |
| 1246 | 1246 | } |
| 1247 | 1247 | } |
@@ -1193,8 +1193,7 @@ discard block |
||
| 1193 | 1193 | if ($this->has8bitChars($domain) and @mb_check_encoding($domain, $this->CharSet)) { |
| 1194 | 1194 | $domain = mb_convert_encoding($domain, 'UTF-8', $this->CharSet); |
| 1195 | 1195 | if (($punycode = defined('INTL_IDNA_VARIANT_UTS46') ? |
| 1196 | - idn_to_ascii($domain, 0, INTL_IDNA_VARIANT_UTS46) : |
|
| 1197 | - idn_to_ascii($domain)) !== false) { |
|
| 1196 | + idn_to_ascii($domain, 0, INTL_IDNA_VARIANT_UTS46) : idn_to_ascii($domain)) !== false) { |
|
| 1198 | 1197 | return substr($address, 0, $pos) . $punycode; |
| 1199 | 1198 | } |
| 1200 | 1199 | } |
@@ -1340,7 +1339,7 @@ discard block |
||
| 1340 | 1339 | case 'mail': |
| 1341 | 1340 | return $this->mailSend($this->MIMEHeader, $this->MIMEBody); |
| 1342 | 1341 | default: |
| 1343 | - $sendMethod = $this->Mailer.'Send'; |
|
| 1342 | + $sendMethod = $this->Mailer . 'Send'; |
|
| 1344 | 1343 | if (method_exists($this, $sendMethod)) { |
| 1345 | 1344 | return $this->$sendMethod($this->MIMEHeader, $this->MIMEBody); |
| 1346 | 1345 | } |
@@ -1652,7 +1651,7 @@ discard block |
||
| 1652 | 1651 | if ('tls' === $secure or 'ssl' === $secure) { |
| 1653 | 1652 | //Check for an OpenSSL constant rather than using extension_loaded, which is sometimes disabled |
| 1654 | 1653 | if (!$sslext) { |
| 1655 | - throw new phpmailerException($this->lang('extension_missing').'openssl', self::STOP_CRITICAL); |
|
| 1654 | + throw new phpmailerException($this->lang('extension_missing') . 'openssl', self::STOP_CRITICAL); |
|
| 1656 | 1655 | } |
| 1657 | 1656 | } |
| 1658 | 1657 | $host = $hostinfo[3]; |
@@ -1776,7 +1775,7 @@ discard block |
||
| 1776 | 1775 | ); |
| 1777 | 1776 | if (empty($lang_path)) { |
| 1778 | 1777 | // Calculate an absolute path so it can work if CWD is not here |
| 1779 | - $lang_path = dirname(__FILE__). DIRECTORY_SEPARATOR . 'language'. DIRECTORY_SEPARATOR; |
|
| 1778 | + $lang_path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'language' . DIRECTORY_SEPARATOR; |
|
| 1780 | 1779 | } |
| 1781 | 1780 | //Validate $langcode |
| 1782 | 1781 | if (!preg_match('/^[a-z]{2}(?:_[a-zA-Z]{2})?$/', $langcode)) { |
@@ -3252,7 +3251,7 @@ discard block |
||
| 3252 | 3251 | if (!empty($lasterror['error'])) { |
| 3253 | 3252 | $msg .= $this->lang('smtp_error') . $lasterror['error']; |
| 3254 | 3253 | if (!empty($lasterror['detail'])) { |
| 3255 | - $msg .= ' Detail: '. $lasterror['detail']; |
|
| 3254 | + $msg .= ' Detail: ' . $lasterror['detail']; |
|
| 3256 | 3255 | } |
| 3257 | 3256 | if (!empty($lasterror['smtp_code'])) { |
| 3258 | 3257 | $msg .= ' SMTP code: ' . $lasterror['smtp_code']; |
@@ -3948,7 +3947,7 @@ discard block |
||
| 3948 | 3947 | public static function hasLineLongerThanMax($str) |
| 3949 | 3948 | { |
| 3950 | 3949 | //+2 to include CRLF line break for a 1000 total |
| 3951 | - return (boolean)preg_match('/^(.{'.(self::MAX_LINE_LENGTH + 2).',})/m', $str); |
|
| 3950 | + return (boolean)preg_match('/^(.{' . (self::MAX_LINE_LENGTH + 2) . ',})/m', $str); |
|
| 3952 | 3951 | } |
| 3953 | 3952 | |
| 3954 | 3953 | /** |
@@ -616,8 +616,7 @@ discard block |
||
| 616 | 616 | */ |
| 617 | 617 | public function getTriggerTokens() |
| 618 | 618 | { |
| 619 | - return array |
|
| 620 | - ( |
|
| 619 | + return array( |
|
| 621 | 620 | "CssAtFontFaceDeclarationToken", |
| 622 | 621 | "CssAtPageDeclarationToken", |
| 623 | 622 | "CssRulesetDeclarationToken" |
@@ -1378,8 +1377,7 @@ discard block |
||
| 1378 | 1377 | */ |
| 1379 | 1378 | public function __construct($source = null, array $plugins = null) |
| 1380 | 1379 | { |
| 1381 | - $plugins = array_merge(array |
|
| 1382 | - ( |
|
| 1380 | + $plugins = array_merge(array( |
|
| 1383 | 1381 | "Comment" => true, |
| 1384 | 1382 | "String" => true, |
| 1385 | 1383 | "Url" => true, |
@@ -1867,8 +1865,7 @@ discard block |
||
| 1867 | 1865 | */ |
| 1868 | 1866 | public function __construct($source = null, array $filters = null, array $plugins = null) |
| 1869 | 1867 | { |
| 1870 | - $filters = array_merge(array |
|
| 1871 | - ( |
|
| 1868 | + $filters = array_merge(array( |
|
| 1872 | 1869 | "ImportImports" => false, |
| 1873 | 1870 | "RemoveComments" => true, |
| 1874 | 1871 | "RemoveEmptyRulesets" => true, |
@@ -1878,8 +1875,7 @@ discard block |
||
| 1878 | 1875 | "Variables" => true, |
| 1879 | 1876 | "RemoveLastDelarationSemiColon" => true |
| 1880 | 1877 | ), is_array($filters) ? $filters : array()); |
| 1881 | - $plugins = array_merge(array |
|
| 1882 | - ( |
|
| 1878 | + $plugins = array_merge(array( |
|
| 1883 | 1879 | "Variables" => true, |
| 1884 | 1880 | "ConvertFontWeight" => false, |
| 1885 | 1881 | "ConvertHslColors" => false, |
@@ -2563,8 +2559,7 @@ discard block |
||
| 2563 | 2559 | */ |
| 2564 | 2560 | public function getTriggerTokens() |
| 2565 | 2561 | { |
| 2566 | - return array |
|
| 2567 | - ( |
|
| 2562 | + return array( |
|
| 2568 | 2563 | "CssAtFontFaceDeclarationToken", |
| 2569 | 2564 | "CssAtPageDeclarationToken", |
| 2570 | 2565 | "CssRulesetDeclarationToken" |
@@ -2614,8 +2609,7 @@ discard block |
||
| 2614 | 2609 | * |
| 2615 | 2610 | * @var array |
| 2616 | 2611 | */ |
| 2617 | - private $transformation = array |
|
| 2618 | - ( |
|
| 2612 | + private $transformation = array( |
|
| 2619 | 2613 | "aliceblue" => "#f0f8ff", |
| 2620 | 2614 | "antiquewhite" => "#faebd7", |
| 2621 | 2615 | "aqua" => "#0ff", |
@@ -2796,8 +2790,7 @@ discard block |
||
| 2796 | 2790 | */ |
| 2797 | 2791 | public function getTriggerTokens() |
| 2798 | 2792 | { |
| 2799 | - return array |
|
| 2800 | - ( |
|
| 2793 | + return array( |
|
| 2801 | 2794 | "CssAtFontFaceDeclarationToken", |
| 2802 | 2795 | "CssAtPageDeclarationToken", |
| 2803 | 2796 | "CssRulesetDeclarationToken" |
@@ -2824,8 +2817,7 @@ discard block |
||
| 2824 | 2817 | * |
| 2825 | 2818 | * @var array |
| 2826 | 2819 | */ |
| 2827 | - private $transformations = array |
|
| 2828 | - ( |
|
| 2820 | + private $transformations = array( |
|
| 2829 | 2821 | // Property Array(Mozilla, Webkit, Opera, Internet Explorer); NULL values are placeholders and will get ignored |
| 2830 | 2822 | "animation" => array(null, "-webkit-animation", null, null), |
| 2831 | 2823 | "animation-delay" => array(null, "-webkit-animation-delay", null, null), |
@@ -3039,8 +3031,7 @@ discard block |
||
| 3039 | 3031 | */ |
| 3040 | 3032 | private static function filter($token) |
| 3041 | 3033 | { |
| 3042 | - $r = array |
|
| 3043 | - ( |
|
| 3034 | + $r = array( |
|
| 3044 | 3035 | new CssRulesetDeclarationToken("-ms-filter", "\"" . $token->Value . "\"", $token->MediaTypes), |
| 3045 | 3036 | ); |
| 3046 | 3037 | return $r; |
@@ -3056,8 +3047,7 @@ discard block |
||
| 3056 | 3047 | { |
| 3057 | 3048 | // Calculate the value for Internet Explorer filter statement |
| 3058 | 3049 | $ieValue = (int)((float)$token->Value * 100); |
| 3059 | - $r = array |
|
| 3060 | - ( |
|
| 3050 | + $r = array( |
|
| 3061 | 3051 | // Internet Explorer >= 8 |
| 3062 | 3052 | new CssRulesetDeclarationToken("-ms-filter", "\"alpha(opacity=" . $ieValue . ")\"", $token->MediaTypes), |
| 3063 | 3053 | // Internet Explorer >= 4 <= 7 |
@@ -3076,8 +3066,7 @@ discard block |
||
| 3076 | 3066 | private static function whiteSpace($token) |
| 3077 | 3067 | { |
| 3078 | 3068 | if (strtolower($token->Value) === "pre-wrap") { |
| 3079 | - $r = array |
|
| 3080 | - ( |
|
| 3069 | + $r = array( |
|
| 3081 | 3070 | // Firefox < 3 |
| 3082 | 3071 | new CssRulesetDeclarationToken("white-space", "-moz-pre-wrap", $token->MediaTypes), |
| 3083 | 3072 | // Webkit |
@@ -3305,8 +3294,7 @@ discard block |
||
| 3305 | 3294 | */ |
| 3306 | 3295 | public function getTriggerTokens() |
| 3307 | 3296 | { |
| 3308 | - return array |
|
| 3309 | - ( |
|
| 3297 | + return array( |
|
| 3310 | 3298 | "CssAtFontFaceDeclarationToken", |
| 3311 | 3299 | "CssAtPageDeclarationToken", |
| 3312 | 3300 | "CssRulesetDeclarationToken" |
@@ -3344,8 +3332,7 @@ discard block |
||
| 3344 | 3332 | * |
| 3345 | 3333 | * @var array |
| 3346 | 3334 | */ |
| 3347 | - private $include = array |
|
| 3348 | - ( |
|
| 3335 | + private $include = array( |
|
| 3349 | 3336 | "font", |
| 3350 | 3337 | "font-weight" |
| 3351 | 3338 | ); |
@@ -3366,8 +3353,7 @@ discard block |
||
| 3366 | 3353 | * |
| 3367 | 3354 | * @var array |
| 3368 | 3355 | */ |
| 3369 | - private $transformation = array |
|
| 3370 | - ( |
|
| 3356 | + private $transformation = array( |
|
| 3371 | 3357 | "normal" => "400", |
| 3372 | 3358 | "bold" => "700" |
| 3373 | 3359 | ); |
@@ -3408,8 +3394,7 @@ discard block |
||
| 3408 | 3394 | */ |
| 3409 | 3395 | public function getTriggerTokens() |
| 3410 | 3396 | { |
| 3411 | - return array |
|
| 3412 | - ( |
|
| 3397 | + return array( |
|
| 3413 | 3398 | "CssAtFontFaceDeclarationToken", |
| 3414 | 3399 | "CssAtPageDeclarationToken", |
| 3415 | 3400 | "CssRulesetDeclarationToken" |
@@ -3450,8 +3435,7 @@ discard block |
||
| 3450 | 3435 | * |
| 3451 | 3436 | * @var array |
| 3452 | 3437 | */ |
| 3453 | - private $re = array |
|
| 3454 | - ( |
|
| 3438 | + private $re = array( |
|
| 3455 | 3439 | "/(^| |-)0\.([0-9]+?)(0+)?(%|em|ex|px|in|cm|mm|pt|pc)/iS" => "\${1}.\${2}\${4}", |
| 3456 | 3440 | "/(^| )-?(\.?)0(%|em|ex|px|in|cm|mm|pt|pc)/iS" => "\${1}0", |
| 3457 | 3441 | "/(^0\s0\s0\s0)|(^0\s0\s0$)|(^0\s0$)/iS" => "0" |
@@ -3486,8 +3470,7 @@ discard block |
||
| 3486 | 3470 | */ |
| 3487 | 3471 | public function getTriggerTokens() |
| 3488 | 3472 | { |
| 3489 | - return array |
|
| 3490 | - ( |
|
| 3473 | + return array( |
|
| 3491 | 3474 | "CssAtFontFaceDeclarationToken", |
| 3492 | 3475 | "CssAtPageDeclarationToken", |
| 3493 | 3476 | "CssRulesetDeclarationToken" |
@@ -3534,8 +3517,7 @@ discard block |
||
| 3534 | 3517 | */ |
| 3535 | 3518 | public function getTriggerTokens() |
| 3536 | 3519 | { |
| 3537 | - return array |
|
| 3538 | - ( |
|
| 3520 | + return array( |
|
| 3539 | 3521 | "CssAtFontFaceDeclarationToken", |
| 3540 | 3522 | "CssAtPageDeclarationToken", |
| 3541 | 3523 | "CssRulesetDeclarationToken" |
@@ -3597,8 +3579,7 @@ discard block |
||
| 3597 | 3579 | */ |
| 3598 | 3580 | public function getTriggerTokens() |
| 3599 | 3581 | { |
| 3600 | - return array |
|
| 3601 | - ( |
|
| 3582 | + return array( |
|
| 3602 | 3583 | "CssAtFontFaceDeclarationToken", |
| 3603 | 3584 | "CssAtPageDeclarationToken", |
| 3604 | 3585 | "CssRulesetDeclarationToken" |
@@ -157,7 +157,9 @@ |
||
| 157 | 157 | |
| 158 | 158 | if (!$bytes) { |
| 159 | 159 | // Last bits; match final character and exit loop |
| 160 | - if ($rightPadFinalBits) $oldBits <<= $newBitCount; |
|
| 160 | + if ($rightPadFinalBits) { |
|
| 161 | + $oldBits <<= $newBitCount; |
|
| 162 | + } |
|
| 161 | 163 | $encodedString .= $chars[$oldBits]; |
| 162 | 164 | |
| 163 | 165 | if ($padFinalGroup) { |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | $keys = $secret->deriveKeys($salt); |
| 182 | 182 | $ekey = $keys->getEncryptionKey(); |
| 183 | 183 | $akey = $keys->getAuthenticationKey(); |
| 184 | - $iv = Core::secureRandom(Core::BLOCK_BYTE_SIZE); |
|
| 184 | + $iv = Core::secureRandom(Core::BLOCK_BYTE_SIZE); |
|
| 185 | 185 | |
| 186 | 186 | $ciphertext = Core::CURRENT_VERSION . $salt . $iv . self::plainEncrypt($plaintext, $ekey, $iv); |
| 187 | 187 | $auth = \hash_hmac(Core::HASH_FUNCTION_NAME, $ciphertext, $akey, true); |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | { |
| 210 | 210 | RuntimeTests::runtimeTest(); |
| 211 | 211 | |
| 212 | - if (! $raw_binary) { |
|
| 212 | + if (!$raw_binary) { |
|
| 213 | 213 | try { |
| 214 | 214 | $ciphertext = Encoding::hexToBin($ciphertext); |
| 215 | 215 | } catch (Ex\BadFormatException $ex) { |
@@ -312,12 +312,12 @@ discard block |
||
| 312 | 312 | */ |
| 313 | 313 | private static function encryptResourceInternal($inputHandle, $outputHandle, KeyOrPassword $secret) |
| 314 | 314 | { |
| 315 | - if (! \is_resource($inputHandle)) { |
|
| 315 | + if (!\is_resource($inputHandle)) { |
|
| 316 | 316 | throw new Ex\IOException( |
| 317 | 317 | 'Input handle must be a resource!' |
| 318 | 318 | ); |
| 319 | 319 | } |
| 320 | - if (! \is_resource($outputHandle)) { |
|
| 320 | + if (!\is_resource($outputHandle)) { |
|
| 321 | 321 | throw new Ex\IOException( |
| 322 | 322 | 'Output handle must be a resource!' |
| 323 | 323 | ); |
@@ -362,7 +362,7 @@ discard block |
||
| 362 | 362 | |
| 363 | 363 | /* Loop until we reach the end of the input file. */ |
| 364 | 364 | $at_file_end = false; |
| 365 | - while (! (\feof($inputHandle) || $at_file_end)) { |
|
| 365 | + while (!(\feof($inputHandle) || $at_file_end)) { |
|
| 366 | 366 | /* Find out if we can read a full buffer, or only a partial one. */ |
| 367 | 367 | $pos = \ftell($inputHandle); |
| 368 | 368 | if ($pos === false) { |
@@ -429,12 +429,12 @@ discard block |
||
| 429 | 429 | */ |
| 430 | 430 | public static function decryptResourceInternal($inputHandle, $outputHandle, KeyOrPassword $secret) |
| 431 | 431 | { |
| 432 | - if (! \is_resource($inputHandle)) { |
|
| 432 | + if (!\is_resource($inputHandle)) { |
|
| 433 | 433 | throw new Ex\IOException( |
| 434 | 434 | 'Input handle must be a resource!' |
| 435 | 435 | ); |
| 436 | 436 | } |
| 437 | - if (! \is_resource($outputHandle)) { |
|
| 437 | + if (!\is_resource($outputHandle)) { |
|
| 438 | 438 | throw new Ex\IOException( |
| 439 | 439 | 'Output handle must be a resource!' |
| 440 | 440 | ); |
@@ -528,7 +528,7 @@ discard block |
||
| 528 | 528 | $hmac2 = \hash_copy($hmac); |
| 529 | 529 | |
| 530 | 530 | $break = false; |
| 531 | - while (! $break) { |
|
| 531 | + while (!$break) { |
|
| 532 | 532 | $pos = \ftell($inputHandle); |
| 533 | 533 | if ($pos === false) { |
| 534 | 534 | throw new Ex\IOException( |
@@ -560,14 +560,14 @@ discard block |
||
| 560 | 560 | 'Cannot duplicate a hash context' |
| 561 | 561 | ); |
| 562 | 562 | } |
| 563 | - $macs []= \hash_final($chunk_mac); |
|
| 563 | + $macs [] = \hash_final($chunk_mac); |
|
| 564 | 564 | } |
| 565 | 565 | |
| 566 | 566 | /* Get the final HMAC, which should match the stored one. */ |
| 567 | 567 | $final_mac = \hash_final($hmac, true); |
| 568 | 568 | |
| 569 | 569 | /* Verify the HMAC. */ |
| 570 | - if (! Core::hashEquals($final_mac, $stored_mac)) { |
|
| 570 | + if (!Core::hashEquals($final_mac, $stored_mac)) { |
|
| 571 | 571 | throw new Ex\WrongKeyOrModifiedCiphertextException( |
| 572 | 572 | 'Integrity check failed.' |
| 573 | 573 | ); |
@@ -583,7 +583,7 @@ discard block |
||
| 583 | 583 | } |
| 584 | 584 | |
| 585 | 585 | $at_file_end = false; |
| 586 | - while (! $at_file_end) { |
|
| 586 | + while (!$at_file_end) { |
|
| 587 | 587 | $pos = \ftell($inputHandle); |
| 588 | 588 | if ($pos === false) { |
| 589 | 589 | throw new Ex\IOException( |
@@ -594,7 +594,7 @@ discard block |
||
| 594 | 594 | /* Read the next buffer-sized chunk (or less). */ |
| 595 | 595 | if ($pos + Core::BUFFER_BYTE_SIZE >= $cipher_end) { |
| 596 | 596 | $at_file_end = true; |
| 597 | - $read = self::readBytes( |
|
| 597 | + $read = self::readBytes( |
|
| 598 | 598 | $inputHandle, |
| 599 | 599 | $cipher_end - $pos + 1 |
| 600 | 600 | ); |
@@ -621,7 +621,7 @@ discard block |
||
| 621 | 621 | throw new Ex\WrongKeyOrModifiedCiphertextException( |
| 622 | 622 | 'File was modified after MAC verification' |
| 623 | 623 | ); |
| 624 | - } elseif (! Core::hashEquals(\array_shift($macs), $calc)) { |
|
| 624 | + } elseif (!Core::hashEquals(\array_shift($macs), $calc)) { |
|
| 625 | 625 | throw new Ex\WrongKeyOrModifiedCiphertextException( |
| 626 | 626 | 'File was modified after MAC verification' |
| 627 | 627 | ); |
@@ -678,7 +678,7 @@ discard block |
||
| 678 | 678 | } |
| 679 | 679 | $buf = ''; |
| 680 | 680 | $remaining = $num_bytes; |
| 681 | - while ($remaining > 0 && ! \feof($stream)) { |
|
| 681 | + while ($remaining > 0 && !\feof($stream)) { |
|
| 682 | 682 | $read = \fread($stream, $remaining); |
| 683 | 683 | |
| 684 | 684 | if ($read === false) { |
@@ -50,25 +50,25 @@ discard block |
||
| 50 | 50 | { |
| 51 | 51 | if (Core::ourStrlen($ctr) !== Core::BLOCK_BYTE_SIZE) { |
| 52 | 52 | throw new Ex\EnvironmentIsBrokenException( |
| 53 | - 'Trying to increment a nonce of the wrong size.' |
|
| 53 | + 'Trying to increment a nonce of the wrong size.' |
|
| 54 | 54 | ); |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | if (! \is_int($inc)) { |
| 58 | 58 | throw new Ex\EnvironmentIsBrokenException( |
| 59 | - 'Trying to increment nonce by a non-integer.' |
|
| 59 | + 'Trying to increment nonce by a non-integer.' |
|
| 60 | 60 | ); |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | if ($inc < 0) { |
| 64 | 64 | throw new Ex\EnvironmentIsBrokenException( |
| 65 | - 'Trying to increment nonce by a negative amount.' |
|
| 65 | + 'Trying to increment nonce by a negative amount.' |
|
| 66 | 66 | ); |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | if ($inc > PHP_INT_MAX - 255) { |
| 70 | 70 | throw new Ex\EnvironmentIsBrokenException( |
| 71 | - 'Integer overflow may occur.' |
|
| 71 | + 'Integer overflow may occur.' |
|
| 72 | 72 | ); |
| 73 | 73 | } |
| 74 | 74 | |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | /* Detect integer overflow and fail. */ |
| 83 | 83 | if (! \is_int($sum)) { |
| 84 | 84 | throw new Ex\EnvironmentIsBrokenException( |
| 85 | - 'Integer overflow in CTR mode nonce increment.' |
|
| 85 | + 'Integer overflow in CTR mode nonce increment.' |
|
| 86 | 86 | ); |
| 87 | 87 | } |
| 88 | 88 | |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | ); |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - if (! \is_int($inc)) { |
|
| 57 | + if (!\is_int($inc)) { |
|
| 58 | 58 | throw new Ex\EnvironmentIsBrokenException( |
| 59 | 59 | 'Trying to increment nonce by a non-integer.' |
| 60 | 60 | ); |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | $sum = \ord($ctr[$i]) + $inc; |
| 81 | 81 | |
| 82 | 82 | /* Detect integer overflow and fail. */ |
| 83 | - if (! \is_int($sum)) { |
|
| 83 | + if (!\is_int($sum)) { |
|
| 84 | 84 | throw new Ex\EnvironmentIsBrokenException( |
| 85 | 85 | 'Integer overflow in CTR mode nonce increment.' |
| 86 | 86 | ); |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | $digest_length = Core::ourStrlen(\hash_hmac($hash, '', '', true)); |
| 133 | 133 | |
| 134 | 134 | // Sanity-check the desired output length. |
| 135 | - if (empty($length) || ! \is_int($length) || |
|
| 135 | + if (empty($length) || !\is_int($length) || |
|
| 136 | 136 | $length < 0 || $length > 255 * $digest_length) { |
| 137 | 137 | throw new Ex\EnvironmentIsBrokenException( |
| 138 | 138 | 'Bad output length requested of HKDF.' |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | */ |
| 228 | 228 | public static function ensureConstantExists($name) |
| 229 | 229 | { |
| 230 | - if (! \defined($name)) { |
|
| 230 | + if (!\defined($name)) { |
|
| 231 | 231 | throw new Ex\EnvironmentIsBrokenException(); |
| 232 | 232 | } |
| 233 | 233 | } |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | */ |
| 242 | 242 | public static function ensureFunctionExists($name) |
| 243 | 243 | { |
| 244 | - if (! \function_exists($name)) { |
|
| 244 | + if (!\function_exists($name)) { |
|
| 245 | 245 | throw new Ex\EnvironmentIsBrokenException(); |
| 246 | 246 | } |
| 247 | 247 | } |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | if ($exists) { |
| 300 | 300 | // mb_substr($str, 0, NULL, '8bit') returns an empty string on PHP |
| 301 | 301 | // 5.3, so we have to find the length ourselves. |
| 302 | - if (! isset($length)) { |
|
| 302 | + if (!isset($length)) { |
|
| 303 | 303 | if ($start >= 0) { |
| 304 | 304 | $length = Core::ourStrlen($str) - $start; |
| 305 | 305 | } else { |
@@ -358,17 +358,17 @@ discard block |
||
| 358 | 358 | public static function pbkdf2($algorithm, $password, $salt, $count, $key_length, $raw_output = false) |
| 359 | 359 | { |
| 360 | 360 | // Type checks: |
| 361 | - if (! \is_string($algorithm)) { |
|
| 361 | + if (!\is_string($algorithm)) { |
|
| 362 | 362 | throw new \InvalidArgumentException( |
| 363 | 363 | 'pbkdf2(): algorithm must be a string' |
| 364 | 364 | ); |
| 365 | 365 | } |
| 366 | - if (! \is_string($password)) { |
|
| 366 | + if (!\is_string($password)) { |
|
| 367 | 367 | throw new \InvalidArgumentException( |
| 368 | 368 | 'pbkdf2(): password must be a string' |
| 369 | 369 | ); |
| 370 | 370 | } |
| 371 | - if (! \is_string($salt)) { |
|
| 371 | + if (!\is_string($salt)) { |
|
| 372 | 372 | throw new \InvalidArgumentException( |
| 373 | 373 | 'pbkdf2(): salt must be a string' |
| 374 | 374 | ); |
@@ -378,7 +378,7 @@ discard block |
||
| 378 | 378 | $key_length += 0; |
| 379 | 379 | |
| 380 | 380 | $algorithm = \strtolower($algorithm); |
| 381 | - if (! \in_array($algorithm, \hash_algos(), true)) { |
|
| 381 | + if (!\in_array($algorithm, \hash_algos(), true)) { |
|
| 382 | 382 | throw new Ex\EnvironmentIsBrokenException( |
| 383 | 383 | 'Invalid or unsupported hash algorithm.' |
| 384 | 384 | ); |
@@ -389,7 +389,7 @@ discard block |
||
| 389 | 389 | 'sha1', 'sha224', 'sha256', 'sha384', 'sha512', |
| 390 | 390 | 'ripemd160', 'ripemd256', 'ripemd320', 'whirlpool', |
| 391 | 391 | ]; |
| 392 | - if (! \in_array($algorithm, $ok_algorithms, true)) { |
|
| 392 | + if (!\in_array($algorithm, $ok_algorithms, true)) { |
|
| 393 | 393 | throw new Ex\EnvironmentIsBrokenException( |
| 394 | 394 | 'Algorithm is not a secure cryptographic hash function.' |
| 395 | 395 | ); |
@@ -403,7 +403,7 @@ discard block |
||
| 403 | 403 | |
| 404 | 404 | if (\function_exists('hash_pbkdf2')) { |
| 405 | 405 | // The output length is in NIBBLES (4-bits) if $raw_output is false! |
| 406 | - if (! $raw_output) { |
|
| 406 | + if (!$raw_output) { |
|
| 407 | 407 | $key_length = $key_length * 2; |
| 408 | 408 | } |
| 409 | 409 | return \hash_pbkdf2($algorithm, $password, $salt, $count, $key_length, $raw_output); |
@@ -197,7 +197,7 @@ |
||
| 197 | 197 | $checksum_b = \hash(self::CHECKSUM_HASH_ALGO, $checked_bytes, true); |
| 198 | 198 | |
| 199 | 199 | /* Check if the checksum matches. */ |
| 200 | - if (! Core::hashEquals($checksum_a, $checksum_b)) { |
|
| 200 | + if (!Core::hashEquals($checksum_a, $checksum_b)) { |
|
| 201 | 201 | throw new Ex\BadFormatException( |
| 202 | 202 | "Data is corrupted, the checksum doesn't match" |
| 203 | 203 | ); |
@@ -51,9 +51,9 @@ discard block |
||
| 51 | 51 | |
| 52 | 52 | $RandomCompatDIR = dirname(__FILE__); |
| 53 | 53 | |
| 54 | - require_once $RandomCompatDIR.'/byte_safe_strings.php'; |
|
| 55 | - require_once $RandomCompatDIR.'/cast_to_int.php'; |
|
| 56 | - require_once $RandomCompatDIR.'/error_polyfill.php'; |
|
| 54 | + require_once $RandomCompatDIR . '/byte_safe_strings.php'; |
|
| 55 | + require_once $RandomCompatDIR . '/cast_to_int.php'; |
|
| 56 | + require_once $RandomCompatDIR . '/error_polyfill.php'; |
|
| 57 | 57 | |
| 58 | 58 | if (!is_callable('random_bytes')) { |
| 59 | 59 | /** |
@@ -74,9 +74,9 @@ discard block |
||
| 74 | 74 | if (extension_loaded('libsodium')) { |
| 75 | 75 | // See random_bytes_libsodium.php |
| 76 | 76 | if (PHP_VERSION_ID >= 50300 && is_callable('\\Sodium\\randombytes_buf')) { |
| 77 | - require_once $RandomCompatDIR.'/random_bytes_libsodium.php'; |
|
| 77 | + require_once $RandomCompatDIR . '/random_bytes_libsodium.php'; |
|
| 78 | 78 | } elseif (method_exists('Sodium', 'randombytes_buf')) { |
| 79 | - require_once $RandomCompatDIR.'/random_bytes_libsodium_legacy.php'; |
|
| 79 | + require_once $RandomCompatDIR . '/random_bytes_libsodium_legacy.php'; |
|
| 80 | 80 | } |
| 81 | 81 | } |
| 82 | 82 | |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | // place, that is not helpful to us here. |
| 116 | 116 | |
| 117 | 117 | // See random_bytes_dev_urandom.php |
| 118 | - require_once $RandomCompatDIR.'/random_bytes_dev_urandom.php'; |
|
| 118 | + require_once $RandomCompatDIR . '/random_bytes_dev_urandom.php'; |
|
| 119 | 119 | } |
| 120 | 120 | // Unset variables after use |
| 121 | 121 | $RandomCompat_basedir = null; |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | (PHP_VERSION_ID <= 50609 || PHP_VERSION_ID >= 50613) |
| 155 | 155 | ) { |
| 156 | 156 | // See random_bytes_mcrypt.php |
| 157 | - require_once $RandomCompatDIR.'/random_bytes_mcrypt.php'; |
|
| 157 | + require_once $RandomCompatDIR . '/random_bytes_mcrypt.php'; |
|
| 158 | 158 | } |
| 159 | 159 | } |
| 160 | 160 | $RandomCompatUrandom = null; |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | $RandomCompatCOMtest = new COM('CAPICOM.Utilities.1'); |
| 181 | 181 | if (method_exists($RandomCompatCOMtest, 'GetRandom')) { |
| 182 | 182 | // See random_bytes_com_dotnet.php |
| 183 | - require_once $RandomCompatDIR.'/random_bytes_com_dotnet.php'; |
|
| 183 | + require_once $RandomCompatDIR . '/random_bytes_com_dotnet.php'; |
|
| 184 | 184 | } |
| 185 | 185 | } catch (com_exception $e) { |
| 186 | 186 | // Don't try to use it. |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | if (!is_callable('random_int')) { |
| 211 | - require_once $RandomCompatDIR.'/random_int.php'; |
|
| 211 | + require_once $RandomCompatDIR . '/random_int.php'; |
|
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | $RandomCompatDIR = null; |