CS: Fix "PEAR.Files.IncludingFile.UseIncludeOnce" sniff.

This commit is contained in:
Andreas Fischer 2013-12-06 01:03:34 +01:00
parent 52e85604e5
commit 6d1fb9f7db
18 changed files with 64 additions and 65 deletions

View File

@ -65,7 +65,7 @@
* Include Crypt_Rijndael
*/
if (!class_exists('Crypt_Rijndael')) {
require_once 'Rijndael.php';
include_once 'Rijndael.php';
}
/**#@+

View File

@ -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';
include_once 'Crypt/Hash.php';
}
$i = 1;
while (strlen($key) < $dkLen) {

View File

@ -60,7 +60,7 @@
* Base cipher class
*/
if (!class_exists('Crypt_Base')) {
require_once 'Base.php';
include_once 'Base.php';
}
/**#@+

View File

@ -64,7 +64,7 @@
* Base cipher class
*/
if (!class_exists('Crypt_Base')) {
require_once 'Base.php';
include_once 'Base.php';
}
/**#@+

View File

@ -581,7 +581,7 @@ class Crypt_Hash
function _sha512($m)
{
if (!class_exists('Math_BigInteger')) {
require_once 'Math/BigInteger.php';
include_once 'Math/BigInteger.php';
}
static $init384, $init512, $k;

View File

@ -57,7 +57,7 @@
* Base cipher class
*/
if (!class_exists('Crypt_Base')) {
require_once 'Base.php';
include_once 'Base.php';
}
/**#@+

View File

@ -66,7 +66,7 @@
* Base cipher class
*/
if (!class_exists('Crypt_Base')) {
require_once 'Base.php';
include_once 'Base.php';
}
/**#@+

View File

@ -72,17 +72,17 @@
*/
// the class_exists() will only be called if the crypt_random_string function hasn't been defined and
// will trigger a call to __autoload() if you're wanting to auto-load classes
// call function_exists() a second time to stop the require_once from being called outside
// call function_exists() a second time to stop the include_once from being called outside
// of the auto loader
if (!function_exists('crypt_random_string')) {
require_once 'Random.php';
include_once 'Random.php';
}
/**
* Include Crypt_Hash
*/
if (!class_exists('Crypt_Hash')) {
require_once 'Hash.php';
include_once 'Hash.php';
}
/**#@+
@ -461,7 +461,7 @@ class Crypt_RSA
function Crypt_RSA()
{
if (!class_exists('Math_BigInteger')) {
require_once 'Math/BigInteger.php';
include_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';
include_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';
include_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';
include_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';
include_once 'Crypt/AES.php';
}
$crypto = new Crypt_AES();
break;
case 'AES-128-CBC':
if (!class_exists('Crypt_AES')) {
require_once 'Crypt/AES.php';
include_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';
include_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';
include_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';
include_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';
include_once 'Crypt/AES.php';
}
$symkey = '';
$sequence = 0;

View File

@ -76,7 +76,7 @@
* Base cipher class
*/
if (!class_exists('Crypt_Base')) {
require_once 'Base.php';
include_once 'Base.php';
}
/**#@+

View File

@ -56,7 +56,7 @@
* Include Crypt_DES
*/
if (!class_exists('Crypt_DES')) {
require_once 'DES.php';
include_once 'DES.php';
}
/**

View File

@ -60,7 +60,7 @@
* Base cipher class
*/
if (!class_exists('Crypt_Base')) {
require_once 'Base.php';
include_once 'Base.php';
}
/**#@+

View File

@ -253,7 +253,7 @@ class File_ASN1
if (!$static_init) {
$static_init = true;
if (!class_exists('Math_BigInteger')) {
require_once 'Math/BigInteger.php';
include_once 'Math/BigInteger.php';
}
}
}

View File

@ -46,7 +46,7 @@
* Include File_ASN1
*/
if (!class_exists('File_ASN1')) {
require_once 'ASN1.php';
include_once 'ASN1.php';
}
/**
@ -307,7 +307,7 @@ class File_X509
function File_X509()
{
if (!class_exists('Math_BigInteger')) {
require_once 'Math/BigInteger.php';
include_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';
include_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';
include_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';
include_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';
include_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';
include_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';
include_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';
include_once 'Crypt/Hash.php';
}
$hash = new Crypt_Hash('sha1');
$hash = $hash->hash($key);

View File

@ -57,7 +57,7 @@
* Include Net_SSH2
*/
if (!class_exists('Net_SSH2')) {
require_once 'SSH2.php';
include_once 'SSH2.php';
}
/**#@+

View File

@ -139,7 +139,7 @@ class Net_SFTP_Stream
}
if (!class_exists('Net_SFTP')) {
require_once 'Net/SFTP.php';
include_once 'Net/SFTP.php';
}
}

View File

@ -449,16 +449,16 @@ 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';
include_once 'Math/BigInteger.php';
}
// Include Crypt_Random
// the class_exists() will only be called if the crypt_random_string function hasn't been defined and
// will trigger a call to __autoload() if you're wanting to auto-load classes
// call function_exists() a second time to stop the require_once from being called outside
// call function_exists() a second time to stop the include_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';
include_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';
include_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';
include_once 'Crypt/TripleDES.php';
}
$this->crypto = new Crypt_TripleDES(CRYPT_DES_MODE_3CBC);
$this->crypto->disablePadding();
@ -621,7 +621,7 @@ class Net_SSH1
break;
//case NET_SSH1_CIPHER_RC4:
// if (!class_exists('Crypt_RC4')) {
// require_once('Crypt/RC4.php');
// include_once('Crypt/RC4.php');
// }
// $this->crypto = new Crypt_RC4();
// $this->crypto->enableContinuousBuffer();
@ -1253,7 +1253,7 @@ class Net_SSH1
{
/*
if (!class_exists('Crypt_RSA')) {
require_once 'Crypt/RSA.php';
include_once 'Crypt/RSA.php';
}
$rsa = new Crypt_RSA();

View File

@ -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';
include_once 'Math/BigInteger.php';
}
if (!function_exists('crypt_random_string')) {
require_once 'Crypt/Random.php';
include_once 'Crypt/Random.php';
}
if (!class_exists('Crypt_Hash')) {
require_once 'Crypt/Hash.php';
include_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';
include_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';
include_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';
include_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';
include_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';
include_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';
include_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';
include_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';
include_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';
include_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';
include_once 'Crypt/TripleDES.php';
}
$this->decrypt = new Crypt_TripleDES();
break;
case '3des-ctr':
if (!class_exists('Crypt_TripleDES')) {
require_once 'Crypt/TripleDES.php';
include_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';
include_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';
include_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';
include_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';
include_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';
include_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';
include_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';
include_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';
include_once 'Crypt/RSA.php';
}
$rsa = new Crypt_RSA();

View File

@ -29,7 +29,6 @@
<rule ref="PEAR.Commenting.FunctionComment.SpacingAfterParams"><severity>0</severity></rule>
<rule ref="PEAR.Commenting.FunctionComment.SpacingBeforeParams"><severity>0</severity></rule>
<rule ref="PEAR.Commenting.FunctionComment.SpacingBeforeTags"><severity>0</severity></rule>
<rule ref="PEAR.Files.IncludingFile.UseIncludeOnce"><severity>0</severity></rule>
<rule ref="PEAR.Formatting.MultiLineAssignment.EqualSignLine"><severity>0</severity></rule>
<rule ref="PEAR.Functions.FunctionCallSignature.ContentAfterOpenBracket"><severity>0</severity></rule>
<rule ref="PEAR.Functions.FunctionCallSignature.CloseBracketLine"><severity>0</severity></rule>