Don't use error suppression on realpath() + style adjustments
diff --git a/system/helpers/file_helper.php b/system/helpers/file_helper.php
index b8b7053..8cfe0f1 100644
--- a/system/helpers/file_helper.php
+++ b/system/helpers/file_helper.php
@@ -137,14 +137,12 @@
 				}
 			}
 		}
-		@closedir($current_dir);
 
-		if ($del_dir === TRUE && $_level > 0)
-		{
-			return @rmdir($path);
-		}
+		closedir($current_dir);
 
-		return TRUE;
+		return ($del_dir === TRUE && $_level > 0)
+			? @rmdir($path)
+			: TRUE;
 	}
 }
 
@@ -178,7 +176,7 @@
 
 			while (FALSE !== ($file = readdir($fp)))
 			{
-				if (@is_dir($source_dir.$file) && $file[0] !== '.')
+				if (is_dir($source_dir.$file) && $file[0] !== '.')
 				{
 					get_filenames($source_dir.$file.DIRECTORY_SEPARATOR, $include_path, TRUE);
 				}
@@ -187,8 +185,8 @@
 					$_filedata[] = ($include_path === TRUE) ? $source_dir.$file : $file;
 				}
 			}
-			closedir($fp);
 
+			closedir($fp);
 			return $_filedata;
 		}
 
@@ -230,7 +228,7 @@
 			// foreach (scandir($source_dir, 1) as $file) // In addition to being PHP5+, scandir() is simply not as fast
 			while (FALSE !== ($file = readdir($fp)))
 			{
-				if (@is_dir($source_dir.$file) && $file[0] !== '.' && $top_level_only === FALSE)
+				if (is_dir($source_dir.$file) && $file[0] !== '.' && $top_level_only === FALSE)
 				{
 					get_dir_file_info($source_dir.$file.DIRECTORY_SEPARATOR, $top_level_only, TRUE);
 				}
@@ -240,8 +238,8 @@
 					$_filedata[$file]['relative_path'] = $relative_path;
 				}
 			}
-			closedir($fp);
 
+			closedir($fp);
 			return $_filedata;
 		}
 
@@ -330,8 +328,6 @@
 	 */
 	function get_mime_by_extension($filename)
 	{
-		$extension = strtolower(substr(strrchr($filename, '.'), 1));
-
 		static $mimes;
 
 		if ( ! is_array($mimes))
@@ -344,6 +340,8 @@
 			}
 		}
 
+		$extension = strtolower(substr(strrchr($filename, '.'), 1));
+
 		if (isset($mimes[$extension]))
 		{
 			return is_array($mimes[$extension])
@@ -405,18 +403,18 @@
 
 		// Owner
 		$symbolic .= (($perms & 0x0100) ? 'r' : '-')
-			. (($perms & 0x0080) ? 'w' : '-')
-			. (($perms & 0x0040) ? (($perms & 0x0800) ? 's' : 'x' ) : (($perms & 0x0800) ? 'S' : '-'));
+			.(($perms & 0x0080) ? 'w' : '-')
+			.(($perms & 0x0040) ? (($perms & 0x0800) ? 's' : 'x' ) : (($perms & 0x0800) ? 'S' : '-'));
 
 		// Group
 		$symbolic .= (($perms & 0x0020) ? 'r' : '-')
-			. (($perms & 0x0010) ? 'w' : '-')
-			. (($perms & 0x0008) ? (($perms & 0x0400) ? 's' : 'x' ) : (($perms & 0x0400) ? 'S' : '-'));
+			.(($perms & 0x0010) ? 'w' : '-')
+			.(($perms & 0x0008) ? (($perms & 0x0400) ? 's' : 'x' ) : (($perms & 0x0400) ? 'S' : '-'));
 
 		// World
 		$symbolic .= (($perms & 0x0004) ? 'r' : '-')
-			. (($perms & 0x0002) ? 'w' : '-')
-			. (($perms & 0x0001) ? (($perms & 0x0200) ? 't' : 'x' ) : (($perms & 0x0200) ? 'T' : '-'));
+			.(($perms & 0x0002) ? 'w' : '-')
+			.(($perms & 0x0001) ? (($perms & 0x0200) ? 't' : 'x' ) : (($perms & 0x0200) ? 'T' : '-'));
 
 		return $symbolic;
 	}
diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php
index a724406..2592890 100644
--- a/system/helpers/form_helper.php
+++ b/system/helpers/form_helper.php
@@ -54,16 +54,16 @@
 	{
 		$CI =& get_instance();
 
+		// If no action is provided then set to the current url
+		if ( ! $action)
+		{
+			$action = $CI->config->site_url($CI->uri->uri_string());
+		}
 		// If an action is not a full URL then turn it into one
-		if ($action && strpos($action, '://') === FALSE)
+		elseif (strpos($action, '://') === FALSE)
 		{
 			$action = $CI->config->site_url($action);
 		}
-		elseif ( ! $action)
-		{
-			// If no action is provided then set to the current url
-			$action = $CI->config->site_url($CI->uri->uri_string());
-		}
 
 		$attributes = _attributes_to_string($attributes);
 
@@ -80,7 +80,7 @@
 		$form = '<form action="'.$action.'"'.$attributes.">\n";
 
 		// Add CSRF field if enabled, but leave it out for GET requests and requests to external websites
-		if ($CI->config->item('csrf_protection') === TRUE && ! (strpos($action, $CI->config->base_url()) === FALSE OR stripos($form, 'method="get"')))
+		if ($CI->config->item('csrf_protection') === TRUE && strpos($action, $CI->config->base_url()) !== FALSE && ! stripos($form, 'method="get"'))
 		{
 			$hidden[$CI->security->get_csrf_token_name()] = $CI->security->get_csrf_hash();
 		}
@@ -153,6 +153,7 @@
 			{
 				form_hidden($key, $val, TRUE);
 			}
+
 			return $form;
 		}
 
@@ -187,7 +188,11 @@
 	 */
 	function form_input($data = '', $value = '', $extra = '')
 	{
-		$defaults = array('type' => 'text', 'name' => ( ! is_array($data) ? $data : ''), 'value' => $value);
+		$defaults = array(
+			'type' => 'text',
+			'name' => is_array($data) ? '' : $data,
+			'value' => $value
+		);
 
 		return '<input '._parse_form_attributes($data, $defaults).$extra." />\n";
 	}
@@ -209,11 +214,7 @@
 	 */
 	function form_password($data = '', $value = '', $extra = '')
 	{
-		if ( ! is_array($data))
-		{
-			$data = array('name' => $data);
-		}
-
+		is_array($data) OR $data = array('name' => $data);
 		$data['type'] = 'password';
 		return form_input($data, $value, $extra);
 	}
@@ -256,7 +257,11 @@
 	 */
 	function form_textarea($data = '', $value = '', $extra = '')
 	{
-		$defaults = array('name' => ( ! is_array($data) ? $data : ''), 'cols' => '40', 'rows' => '10');
+		$defaults = array(
+			'name' => is_array($data) ? '' : $data,
+			'cols' => '40',
+			'rows' => '10'
+		);
 
 		if ( ! is_array($data) OR ! isset($data['value']))
 		{
@@ -434,11 +439,7 @@
 	 */
 	function form_radio($data = '', $value = '', $checked = FALSE, $extra = '')
 	{
-		if ( ! is_array($data))
-		{
-			$data = array('name' => $data);
-		}
-
+		is_array($data) OR $data = array('name' => $data);
 		$data['type'] = 'radio';
 		return form_checkbox($data, $value, $checked, $extra);
 	}
@@ -458,7 +459,12 @@
 	 */
 	function form_submit($data = '', $value = '', $extra = '')
 	{
-		$defaults = array('type' => 'submit', 'name' => ( ! is_array($data) ? $data : ''), 'value' => $value);
+		$defaults = array(
+			'type' => 'submit',
+			'name' => is_array($data) ? '' : $data,
+			'value' => $value
+		);
+
 		return '<input '._parse_form_attributes($data, $defaults).$extra." />\n";
 	}
 }
@@ -477,7 +483,12 @@
 	 */
 	function form_reset($data = '', $value = '', $extra = '')
 	{
-		$defaults = array('type' => 'reset', 'name' => ( ! is_array($data) ? $data : ''), 'value' => $value);
+		$defaults = array(
+			'type' => 'reset',
+			'name' => is_array($data) ? '' : $data,
+			'value' => $value
+		);
+
 		return '<input '._parse_form_attributes($data, $defaults).$extra." />\n";
 	}
 }
