From b5837a8f778b0d9615bed59f4897e21d70be8f97 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Sun, 19 Jul 2009 22:58:12 -0600 Subject: [PATCH] Fixes found through lint checking --- framework/Browser/lib/Horde/Browser.php | 2 +- framework/Cache/lib/Horde/Cache.php | 2 +- .../Cipher/lib/Horde/Cipher/BlockMode/Cfb64.php | 4 +-- framework/Compress/lib/Horde/Compress/Rar.php | 3 +- framework/Compress/lib/Horde/Compress/Tar.php | 5 ++-- framework/Compress/lib/Horde/Compress/Tnef.php | 2 +- framework/Compress/lib/Horde/Compress/Zip.php | 34 ++++++++++++---------- framework/Core/lib/Horde.php | 4 +-- framework/Core/lib/Horde/Config.php | 2 +- framework/Core/lib/Horde/Menu.php | 4 +-- framework/Crypt/lib/Horde/Crypt.php | 2 +- framework/Crypt/lib/Horde/Crypt/Pgp.php | 12 ++++---- framework/Crypt/lib/Horde/Crypt/Smime.php | 21 +++++++------ framework/Editor/lib/Horde/Editor.php | 2 +- .../Imap_Client/lib/Horde/Imap/Client/Cclient.php | 2 +- .../lib/Horde/Imap/Client/Cclient/Pop3.php | 2 +- .../Imap_Client/lib/Horde/Imap/Client/Socket.php | 6 ++-- .../lib/Horde/Imap/Client/Socket/Pop3.php | 8 ++--- framework/Mime/lib/Horde/Mime/Address.php | 4 +-- framework/Mime/lib/Horde/Mime/Exception.php | 4 ++- framework/Mime/lib/Horde/Mime/Headers.php | 8 ++--- framework/Mime/lib/Horde/Mime/Magic.php | 2 +- framework/Mime/lib/Horde/Mime/Mail.php | 4 +-- framework/Mime/lib/Horde/Mime/Mdn.php | 2 +- framework/Mime/lib/Horde/Mime/Part.php | 30 +++++++++---------- framework/Mime/lib/Horde/Mime/Viewer/Default.php | 4 ++- framework/Mime/lib/Horde/Mime/Viewer/Driver.php | 10 +++---- framework/Mime/lib/Horde/Mime/Viewer/Enscript.php | 8 ++--- framework/Mime/lib/Horde/Mime/Viewer/Html.php | 2 +- framework/Mime/lib/Horde/Mime/Viewer/Php.php | 2 +- framework/Mime/lib/Horde/Mime/Viewer/Rar.php | 4 +-- .../Mime/lib/Horde/Mime/Viewer/Srchighlite.php | 4 +-- framework/Mime/lib/Horde/Mime/Viewer/Tgz.php | 4 +-- framework/Mime/lib/Horde/Mime/Viewer/Zip.php | 8 ++--- framework/Util/lib/Horde/Util.php | 32 +++++++++++++------- framework/Util/lib/Horde/Variables.php | 7 +++-- 36 files changed, 138 insertions(+), 118 deletions(-) diff --git a/framework/Browser/lib/Horde/Browser.php b/framework/Browser/lib/Horde/Browser.php index 022b0e899..ad6900bb3 100644 --- a/framework/Browser/lib/Horde/Browser.php +++ b/framework/Browser/lib/Horde/Browser.php @@ -556,7 +556,7 @@ class Horde_Browser list($this->_majorVersion, $this->_minorVersion) = explode('.', $version_string[1], 2); $this->_minorVersion = intval($this->_minorVersion); $this->setFeature('rte'); - } elseif ($this->_majorVersion >= 412) { + } elseif ($this->_majorVersion >= 412) { $this->_majorVersion = 2; $this->_minorVersion = 0; } else { diff --git a/framework/Cache/lib/Horde/Cache.php b/framework/Cache/lib/Horde/Cache.php index bcf2804e5..12b09e2d8 100644 --- a/framework/Cache/lib/Horde/Cache.php +++ b/framework/Cache/lib/Horde/Cache.php @@ -84,7 +84,7 @@ class Horde_Cache $signature = hash('md5', serialize(array($driver, $params))); if (!isset(self::$_instances[$signature])) { - self::$_instances[$signature] = Horde_Cache::factory($driver, $params); + self::$_instances[$signature] = self::factory($driver, $params); } return self::$_instances[$signature]; diff --git a/framework/Cipher/lib/Horde/Cipher/BlockMode/Cfb64.php b/framework/Cipher/lib/Horde/Cipher/BlockMode/Cfb64.php index 96a7fe729..8f677bbed 100644 --- a/framework/Cipher/lib/Horde/Cipher/BlockMode/Cfb64.php +++ b/framework/Cipher/lib/Horde/Cipher/BlockMode/Cfb64.php @@ -24,7 +24,7 @@ class Horde_Cipher_BlockMode_Cfb64 extends Horde_Cipher_BlockMode * * @return string The encrypted data. */ - function encrypt($cipher, $plaintext) + public function encrypt($cipher, $plaintext) { $encrypted = ''; @@ -53,7 +53,7 @@ class Horde_Cipher_BlockMode_Cfb64 extends Horde_Cipher_BlockMode * * @return string The decrypted data. */ - function decrypt($cipher, $ciphertext) + public function decrypt($cipher, $ciphertext) { $decrypted = ''; diff --git a/framework/Compress/lib/Horde/Compress/Rar.php b/framework/Compress/lib/Horde/Compress/Rar.php index 6e77d9646..a91889ee3 100644 --- a/framework/Compress/lib/Horde/Compress/Rar.php +++ b/framework/Compress/lib/Horde/Compress/Rar.php @@ -54,10 +54,11 @@ class Horde_Compress_Rar extends Horde_Compress throw new Horde_Exception(_("Invalid RAR data.")); } + $data_len = strlen($data); $position = $blockStart + 7; $return_array = array(); - while ($position < strlen($data)) { + while ($position < $data_len) { $head_crc = substr($data, $position + 0, 2); $head_type = ord(substr($data, $position + 2, 1)); $head_flags = unpack('vFlags', substr($data, $position + 3, 2)); diff --git a/framework/Compress/lib/Horde/Compress/Tar.php b/framework/Compress/lib/Horde/Compress/Tar.php index 60c9beaf9..55581471d 100644 --- a/framework/Compress/lib/Horde/Compress/Tar.php +++ b/framework/Compress/lib/Horde/Compress/Tar.php @@ -64,10 +64,11 @@ class Horde_Compress_Tar extends Horde_Compress */ public function decompress($data, $params = array()) { + $data_len = strlen($data); $position = 0; $return_array = array(); - while ($position < strlen($data)) { + while ($position < $data_len) { $info = @unpack("a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/Ctypeflag/a100link/a6magic/a2version/a32uname/a32gname/a8devmajor/a8devminor", substr($data, $position)); if (!$info) { throw new Horde_Exception(_("Unable to decompress data.")); @@ -105,8 +106,6 @@ class Horde_Compress_Tar extends Horde_Compress (($mode & 0x004) ? 'r' : '-') . (($mode & 0x002) ? 'w' : '-') . (($mode & 0x001) ? 'x' : '-'); - } else { - /* Some other type. */ } $return_array[] = $file; diff --git a/framework/Compress/lib/Horde/Compress/Tnef.php b/framework/Compress/lib/Horde/Compress/Tnef.php index 1ebe1fac2..4d0ecc601 100644 --- a/framework/Compress/lib/Horde/Compress/Tnef.php +++ b/framework/Compress/lib/Horde/Compress/Tnef.php @@ -237,7 +237,7 @@ class Horde_Compress_Tnef extends Horde_Compress $datalen = $length + ((4 - ($length % 4)) % 4); if ($attr_type == self::MAPI_STRING) { - $length -= 1; + --$length; } /* Read and truncate to length. */ diff --git a/framework/Compress/lib/Horde/Compress/Zip.php b/framework/Compress/lib/Horde/Compress/Zip.php index 4dbce8305..510961d35 100644 --- a/framework/Compress/lib/Horde/Compress/Zip.php +++ b/framework/Compress/lib/Horde/Compress/Zip.php @@ -237,14 +237,16 @@ class Horde_Compress_Zip extends Horde_Compress /* Get details from local file header. */ $fhStart = strpos($data, self::FILE_HEADER); + $data_len = strlen($data); + do { - if (strlen($data) < $fhStart + 34) { + if ($data_len < $fhStart + 34) { throw new Horde_Exception(_("Invalid ZIP data")); } $info = unpack('vMethod/VTime/VCRC32/VCompressed/VUncompressed/vLength/vExtraLength', substr($data, $fhStart + 8, 25)); $name = substr($data, $fhStart + 30, $info['Length']); $entries[$name]['_dataStart'] = $fhStart + 30 + $info['Length'] + $info['ExtraLength']; - } while (strlen($data) > $fhStart + 30 + $info['Length'] && + } while ($data_len > $fhStart + 30 + $info['Length'] && ($fhStart = strpos($data, self::FILE_HEADER, $fhStart + 30 + $info['Length'])) !== false); return array_values($entries); @@ -365,25 +367,25 @@ class Horde_Compress_Zip extends Horde_Compress $old_offset = ftell($this->_tmp); fwrite($this->_tmp, - self::FILE_HEADER . /* Begin creating the ZIP data. */ - $common . /* Common data. */ - $name . /* File name. */ - $zdata /* "File data" segment. */ + self::FILE_HEADER . /* Begin creating the ZIP data. */ + $common . /* Common data. */ + $name . /* File name. */ + $zdata /* "File data" segment. */ ); /* Add to central directory record. */ $this->_ctrldir[] = self::CTRL_DIR_HEADER . - "\x00\x00" . /* Version made by. */ - $common . /* Common data. */ - pack('v', 0) . /* File comment length. */ - pack('v', 0) . /* Disk number start. */ - pack('v', 0) . /* Internal file attributes. */ - pack('V', 32) . /* External file attributes - - 'archive' bit set. */ - pack('V', $old_offset) . /* Relative offset of local - header. */ - $name; /* File name. */ + "\x00\x00" . /* Version made by. */ + $common . /* Common data. */ + pack('v', 0) . /* File comment length. */ + pack('v', 0) . /* Disk number start. */ + pack('v', 0) . /* Internal file attributes. */ + pack('V', 32) . /* External file attributes - + * 'archive' bit set. */ + pack('V', $old_offset) . /* Relative offset of local + * header. */ + $name; /* File name. */ } } diff --git a/framework/Core/lib/Horde.php b/framework/Core/lib/Horde.php index 4cf67cb6d..5d58e5953 100644 --- a/framework/Core/lib/Horde.php +++ b/framework/Core/lib/Horde.php @@ -702,7 +702,7 @@ HTML; // Return an error if neither main or vhosted versions of the config // file exist. if (!$was_included) { - Horde::logMessage(sprintf('Failed to import configuration file "%s".', $config_dir . $config_file), __FILE__, __LINE__, PEAR_LOG_DEBUG); + self::logMessage(sprintf('Failed to import configuration file "%s".', $config_dir . $config_file), __FILE__, __LINE__, PEAR_LOG_DEBUG); return; } @@ -1972,7 +1972,7 @@ HTML; $url .= '/' . $key . '=' . rawurlencode(strval($val)); } - return Horde::url($url); + return self::url($url); } } diff --git a/framework/Core/lib/Horde/Config.php b/framework/Core/lib/Horde/Config.php index f1a089044..b0a902eda 100644 --- a/framework/Core/lib/Horde/Config.php +++ b/framework/Core/lib/Horde/Config.php @@ -1170,7 +1170,7 @@ class Horde_Config $ctx = explode('|', $ctx); $ptr = $this->_currentConfig; - for ($i = 0; $i < count($ctx); ++$i) { + for ($i = 0, $ctx_count = count($ctx); $i < $ctx_count; ++$i) { if (!isset($ptr[$ctx[$i]])) { return array($default, true); } diff --git a/framework/Core/lib/Horde/Menu.php b/framework/Core/lib/Horde/Menu.php index 2c9cbc48a..b324a4ba6 100644 --- a/framework/Core/lib/Horde/Menu.php +++ b/framework/Core/lib/Horde/Menu.php @@ -203,8 +203,8 @@ class Horde_Menu /* Sort to match explicitly set positions. */ ksort($this->_menu); - if (!empty($GLOBALS['nls']['rtl'][$GLOBALS['language']])) { - $this->_menu = array_reverse($this->_menu) ; + if (!empty($GLOBALS['nls']['rtl'][$GLOBALS['language']])) { + $this->_menu = array_reverse($this->_menu); } $menu_view = $prefs->getValue('menu_view'); diff --git a/framework/Crypt/lib/Horde/Crypt.php b/framework/Crypt/lib/Horde/Crypt.php index ee4a8651d..951077429 100644 --- a/framework/Crypt/lib/Horde/Crypt.php +++ b/framework/Crypt/lib/Horde/Crypt.php @@ -89,7 +89,7 @@ class Horde_Crypt $signature = hash('md5', serialize(array($driver, $params))); if (!isset(self::$_instances[$signature])) { - self::$_instances[$signature] = Horde_Crypt::factory($driver, $params); + self::$_instances[$signature] = self::factory($driver, $params); } return self::$_instances[$signature]; diff --git a/framework/Crypt/lib/Horde/Crypt/Pgp.php b/framework/Crypt/lib/Horde/Crypt/Pgp.php index afbbb2675..4be563b6b 100644 --- a/framework/Crypt/lib/Horde/Crypt/Pgp.php +++ b/framework/Crypt/lib/Horde/Crypt/Pgp.php @@ -654,7 +654,7 @@ class Horde_Crypt_Pgp extends Horde_Crypt /* Try to decrypt the message. */ try { - $this->decrypt($result, array('type' => 'message', 'pubkey' => $public_key, 'privkey' => $private_key, 'passphrase' => $passphrase)); + $this->decrypt($result, array('type' => 'message', 'pubkey' => $public_key, 'privkey' => $private_key, 'passphrase' => $passphrase)); } catch (Horde_Exception $e) { return false; } @@ -1394,7 +1394,7 @@ class Horde_Crypt_Pgp extends Horde_Crypt /* Setup the multipart MIME Part. */ $part = new Horde_Mime_Part(); $part->setType('multipart/signed'); - $part->setContents('This message is in MIME format and has been PGP signed.' . "\n"); + $part->setContents("This message is in MIME format and has been PGP signed.\n"); $part->addPart($mime_part); $part->addPart($pgp_sign); $part->setContentTypeParameter('protocol', 'application/pgp-signature'); @@ -1429,7 +1429,7 @@ class Horde_Crypt_Pgp extends Horde_Crypt $part->setCharset($charset); $part->setContentTypeParameter('protocol', 'application/pgp-encrypted'); $part->setDescription(Horde_String::convertCharset(_("PGP Encrypted Data"), Horde_Nls::getCharset(), $charset)); - $part->setContents('This message is in MIME format and has been PGP encrypted.' . "\n"); + $part->setContents("This message is in MIME format and has been PGP encrypted.\n"); $part1 = new Horde_Mime_Part(); $part1->setType('application/pgp-encrypted'); @@ -1468,7 +1468,7 @@ class Horde_Crypt_Pgp extends Horde_Crypt * know whether a subclass has extended these methods. */ $part = $this->signMIMEPart($mime_part, $sign_params); $part = $this->encryptMIMEPart($part, $encrypt_params); - $part->setContents('This message is in MIME format and has been PGP signed and encrypted.' . "\n"); + $part->setContents("This message is in MIME format and has been PGP signed and encrypted.\n"); $charset = Horde_Nls::getEmailCharset(); $part->setCharset($charset); @@ -1546,7 +1546,7 @@ class Horde_Crypt_Pgp extends Horde_Crypt $cmdline = implode(' ', array_merge($this->_gnupg, $options)); if ($mode == 'w') { - if ($fp = popen($cmdline, 'w')) {; + if ($fp = popen($cmdline, 'w')) { $win32 = !strncasecmp(PHP_OS, 'WIN', 3); if (!is_array($input)) { @@ -1618,7 +1618,7 @@ class Horde_Crypt_Pgp extends Horde_Crypt $cmdline = array( $keyring, '--command-fd 0', - '--gen-revoke' . ' ' . $email, + '--gen-revoke ' . $email, ); $results = $this->_callGpg($cmdline, 'w', $input, true); diff --git a/framework/Crypt/lib/Horde/Crypt/Smime.php b/framework/Crypt/lib/Horde/Crypt/Smime.php index 8eceaa51d..5049cf3bf 100644 --- a/framework/Crypt/lib/Horde/Crypt/Smime.php +++ b/framework/Crypt/lib/Horde/Crypt/Smime.php @@ -262,7 +262,7 @@ class Horde_Crypt_Smime extends Horde_Crypt $smime_part = new Horde_Mime_Part(); $smime_part->setType('multipart/signed'); - $smime_part->setContents('This is a cryptographically signed message in MIME format.' . "\n"); + $smime_part->setContents("This is a cryptographically signed message in MIME format.\n"); $smime_part->setContentTypeParameter('protocol', 'application/pkcs7-signature'); $smime_part->setContentTypeParameter('micalg', 'sha1'); $smime_part->addPart($mime_part); @@ -581,7 +581,8 @@ class Horde_Crypt_Smime extends Horde_Crypt $text .= "  " . sprintf(_("RSA Public Key (%d bit)"), strlen($modulus_hex) * 4) . ":\n"; $modulus_str = ''; - for ($i = 0; $i < strlen($modulus_hex); $i += 2) { + + for ($i = 0, $m_len = strlen($modulus_hex); $i < $m_len; $i += 2) { if (($i % 32) == 0) { $modulus_str .= "\n      "; } @@ -621,7 +622,7 @@ class Horde_Crypt_Smime extends Horde_Crypt foreach ($cert_details['fingerprints'] as $hash => $fingerprint) { $label = sprintf(_("%s Fingerprint"), Horde_String::upper($hash)); $fingerprint_str = ''; - for ($i = 0; $i < strlen($fingerprint); $i += 2) { + for ($i = 0, $f_len = strlen($fingerprint); $i < $f_len; $i += 2) { $fingerprint_str .= substr($fingerprint, $i, 2) . ':'; } $text .= sprintf("  %s:\n      %s\n", $label, $fingerprint_str); @@ -630,7 +631,7 @@ class Horde_Crypt_Smime extends Horde_Crypt $text .= sprintf("  %s:", _("Signature")); $sig_str = ''; - for ($i = 0; $i < strlen($cert_details['signature']); $i++) { + for ($i = 0, $s_len = strlen($cert_details['signature']); $i < $s_len; ++$i) { if (($i % 16) == 0) { $sig_str .= "\n      "; } @@ -824,7 +825,7 @@ class Horde_Crypt_Smime extends Horde_Crypt $newVal = ''; - for ($i = 0; $i < strlen($val); $i++) { + for ($i = 0, $v_len = strlen($val); $i < $v_len; ++$i) { $newVal .= sprintf("%02x:", ord($val[$i])); } $cert_details['certificate']['extensions'][$oid] = $newVal; @@ -836,7 +837,7 @@ class Horde_Crypt_Smime extends Horde_Crypt $val = $val[1]; $newVal = ''; - for ($i = 0; $i < strlen($val); $i++) { + for ($i = 0, $v_len = strlen($val); $i < $v_len; ++$i) { $newVal .= sprintf("%02x:", ord($val[$i])); } $cert_details['certificate']['extensions'][$oid] = $newVal; @@ -940,13 +941,13 @@ class Horde_Crypt_Smime extends Horde_Crypt $value = 0; if ($len <= 4) { /* Method works fine for small integers */ - for ($i = 0; $i < strlen($integer_data); $i++) { + for ($i = 0, $i_len = strlen($integer_data); $i < $i_len; ++$i) { $value = ($value << 8) | ord($integer_data[$i]); } } else { /* Method works for arbitrary length integers */ if (Horde_Util::extensionExists('bcmath')) { - for ($i = 0; $i < strlen($integer_data); $i++) { + for ($i = 0, $i_len = strlen($integer_data); $i < $i_len; ++$i) { $value = bcadd(bcmul($value, 256), ord($integer_data[$i])); } } else { @@ -1014,7 +1015,9 @@ class Horde_Crypt_Smime extends Horde_Crypt $value = 0; $i = 1; - while ($i < strlen($oid_data)) { + $o_len = strlen($oid_data); + + while ($i < $o_len) { $value = $value << 7; $value = $value | (ord($oid_data[$i]) & 0x7f); diff --git a/framework/Editor/lib/Horde/Editor.php b/framework/Editor/lib/Horde/Editor.php index 3cd65346c..1f753c000 100644 --- a/framework/Editor/lib/Horde/Editor.php +++ b/framework/Editor/lib/Horde/Editor.php @@ -82,7 +82,7 @@ class Horde_Editor $signature = serialize(array($driver, $params)); if (!array_key_exists($signature, $instances)) { - $instances[$signature] = Horde_Editor::factory($driver, $params); + $instances[$signature] = self::factory($driver, $params); } return $instances[$signature]; diff --git a/framework/Imap_Client/lib/Horde/Imap/Client/Cclient.php b/framework/Imap_Client/lib/Horde/Imap/Client/Cclient.php index 9b4fdd50b..dab434896 100644 --- a/framework/Imap_Client/lib/Horde/Imap/Client/Cclient.php +++ b/framework/Imap_Client/lib/Horde/Imap/Client/Cclient.php @@ -825,7 +825,7 @@ class Horde_Imap_Client_Cclient extends Horde_Imap_Client_Base return $ret; } - /** + /** * Set the comparator to use for searching/sorting (RFC 5255). * * @param string $comparator The comparator string (see RFC 4790 [3.1] - diff --git a/framework/Imap_Client/lib/Horde/Imap/Client/Cclient/Pop3.php b/framework/Imap_Client/lib/Horde/Imap/Client/Cclient/Pop3.php index 684c10764..56df970fb 100644 --- a/framework/Imap_Client/lib/Horde/Imap/Client/Cclient/Pop3.php +++ b/framework/Imap_Client/lib/Horde/Imap/Client/Cclient/Pop3.php @@ -250,7 +250,7 @@ class Horde_Imap_Client_Cclient_Pop3 extends Horde_Imap_Client_Cclient return parent::_search($query, $options); } - /** + /** * Set the comparator to use for searching/sorting (RFC 5255). * * @param string $comparator The comparator string (see RFC 4790 [3.1] - diff --git a/framework/Imap_Client/lib/Horde/Imap/Client/Socket.php b/framework/Imap_Client/lib/Horde/Imap/Client/Socket.php index 23270f989..d41def619 100644 --- a/framework/Imap_Client/lib/Horde/Imap/Client/Socket.php +++ b/framework/Imap_Client/lib/Horde/Imap/Client/Socket.php @@ -2017,7 +2017,7 @@ class Horde_Imap_Client_Socket extends Horde_Imap_Client_Base $this->_temp['threadparse'] = array('base' => null, 'resp' => array()); reset($data); - while(list($k, $v) = each($data)) { + while (list($k, $v) = each($data)) { $subject = empty($v['envelope']['subject']) ? '' : $this->utils->getBaseSubject($v['envelope']['subject']); @@ -3219,7 +3219,7 @@ class Horde_Imap_Client_Socket extends Horde_Imap_Client_Base $this->_temp['logout'] = true; $this->logout(); if ($this->_debug) { - fwrite($this->_debug, '[ERROR: IMAP server closed the connection.]' . "\n"); + fwrite($this->_debug, "[ERROR: IMAP server closed the connection.]\n"); } throw new Horde_Imap_Client_Exception('IMAP server closed the connection unexpectedly.', Horde_Imap_Client_Exception::DISCONNECT); } @@ -3271,7 +3271,7 @@ class Horde_Imap_Client_Socket extends Horde_Imap_Client_Base if (!$got_data) { if ($this->_debug) { - fwrite($this->_debug, '[ERROR: IMAP read/timeout error.]' . "\n"); + fwrite($this->_debug, "[ERROR: IMAP read/timeout error.]\n"); } throw new Horde_Imap_Client_Exception('IMAP read error or IMAP connection timed out.', Horde_Imap_Client_Exception::SERVER_READERROR); } diff --git a/framework/Imap_Client/lib/Horde/Imap/Client/Socket/Pop3.php b/framework/Imap_Client/lib/Horde/Imap/Client/Socket/Pop3.php index 1c16f7ecf..3e296853c 100644 --- a/framework/Imap_Client/lib/Horde/Imap/Client/Socket/Pop3.php +++ b/framework/Imap_Client/lib/Horde/Imap/Client/Socket/Pop3.php @@ -688,7 +688,7 @@ class Horde_Imap_Client_Socket_Pop3 extends Horde_Imap_Client_Base return $ret; } - /** + /** * Set the comparator to use for searching/sorting (RFC 5255). * * @param string $comparator The comparator string (see RFC 4790 [3.1] - @@ -1059,15 +1059,15 @@ class Horde_Imap_Client_Socket_Pop3 extends Horde_Imap_Client_Base /* Only support deleting/undeleting messages. */ if (isset($options['replace'])) { - $delete = (bool) (count(array_intersect($options['replace'], array('\\deleted')))); + $delete = (bool)(count(array_intersect($options['replace'], array('\\deleted')))); $reset = !$delete; } else { if (!empty($options['add'])) { - $delete = (bool) (count(array_intersect($options['add'], array('\\deleted')))); + $delete = (bool)(count(array_intersect($options['add'], array('\\deleted')))); } if (!empty($options['remove'])) { - $reset = !(bool) (count(array_intersect($options['remove'], array('\\deleted')))); + $reset = !(bool)(count(array_intersect($options['remove'], array('\\deleted')))); } } diff --git a/framework/Mime/lib/Horde/Mime/Address.php b/framework/Mime/lib/Horde/Mime/Address.php index af50439c3..8a1c3f4f9 100644 --- a/framework/Mime/lib/Horde/Mime/Address.php +++ b/framework/Mime/lib/Horde/Mime/Address.php @@ -392,11 +392,11 @@ class Horde_Mime_Address /* Convert objects to arrays. */ foreach (array_keys($ret) as $key) { - $ret[$key] = (array) $ret[$key]; + $ret[$key] = (array)$ret[$key]; if (isset($ret[$key]['addresses'])) { $ptr = &$ret[$key]['addresses']; foreach (array_keys($ptr) as $key2) { - $ptr[$key2] = (array) $ptr[$key2]; + $ptr[$key2] = (array)$ptr[$key2]; } } } diff --git a/framework/Mime/lib/Horde/Mime/Exception.php b/framework/Mime/lib/Horde/Mime/Exception.php index 8e787170d..2772c600b 100644 --- a/framework/Mime/lib/Horde/Mime/Exception.php +++ b/framework/Mime/lib/Horde/Mime/Exception.php @@ -11,4 +11,6 @@ * @category Horde * @package Horde_Mime */ -class Horde_Mime_Exception extends Horde_Exception {} +class Horde_Mime_Exception extends Horde_Exception +{ +} diff --git a/framework/Mime/lib/Horde/Mime/Headers.php b/framework/Mime/lib/Horde/Mime/Headers.php index f578d0924..9cc0e91af 100644 --- a/framework/Mime/lib/Horde/Mime/Headers.php +++ b/framework/Mime/lib/Horde/Mime/Headers.php @@ -273,7 +273,7 @@ class Horde_Mime_Headers *
      * 'decode' - (boolean) MIME decode the value?
      * 'params' - (array) MIME parameters for Content-Type or
-     *            Content-Disposition
+     *            Content-Disposition.
      * 
*/ public function addHeader($header, $value, $options = array()) @@ -351,7 +351,7 @@ class Horde_Mime_Headers *
      * 'decode' - (boolean) MIME decode the value?
      * 'params' - (array) MIME parameters for Content-Type or
-     *            Content-Disposition
+     *            Content-Disposition.
      * 
* * @return boolean True if value was set. @@ -359,7 +359,7 @@ class Horde_Mime_Headers public function setValue($header, $value, $options = array()) { if (isset($this->_headers[Horde_String::lower($header)])) { - $this->addHeader($header, $value, $decode); + $this->addHeader($header, $value, $options); return true; } @@ -509,7 +509,7 @@ class Horde_Mime_Headers */ public function listHeadersExist() { - return (bool) count(array_intersect(array_keys($this->listHeaders()), array_keys($this->_headers))); + return (bool)count(array_intersect(array_keys($this->listHeaders()), array_keys($this->_headers))); } /** diff --git a/framework/Mime/lib/Horde/Mime/Magic.php b/framework/Mime/lib/Horde/Mime/Magic.php index 65c5b26c7..609b44929 100644 --- a/framework/Mime/lib/Horde/Mime/Magic.php +++ b/framework/Mime/lib/Horde/Mime/Magic.php @@ -58,7 +58,7 @@ class Horde_Mime_Magic static public function extToMime($ext) { if (empty($ext)) { - return 'application/octet-stream'; + return 'application/octet-stream'; } $ext = Horde_String::lower($ext); diff --git a/framework/Mime/lib/Horde/Mime/Mail.php b/framework/Mime/lib/Horde/Mime/Mail.php index cf809a3a9..847295afb 100644 --- a/framework/Mime/lib/Horde/Mime/Mail.php +++ b/framework/Mime/lib/Horde/Mime/Mail.php @@ -89,8 +89,8 @@ class Horde_Mime_Mail * * @throws Horde_Mime_Exception */ - function __construct($subject = null, $body = null, $to = null, - $from = null, $charset = null) + public function __construct($subject = null, $body = null, $to = null, + $from = null, $charset = null) { /* Set SERVER_NAME. */ if (!isset($_SERVER['SERVER_NAME'])) { diff --git a/framework/Mime/lib/Horde/Mime/Mdn.php b/framework/Mime/lib/Horde/Mime/Mdn.php index c11cb7a2d..be54b59b5 100644 --- a/framework/Mime/lib/Horde/Mime/Mdn.php +++ b/framework/Mime/lib/Horde/Mime/Mdn.php @@ -32,7 +32,7 @@ class Horde_Mime_Mdn * * @param Horde_Mime_Headers $mime_headers A Horde_Mime_Headers object. */ - function __construct($headers = null) + public function __construct($headers = null) { $this->_headers = $headers; } diff --git a/framework/Mime/lib/Horde/Mime/Part.php b/framework/Mime/lib/Horde/Mime/Part.php index e60bd54d1..91462ad89 100644 --- a/framework/Mime/lib/Horde/Mime/Part.php +++ b/framework/Mime/lib/Horde/Mime/Part.php @@ -508,20 +508,20 @@ class Horde_Mime_Part * @return string The mimetype of this part (ex.: text/plain; * charset=us-ascii) or false. */ - public function getType($charset = false) - { - if (empty($this->_type) || empty($this->_subtype)) { - return false; - } + public function getType($charset = false) + { + if (empty($this->_type) || empty($this->_subtype)) { + return false; + } - $ptype = $this->getPrimaryType(); - $type = $ptype . '/' . $this->getSubType(); - if ($charset && ($ptype == 'text')) { - $type .= '; charset=' . $this->getCharset(); - } + $ptype = $this->getPrimaryType(); + $type = $ptype . '/' . $this->getSubType(); + if ($charset && ($ptype == 'text')) { + $type .= '; charset=' . $this->getCharset(); + } - return $type; - } + return $type; + } /** * If the subtype of a MIME part is unrecognized by an application, the @@ -1213,7 +1213,7 @@ class Horde_Mime_Part $localeinfo = Horde_Nls::getLocaleInfo(); return number_format($bytes / 1024, 2, $localeinfo['decimal_point'], $localeinfo['thousands_sep']); - } + } /** * Sets the Content-ID header for this part. @@ -1289,7 +1289,7 @@ class Horde_Mime_Part } $i = 1; foreach (array_keys($this->_parts) as $val) { - $this->_parts[$val]->buildMimeIds($id . $i++); + $this->_parts[$val]->buildMimeIds($id . ($i++)); } } } else { @@ -1304,7 +1304,7 @@ class Horde_Mime_Part } elseif (!empty($this->_parts)) { $i = 1; foreach (array_keys($this->_parts) as $val) { - $this->_parts[$val]->buildMimeIds($id . $i++); + $this->_parts[$val]->buildMimeIds($id . ($i++)); } } } diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Default.php b/framework/Mime/lib/Horde/Mime/Viewer/Default.php index 64b7421b9..0a0b9970b 100644 --- a/framework/Mime/lib/Horde/Mime/Viewer/Default.php +++ b/framework/Mime/lib/Horde/Mime/Viewer/Default.php @@ -12,4 +12,6 @@ * @author Anil Madhavapeddy * @package Horde_Mime_Viewer */ -class Horde_Mime_Viewer_Default extends Horde_Mime_Viewer_Driver {} +class Horde_Mime_Viewer_Default extends Horde_Mime_Viewer_Driver +{ +} diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Driver.php b/framework/Mime/lib/Horde/Mime/Viewer/Driver.php index 5ab5ab17a..816469ed8 100644 --- a/framework/Mime/lib/Horde/Mime/Viewer/Driver.php +++ b/framework/Mime/lib/Horde/Mime/Viewer/Driver.php @@ -50,12 +50,12 @@ class Horde_Mime_Viewer_Driver /** * Constructor. * - * @param Horde_Mime_Part &$mime_part Reference to an object with the - * information to be rendered. - * @param array $conf Configuration specific to the - * driver. + * @param Horde_Mime_Part $mime_part Reference to an object with the + * information to be rendered. + * @param array $conf Configuration specific to the + * driver. */ - function __construct(&$mime_part, $conf = array()) + public function __construct($mime_part, $conf = array()) { $this->_mimepart = $mime_part; $this->_conf = $conf; diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Enscript.php b/framework/Mime/lib/Horde/Mime/Viewer/Enscript.php index 1cad8b246..1a2ddf50f 100644 --- a/framework/Mime/lib/Horde/Mime/Viewer/Enscript.php +++ b/framework/Mime/lib/Horde/Mime/Viewer/Enscript.php @@ -35,7 +35,7 @@ class Horde_Mime_Viewer_Enscript extends Horde_Mime_Viewer_Source { return array( $this->_mimepart->getMimeId() => array( - 'data' => $this->_toHTML(false), + 'data' => $this->_toHTML(), 'status' => array(), 'type' => 'text/html; charset=' . Horde_Nls::getCharset() ) @@ -51,7 +51,7 @@ class Horde_Mime_Viewer_Enscript extends Horde_Mime_Viewer_Source { return array( $this->_mimepart->getMimeId() => array( - 'data' => $this->_toHTML(true), + 'data' => $this->_toHTML(), 'status' => array(), 'type' => 'text/html; charset=' . Horde_Nls::getCharset() ) @@ -61,11 +61,9 @@ class Horde_Mime_Viewer_Enscript extends Horde_Mime_Viewer_Source /** * Converts the code to HTML. * - * @param boolean $inline Is this an inline display? - * * @return string The HTML-ified version of the MIME part contents. */ - protected function _toHTML($inline) + protected function _toHTML() { /* Check to make sure the viewer program exists. */ if (!isset($this->_conf['location']) || diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Html.php b/framework/Mime/lib/Horde/Mime/Viewer/Html.php index b32ff7555..00e8eda22 100644 --- a/framework/Mime/lib/Horde/Mime/Viewer/Html.php +++ b/framework/Mime/lib/Horde/Mime/Viewer/Html.php @@ -13,7 +13,7 @@ * @author Michael Slusarz * @package Horde_Mime_Viewer */ -class Horde_Mime_Viewer_html extends Horde_Mime_Viewer_Driver +class Horde_Mime_Viewer_Html extends Horde_Mime_Viewer_Driver { /** * Can this driver render various views? diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Php.php b/framework/Mime/lib/Horde/Mime/Viewer/Php.php index 39d52cd01..56b4f21af 100644 --- a/framework/Mime/lib/Horde/Mime/Viewer/Php.php +++ b/framework/Mime/lib/Horde/Mime/Viewer/Php.php @@ -78,7 +78,7 @@ class Horde_Mime_Viewer_Php extends Horde_Mime_Viewer_Source * * @return string The code with line numbers added. */ - protected function _lineNumber($code, $linebreak = "\n") + protected function _lineNumber($code) { // Clean up. $code = preg_replace( diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Rar.php b/framework/Mime/lib/Horde/Mime/Viewer/Rar.php index 1aef5aaa7..e35be9f91 100644 --- a/framework/Mime/lib/Horde/Mime/Viewer/Rar.php +++ b/framework/Mime/lib/Horde/Mime/Viewer/Rar.php @@ -63,7 +63,7 @@ class Horde_Mime_Viewer_Rar extends Horde_Mime_Viewer_Driver $name = _("unnamed"); } - $text = '' . htmlspecialchars(sprintf(_("Contents of \"%s\""), $name)) . ':' . "\n" . + $text = '' . htmlspecialchars(sprintf(_("Contents of \"%s\""), $name)) . ":\n" . '
' . Horde_Text_Filter::filter(_("Archive Name") . ': ' . $name, 'space2html', array('charset' => $charset, 'encode' => true, 'encode_all' => true)) . "\n" . Horde_Text_Filter::filter(_("Archive File Size") . ': ' . strlen($contents) . ' bytes', 'space2html', array('charset' => $charset, 'encode' => true, 'encode_all' => true)) . "\n" . @@ -99,7 +99,7 @@ class Horde_Mime_Viewer_Rar extends Horde_Mime_Viewer_Driver return array( $this->_mimepart->getMimeId() => array( - 'data' => nl2br($text . str_repeat('-', 106) . "\n" . '
'), + 'data' => nl2br($text . str_repeat('-', 106) . "\n"), 'status' => array(), 'type' => 'text/html; charset=' . $charset ) diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Srchighlite.php b/framework/Mime/lib/Horde/Mime/Viewer/Srchighlite.php index 5beff68ce..0ee5c63a7 100644 --- a/framework/Mime/lib/Horde/Mime/Viewer/Srchighlite.php +++ b/framework/Mime/lib/Horde/Mime/Viewer/Srchighlite.php @@ -93,6 +93,8 @@ class Horde_Mime_Viewer_Srchighlite extends Horde_Mime_Viewer_Source */ protected function _typeToLang($type) { + // TODO: 'prolog', 'flex', 'changelog', 'ruby' + switch ($type) { case 'text/x-java': return 'java'; @@ -115,8 +117,6 @@ class Horde_Mime_Viewer_Srchighlite extends Horde_Mime_Viewer_Source case 'application/x-python': return 'python'; - - // TODO: 'prolog', 'flex', 'changelog', 'ruby' } } } diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Tgz.php b/framework/Mime/lib/Horde/Mime/Viewer/Tgz.php index e6c35121e..e80035e64 100644 --- a/framework/Mime/lib/Horde/Mime/Viewer/Tgz.php +++ b/framework/Mime/lib/Horde/Mime/Viewer/Tgz.php @@ -69,7 +69,7 @@ class Horde_Mime_Viewer_Tgz extends Horde_Mime_Viewer_Driver $name = _("unnamed"); } - $text = '' . htmlspecialchars(sprintf(_("Contents of \"%s\""), $name)) . ':' . "\n" . + $text = '' . htmlspecialchars(sprintf(_("Contents of \"%s\""), $name)) . ":\n" . '
' . Horde_Text_Filter::filter(_("Archive Name") . ': ' . $name, 'space2html', array('charset' => $charset, 'encode' => true, 'encode_all' => true)) . "\n" . Horde_Text_Filter::filter(_("Archive File Size") . ': ' . strlen($contents) . ' bytes', 'space2html', array('charset' => $charset, 'encode' => true, 'encode_all' => true)) . "\n" . @@ -98,7 +98,7 @@ class Horde_Mime_Viewer_Tgz extends Horde_Mime_Viewer_Driver return array( $this->_mimepart->getMimeId() => array( - 'data' => nl2br($text . str_repeat('-', 106) . "\n" . '
'), + 'data' => nl2br($text . str_repeat('-', 106) . "\n"), 'status' => array(), 'type' => 'text/html; charset=' . $charset ) diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Zip.php b/framework/Mime/lib/Horde/Mime/Viewer/Zip.php index fad2e6f10..268a10c5b 100644 --- a/framework/Mime/lib/Horde/Mime/Viewer/Zip.php +++ b/framework/Mime/lib/Horde/Mime/Viewer/Zip.php @@ -88,12 +88,12 @@ class Horde_Mime_Viewer_Zip extends Horde_Mime_Viewer_Driver $name = _("unnamed"); } - $text = '' . htmlspecialchars(sprintf(_("Contents of \"%s\""), $name)) . ':' . "\n" . + $text = '' . htmlspecialchars(sprintf(_("Contents of \"%s\""), $name)) . ":\n" . '
' . Horde_Text_Filter::filter( _("Archive Name") . ': ' . $name . "\n" . _("Archive File Size") . ': ' . strlen($contents) . - ' bytes' . "\n" . + " bytes\n" . sprintf(ngettext("File Count: %d file", "File Count: %d files", $fileCount), $fileCount) . "\n\n" . Horde_String::pad(_("File Name"), $maxlen, ' ', STR_PAD_RIGHT) . @@ -114,7 +114,7 @@ class Horde_Mime_Viewer_Zip extends Horde_Mime_Viewer_Driver : 100 * ($val['csize'] / $val['size']); $val['name'] = Horde_String::pad($val['name'], $maxlen, ' ', STR_PAD_RIGHT); - $val['attr'] = Horde_String::pad($val['attr'], 10,' ', STR_PAD_LEFT); + $val['attr'] = Horde_String::pad($val['attr'], 10, ' ', STR_PAD_LEFT); $val['size'] = Horde_String::pad($val['size'], 10, ' ', STR_PAD_LEFT); $val['date'] = Horde_String::pad(strftime("%d-%b-%Y %H:%M", $val['date']), 19, ' ', STR_PAD_LEFT); $val['method'] = Horde_String::pad($val['method'], 10, ' ', STR_PAD_LEFT); @@ -133,7 +133,7 @@ class Horde_Mime_Viewer_Zip extends Horde_Mime_Viewer_Driver return array( $this->_mimepart->getMimeId() => array( - 'data' => nl2br($text . str_repeat('-', 69 + $maxlen) . "\n" . '
'), + 'data' => nl2br($text . str_repeat('-', 69 + $maxlen) . "\n"), 'status' => array(), 'type' => 'text/html; charset=' . Horde_Nls::getCharset() ) diff --git a/framework/Util/lib/Horde/Util.php b/framework/Util/lib/Horde/Util.php index 7d0e93bb6..930f6974a 100644 --- a/framework/Util/lib/Horde/Util.php +++ b/framework/Util/lib/Horde/Util.php @@ -57,6 +57,16 @@ class Horde_Util ); /** + * Temp directory locations. + * + * @var array + */ + static public $tmpLocations = array( + '/tmp', '/var/tmp', 'c:\WUTemp', 'c:\temp', 'c:\windows\temp', + 'c:\winnt\temp' + ); + + /** * Random number for nocacheUrl(). * * @var integer. @@ -487,17 +497,15 @@ class Horde_Util // If we still cannot determine a value, then cycle through a // list of preset possibilities. - $tmp_locations = array('/tmp', '/var/tmp', 'c:\WUTemp', 'c:\temp', - 'c:\windows\temp', 'c:\winnt\temp'); - while (empty($tmp) && count($tmp_locations)) { - $tmp_check = array_shift($tmp_locations); - if (@is_dir($tmp_check)) { - $tmp = $tmp_check; + if (empty($tmp)) { + foreach (self::$tmpLocations as $tmp_check) { + if (@is_dir($tmp_check)) { + $tmp = $tmp_check; + break; + } } } - // If it is still empty, we have failed, so return false; - // otherwise return the directory determined. return empty($tmp) ? false : $tmp; } @@ -791,8 +799,9 @@ class Horde_Util */ static public function closeWindowJS($code = '') { - echo '\n"; + echo "\n"; } /** @@ -899,9 +908,10 @@ class Horde_Util */ static public function date2strftime($format) { + $f_len = strlen($format); $result = ''; - for ($pos = 0; $pos < strlen($format);) { + for ($pos = 0; $pos < $f_len;) { for ($symbol = 0, $symcount = count(self::$dateSymbols); $symbol < $symcount; ++$symbol) { if (strpos($format, self::$dateSymbols[$symbol], $pos) === $pos) { $result .= self::$strftimeSymbols[$symbol]; diff --git a/framework/Util/lib/Horde/Variables.php b/framework/Util/lib/Horde/Variables.php index 12d3dd027..ab22d8229 100644 --- a/framework/Util/lib/Horde/Variables.php +++ b/framework/Util/lib/Horde/Variables.php @@ -123,8 +123,9 @@ class Horde_Variables } else { array_unshift($keys, $base); $place = &$this->_vars; + $i = count($keys); - while (count($keys)) { + while ($i--) { $key = array_shift($keys); if (!isset($place[$key])) { $place[$key] = array(); @@ -238,7 +239,9 @@ class Horde_Variables : false; } else { $searchspace = &$array[$base]; - while (count($keys)) { + $i = count($keys); + + while ($i--) { $key = array_shift($keys); if (!isset($searchspace[$key])) { $value = null; -- 2.11.0