From bc6ff962927e09c4cec160fd0a1830d7eb4e5b88 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Thu, 5 Dec 2013 23:17:40 +0100 Subject: [PATCH] Fix "PEAR.Files.IncludingFile.BracketsNotRequired" sniff. --- phpseclib/Crypt/AES.php | 2 +- phpseclib/Crypt/Base.php | 2 +- phpseclib/Crypt/Blowfish.php | 2 +- phpseclib/Crypt/DES.php | 2 +- phpseclib/Crypt/Hash.php | 2 +- phpseclib/Crypt/RC2.php | 2 +- phpseclib/Crypt/RC4.php | 2 +- phpseclib/Crypt/RSA.php | 24 +++++++++---------- phpseclib/Crypt/Rijndael.php | 2 +- phpseclib/Crypt/TripleDES.php | 2 +- phpseclib/Crypt/Twofish.php | 2 +- phpseclib/File/ASN1.php | 2 +- phpseclib/File/X509.php | 18 +++++++------- phpseclib/Net/SFTP.php | 2 +- phpseclib/Net/SFTP/Stream.php | 2 +- phpseclib/Net/SSH1.php | 10 ++++---- phpseclib/Net/SSH2.php | 44 +++++++++++++++++----------------- tests/code_sniffer_ruleset.xml | 1 - 18 files changed, 61 insertions(+), 62 deletions(-) diff --git a/phpseclib/Crypt/AES.php b/phpseclib/Crypt/AES.php index 7313e640..7fbff79d 100644 --- a/phpseclib/Crypt/AES.php +++ b/phpseclib/Crypt/AES.php @@ -65,7 +65,7 @@ * Include Crypt_Rijndael */ if (!class_exists('Crypt_Rijndael')) { - require_once('Rijndael.php'); + require_once 'Rijndael.php'; } /**#@+ diff --git a/phpseclib/Crypt/Base.php b/phpseclib/Crypt/Base.php index 6c7136cc..2c9002a0 100644 --- a/phpseclib/Crypt/Base.php +++ b/phpseclib/Crypt/Base.php @@ -582,7 +582,7 @@ class Crypt_Base case !function_exists('hash_algos'): case !in_array($hash, hash_algos()): if (!class_exists('Crypt_Hash')) { - require_once('Crypt/Hash.php'); + require_once 'Crypt/Hash.php'; } $i = 1; while (strlen($key) < $dkLen) { diff --git a/phpseclib/Crypt/Blowfish.php b/phpseclib/Crypt/Blowfish.php index 8fedee0e..40389980 100644 --- a/phpseclib/Crypt/Blowfish.php +++ b/phpseclib/Crypt/Blowfish.php @@ -60,7 +60,7 @@ * Base cipher class */ if (!class_exists('Crypt_Base')) { - require_once('Base.php'); + require_once 'Base.php'; } /**#@+ diff --git a/phpseclib/Crypt/DES.php b/phpseclib/Crypt/DES.php index d8d15893..167a4128 100644 --- a/phpseclib/Crypt/DES.php +++ b/phpseclib/Crypt/DES.php @@ -64,7 +64,7 @@ * Base cipher class */ if (!class_exists('Crypt_Base')) { - require_once('Base.php'); + require_once 'Base.php'; } /**#@+ diff --git a/phpseclib/Crypt/Hash.php b/phpseclib/Crypt/Hash.php index 4abae510..a2ba4b11 100644 --- a/phpseclib/Crypt/Hash.php +++ b/phpseclib/Crypt/Hash.php @@ -581,7 +581,7 @@ class Crypt_Hash function _sha512($m) { if (!class_exists('Math_BigInteger')) { - require_once('Math/BigInteger.php'); + require_once 'Math/BigInteger.php'; } static $init384, $init512, $k; diff --git a/phpseclib/Crypt/RC2.php b/phpseclib/Crypt/RC2.php index 872d96cc..629f80d3 100755 --- a/phpseclib/Crypt/RC2.php +++ b/phpseclib/Crypt/RC2.php @@ -57,7 +57,7 @@ * Base cipher class */ if (!class_exists('Crypt_Base')) { - require_once('Base.php'); + require_once 'Base.php'; } /**#@+ diff --git a/phpseclib/Crypt/RC4.php b/phpseclib/Crypt/RC4.php index 38e778cf..75919717 100644 --- a/phpseclib/Crypt/RC4.php +++ b/phpseclib/Crypt/RC4.php @@ -66,7 +66,7 @@ * Base cipher class */ if (!class_exists('Crypt_Base')) { - require_once('Base.php'); + require_once 'Base.php'; } /**#@+ diff --git a/phpseclib/Crypt/RSA.php b/phpseclib/Crypt/RSA.php index 0ae214d2..2df9c431 100644 --- a/phpseclib/Crypt/RSA.php +++ b/phpseclib/Crypt/RSA.php @@ -75,14 +75,14 @@ // call function_exists() a second time to stop the require_once from being called outside // of the auto loader if (!function_exists('crypt_random_string')) { - require_once('Random.php'); + require_once 'Random.php'; } /** * Include Crypt_Hash */ if (!class_exists('Crypt_Hash')) { - require_once('Hash.php'); + require_once 'Hash.php'; } /**#@+ @@ -461,7 +461,7 @@ class Crypt_RSA function Crypt_RSA() { if (!class_exists('Math_BigInteger')) { - require_once('Math/BigInteger.php'); + require_once 'Math/BigInteger.php'; } $this->configFile = CRYPT_RSA_OPENSSL_CONFIG; @@ -773,7 +773,7 @@ class Crypt_RSA $private.= crypt_random_string(16 - (strlen($private) & 15)); $source.= pack('Na*', strlen($private), $private); if (!class_exists('Crypt_AES')) { - require_once('Crypt/AES.php'); + require_once 'Crypt/AES.php'; } $sequence = 0; $symkey = ''; @@ -794,7 +794,7 @@ class Crypt_RSA $key.= 'Private-Lines: ' . ((strlen($private) + 63) >> 6) . "\r\n"; $key.= chunk_split($private, 64); if (!class_exists('Crypt_Hash')) { - require_once('Crypt/Hash.php'); + require_once 'Crypt/Hash.php'; } $hash = new Crypt_Hash('sha1'); $hash->setKey(pack('H*', sha1($hashkey))); @@ -834,7 +834,7 @@ class Crypt_RSA $symkey = pack('H*', md5($this->password . $iv)); // symkey is short for symmetric key $symkey.= substr(pack('H*', md5($symkey . $this->password . $iv)), 0, 8); if (!class_exists('Crypt_TripleDES')) { - require_once('Crypt/TripleDES.php'); + require_once 'Crypt/TripleDES.php'; } $des = new Crypt_TripleDES(); $des->setKey($symkey); @@ -1000,33 +1000,33 @@ class Crypt_RSA switch ($matches[1]) { case 'AES-256-CBC': if (!class_exists('Crypt_AES')) { - require_once('Crypt/AES.php'); + require_once 'Crypt/AES.php'; } $crypto = new Crypt_AES(); break; case 'AES-128-CBC': if (!class_exists('Crypt_AES')) { - require_once('Crypt/AES.php'); + require_once 'Crypt/AES.php'; } $symkey = substr($symkey, 0, 16); $crypto = new Crypt_AES(); break; case 'DES-EDE3-CFB': if (!class_exists('Crypt_TripleDES')) { - require_once('Crypt/TripleDES.php'); + require_once 'Crypt/TripleDES.php'; } $crypto = new Crypt_TripleDES(CRYPT_DES_MODE_CFB); break; case 'DES-EDE3-CBC': if (!class_exists('Crypt_TripleDES')) { - require_once('Crypt/TripleDES.php'); + require_once 'Crypt/TripleDES.php'; } $symkey = substr($symkey, 0, 24); $crypto = new Crypt_TripleDES(); break; case 'DES-CBC': if (!class_exists('Crypt_DES')) { - require_once('Crypt/DES.php'); + require_once 'Crypt/DES.php'; } $crypto = new Crypt_DES(); break; @@ -1240,7 +1240,7 @@ class Crypt_RSA switch ($encryption) { case 'aes256-cbc': if (!class_exists('Crypt_AES')) { - require_once('Crypt/AES.php'); + require_once 'Crypt/AES.php'; } $symkey = ''; $sequence = 0; diff --git a/phpseclib/Crypt/Rijndael.php b/phpseclib/Crypt/Rijndael.php index 9e77f056..884fa8a2 100644 --- a/phpseclib/Crypt/Rijndael.php +++ b/phpseclib/Crypt/Rijndael.php @@ -76,7 +76,7 @@ * Base cipher class */ if (!class_exists('Crypt_Base')) { - require_once('Base.php'); + require_once 'Base.php'; } /**#@+ diff --git a/phpseclib/Crypt/TripleDES.php b/phpseclib/Crypt/TripleDES.php index 8eb69005..84c10e16 100644 --- a/phpseclib/Crypt/TripleDES.php +++ b/phpseclib/Crypt/TripleDES.php @@ -56,7 +56,7 @@ * Include Crypt_DES */ if (!class_exists('Crypt_DES')) { - require_once('DES.php'); + require_once 'DES.php'; } /** diff --git a/phpseclib/Crypt/Twofish.php b/phpseclib/Crypt/Twofish.php index 6c0cb181..68d5c0d9 100644 --- a/phpseclib/Crypt/Twofish.php +++ b/phpseclib/Crypt/Twofish.php @@ -60,7 +60,7 @@ * Base cipher class */ if (!class_exists('Crypt_Base')) { - require_once('Base.php'); + require_once 'Base.php'; } /**#@+ diff --git a/phpseclib/File/ASN1.php b/phpseclib/File/ASN1.php index 3750f9f1..bce5c80e 100644 --- a/phpseclib/File/ASN1.php +++ b/phpseclib/File/ASN1.php @@ -253,7 +253,7 @@ class File_ASN1 if (!$static_init) { $static_init = true; if (!class_exists('Math_BigInteger')) { - require_once('Math/BigInteger.php'); + require_once 'Math/BigInteger.php'; } } } diff --git a/phpseclib/File/X509.php b/phpseclib/File/X509.php index d6fe7906..e392839e 100644 --- a/phpseclib/File/X509.php +++ b/phpseclib/File/X509.php @@ -46,7 +46,7 @@ * Include File_ASN1 */ if (!class_exists('File_ASN1')) { - require_once('ASN1.php'); + require_once 'ASN1.php'; } /** @@ -307,7 +307,7 @@ class File_X509 function File_X509() { if (!class_exists('Math_BigInteger')) { - require_once('Math/BigInteger.php'); + require_once 'Math/BigInteger.php'; } // Explicitly Tagged Module, 1988 Syntax @@ -2121,7 +2121,7 @@ class File_X509 switch ($publicKeyAlgorithm) { case 'rsaEncryption': if (!class_exists('Crypt_RSA')) { - require_once('Crypt/RSA.php'); + require_once 'Crypt/RSA.php'; } $rsa = new Crypt_RSA(); $rsa->loadKey($publicKey); @@ -2523,7 +2523,7 @@ class File_X509 case FILE_X509_DN_HASH: $dn = $this->getDN(FILE_X509_DN_CANON, $dn); if (!class_exists('Crypt_Hash')) { - require_once('Crypt/Hash.php'); + require_once 'Crypt/Hash.php'; } $hash = new Crypt_Hash('sha1'); $hash = $hash->hash($dn); @@ -2791,7 +2791,7 @@ class File_X509 switch ($keyinfo['algorithm']['algorithm']) { case 'rsaEncryption': if (!class_exists('Crypt_RSA')) { - require_once('Crypt/RSA.php'); + require_once 'Crypt/RSA.php'; } $publicKey = new Crypt_RSA(); $publicKey->loadKey($key); @@ -2864,7 +2864,7 @@ class File_X509 switch ($algorithm) { case 'rsaEncryption': if (!class_exists('Crypt_RSA')) { - require_once('Crypt/RSA.php'); + require_once 'Crypt/RSA.php'; } $this->publicKey = new Crypt_RSA(); $this->publicKey->loadKey($key); @@ -2989,7 +2989,7 @@ class File_X509 switch ($algorithm) { case 'rsaEncryption': if (!class_exists('Crypt_RSA')) { - require_once('Crypt/RSA.php'); + require_once 'Crypt/RSA.php'; } $this->publicKey = new Crypt_RSA(); $this->publicKey->loadKey($key); @@ -4061,7 +4061,7 @@ class File_X509 $raw = base64_decode($raw); // If the key is private, compute identifier from its corresponding public key. if (!class_exists('Crypt_RSA')) { - require_once('Crypt/RSA.php'); + require_once 'Crypt/RSA.php'; } $key = new Crypt_RSA(); if (!$key->loadKey($raw)) { @@ -4093,7 +4093,7 @@ class File_X509 // Now we have the key string: compute its sha-1 sum. if (!class_exists('Crypt_Hash')) { - require_once('Crypt/Hash.php'); + require_once 'Crypt/Hash.php'; } $hash = new Crypt_Hash('sha1'); $hash = $hash->hash($key); diff --git a/phpseclib/Net/SFTP.php b/phpseclib/Net/SFTP.php index 86b71650..9dfb35ee 100644 --- a/phpseclib/Net/SFTP.php +++ b/phpseclib/Net/SFTP.php @@ -57,7 +57,7 @@ * Include Net_SSH2 */ if (!class_exists('Net_SSH2')) { - require_once('SSH2.php'); + require_once 'SSH2.php'; } /**#@+ diff --git a/phpseclib/Net/SFTP/Stream.php b/phpseclib/Net/SFTP/Stream.php index 1bc8c6cc..14ce6286 100644 --- a/phpseclib/Net/SFTP/Stream.php +++ b/phpseclib/Net/SFTP/Stream.php @@ -139,7 +139,7 @@ class Net_SFTP_Stream } if (!class_exists('Net_SFTP')) { - require_once('Net/SFTP.php'); + require_once 'Net/SFTP.php'; } } diff --git a/phpseclib/Net/SSH1.php b/phpseclib/Net/SSH1.php index 4098b3fa..682b4455 100644 --- a/phpseclib/Net/SSH1.php +++ b/phpseclib/Net/SSH1.php @@ -449,7 +449,7 @@ class Net_SSH1 function Net_SSH1($host, $port = 22, $timeout = 10, $cipher = NET_SSH1_CIPHER_3DES) { if (!class_exists('Math_BigInteger')) { - require_once('Math/BigInteger.php'); + require_once 'Math/BigInteger.php'; } // Include Crypt_Random @@ -458,7 +458,7 @@ class Net_SSH1 // call function_exists() a second time to stop the require_once from being called outside // of the auto loader if (!function_exists('crypt_random_string') && !class_exists('Crypt_Random') && !function_exists('crypt_random_string')) { - require_once('Crypt/Random.php'); + require_once 'Crypt/Random.php'; } $this->protocol_flags = array( @@ -603,7 +603,7 @@ class Net_SSH1 // break; case NET_SSH1_CIPHER_DES: if (!class_exists('Crypt_DES')) { - require_once('Crypt/DES.php'); + require_once 'Crypt/DES.php'; } $this->crypto = new Crypt_DES(); $this->crypto->disablePadding(); @@ -612,7 +612,7 @@ class Net_SSH1 break; case NET_SSH1_CIPHER_3DES: if (!class_exists('Crypt_TripleDES')) { - require_once('Crypt/TripleDES.php'); + require_once 'Crypt/TripleDES.php'; } $this->crypto = new Crypt_TripleDES(CRYPT_DES_MODE_3CBC); $this->crypto->disablePadding(); @@ -1253,7 +1253,7 @@ class Net_SSH1 { /* if (!class_exists('Crypt_RSA')) { - require_once('Crypt/RSA.php'); + require_once 'Crypt/RSA.php'; } $rsa = new Crypt_RSA(); diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index c0c2def4..4204ffe8 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -763,15 +763,15 @@ class Net_SSH2 // Include Math_BigInteger // Used to do Diffie-Hellman key exchange and DSA/RSA signature verification. if (!class_exists('Math_BigInteger')) { - require_once('Math/BigInteger.php'); + require_once 'Math/BigInteger.php'; } if (!function_exists('crypt_random_string')) { - require_once('Crypt/Random.php'); + require_once 'Crypt/Random.php'; } if (!class_exists('Crypt_Hash')) { - require_once('Crypt/Hash.php'); + require_once 'Crypt/Hash.php'; } $this->last_packet = strtok(microtime(), ' ') + strtok(''); // == microtime(true) in PHP5 @@ -1353,14 +1353,14 @@ class Net_SSH2 switch ($encrypt) { case '3des-cbc': if (!class_exists('Crypt_TripleDES')) { - require_once('Crypt/TripleDES.php'); + require_once 'Crypt/TripleDES.php'; } $this->encrypt = new Crypt_TripleDES(); // $this->encrypt_block_size = 64 / 8 == the default break; case '3des-ctr': if (!class_exists('Crypt_TripleDES')) { - require_once('Crypt/TripleDES.php'); + require_once 'Crypt/TripleDES.php'; } $this->encrypt = new Crypt_TripleDES(CRYPT_DES_MODE_CTR); // $this->encrypt_block_size = 64 / 8 == the default @@ -1369,7 +1369,7 @@ class Net_SSH2 case 'aes192-cbc': case 'aes128-cbc': if (!class_exists('Crypt_Rijndael')) { - require_once('Crypt/Rijndael.php'); + require_once 'Crypt/Rijndael.php'; } $this->encrypt = new Crypt_Rijndael(); $this->encrypt_block_size = 16; // eg. 128 / 8 @@ -1378,21 +1378,21 @@ class Net_SSH2 case 'aes192-ctr': case 'aes128-ctr': if (!class_exists('Crypt_Rijndael')) { - require_once('Crypt/Rijndael.php'); + require_once 'Crypt/Rijndael.php'; } $this->encrypt = new Crypt_Rijndael(CRYPT_RIJNDAEL_MODE_CTR); $this->encrypt_block_size = 16; // eg. 128 / 8 break; case 'blowfish-cbc': if (!class_exists('Crypt_Blowfish')) { - require_once('Crypt/Blowfish.php'); + require_once 'Crypt/Blowfish.php'; } $this->encrypt = new Crypt_Blowfish(); $this->encrypt_block_size = 8; break; case 'blowfish-ctr': if (!class_exists('Crypt_Blowfish')) { - require_once('Crypt/Blowfish.php'); + require_once 'Crypt/Blowfish.php'; } $this->encrypt = new Crypt_Blowfish(CRYPT_BLOWFISH_MODE_CTR); $this->encrypt_block_size = 8; @@ -1402,7 +1402,7 @@ class Net_SSH2 case 'twofish256-cbc': case 'twofish-cbc': if (!class_exists('Crypt_Twofish')) { - require_once('Crypt/Twofish.php'); + require_once 'Crypt/Twofish.php'; } $this->encrypt = new Crypt_Twofish(); $this->encrypt_block_size = 16; @@ -1411,7 +1411,7 @@ class Net_SSH2 case 'twofish192-ctr': case 'twofish256-ctr': if (!class_exists('Crypt_Twofish')) { - require_once('Crypt/Twofish.php'); + require_once 'Crypt/Twofish.php'; } $this->encrypt = new Crypt_Twofish(CRYPT_TWOFISH_MODE_CTR); $this->encrypt_block_size = 16; @@ -1420,7 +1420,7 @@ class Net_SSH2 case 'arcfour128': case 'arcfour256': if (!class_exists('Crypt_RC4')) { - require_once('Crypt/RC4.php'); + require_once 'Crypt/RC4.php'; } $this->encrypt = new Crypt_RC4(); break; @@ -1431,13 +1431,13 @@ class Net_SSH2 switch ($decrypt) { case '3des-cbc': if (!class_exists('Crypt_TripleDES')) { - require_once('Crypt/TripleDES.php'); + require_once 'Crypt/TripleDES.php'; } $this->decrypt = new Crypt_TripleDES(); break; case '3des-ctr': if (!class_exists('Crypt_TripleDES')) { - require_once('Crypt/TripleDES.php'); + require_once 'Crypt/TripleDES.php'; } $this->decrypt = new Crypt_TripleDES(CRYPT_DES_MODE_CTR); break; @@ -1445,7 +1445,7 @@ class Net_SSH2 case 'aes192-cbc': case 'aes128-cbc': if (!class_exists('Crypt_Rijndael')) { - require_once('Crypt/Rijndael.php'); + require_once 'Crypt/Rijndael.php'; } $this->decrypt = new Crypt_Rijndael(); $this->decrypt_block_size = 16; @@ -1454,21 +1454,21 @@ class Net_SSH2 case 'aes192-ctr': case 'aes128-ctr': if (!class_exists('Crypt_Rijndael')) { - require_once('Crypt/Rijndael.php'); + require_once 'Crypt/Rijndael.php'; } $this->decrypt = new Crypt_Rijndael(CRYPT_RIJNDAEL_MODE_CTR); $this->decrypt_block_size = 16; break; case 'blowfish-cbc': if (!class_exists('Crypt_Blowfish')) { - require_once('Crypt/Blowfish.php'); + require_once 'Crypt/Blowfish.php'; } $this->decrypt = new Crypt_Blowfish(); $this->decrypt_block_size = 8; break; case 'blowfish-ctr': if (!class_exists('Crypt_Blowfish')) { - require_once('Crypt/Blowfish.php'); + require_once 'Crypt/Blowfish.php'; } $this->decrypt = new Crypt_Blowfish(CRYPT_BLOWFISH_MODE_CTR); $this->decrypt_block_size = 8; @@ -1478,7 +1478,7 @@ class Net_SSH2 case 'twofish256-cbc': case 'twofish-cbc': if (!class_exists('Crypt_Twofish')) { - require_once('Crypt/Twofish.php'); + require_once 'Crypt/Twofish.php'; } $this->decrypt = new Crypt_Twofish(); $this->decrypt_block_size = 16; @@ -1487,7 +1487,7 @@ class Net_SSH2 case 'twofish192-ctr': case 'twofish256-ctr': if (!class_exists('Crypt_Twofish')) { - require_once('Crypt/Twofish.php'); + require_once 'Crypt/Twofish.php'; } $this->decrypt = new Crypt_Twofish(CRYPT_TWOFISH_MODE_CTR); $this->decrypt_block_size = 16; @@ -1496,7 +1496,7 @@ class Net_SSH2 case 'arcfour128': case 'arcfour256': if (!class_exists('Crypt_RC4')) { - require_once('Crypt/RC4.php'); + require_once 'Crypt/RC4.php'; } $this->decrypt = new Crypt_RC4(); break; @@ -3503,7 +3503,7 @@ class Net_SSH2 $signature = $this->_string_shift($signature, $temp['length']); if (!class_exists('Crypt_RSA')) { - require_once('Crypt/RSA.php'); + require_once 'Crypt/RSA.php'; } $rsa = new Crypt_RSA(); diff --git a/tests/code_sniffer_ruleset.xml b/tests/code_sniffer_ruleset.xml index 1838e1b5..047b3229 100644 --- a/tests/code_sniffer_ruleset.xml +++ b/tests/code_sniffer_ruleset.xml @@ -29,7 +29,6 @@ 0 0 0 - 0 0 0 0