@@ -496,7 +507,11 @@
 	 */
 	function form_button($data = '', $content = '', $extra = '')
 	{
-		$defaults = array('name' => ( ! is_array($data) ? $data : ''), 'type' => 'button');
+		$defaults = array(
+			'name' => is_array($data) ? '' : $data,
+			'type' => 'button'
+		);
+
 		if (is_array($data) && isset($data['content']))
 		{
 			$content = $data['content'];
diff --git a/system/helpers/html_helper.php b/system/helpers/html_helper.php
index 604d114..8246cbd 100644
--- a/system/helpers/html_helper.php
+++ b/system/helpers/html_helper.php
@@ -118,10 +118,10 @@
 		}
 
 		// Set the indentation based on the depth
-		$out = str_repeat(' ', $depth);
+		$out = str_repeat(' ', $depth)
+			// Write the opening list tag
+			.'<'.$type._stringify_attributes($attributes).">\n";
 
-		// Write the opening list tag
-		$out .= '<'.$type._stringify_attributes($attributes).">\n";
 
 		// Cycle through the list elements.  If an array is
 		// encountered we will recursively call _list()
@@ -152,22 +152,6 @@
 
 // ------------------------------------------------------------------------
 
-if ( ! function_exists('br'))
-{
-	/**
-	 * Generates HTML BR tags based on number supplied
-	 *
-	 * @param	int	$count	Number of times to repeat the tag
-	 * @return	string
-	 */
-	function br($count = 1)
-	{
-		return str_repeat('<br />', $count);
-	}
-}
-
-// ------------------------------------------------------------------------
-
 if ( ! function_exists('img'))
 {
 	/**
@@ -368,7 +352,7 @@
 		$str = '';
 		foreach ($name as $meta)
 		{
-			$type		= ( ! isset($meta['type']) OR $meta['type'] === 'name') ? 'name' : 'http-equiv';
+			$type		= (isset($meta['type']) && $meta['type'] !== 'name')	? 'http-equiv' : 'name';
 			$name		= isset($meta['name'])					? $meta['name'] : '';
 			$content	= isset($meta['content'])				? $meta['content'] : '';
 			$newline	= isset($meta['newline'])				? $meta['newline'] : "\n";
@@ -382,6 +366,22 @@
 
 // ------------------------------------------------------------------------
 
+if ( ! function_exists('br'))
+{
+	/**
+	 * Generates HTML BR tags based on number supplied
+	 *
+	 * @param	int	$count	Number of times to repeat the tag
+	 * @return	string
+	 */
+	function br($count = 1)
+	{
+		return str_repeat('<br />', $count);
+	}
+}
+
+// ------------------------------------------------------------------------
+
 if ( ! function_exists('nbs'))
 {
 	/**
diff --git a/system/helpers/path_helper.php b/system/helpers/path_helper.php
index ae1f0bf..15e7968 100644
--- a/system/helpers/path_helper.php
+++ b/system/helpers/path_helper.php
@@ -56,7 +56,7 @@
 		}
 
 		// Resolve the path
-		if (@realpath($path) !== FALSE)
+		if (realpath($path) !== FALSE)
 		{
 			$path = realpath($path);
 		}
diff --git a/system/helpers/smiley_helper.php b/system/helpers/smiley_helper.php
index 57debff..f67890c 100644
--- a/system/helpers/smiley_helper.php
+++ b/system/helpers/smiley_helper.php
@@ -114,7 +114,9 @@
 			}
 		}
 
-		return ($inline) ? '<script type="text/javascript" charset="utf-8">/*<![CDATA[ */'.$r.'// ]]></script>' : $r;
+		return ($inline)
+			? '<script type="text/javascript" charset="utf-8">/*<![CDATA[ */'.$r.'// ]]></script>'
+			: $r;
 	}
 }
 
diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php
index 76e1735..af14dfe 100644
--- a/system/helpers/text_helper.php
+++ b/system/helpers/text_helper.php
@@ -157,8 +157,8 @@
 				if (count($temp) === $count)
 				{
 					$number = ($count === 3)
-							? (($temp[0] % 16) * 4096) + (($temp[1] % 64) * 64) + ($temp[2] % 64)
-							: (($temp[0] % 32) * 64) + ($temp[1] % 64);
+						? (($temp[0] % 16) * 4096) + (($temp[1] % 64) * 64) + ($temp[2] % 64)
+						: (($temp[0] % 32) * 64) + ($temp[1] % 64);
 
 					$out .= '&#'.$number.';';
 					$count = 1;
@@ -220,9 +220,11 @@
 
 		if ($all)
 		{
-			return str_replace(array('&amp;', '&lt;', '&gt;', '&quot;', '&apos;', '&#45;'),
-						array('&', '<', '>', '"', "'", '-'),
-						$str);
+			return str_replace(
+				array('&amp;', '&lt;', '&gt;', '&quot;', '&apos;', '&#45;'),
+				array('&', '<', '>', '"', "'", '-'),
+				$str
+			);
 		}
 
 		return $str;
@@ -297,31 +299,37 @@
 		 * so they don't accidentally break the string out of PHP,
 		 * and thus, thwart the highlighting.
 		 */
-		$str = str_replace(array('&lt;', '&gt;', '<?', '?>', '<%', '%>', '\\', '</script>'),
-					array('<', '>', 'phptagopen', 'phptagclose', 'asptagopen', 'asptagclose', 'backslashtmp', 'scriptclose'),
-					$str);
+		$str = str_replace(
+			array('&lt;', '&gt;', '<?', '?>', '<%', '%>', '\\', '</script>'),
+			array('<', '>', 'phptagopen', 'phptagclose', 'asptagopen', 'asptagclose', 'backslashtmp', 'scriptclose'),
+			$str
+		);
 
 		// The highlight_string function requires that the text be surrounded
 		// by PHP tags, which we will remove later
 		$str = highlight_string('<?php '.$str.' ?>', TRUE);
 
 		// Remove our artificially added PHP, and the syntax highlighting that came with it
-		$str = preg_replace(array(
-						'/<span style="color: #([A-Z0-9]+)">&lt;\?php(&nbsp;| )/i',
-						'/(<span style="color: #[A-Z0-9]+">.*?)\?&gt;<\/span>\n<\/span>\n<\/code>/is',
-						'/<span style="color: #[A-Z0-9]+"\><\/span>/i'
-					),
-					array(
-						'<span style="color: #$1">',
-						"$1</span>\n</span>\n</code>",
-						''
-					),
-					$str);
+		$str = preg_replace(
+			array(
+				'/<span style="color: #([A-Z0-9]+)">&lt;\?php(&nbsp;| )/i',
+				'/(<span style="color: #[A-Z0-9]+">.*?)\?&gt;<\/span>\n<\/span>\n<\/code>/is',
+				'/<span style="color: #[A-Z0-9]+"\><\/span>/i'
+			),
+			array(
+				'<span style="color: #$1">',
+				"$1</span>\n</span>\n</code>",
+				''
+			),
+			$str
+		);
 
 		// Replace our markers back to PHP tags.
-		return str_replace(array('phptagopen', 'phptagclose', 'asptagopen', 'asptagclose', 'backslashtmp', 'scriptclose'),
-					array('&lt;?', '?&gt;', '&lt;%', '%&gt;', '\\', '&lt;/script&gt;'),
-					$str);
+		return str_replace(
+			array('phptagopen', 'phptagclose', 'asptagopen', 'asptagclose', 'backslashtmp', 'scriptclose'),
+			array('&lt;?', '?&gt;', '&lt;%', '%&gt;', '\\', '&lt;/script&gt;'),
+			$str
+		);
 	}
 }
 
@@ -408,10 +416,7 @@
 	function word_wrap($str, $charlim = 76)
 	{
 		// Set the character limit
-		if ( ! is_numeric($charlim))
-		{
-			$charlim = 76;
-		}
+		is_numeric($charlim) OR $charlim = 76;
 
 		// Reduce multiple spaces
 		$str = preg_replace('| +|', ' ', $str);
diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php
index 5f11a42..dff1a86 100644
--- a/system/helpers/url_helper.php
+++ b/system/helpers/url_helper.php
@@ -148,14 +148,9 @@
 	{
 		$title = (string) $title;
 
-		if ( ! is_array($uri))
-		{
-			$site_url = preg_match('#^(\w+:)?//#i', $uri) ? $uri : site_url($uri);
-		}
-		else
-		{
-			$site_url = site_url($uri);
-		}
+		$site_url = is_array($uri)
+			? site_url($uri)
+			: preg_match('#^(\w+:)?//#i', $uri) ? $uri : site_url($uri);
 
 		if ($title === '')
 		{
@@ -481,11 +476,11 @@
 		$q_separator = preg_quote($separator, '#');
 
 		$trans = array(
-				'&.+?;'			=> '',
-				'[^a-z0-9 _-]'		=> '',
-				'\s+'			=> $separator,
-				'('.$q_separator.')+'	=> $separator
-			);
+			'&.+?;'			=> '',
+			'[^a-z0-9 _-]'		=> '',
+			'\s+'			=> $separator,
+			'('.$q_separator.')+'	=> $separator
+		);
 
 		$str = strip_tags($str);
 		foreach ($trans as $key => $val)
diff --git a/system/helpers/xml_helper.php b/system/helpers/xml_helper.php
index 4c38b69..5c1414b 100644
--- a/system/helpers/xml_helper.php
+++ b/system/helpers/xml_helper.php
@@ -60,9 +60,11 @@
 			$str = preg_replace('/&(\w+);/', $temp.'\\1;', $str);
 		}
 
-		$str = str_replace(array('&', '<', '>', '"', "'", '-'),
-					array('&amp;', '&lt;', '&gt;', '&quot;', '&apos;', '&#45;'),
-					$str);
+		$str = str_replace(
+			array('&', '<', '>', '"', "'", '-'),
+			array('&amp;', '&lt;', '&gt;', '&quot;', '&apos;', '&#45;'),
+			$str
+		);
 
 		// Decode the temp markers back to entities
 		$str = preg_replace('/'.$temp.'(\d+);/', '&#\\1;', $str);
diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php
index db45a80..ac3db41 100644
--- a/system/libraries/Image_lib.php
+++ b/system/libraries/Image_lib.php
@@ -493,9 +493,9 @@
 		 * Either way, we'll try use realpath to generate the
 		 * full server path in order to more reliably read it.
 		 */
-		if (function_exists('realpath') && @realpath($this->source_image) !== FALSE)
+		if (($full_source_path = realpath($this->source_image)) !== FALSE)
 		{
-			$full_source_path = str_replace('\\', '/', realpath($this->source_image));
+			$full_source_path = str_replace('\\', '/', $full_source_path);
 		}
 		else
 		{
diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php
index 583a976..62cfb28 100644
--- a/system/libraries/Upload.php
+++ b/system/libraries/Upload.php
@@ -967,7 +967,7 @@
 			return FALSE;
 		}
 
-		if (@realpath($this->upload_path) !== FALSE)
+		if (realpath($this->upload_path) !== FALSE)
 		{
 			$this->upload_path = str_replace('\\', '/', realpath($this->upload_path));
 		}