diff options
Diffstat (limited to 'system')
82 files changed, 577 insertions, 570 deletions
diff --git a/system/core/Benchmark.php b/system/core/Benchmark.php index bb630f40b..2fabdf46e 100755 --- a/system/core/Benchmark.php +++ b/system/core/Benchmark.php @@ -79,7 +79,7 @@ class CI_Benchmark { */ public function elapsed_time($point1 = '', $point2 = '', $decimals = 4) { - if ($point1 == '') + if ($point1 === '') { return '{elapsed_time}'; } diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php index c8245fcfa..b3e984d4d 100755 --- a/system/core/CodeIgniter.php +++ b/system/core/CodeIgniter.php @@ -94,7 +94,7 @@ * Note: Since the config file data is cached it doesn't * hurt to load it here. */ - if (isset($assign_to_config['subclass_prefix']) && $assign_to_config['subclass_prefix'] != '') + if ( ! empty($assign_to_config['subclass_prefix'])) { get_config(array('subclass_prefix' => $assign_to_config['subclass_prefix'])); } @@ -182,7 +182,7 @@ * ------------------------------------------------------ */ if ($EXT->call_hook('cache_override') === FALSE - && $OUT->_display_cache($CFG, $URI) == TRUE) + && $OUT->_display_cache($CFG, $URI) === TRUE) { exit; } diff --git a/system/core/Common.php b/system/core/Common.php index 4b733ac97..8af7d6323 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -200,7 +200,7 @@ if ( ! function_exists('is_loaded')) { static $_is_loaded = array(); - if ($class != '') + if ($class !== '') { $_is_loaded[strtolower($class)] = $class; } @@ -231,21 +231,25 @@ if ( ! function_exists('get_config')) return $_config[0]; } - // Is the config file in the environment folder? - if ( ! defined('ENVIRONMENT') OR ! file_exists($file_path = APPPATH.'config/'.ENVIRONMENT.'/config.php')) + $file_path = APPPATH.'config/config.php'; + $found = FALSE; + if (file_exists($file_path)) { - $file_path = APPPATH.'config/config.php'; + $found = TRUE; + require($file_path); } - // Fetch the config file - if ( ! file_exists($file_path)) + // Is the config file in the environment folder? + if (defined(ENVIRONMENT) && file_exists($file_path = APPPATH.'config/'.ENVIRONMENT.'/config.php')) + { + require($file_path); + } + elseif ( ! $found) { set_status_header(503); exit('The configuration file does not exist.'); } - require($file_path); - // Does the $config array exist in the file? if ( ! isset($config) OR ! is_array($config)) { @@ -366,7 +370,7 @@ if ( ! function_exists('log_message')) { static $_log; - if (config_item('log_threshold') == 0) + if (config_item('log_threshold') === 0) { return; } @@ -436,13 +440,12 @@ if ( ! function_exists('set_status_header')) { show_error('Status codes must be numeric', 500); } - - if (isset($stati[$code]) && $text == '') + elseif (isset($stati[$code]) && $text === '') { $text = $stati[$code]; } - if ($text == '') + if ($text === '') { show_error('No status text available. Please check your status code number or supply your own message text.', 500); } @@ -491,13 +494,13 @@ if ( ! function_exists('_exception_handler')) // Should we display the error? We'll get the current error_reporting // level and add its bits with the severity bits to find out. - if (($severity & error_reporting()) == $severity) + if (($severity & error_reporting()) === $severity) { $_error->show_php_error($severity, $message, $filepath, $line); } // Should we log the error? No? We're done... - if (config_item('log_threshold') == 0) + if (config_item('log_threshold') === 0) { return; } diff --git a/system/core/Config.php b/system/core/Config.php index c07ffa591..3de1bcb96 100755 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -100,7 +100,7 @@ class CI_Config { */ public function load($file = '', $use_sections = FALSE, $fail_gracefully = FALSE) { - $file = ($file == '') ? 'config' : str_replace('.php', '', $file); + $file = ($file === '') ? 'config' : str_replace('.php', '', $file); $found = $loaded = FALSE; foreach ($this->_config_paths as $path) @@ -211,7 +211,7 @@ class CI_Config { { return FALSE; } - elseif (trim($this->config[$item]) == '') + elseif (trim($this->config[$item]) === '') { return ''; } @@ -230,14 +230,14 @@ class CI_Config { */ public function site_url($uri = '') { - if ($uri == '') + if ($uri === '') { return $this->slash_item('base_url').$this->item('index_page'); } - if ($this->item('enable_query_strings') == FALSE) + if ($this->item('enable_query_strings') === FALSE) { - $suffix = ($this->item('url_suffix') == FALSE) ? '' : $this->item('url_suffix'); + $suffix = ($this->item('url_suffix') === FALSE) ? '' : $this->item('url_suffix'); return $this->slash_item('base_url').$this->slash_item('index_page').$this->_uri_string($uri).$suffix; } else @@ -270,7 +270,7 @@ class CI_Config { */ protected function _uri_string($uri) { - if ($this->item('enable_query_strings') == FALSE) + if ($this->item('enable_query_strings') === FALSE) { if (is_array($uri)) { diff --git a/system/core/Hooks.php b/system/core/Hooks.php index 5bbb0009a..29fd88201 100755 --- a/system/core/Hooks.php +++ b/system/core/Hooks.php @@ -72,7 +72,7 @@ class CI_Hooks { // If hooks are not enabled in the config file // there is nothing else to do - if ($CFG->item('enable_hooks') == FALSE) + if ($CFG->item('enable_hooks') === FALSE) { return; } diff --git a/system/core/Input.php b/system/core/Input.php index 97be9e690..73f46ba6a 100755 --- a/system/core/Input.php +++ b/system/core/Input.php @@ -263,23 +263,27 @@ class CI_Input { } } - if ($prefix == '' && config_item('cookie_prefix') != '') + if ($prefix === '' && config_item('cookie_prefix') !== '') { $prefix = config_item('cookie_prefix'); } + if ($domain == '' && config_item('cookie_domain') != '') { $domain = config_item('cookie_domain'); } - if ($path == '/' && config_item('cookie_path') !== '/') + + if ($path === '/' && config_item('cookie_path') !== '/') { $path = config_item('cookie_path'); } - if ($secure == FALSE && config_item('cookie_secure') != FALSE) + + if ($secure === FALSE && config_item('cookie_secure') !== FALSE) { $secure = config_item('cookie_secure'); } - if ($httponly == FALSE && config_item('cookie_httponly') != FALSE) + + if ($httponly === FALSE && config_item('cookie_httponly') !== FALSE) { $httponly = config_item('cookie_httponly'); } @@ -459,7 +463,7 @@ class CI_Input { } // Is $_GET data allowed? If not we'll set the $_GET to an empty array - if ($this->_allow_get_array == FALSE) + if ($this->_allow_get_array === FALSE) { $_GET = array(); } @@ -502,7 +506,7 @@ class CI_Input { $_SERVER['PHP_SELF'] = strip_tags($_SERVER['PHP_SELF']); // CSRF Protection check - if ($this->_enable_csrf == TRUE) + if ($this->_enable_csrf === TRUE) { $this->security->csrf_verify(); } @@ -559,7 +563,7 @@ class CI_Input { } // Standardize newlines if needed - if ($this->_standardize_newlines == TRUE && strpos($str, "\r") !== FALSE) + if ($this->_standardize_newlines === TRUE && strpos($str, "\r") !== FALSE) { return str_replace(array("\r\n", "\r", "\r\n\n"), PHP_EOL, $str); } diff --git a/system/core/Lang.php b/system/core/Lang.php index 73c9127ac..3001f1b13 100755 --- a/system/core/Lang.php +++ b/system/core/Lang.php @@ -76,26 +76,26 @@ class CI_Lang { { $langfile = str_replace('.php', '', $langfile); - if ($add_suffix == TRUE) + if ($add_suffix === TRUE) { $langfile = str_replace('_lang', '', $langfile).'_lang'; } $langfile .= '.php'; - if ($idiom == '') + if ($idiom === '') { $config =& get_config(); $idiom = ( ! empty($config['language'])) ? $config['language'] : 'english'; } - if ($return == FALSE && isset($this->is_loaded[$langfile]) && $this->is_loaded[$langfile] === $idiom) + if ($return === FALSE && isset($this->is_loaded[$langfile]) && $this->is_loaded[$langfile] === $idiom) { return; } // Determine where the language file is and load it - if ($alt_path != '' && file_exists($alt_path.'language/'.$idiom.'/'.$langfile)) + if ($alt_path !== '' && file_exists($alt_path.'language/'.$idiom.'/'.$langfile)) { include($alt_path.'language/'.$idiom.'/'.$langfile); } @@ -124,14 +124,14 @@ class CI_Lang { { log_message('error', 'Language file contains no data: language/'.$idiom.'/'.$langfile); - if ($return == TRUE) + if ($return === TRUE) { return array(); } return; } - if ($return == TRUE) + if ($return === TRUE) { return $lang; } @@ -153,7 +153,7 @@ class CI_Lang { */ public function line($line = '') { - $value = ($line == '' OR ! isset($this->language[$line])) ? FALSE : $this->language[$line]; + $value = ($line === '' OR ! isset($this->language[$line])) ? FALSE : $this->language[$line]; // Because killer robots like unicorns! if ($value === FALSE) diff --git a/system/core/Loader.php b/system/core/Loader.php index 3eb09e6ab..09e948714 100644 --- a/system/core/Loader.php +++ b/system/core/Loader.php @@ -208,7 +208,7 @@ class CI_Loader { return; } - if ($library == '' OR isset($this->_base_classes[$library])) + if ($library === '' OR isset($this->_base_classes[$library])) { return FALSE; } @@ -244,7 +244,7 @@ class CI_Loader { return; } - if ($model == '') + if ($model === '') { return; } @@ -261,7 +261,7 @@ class CI_Loader { $model = substr($model, $last_slash); } - if ($name == '') + if (empty($name)) { $name = $model; } @@ -329,7 +329,7 @@ class CI_Loader { $CI =& get_instance(); // Do we even need to load the database class? - if (class_exists('CI_DB') && $return == FALSE && $query_builder == NULL && isset($CI->db) && is_object($CI->db)) + if (class_exists('CI_DB') && $return === FALSE && $query_builder === NULL && isset($CI->db) && is_object($CI->db)) { return FALSE; } @@ -452,7 +452,7 @@ class CI_Loader { */ public function vars($vars = array(), $val = '') { - if ($val != '' && is_string($vars)) + if ($val !== '' && is_string($vars)) { $vars = array($vars => $val); } @@ -642,7 +642,7 @@ class CI_Loader { require BASEPATH.'libraries/Driver.php'; } - if ($library == '') + if ($library === '') { return FALSE; } @@ -714,7 +714,7 @@ class CI_Loader { { $config =& $this->_ci_get_component('config'); - if ($path == '') + if ($path === '') { array_shift($this->_ci_library_paths); array_shift($this->_ci_model_paths); @@ -775,7 +775,7 @@ class CI_Loader { $file_exists = FALSE; // Set the path to the requested file - if ($_ci_path != '') + if (is_string($_ci_path) && $_ci_path !== '') { $_ci_x = explode('/', $_ci_path); $_ci_file = end($_ci_x); @@ -783,7 +783,7 @@ class CI_Loader { else { $_ci_ext = pathinfo($_ci_view, PATHINFO_EXTENSION); - $_ci_file = ($_ci_ext == '') ? $_ci_view.'.php' : $_ci_view; + $_ci_file = ($_ci_ext === '') ? $_ci_view.'.php' : $_ci_view; foreach ($this->_ci_view_paths as $view_file => $cascade) { @@ -847,7 +847,7 @@ class CI_Loader { // If the PHP installation does not support short tags we'll // do a little string replacement, changing the short tags // to standard PHP echo statements. - if ( ! is_php('5.4') && (bool) @ini_get('short_open_tag') === FALSE && config_item('rewrite_short_tags') == TRUE) + if ( ! is_php('5.4') && (bool) @ini_get('short_open_tag') === FALSE && config_item('rewrite_short_tags') === TRUE) { echo eval('?>'.preg_replace('/;*\s*\?>/', '; ?>', str_replace('<?=', '<?php echo ', file_get_contents($_ci_path)))); } @@ -1000,7 +1000,7 @@ class CI_Loader { } // END FOREACH // One last attempt. Maybe the library is in a subdirectory, but it wasn't specified? - if ($subdir == '') + if ($subdir === '') { $path = strtolower($class).'/'.$class; return $this->_ci_load_class($path, $params); @@ -1008,7 +1008,7 @@ class CI_Loader { // If we got this far we were unable to find the requested class. // We do not issue errors if the load call failed due to a duplicate request - if ($is_duplicate == FALSE) + if ($is_duplicate === FALSE) { log_message('error', 'Unable to load the requested class: '.$class); show_error('Unable to load the requested class: '.$class); @@ -1067,7 +1067,7 @@ class CI_Loader { } } - if ($prefix == '') + if ($prefix === '') { if (class_exists('CI_'.$class)) { diff --git a/system/core/Output.php b/system/core/Output.php index c8feb4e67..9b85b3ec4 100755 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -101,7 +101,7 @@ class CI_Output { */ public function __construct() { - $this->_zlib_oc = @ini_get('zlib.output_compression'); + $this->_zlib_oc = (bool) @ini_get('zlib.output_compression'); // Get mime types for later if (defined('ENVIRONMENT') && file_exists(APPPATH.'config/'.ENVIRONMENT.'/mimes.php')) @@ -192,7 +192,7 @@ class CI_Output { // but it will not modify the content-length header to compensate for // the reduction, causing the browser to hang waiting for more data. // We'll just skip content-length in those cases. - if ($this->_zlib_oc && strncasecmp($header, 'content-length', 14) == 0) + if ($this->_zlib_oc && strncasecmp($header, 'content-length', 14) === 0) { return; } @@ -349,7 +349,7 @@ class CI_Output { // -------------------------------------------------------------------- // Set the output data - if ($output == '') + if ($output === '') { $output =& $this->final_output; } @@ -381,7 +381,7 @@ class CI_Output { // -------------------------------------------------------------------- // Is compression requested? - if ($CFG->item('compress_output') === TRUE && $this->_zlib_oc == FALSE + if ($CFG->item('compress_output') === TRUE && $this->_zlib_oc === FALSE && extension_loaded('zlib') && isset($_SERVER['HTTP_ACCEPT_ENCODING']) && strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== FALSE) { @@ -416,7 +416,7 @@ class CI_Output { // Do we need to generate profile data? // If so, load the Profile class and run it. - if ($this->enable_profiler == TRUE) + if ($this->enable_profiler === TRUE) { $CI->load->library('profiler'); if ( ! empty($this->_profiler_sections)) @@ -460,7 +460,7 @@ class CI_Output { { $CI =& get_instance(); $path = $CI->config->item('cache_path'); - $cache_path = ($path == '') ? APPPATH.'cache/' : $path; + $cache_path = ($path === '') ? APPPATH.'cache/' : $path; if ( ! is_dir($cache_path) OR ! is_really_writable($cache_path)) { @@ -505,11 +505,11 @@ class CI_Output { * * @param object config class * @param object uri class - * @return void + * @return bool */ public function _display_cache(&$CFG, &$URI) { - $cache_path = ($CFG->item('cache_path') == '') ? APPPATH.'cache/' : $CFG->item('cache_path'); + $cache_path = ($CFG->item('cache_path') === '') ? APPPATH.'cache/' : $CFG->item('cache_path'); // Build the file path. The file name is an MD5 hash of the full URI $uri = $CFG->item('base_url').$CFG->item('index_page').$URI->uri_string; diff --git a/system/core/Router.php b/system/core/Router.php index 5ea13797b..5bc053045 100755 --- a/system/core/Router.php +++ b/system/core/Router.php @@ -435,7 +435,7 @@ class CI_Router { */ public function fetch_method() { - return ($this->method == $this->fetch_class()) ? 'index' : $this->method; + return ($this->method === $this->fetch_class()) ? 'index' : $this->method; } // -------------------------------------------------------------------- @@ -483,7 +483,7 @@ class CI_Router { $this->set_directory($routing['directory']); } - if (isset($routing['controller']) && $routing['controller'] != '') + if ( ! empty($routing['controller'])) { $this->set_class($routing['controller']); } diff --git a/system/core/Security.php b/system/core/Security.php index 9b7ba5799..4593a1090 100755 --- a/system/core/Security.php +++ b/system/core/Security.php @@ -162,7 +162,7 @@ class CI_Security { // Do the tokens exist in both the _POST and _COOKIE arrays? if ( ! isset($_POST[$this->_csrf_token_name]) OR ! isset($_COOKIE[$this->_csrf_cookie_name]) - OR $_POST[$this->_csrf_token_name] != $_COOKIE[$this->_csrf_cookie_name]) // Do the tokens match? + OR $_POST[$this->_csrf_token_name] !== $_COOKIE[$this->_csrf_cookie_name]) // Do the tokens match? { $this->csrf_show_error(); } @@ -408,7 +408,7 @@ class CI_Security { $str = preg_replace('#<(/*)(script|xss)(.*?)\>#si', '[removed]', $str); } } - while($original != $str); + while($original !== $str); unset($original); @@ -475,7 +475,7 @@ class CI_Security { */ public function xss_hash() { - if ($this->_xss_hash == '') + if ($this->_xss_hash === '') { mt_srand(); $this->_xss_hash = md5(time() + mt_rand(0, 1999999999)); @@ -825,7 +825,7 @@ class CI_Security { */ protected function _csrf_set_hash() { - if ($this->_csrf_hash == '') + if ($this->_csrf_hash === '') { // If the cookie exists we will use it's value. // We don't necessarily want to regenerate it with @@ -847,4 +847,4 @@ class CI_Security { } /* End of file Security.php */ -/* Location: ./system/core/Security.php */ +/* Location: ./system/core/Security.php */
\ No newline at end of file diff --git a/system/core/URI.php b/system/core/URI.php index a9432e05d..a575bc36e 100755 --- a/system/core/URI.php +++ b/system/core/URI.php @@ -111,8 +111,8 @@ class CI_URI { // Is there a PATH_INFO variable? // Note: some servers seem to have trouble with getenv() so we'll test it two ways - $path = (isset($_SERVER['PATH_INFO'])) ? $_SERVER['PATH_INFO'] : @getenv('PATH_INFO'); - if (trim($path, '/') != '' && $path !== '/'.SELF) + $path = isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : @getenv('PATH_INFO'); + if (trim($path, '/') !== '' && $path !== '/'.SELF) { $this->_set_uri_string($path); return; @@ -120,14 +120,14 @@ class CI_URI { // No PATH_INFO?... What about QUERY_STRING? $path = (isset($_SERVER['QUERY_STRING'])) ? $_SERVER['QUERY_STRING'] : @getenv('QUERY_STRING'); - if (trim($path, '/') != '') + if (trim($path, '/') !== '') { $this->_set_uri_string($path); return; } // As a last ditch effort lets try using the $_GET array - if (is_array($_GET) && count($_GET) === 1 && trim(key($_GET), '/') != '') + if (is_array($_GET) && count($_GET) === 1 && trim(key($_GET), '/') !== '') { $this->_set_uri_string(key($_GET)); return; @@ -218,7 +218,7 @@ class CI_URI { $_GET = array(); } - if ($uri == '/' OR empty($uri)) + if ($uri === '/' OR empty($uri)) { return '/'; } @@ -270,7 +270,7 @@ class CI_URI { */ public function _filter_uri($str) { - if ($str != '' && $this->config->item('permitted_uri_chars') != '' && $this->config->item('enable_query_strings') == FALSE) + if ($str !== '' && $this->config->item('permitted_uri_chars') != '' && $this->config->item('enable_query_strings') === FALSE) { // preg_quote() in PHP 5.3 escapes -, so the str_replace() and addition of - to preg_quote() is to maintain backwards // compatibility as many are unaware of how characters in the permitted_uri_chars will be parsed as a regex pattern @@ -298,7 +298,7 @@ class CI_URI { */ public function _remove_url_suffix() { - if ($this->config->item('url_suffix') != '') + if ($this->config->item('url_suffix') !== '') { $this->uri_string = preg_replace('|'.preg_quote($this->config->item('url_suffix')).'$|', '', $this->uri_string); } @@ -321,7 +321,7 @@ class CI_URI { // Filter segments for security $val = trim($this->_filter_uri($val)); - if ($val != '') + if ($val !== '') { $this->segments[] = $val; } diff --git a/system/core/Utf8.php b/system/core/Utf8.php index a6faa84ec..0a7ec501c 100644 --- a/system/core/Utf8.php +++ b/system/core/Utf8.php @@ -54,7 +54,7 @@ class CI_Utf8 { if ( @preg_match('/./u', 'é') === 1 // PCRE must support UTF-8 && function_exists('iconv') // iconv must be installed - && @ini_get('mbstring.func_overload') != 1 // Multibyte string function overloading cannot be enabled + && (bool) @ini_get('mbstring.func_overload') !== TRUE // Multibyte string function overloading cannot be enabled && $CFG->item('charset') === 'UTF-8' // Application charset must be UTF-8 ) { diff --git a/system/database/DB.php b/system/database/DB.php index 1fe44c0e5..00d14b43e 100755 --- a/system/database/DB.php +++ b/system/database/DB.php @@ -53,7 +53,7 @@ function &DB($params = '', $query_builder_override = NULL) show_error('No database connection settings were found in the database config file.'); } - if ($params != '') + if ($params !== '') { $active_group = $params; } @@ -106,7 +106,7 @@ function &DB($params = '', $query_builder_override = NULL) } // No DB specified yet? Beat them senseless... - if ( ! isset($params['dbdriver']) OR $params['dbdriver'] == '') + if (empty($params['dbdriver'])) { show_error('You have not selected a database type to connect to.'); } @@ -128,7 +128,7 @@ function &DB($params = '', $query_builder_override = NULL) require_once(BASEPATH.'database/DB_driver.php'); - if ( ! isset($query_builder) OR $query_builder == TRUE) + if ( ! isset($query_builder) OR $query_builder === TRUE) { require_once(BASEPATH.'database/DB_query_builder.php'); if ( ! class_exists('CI_DB')) @@ -152,12 +152,12 @@ function &DB($params = '', $query_builder_override = NULL) $driver = 'CI_DB_'.$params['dbdriver'].'_driver'; $DB = new $driver($params); - if ($DB->autoinit == TRUE) + if ($DB->autoinit === TRUE) { $DB->initialize(); } - if (isset($params['stricton']) && $params['stricton'] == TRUE) + if ( ! empty($params['stricton'])) { $DB->query('SET SESSION sql_mode="STRICT_ALL_TABLES"'); } diff --git a/system/database/DB_cache.php b/system/database/DB_cache.php index ff942856b..14f3c21bc 100644 --- a/system/database/DB_cache.php +++ b/system/database/DB_cache.php @@ -55,9 +55,9 @@ class CI_DB_Cache { */ public function check_path($path = '') { - if ($path == '') + if ($path === '') { - if ($this->db->cachedir == '') + if ($this->db->cachedir === '') { return $this->db->cache_off(); } @@ -154,12 +154,12 @@ class CI_DB_Cache { */ public function delete($segment_one = '', $segment_two = '') { - if ($segment_one == '') + if ($segment_one === '') { $segment_one = ($this->CI->uri->segment(1) == FALSE) ? 'default' : $this->CI->uri->segment(1); } - if ($segment_two == '') + if ($segment_two === '') { $segment_two = ($this->CI->uri->segment(2) == FALSE) ? 'index' : $this->CI->uri->segment(2); } diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index bbb7b7a80..39c19cdf7 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -113,7 +113,7 @@ abstract class CI_DB_driver { // ---------------------------------------------------------------- // Connect to the database and set the connection ID - $this->conn_id = ($this->pconnect == FALSE) ? $this->db_connect() : $this->db_pconnect(); + $this->conn_id = ($this->pconnect === FALSE) ? $this->db_connect() : $this->db_pconnect(); // No connection resource? Check if there is a failover else throw an error if ( ! $this->conn_id) @@ -131,7 +131,7 @@ abstract class CI_DB_driver { } // Try to connect - $this->conn_id = ($this->pconnect == FALSE) ? $this->db_connect() : $this->db_pconnect(); + $this->conn_id = ($this->pconnect === FALSE) ? $this->db_connect() : $this->db_pconnect(); // If a connection is made break the foreach loop if ($this->conn_id) @@ -297,7 +297,7 @@ abstract class CI_DB_driver { */ public function query($sql, $binds = FALSE, $return_object = TRUE) { - if ($sql == '') + if ($sql === '') { log_message('error', 'Invalid query: '.$sql); @@ -305,7 +305,7 @@ abstract class CI_DB_driver { } // Verify table prefix and replace if necessary - if ($this->dbprefix != '' && $this->swap_pre != '' && $this->dbprefix != $this->swap_pre) + if ($this->dbprefix !== '' && $this->swap_pre !== '' && $this->dbprefix !== $this->swap_pre) { $sql = preg_replace('/(\W)'.$this->swap_pre.'(\S+?)/', '\\1'.$this->dbprefix.'\\2', $sql); } @@ -319,7 +319,7 @@ abstract class CI_DB_driver { // Is query caching enabled? If the query is a "read type" // we will load the caching class and return the previously // cached query if it exists - if ($this->cache_on == TRUE && stripos($sql, 'SELECT') !== FALSE && $this->_cache_init()) + if ($this->cache_on === TRUE && stripos($sql, 'SELECT') !== FALSE && $this->_cache_init()) { $this->load_rdriver(); if (FALSE !== ($cache = $this->CACHE->read($sql))) @@ -329,7 +329,7 @@ abstract class CI_DB_driver { } // Save the query for debugging - if ($this->save_queries == TRUE) + if ($this->save_queries === TRUE) { $this->queries[] = $sql; } @@ -340,7 +340,7 @@ abstract class CI_DB_driver { // Run the Query if (FALSE === ($this->result_id = $this->simple_query($sql))) { - if ($this->save_queries == TRUE) + if ($this->save_queries === TRUE) { $this->query_times[] = 0; } @@ -373,7 +373,7 @@ abstract class CI_DB_driver { $time_end = microtime(TRUE); $this->benchmark += $time_end - $time_start; - if ($this->save_queries == TRUE) + if ($this->save_queries === TRUE) { $this->query_times[] = $time_end - $time_start; } @@ -387,7 +387,7 @@ abstract class CI_DB_driver { { // If caching is enabled we'll auto-cleanup any // existing files related to this particular URI - if ($this->cache_on == TRUE && $this->cache_autodel == TRUE && $this->_cache_init()) + if ($this->cache_on === TRUE && $this->cache_autodel === TRUE && $this->_cache_init()) { $this->CACHE->delete(); } @@ -409,7 +409,7 @@ abstract class CI_DB_driver { // Is query caching enabled? If so, we'll serialize the // result object and save it to a cache file. - if ($this->cache_on == TRUE && $this->_cache_init()) + if ($this->cache_on === TRUE && $this->_cache_init()) { // We'll create a new instance of the result object // only without the platform specific driver since @@ -752,13 +752,13 @@ abstract class CI_DB_driver { */ public function count_all($table = '') { - if ($table == '') + if ($table === '') { return 0; } $query = $this->query($this->_count_string.$this->escape_identifiers('numrows').' FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE)); - if ($query->num_rows() == 0) + if ($query->num_rows() === 0) { return 0; } @@ -850,7 +850,7 @@ abstract class CI_DB_driver { return $this->data_cache['field_names'][$table]; } - if ($table == '') + if ($table === '') { return ($this->db_debug) ? $this->display_error('db_field_param_missing') : FALSE; } @@ -918,7 +918,7 @@ abstract class CI_DB_driver { */ public function field_data($table = '') { - if ($table == '') + if ($table === '') { return ($this->db_debug) ? $this->display_error('db_field_param_missing') : FALSE; } @@ -939,7 +939,7 @@ abstract class CI_DB_driver { */ public function escape_identifiers($item) { - if ($this->_escape_char == '') + if ($this->_escape_char === '') { return $item; } @@ -998,7 +998,7 @@ abstract class CI_DB_driver { */ public function update_string($table, $data, $where) { - if ($where == '') + if ($where === '') { return FALSE; } @@ -1018,7 +1018,7 @@ abstract class CI_DB_driver { $dest = array(); foreach ($where as $key => $val) { - $prefix = (count($dest) == 0) ? '' : ' AND '; + $prefix = (count($dest) === 0) ? '' : ' AND '; $key = $this->protect_identifiers($key); if ($val !== '') @@ -1062,7 +1062,7 @@ abstract class CI_DB_driver { */ public function call_function($function) { - $driver = ($this->dbdriver == 'postgre') ? 'pg_' : $this->dbdriver.'_'; + $driver = ($this->dbdriver === 'postgre') ? 'pg_' : $this->dbdriver.'_'; if (FALSE === strpos($driver, $function)) { @@ -1217,7 +1217,7 @@ abstract class CI_DB_driver { $heading = $LANG->line('db_error_heading'); - if ($native == TRUE) + if ($native === TRUE) { $message = (array) $error; } @@ -1345,7 +1345,7 @@ abstract class CI_DB_driver { } // Is there a table prefix defined in the config file? If not, no need to do anything - if ($this->dbprefix != '') + if ($this->dbprefix !== '') { // We now add the table prefix based on some logic. // Do we have 4 segments (hostname.database.table.column)? @@ -1369,13 +1369,13 @@ abstract class CI_DB_driver { // This flag is set when the supplied $item does not contain a field name. // This can happen when this function is being called from a JOIN. - if ($field_exists == FALSE) + if ($field_exists === FALSE) { $i++; } // Verify table prefix and replace if necessary - if ($this->swap_pre != '' && strpos($parts[$i], $this->swap_pre) === 0) + if ($this->swap_pre !== '' && strpos($parts[$i], $this->swap_pre) === 0) { $parts[$i] = preg_replace('/^'.$this->swap_pre.'(\S+?)/', $this->dbprefix.'\\1', $parts[$i]); } @@ -1398,15 +1398,15 @@ abstract class CI_DB_driver { } // Is there a table prefix? If not, no need to insert it - if ($this->dbprefix != '') + if ($this->dbprefix !== '') { // Verify table prefix and replace if necessary - if ($this->swap_pre != '' && strpos($item, $this->swap_pre) === 0) + if ($this->swap_pre !== '' && strpos($item, $this->swap_pre) === 0) { $item = preg_replace('/^'.$this->swap_pre.'(\S+?)/', $this->dbprefix.'\\1', $item); } // Do we prefix an item with no segments? - elseif ($prefix_single == TRUE && strpos($item, $this->dbprefix) !== 0) + elseif ($prefix_single === TRUE && strpos($item, $this->dbprefix) !== 0) { $item = $this->dbprefix.$item; } diff --git a/system/database/DB_forge.php b/system/database/DB_forge.php index a519575f0..ff5eb3fe6 100644 --- a/system/database/DB_forge.php +++ b/system/database/DB_forge.php @@ -85,7 +85,7 @@ abstract class CI_DB_forge { */ public function drop_database($db_name) { - if ($db_name == '') + if ($db_name === '') { show_error('A table name is required for that operation.'); return FALSE; @@ -123,7 +123,7 @@ abstract class CI_DB_forge { return; } - if ($key == '') + if ($key === '') { show_error('Key information is required for that operation.'); } @@ -150,7 +150,7 @@ abstract class CI_DB_forge { */ public function add_field($field = '') { - if ($field == '') + if ($field === '') { show_error('Field information is required.'); } @@ -197,7 +197,7 @@ abstract class CI_DB_forge { */ public function create_table($table = '', $if_not_exists = FALSE) { - if ($table == '') + if ($table === '') { show_error('A table name is required for that operation.'); } @@ -222,7 +222,7 @@ abstract class CI_DB_forge { */ public function drop_table($table_name) { - if ($table_name == '') + if ($table_name === '') { return ($this->db->db_debug) ? $this->db->display_error('db_table_name_required') : FALSE; } @@ -245,7 +245,7 @@ abstract class CI_DB_forge { */ public function rename_table($table_name, $new_table_name) { - if ($table_name == '' OR $new_table_name == '') + if ($table_name === '' OR $new_table_name === '') { show_error('A table name is required for that operation.'); return FALSE; @@ -273,7 +273,7 @@ abstract class CI_DB_forge { */ public function add_column($table = '', $field = array(), $after_field = '') { - if ($table == '') + if ($table === '') { show_error('A table name is required for that operation.'); } @@ -284,7 +284,7 @@ abstract class CI_DB_forge { { $this->add_field(array($k => $field[$k])); - if (count($this->fields) == 0) + if (count($this->fields) === 0) { show_error('Field information is required.'); } @@ -312,12 +312,12 @@ abstract class CI_DB_forge { */ public function drop_column($table = '', $column_name = '') { - if ($table == '') + if ($table === '') { show_error('A table name is required for that operation.'); } - if ($column_name == '') + if ($column_name === '') { show_error('A column name is required for that operation.'); } @@ -337,7 +337,7 @@ abstract class CI_DB_forge { */ public function modify_column($table = '', $field = array()) { - if ($table == '') + if ($table === '') { show_error('A table name is required for that operation.'); } diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php index cee4354e9..7a0ea0c30 100644 --- a/system/database/DB_query_builder.php +++ b/system/database/DB_query_builder.php @@ -97,7 +97,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { { $val = trim($val); - if ($val != '') + if ($val !== '') { $this->qb_select[] = $val; $this->qb_no_escape[] = $escape; @@ -194,7 +194,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { */ protected function _max_min_avg_sum($select = '', $alias = '', $type = 'MAX') { - if ( ! is_string($select) OR $select == '') + if ( ! is_string($select) OR $select === '') { $this->display_error('db_invalid_query'); } @@ -206,7 +206,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { show_error('Invalid function type: '.$type); } - if ($alias == '') + if ($alias === '') { $alias = $this->_create_alias_from_table(trim($select)); } @@ -325,7 +325,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { */ public function join($table, $cond, $type = '') { - if ($type != '') + if ($type !== '') { $type = strtoupper(trim($type)); @@ -675,23 +675,23 @@ abstract class CI_DB_query_builder extends CI_DB_driver { if ($side === 'none') { - $like_statement = $prefix." $k $not LIKE '{$v}'"; + $like_statement = "{$prefix} $k $not LIKE '{$v}'"; } elseif ($side === 'before') { - $like_statement = $prefix." $k $not LIKE '%{$v}'"; + $like_statement = "{$prefix} $k $not LIKE '%{$v}'"; } elseif ($side === 'after') { - $like_statement = $prefix." $k $not LIKE '{$v}%'"; + $like_statement = "{$prefix} $k $not LIKE '{$v}%'"; } else { - $like_statement = $prefix." $k $not LIKE '%{$v}%'"; + $like_statement = "{$prefix} $k $not LIKE '%{$v}%'"; } // some platforms require an escape sequence definition for LIKE wildcards - if ($this->_like_escape_str != '') + if ($this->_like_escape_str !== '') { $like_statement = $like_statement.sprintf($this->_like_escape_str, $this->_like_escape_chr); } @@ -829,7 +829,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { { $val = trim($val); - if ($val != '') + if ($val !== '') { $this->qb_groupby[] = $val = $this->protect_identifiers($val); @@ -908,7 +908,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { $k .= ' = '; } - if ($v != '') + if ($v !== '') { $v = ' '.$this->escape($v); } @@ -941,7 +941,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { $orderby = ''; // Random results want or don't need a field name $direction = $this->_random_keyword; } - elseif (trim($direction) != '') + elseif (trim($direction) !== '') { $direction = (in_array(strtoupper(trim($direction)), array('ASC', 'DESC'), TRUE)) ? ' '.$direction : ' ASC'; } @@ -963,7 +963,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { $orderby = implode(', ', $temp); } - elseif ($direction != $this->_random_keyword) + elseif ($direction !== $this->_random_keyword) { if ($escape === TRUE) { @@ -1064,7 +1064,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { */ public function get_compiled_select($table = '', $reset = TRUE) { - if ($table != '') + if ($table !== '') { $this->_track_aliases($table); $this->from($table); @@ -1095,7 +1095,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { */ public function get($table = '', $limit = null, $offset = null) { - if ($table != '') + if ($table !== '') { $this->_track_aliases($table); $this->from($table); @@ -1124,7 +1124,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { */ public function count_all_results($table = '') { - if ($table != '') + if ($table !== '') { $this->_track_aliases($table); $this->from($table); @@ -1156,7 +1156,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { */ public function get_where($table = '', $where = null, $limit = null, $offset = null) { - if ($table != '') + if ($table !== '') { $this->from($table); } @@ -1204,7 +1204,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { return FALSE; } - if ($table == '') + if ($table === '') { if ( ! isset($this->qb_from[0])) { @@ -1404,7 +1404,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { return ($this->db_debug) ? $this->display_error('db_must_use_set') : FALSE; } - if ($table != '') + if ($table !== '') { $this->qb_from[0] = $table; } @@ -1439,7 +1439,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { return ($this->db_debug) ? $this->display_error('db_must_use_set') : FALSE; } - if ($table == '') + if ($table === '') { if ( ! isset($this->qb_from[0])) { @@ -1530,7 +1530,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { return FALSE; } - if ($where != NULL) + if ($where !== NULL) { $this->where($where); } @@ -1595,12 +1595,12 @@ abstract class CI_DB_query_builder extends CI_DB_driver { */ protected function _validate_update($table = '') { - if (count($this->qb_set) == 0) + if (count($this->qb_set) === 0) { return ($this->db_debug) ? $this->display_error('db_must_use_set') : FALSE; } - if ($table != '') + if ($table !== '') { $this->qb_from[0] = $table; } @@ -1644,7 +1644,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { return ($this->db_debug) ? $this->display_error('db_must_use_set') : FALSE; } - if ($table == '') + if ($table === '') { if ( ! isset($this->qb_from[0])) { @@ -1689,7 +1689,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { $clean = array(); foreach ($v as $k2 => $v2) { - if ($k2 == $index) + if ($k2 === $index) { $index_set = TRUE; } @@ -1720,7 +1720,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { */ public function empty_table($table = '') { - if ($table == '') + if ($table === '') { if ( ! isset($this->qb_from[0])) { @@ -1753,7 +1753,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { */ public function truncate($table = '') { - if ($table == '') + if ($table === '') { if ( ! isset($this->qb_from[0])) { @@ -1827,7 +1827,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { // Combine any cached components with the current statements $this->_merge_cache(); - if ($table == '') + if ($table === '') { if ( ! isset($this->qb_from[0])) { @@ -1851,7 +1851,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { $table = $this->protect_identifiers($table, TRUE, NULL, FALSE); } - if ($where != '') + if ($where !== '') { $this->where($where); } @@ -1912,7 +1912,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { */ public function dbprefix($table = '') { - if ($table == '') + if ($table === '') { $this->display_error('db_table_name_required'); } @@ -2072,7 +2072,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { $sql .= "\nORDER BY ".implode(', ', $this->qb_orderby); if ($this->qb_order !== FALSE) { - $sql .= ($this->qb_order == 'desc') ? ' DESC' : ' ASC'; + $sql .= ($this->qb_order === 'desc') ? ' DESC' : ' ASC'; } } @@ -2106,7 +2106,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { foreach (get_object_vars($object) as $key => $val) { // There are some built in keys we need to ignore for this conversion - if ( ! is_object($val) && ! is_array($val) && $key != '_parent_name') + if ( ! is_object($val) && ! is_array($val) && $key !== '_parent_name') { $array[$key] = $val; } diff --git a/system/database/DB_result.php b/system/database/DB_result.php index 334e08c72..991f6ba94 100644 --- a/system/database/DB_result.php +++ b/system/database/DB_result.php @@ -81,7 +81,7 @@ class CI_DB_result { return $this->custom_result_object[$class_name]; } - if ($this->result_id === FALSE OR $this->num_rows() == 0) + if ($this->result_id === FALSE OR $this->num_rows() === 0) { return array(); } @@ -122,7 +122,7 @@ class CI_DB_result { // In the event that query caching is on the result_id variable // will return FALSE since there isn't a valid SQL resource so // we'll simply return an empty array. - if ($this->result_id === FALSE OR $this->num_rows() == 0) + if ($this->result_id === FALSE OR $this->num_rows() === 0) { return array(); } @@ -153,7 +153,7 @@ class CI_DB_result { // In the event that query caching is on the result_id variable // will return FALSE since there isn't a valid SQL resource so // we'll simply return an empty array. - if ($this->result_id === FALSE OR $this->num_rows() == 0) + if ($this->result_id === FALSE OR $this->num_rows() === 0) { return array(); } @@ -224,7 +224,7 @@ class CI_DB_result { return; } - if ($key != '' && ! is_null($value)) + if ($key !== '' && ! is_null($value)) { $this->row_data[$key] = $value; } @@ -245,7 +245,7 @@ class CI_DB_result { return NULL; } - if ($n != $this->current_row && isset($result[$n])) + if ($n !== $this->current_row && isset($result[$n])) { $this->current_row = $n; } @@ -268,7 +268,7 @@ class CI_DB_result { return NULL; } - if ($n != $this->current_row && isset($result[$n])) + if ($n !== $this->current_row && isset($result[$n])) { $this->current_row = $n; } @@ -291,7 +291,7 @@ class CI_DB_result { return NULL; } - if ($n != $this->current_row && isset($result[$n])) + if ($n !== $this->current_row && isset($result[$n])) { $this->current_row = $n; } diff --git a/system/database/DB_utility.php b/system/database/DB_utility.php index cb97ff448..02c921834 100644 --- a/system/database/DB_utility.php +++ b/system/database/DB_utility.php @@ -343,7 +343,7 @@ abstract class CI_DB_utility extends CI_DB_forge { if ($prefs['format'] === 'zip') { // Set the filename if not provided (only needed with Zip files) - if ($prefs['filename'] == '') + if ($prefs['filename'] === '') { $prefs['filename'] = (count($prefs['tables']) === 1 ? $prefs['tables'] : $this->db->database) .date('Y-m-d_H-i', time()).'.sql'; @@ -369,7 +369,7 @@ abstract class CI_DB_utility extends CI_DB_forge { $CI->zip->add_data($prefs['filename'], $this->_backup($prefs)); return $CI->zip->get_zip(); } - elseif ($prefs['format'] == 'txt') // Was a text file requested? + elseif ($prefs['format'] === 'txt') // Was a text file requested? { return $this->_backup($prefs); } diff --git a/system/database/drivers/cubrid/cubrid_driver.php b/system/database/drivers/cubrid/cubrid_driver.php index 817dfdc98..6b9286fa0 100644 --- a/system/database/drivers/cubrid/cubrid_driver.php +++ b/system/database/drivers/cubrid/cubrid_driver.php @@ -74,7 +74,7 @@ class CI_DB_cubrid_driver extends CI_DB { else { // If no port is defined by the user, use the default value - $this->port == '' OR $this->port = 33000; + empty($this->port) OR $this->port = 33000; } } @@ -340,7 +340,7 @@ class CI_DB_cubrid_driver extends CI_DB { { $sql = 'SHOW TABLES'; - if ($prefix_limit !== FALSE && $this->dbprefix != '') + if ($prefix_limit !== FALSE && $this->dbprefix !== '') { return $sql." LIKE '".$this->escape_like_str($this->dbprefix)."%'"; } @@ -435,7 +435,7 @@ class CI_DB_cubrid_driver extends CI_DB { foreach (array_keys($val) as $field) { - if ($field != $index) + if ($field !== $index) { $final[$field][] = 'WHEN '.$index.' = '.$val[$index].' THEN '.$val[$field]; } @@ -451,7 +451,7 @@ class CI_DB_cubrid_driver extends CI_DB { } return 'UPDATE '.$table.' SET '.substr($cases, 0, -2) - .' WHERE '.(($where != '' && count($where) > 0) ? implode(' ', $where).' AND ' : '') + .' WHERE '.(($where !== '' && count($where) > 0) ? implode(' ', $where).' AND ' : '') .$index.' IN ('.implode(',', $ids).')'; } diff --git a/system/database/drivers/cubrid/cubrid_forge.php b/system/database/drivers/cubrid/cubrid_forge.php index 4e66f81e3..fb9716226 100644 --- a/system/database/drivers/cubrid/cubrid_forge.php +++ b/system/database/drivers/cubrid/cubrid_forge.php @@ -193,7 +193,7 @@ class CI_DB_cubrid_forge extends CI_DB_forge { } return $sql.$this->_process_fields($fields) - .($after_field != '' ? ' AFTER '.$this->db->protect_identifiers($after_field) : ''); + .($after_field !== '' ? ' AFTER '.$this->db->protect_identifiers($after_field) : ''); } } diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php index 49d3cda87..8cbbfa17d 100644 --- a/system/database/drivers/interbase/interbase_driver.php +++ b/system/database/drivers/interbase/interbase_driver.php @@ -255,7 +255,7 @@ class CI_DB_interbase_driver extends CI_DB { { $sql = 'SELECT "RDB$RELATION_NAME" FROM "RDB$RELATIONS" WHERE "RDB$RELATION_NAME" NOT LIKE \'RDB$%\' AND "RDB$RELATION_NAME" NOT LIKE \'MON$%\''; - if ($prefix_limit !== FALSE && $this->dbprefix != '') + if ($prefix_limit !== FALSE && $this->dbprefix !== '') { return $sql.' AND "RDB$RELATION_NAME" LIKE \''.$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr); } diff --git a/system/database/drivers/interbase/interbase_forge.php b/system/database/drivers/interbase/interbase_forge.php index c850656a8..5470179a1 100644 --- a/system/database/drivers/interbase/interbase_forge.php +++ b/system/database/drivers/interbase/interbase_forge.php @@ -195,7 +195,7 @@ class CI_DB_interbase_forge extends CI_DB_forge { $sql .= " {$column_definition}"; - if ($default_value != '') + if ($default_value !== '') { $sql .= " DEFAULT \"{$default_value}\""; } @@ -209,7 +209,7 @@ class CI_DB_interbase_forge extends CI_DB_forge { $sql .= ' NOT NULL'; } - if ($after_field != '') + if ($after_field !== '') { $sql .= ' AFTER ' . $this->db->protect_identifiers($after_field); } diff --git a/system/database/drivers/mssql/mssql_driver.php b/system/database/drivers/mssql/mssql_driver.php index 342ff2647..697b2fd28 100644 --- a/system/database/drivers/mssql/mssql_driver.php +++ b/system/database/drivers/mssql/mssql_driver.php @@ -64,7 +64,7 @@ class CI_DB_mssql_driver extends CI_DB { */ public function db_connect() { - if ($this->port != '') + if ( ! empty($this->port)) { $this->hostname .= ','.$this->port; } @@ -81,7 +81,7 @@ class CI_DB_mssql_driver extends CI_DB { */ public function db_pconnect() { - if ($this->port != '') + if ( ! empty($this->port)) { $this->hostname .= ','.$this->port; } @@ -316,7 +316,7 @@ class CI_DB_mssql_driver extends CI_DB { $sql = "SELECT name FROM sysobjects WHERE type = 'U' ORDER BY name"; // for future compatibility - if ($prefix_limit !== FALSE AND $this->dbprefix != '') + if ($prefix_limit !== FALSE AND $this->dbprefix !== '') { //$sql .= " LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr); return FALSE; // not currently supported diff --git a/system/database/drivers/mssql/mssql_forge.php b/system/database/drivers/mssql/mssql_forge.php index bbf2d9685..3708c2233 100644 --- a/system/database/drivers/mssql/mssql_forge.php +++ b/system/database/drivers/mssql/mssql_forge.php @@ -155,21 +155,21 @@ class CI_DB_mssql_forge extends CI_DB_forge { $sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '.$this->db->protect_identifiers($column_name); // DROP has everything it needs now. - if ($alter_type == 'DROP') + if ($alter_type === 'DROP') { return $sql; } $sql .= " ".$column_definition; - if ($default_value != '') + if ($default_value !== '') { $sql .= " DEFAULT '".$default_value."'"; } $sql .= ($null === NULL) ? ' NULL' : ' NOT NULL'; - if ($after_field != '') + if ($after_field !== '') { return $sql.' AFTER '.$this->db->protect_identifiers($after_field); } diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php index 7a1a7b9a2..5937b223b 100644 --- a/system/database/drivers/mysql/mysql_driver.php +++ b/system/database/drivers/mysql/mysql_driver.php @@ -68,7 +68,7 @@ class CI_DB_mysql_driver extends CI_DB { { parent::__construct($params); - if ($this->port != '') + if ( ! empty($this->port)) { $this->hostname .= ':'.$this->port; } @@ -337,7 +337,7 @@ class CI_DB_mysql_driver extends CI_DB { { $sql = 'SHOW TABLES FROM '.$this->_escape_char.$this->database.$this->_escape_char; - if ($prefix_limit !== FALSE && $this->dbprefix != '') + if ($prefix_limit !== FALSE && $this->dbprefix !== '') { return $sql." LIKE '".$this->escape_like_str($this->dbprefix)."%'"; } @@ -370,7 +370,7 @@ class CI_DB_mysql_driver extends CI_DB { */ public function field_data($table = '') { - if ($table == '') + if ($table === '') { return ($this->db_debug) ? $this->display_error('db_field_param_missing') : FALSE; } @@ -451,7 +451,7 @@ class CI_DB_mysql_driver extends CI_DB { foreach (array_keys($val) as $field) { - if ($field != $index) + if ($field !== $index) { $final[$field][] = 'WHEN '.$index.' = '.$val[$index].' THEN '.$val[$field]; } @@ -467,7 +467,7 @@ class CI_DB_mysql_driver extends CI_DB { } return 'UPDATE '.$table.' SET '.substr($cases, 0, -2) - .' WHERE '.(($where != '' && count($where) > 0) ? implode(' ', $where).' AND ' : '') + .' WHERE '.(($where !== '' && count($where) > 0) ? implode(' ', $where).' AND ' : '') .$index.' IN('.implode(',', $ids).')'; } diff --git a/system/database/drivers/mysql/mysql_forge.php b/system/database/drivers/mysql/mysql_forge.php index 0e39affa7..ffd374fbf 100644 --- a/system/database/drivers/mysql/mysql_forge.php +++ b/system/database/drivers/mysql/mysql_forge.php @@ -178,7 +178,7 @@ class CI_DB_mysql_forge extends CI_DB_forge { } return $sql.$this->_process_fields($fields) - .($after_field != '' ? ' AFTER '.$this->db->protect_identifiers($after_field) : ''); + .($after_field !== '' ? ' AFTER '.$this->db->protect_identifiers($after_field) : ''); } } diff --git a/system/database/drivers/mysql/mysql_utility.php b/system/database/drivers/mysql/mysql_utility.php index 642323dbd..643682fde 100644 --- a/system/database/drivers/mysql/mysql_utility.php +++ b/system/database/drivers/mysql/mysql_utility.php @@ -76,7 +76,7 @@ class CI_DB_mysql_utility extends CI_DB_utility { // Write out the table schema $output .= '#'.$newline.'# TABLE STRUCTURE FOR: '.$table.$newline.'#'.$newline.$newline; - if ($add_drop == TRUE) + if ($add_drop === TRUE) { $output .= 'DROP TABLE IF EXISTS '.$this->db->protect_identifiers($table).';'.$newline.$newline; } @@ -92,7 +92,7 @@ class CI_DB_mysql_utility extends CI_DB_utility { } // If inserts are not needed we're done... - if ($add_insert == FALSE) + if ($add_insert === FALSE) { continue; } @@ -100,7 +100,7 @@ class CI_DB_mysql_utility extends CI_DB_utility { // Grab all the data from the current table $query = $this->db->query('SELECT * FROM '.$this->db->protect_identifiers($table)); - if ($query->num_rows() == 0) + if ($query->num_rows() === 0) { continue; } @@ -143,7 +143,7 @@ class CI_DB_mysql_utility extends CI_DB_utility { else { // Escape the data if it's not an integer - $val_str .= ($is_int[$i] == FALSE) ? $this->db->escape($v) : $v; + $val_str .= ($is_int[$i] === FALSE) ? $this->db->escape($v) : $v; } // Append a comma diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php index dd544f686..02f893755 100644 --- a/system/database/drivers/mysqli/mysqli_driver.php +++ b/system/database/drivers/mysqli/mysqli_driver.php @@ -71,9 +71,9 @@ class CI_DB_mysqli_driver extends CI_DB { */ public function db_connect() { - return ($this->port != '') - ? @new mysqli($this->hostname, $this->username, $this->password, $this->database, $this->port) - : @new mysqli($this->hostname, $this->username, $this->password, $this->database); + return empty($this->port) + ? @new mysqli($this->hostname, $this->username, $this->password, $this->database) + : @new mysqli($this->hostname, $this->username, $this->password, $this->database, $this->port); } // -------------------------------------------------------------------- @@ -91,9 +91,9 @@ class CI_DB_mysqli_driver extends CI_DB { return $this->db_connect(); } - return ($this->port != '') - ? @new mysqli('p:'.$this->hostname, $this->username, $this->password, $this->database, $this->port) - : @new mysqli('p:'.$this->hostname, $this->username, $this->password, $this->database); + return empty($this->port) + ? @new mysqli('p:'.$this->hostname, $this->username, $this->password, $this->database) + : @new mysqli('p:'.$this->hostname, $this->username, $this->password, $this->database, $this->port); } // -------------------------------------------------------------------- @@ -337,7 +337,7 @@ class CI_DB_mysqli_driver extends CI_DB { { $sql = 'SHOW TABLES FROM '.$this->_escape_char.$this->database.$this->_escape_char; - if ($prefix_limit !== FALSE && $this->dbprefix != '') + if ($prefix_limit !== FALSE && $this->dbprefix !== '') { return $sql." LIKE '".$this->escape_like_str($this->dbprefix)."%'"; } @@ -370,7 +370,7 @@ class CI_DB_mysqli_driver extends CI_DB { */ public function field_data($table = '') { - if ($table == '') + if ($table === '') { return ($this->db_debug) ? $this->display_error('db_field_param_missing') : FALSE; } @@ -451,7 +451,7 @@ class CI_DB_mysqli_driver extends CI_DB { foreach (array_keys($val) as $field) { - if ($field != $index) + if ($field !== $index) { $final[$field][] = 'WHEN '.$index.' = '.$val[$index].' THEN '.$val[$field]; } @@ -466,10 +466,10 @@ class CI_DB_mysqli_driver extends CI_DB { .'ELSE '.$k.' END, '; } - $where = ($where != '' && count($where) > 0) ? implode(' ', $where).' AND ' : ''; + $where = ($where !== '' && count($where) > 0) ? implode(' ', $where).' AND ' : ''; return 'UPDATE '.$table.' SET '.substr($cases, 0, -2) - .' WHERE '.(($where != '' && count($where) > 0) ? implode(' ', $where).' AND ' : '') + .' WHERE '.(($where !== '' && count($where) > 0) ? implode(' ', $where).' AND ' : '') .$index.' IN('.implode(',', $ids).')'; } diff --git a/system/database/drivers/mysqli/mysqli_forge.php b/system/database/drivers/mysqli/mysqli_forge.php index 503574dfc..b00bfde49 100644 --- a/system/database/drivers/mysqli/mysqli_forge.php +++ b/system/database/drivers/mysqli/mysqli_forge.php @@ -179,7 +179,7 @@ class CI_DB_mysqli_forge extends CI_DB_forge { } return $sql.$this->_process_fields($fields) - .($after_field != '' ? ' AFTER '.$this->db->protect_identifiers($after_field) : ''); + .($after_field !== '' ? ' AFTER '.$this->db->protect_identifiers($after_field) : ''); } } diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php index b979c8a17..e78091614 100644 --- a/system/database/drivers/oci8/oci8_driver.php +++ b/system/database/drivers/oci8/oci8_driver.php @@ -262,7 +262,7 @@ class CI_DB_oci8_driver extends CI_DB { */ public function stored_procedure($package, $procedure, $params) { - if ($package == '' OR $procedure == '' OR ! is_array($params)) + if ($package === '' OR $procedure === '' OR ! is_array($params)) { if ($this->db_debug) { @@ -466,7 +466,7 @@ class CI_DB_oci8_driver extends CI_DB { { $sql = 'SELECT TABLE_NAME FROM ALL_TABLES'; - if ($prefix_limit !== FALSE && $this->dbprefix != '') + if ($prefix_limit !== FALSE && $this->dbprefix !== '') { return $sql." WHERE TABLE_NAME LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr); } @@ -634,7 +634,7 @@ class CI_DB_oci8_driver extends CI_DB { { $this->limit_used = TRUE; return 'SELECT * FROM (SELECT inner_query.*, rownum rnum FROM ('.$sql.') inner_query WHERE rownum < '.($offset + $limit).')' - .($offset != 0 ? ' WHERE rnum >= '.$offset : ''); + .($offset !== 0 ? ' WHERE rnum >= '.$offset : ''); } // -------------------------------------------------------------------- diff --git a/system/database/drivers/oci8/oci8_forge.php b/system/database/drivers/oci8/oci8_forge.php index bd265b6e0..837e7eaad 100644 --- a/system/database/drivers/oci8/oci8_forge.php +++ b/system/database/drivers/oci8/oci8_forge.php @@ -141,9 +141,9 @@ class CI_DB_oci8_forge extends CI_DB_forge { } return $sql.' '.$column_definition - .($default_value != '' ? ' DEFAULT "'.$default_value.'"' : '') + .($default_value !== '' ? ' DEFAULT "'.$default_value.'"' : '') .($null === NULL ? ' NULL' : ' NOT NULL') - .($after_field != '' ? ' AFTER '.$this->db->protect_identifiers($after_field) : ''); + .($after_field !== '' ? ' AFTER '.$this->db->protect_identifiers($after_field) : ''); } diff --git a/system/database/drivers/odbc/odbc_driver.php b/system/database/drivers/odbc/odbc_driver.php index 98fd806a8..c3735da05 100644 --- a/system/database/drivers/odbc/odbc_driver.php +++ b/system/database/drivers/odbc/odbc_driver.php @@ -64,7 +64,7 @@ class CI_DB_odbc_driver extends CI_DB { $this->_random_keyword = ' RND('.time().')'; // database specific random keyword // Legacy support for DSN in the hostname field - if ($this->dsn == '') + if (empty($this->dsn)) { $this->dsn = $this->hostname; } @@ -254,9 +254,9 @@ class CI_DB_odbc_driver extends CI_DB { */ protected function _list_tables($prefix_limit = FALSE) { - $sql = "SHOW TABLES FROM `".$this->database."`"; + $sql = 'SHOW TABLES FROM '.$this->database; - if ($prefix_limit !== FALSE AND $this->dbprefix != '') + if ($prefix_limit !== FALSE && $this->dbprefix !== '') { //$sql .= " LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr); return FALSE; // not currently supported diff --git a/system/database/drivers/odbc/odbc_forge.php b/system/database/drivers/odbc/odbc_forge.php index d59b8a911..ce7a1d2ef 100644 --- a/system/database/drivers/odbc/odbc_forge.php +++ b/system/database/drivers/odbc/odbc_forge.php @@ -163,14 +163,14 @@ class CI_DB_odbc_forge extends CI_DB_forge { $sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '.$this->db->protect_identifiers($column_name); // DROP has everything it needs now. - if ($alter_type == 'DROP') + if ($alter_type === 'DROP') { return $sql; } $sql .= " $column_definition"; - if ($default_value != '') + if ($default_value !== '') { $sql .= " DEFAULT \"$default_value\""; } @@ -184,7 +184,7 @@ class CI_DB_odbc_forge extends CI_DB_forge { $sql .= ' NOT NULL'; } - if ($after_field != '') + if ($after_field !== '') { return $sql.' AFTER '.$this->db->protect_identifiers($after_field); } diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php index ec7f3e19b..b4ad52a45 100644 --- a/system/database/drivers/pdo/pdo_driver.php +++ b/system/database/drivers/pdo/pdo_driver.php @@ -65,7 +65,7 @@ class CI_DB_pdo_driver extends CI_DB { { parent::__construct($params); - if (preg_match('/([^;]+):/', $this->dsn, $match) && count($match) == 2) + if (preg_match('/([^;]+):/', $this->dsn, $match) && count($match) === 2) { // If there is a minimum valid dsn string pattern found, we're done // This is for general PDO users, who tend to have a full DSN string. @@ -418,12 +418,12 @@ class CI_DB_pdo_driver extends CI_DB { */ protected function _list_tables($prefix_limit = FALSE) { - if ($this->pdodriver == 'pgsql') + if ($this->pdodriver === 'pgsql') { // Analog function to show all tables in postgre $sql = "SELECT * FROM information_schema.tables WHERE table_schema = 'public'"; } - elseif ($this->pdodriver == 'sqlite') + elseif ($this->pdodriver === 'sqlite') { // Analog function to show all tables in sqlite $sql = "SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%'"; @@ -433,7 +433,7 @@ class CI_DB_pdo_driver extends CI_DB { $sql = 'SHOW TABLES FROM '.$this->escape_identifiers($this->database); } - if ($prefix_limit !== FALSE AND $this->dbprefix != '') + if ($prefix_limit !== FALSE AND $this->dbprefix !== '') { return FALSE; } @@ -468,17 +468,17 @@ class CI_DB_pdo_driver extends CI_DB { */ protected function _field_data($table) { - if ($this->pdodriver == 'mysql' or $this->pdodriver == 'pgsql') + if ($this->pdodriver === 'mysql' or $this->pdodriver === 'pgsql') { // Analog function for mysql and postgre return 'SELECT * FROM '.$this->escape_identifiers($table).' LIMIT 1'; } - elseif ($this->pdodriver == 'oci') + elseif ($this->pdodriver === 'oci') { // Analog function for oci return 'SELECT * FROM '.$this->escape_identifiers($table).' WHERE ROWNUM <= 1'; } - elseif ($this->pdodriver == 'sqlite') + elseif ($this->pdodriver === 'sqlite') { // Analog function for sqlite return 'PRAGMA table_info('.$this->escape_identifiers($table).')'; @@ -552,7 +552,7 @@ class CI_DB_pdo_driver extends CI_DB { protected function _update_batch($table, $values, $index, $where = NULL) { $ids = array(); - $where = ($where != '' && count($where) >=1) ? implode(" ", $where).' AND ' : ''; + $where = ($where !== '' && count($where) >=1) ? implode(" ", $where).' AND ' : ''; foreach ($values as $key => $val) { @@ -560,7 +560,7 @@ class CI_DB_pdo_driver extends CI_DB { foreach (array_keys($val) as $field) { - if ($field != $index) + if ($field !== $index) { $final[$field][] = 'WHEN '.$index.' = '.$val[$index].' THEN '.$val[$field]; } @@ -620,7 +620,7 @@ class CI_DB_pdo_driver extends CI_DB { */ protected function _limit($sql, $limit, $offset) { - if ($this->pdodriver == 'cubrid' OR $this->pdodriver == 'sqlite') + if ($this->pdodriver === 'cubrid' OR $this->pdodriver === 'sqlite') { $offset = ($offset == 0) ? '' : $offset.', '; diff --git a/system/database/drivers/pdo/pdo_forge.php b/system/database/drivers/pdo/pdo_forge.php index ca8657a0f..aee8f718a 100644 --- a/system/database/drivers/pdo/pdo_forge.php +++ b/system/database/drivers/pdo/pdo_forge.php @@ -80,7 +80,7 @@ class CI_DB_pdo_forge extends CI_DB_forge { if (array_key_exists('CONSTRAINT', $attributes)) { // Exception for Postgre numeric which not too happy with constraint within those type - if ( ! ($this->db->pdodriver == 'pgsql' && in_array($attributes['TYPE'], $numeric))) + if ( ! ($this->db->pdodriver === 'pgsql' && in_array($attributes['TYPE'], $numeric))) { $sql .= '('.$attributes['CONSTRAINT'].')'; } @@ -168,14 +168,14 @@ class CI_DB_pdo_forge extends CI_DB_forge { $sql = 'ALTER TABLE `'.$this->db->protect_identifiers($table).'` '.$alter_type.' '.$this->db->protect_identifiers($column_name); // DROP has everything it needs now. - if ($alter_type == 'DROP') + if ($alter_type === 'DROP') { return $sql; } $sql .= " $column_definition"; - if ($default_value != '') + if ($default_value !== '') { $sql .= " DEFAULT \"$default_value\""; } @@ -189,7 +189,7 @@ class CI_DB_pdo_forge extends CI_DB_forge { $sql .= ' NOT NULL'; } - if ($after_field != '') + if ($after_field !== '') { return $sql.' AFTER '.$this->db->protect_identifiers($after_field); } diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php index c2a188416..e5d861bd9 100644 --- a/system/database/drivers/postgre/postgre_driver.php +++ b/system/database/drivers/postgre/postgre_driver.php @@ -356,13 +356,13 @@ class CI_DB_postgre_driver extends CI_DB { $table = (func_num_args() > 0) ? func_get_arg(0) : NULL; $column = (func_num_args() > 1) ? func_get_arg(1) : NULL; - if ($table == NULL && $v >= '8.1') + if ($table === NULL && $v >= '8.1') { $sql = 'SELECT LASTVAL() AS ins_id'; } - elseif ($table != NULL) + elseif ($table !== NULL) { - if ($column != NULL && $v >= '8.0') + if ($column !== NULL && $v >= '8.0') { $sql = 'SELECT pg_get_serial_sequence(\''.$table."', '".$column."') AS seq"; $query = $this->query($sql); @@ -401,7 +401,7 @@ class CI_DB_postgre_driver extends CI_DB { { $sql = "SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'"; - if ($prefix_limit !== FALSE && $this->dbprefix != '') + if ($prefix_limit !== FALSE && $this->dbprefix !== '') { return $sql." AND table_name LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr); } @@ -528,7 +528,7 @@ class CI_DB_postgre_driver extends CI_DB { foreach (array_keys($val) as $field) { - if ($field != $index) + if ($field !== $index) { $final[$field][] = 'WHEN '.$val[$index].' THEN '.$val[$field]; } @@ -544,7 +544,7 @@ class CI_DB_postgre_driver extends CI_DB { } return 'UPDATE '.$table.' SET '.substr($cases, 0, -2) - .' WHERE '.(($where != '' && count($where) > 0) ? implode(' ', $where).' AND ' : '') + .' WHERE '.(($where !== '' && count($where) > 0) ? implode(' ', $where).' AND ' : '') .$index.' IN('.implode(',', $ids).')'; } diff --git a/system/database/drivers/postgre/postgre_forge.php b/system/database/drivers/postgre/postgre_forge.php index 94c97af50..af1c45f9b 100644 --- a/system/database/drivers/postgre/postgre_forge.php +++ b/system/database/drivers/postgre/postgre_forge.php @@ -214,7 +214,7 @@ class CI_DB_postgre_forge extends CI_DB_forge { } return $sql.$this->_process_fields($fields) - .($after_field != '' ? ' AFTER '.$this->db->protect_identifiers($after_field) : ''); + .($after_field !== '' ? ' AFTER '.$this->db->protect_identifiers($after_field) : ''); } } diff --git a/system/database/drivers/sqlite/sqlite_driver.php b/system/database/drivers/sqlite/sqlite_driver.php index d8b869c2e..f52b1ba1b 100644 --- a/system/database/drivers/sqlite/sqlite_driver.php +++ b/system/database/drivers/sqlite/sqlite_driver.php @@ -279,7 +279,7 @@ class CI_DB_sqlite_driver extends CI_DB { { $sql = "SELECT name from sqlite_master WHERE type='table'"; - if ($prefix_limit !== FALSE AND $this->dbprefix != '') + if ($prefix_limit !== FALSE && $this->dbprefix != '') { $sql .= " AND 'name' LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr); } @@ -410,10 +410,10 @@ class CI_DB_sqlite_driver extends CI_DB { } else { - $offset .= ", "; + $offset .= ', '; } - return $sql."LIMIT ".$offset.$limit; + return $sql.'LIMIT '.$offset.$limit; } // -------------------------------------------------------------------- diff --git a/system/database/drivers/sqlite/sqlite_forge.php b/system/database/drivers/sqlite/sqlite_forge.php index dd6f0f78d..35be1b74b 100644 --- a/system/database/drivers/sqlite/sqlite_forge.php +++ b/system/database/drivers/sqlite/sqlite_forge.php @@ -194,7 +194,7 @@ class CI_DB_sqlite_forge extends CI_DB_forge { $sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '.$this->db->protect_identifiers($column_name); // DROP has everything it needs now. - if ($alter_type == 'DROP') + if ($alter_type === 'DROP') { // SQLite does not support dropping columns // http://www.sqlite.org/omitted.html @@ -204,7 +204,7 @@ class CI_DB_sqlite_forge extends CI_DB_forge { $sql .= " $column_definition"; - if ($default_value != '') + if ($default_value !== '') { $sql .= " DEFAULT \"$default_value\""; } @@ -218,7 +218,7 @@ class CI_DB_sqlite_forge extends CI_DB_forge { $sql .= ' NOT NULL'; } - if ($after_field != '') + if ($after_field !== '') { return $sql.' AFTER '.$this->db->protect_identifiers($after_field); } diff --git a/system/database/drivers/sqlite3/sqlite3_driver.php b/system/database/drivers/sqlite3/sqlite3_driver.php index ea4cf2d4f..2acefbcf4 100644 --- a/system/database/drivers/sqlite3/sqlite3_driver.php +++ b/system/database/drivers/sqlite3/sqlite3_driver.php @@ -87,7 +87,7 @@ class CI_DB_sqlite3_driver extends CI_DB { public function db_pconnect() { log_message('debug', 'SQLite3 doesn\'t support persistent connections'); - return $this->db_pconnect(); + return $this->db_connect(); } // -------------------------------------------------------------------- @@ -104,7 +104,7 @@ class CI_DB_sqlite3_driver extends CI_DB { return $this->data_cache['version']; } - $version = $this->conn_id->version(); + $version = SQLite3::version(); return $this->data_cache['version'] = $version['versionString']; } diff --git a/system/database/drivers/sqlite3/sqlite3_forge.php b/system/database/drivers/sqlite3/sqlite3_forge.php index 20f1e6f63..0a5dc9211 100644 --- a/system/database/drivers/sqlite3/sqlite3_forge.php +++ b/system/database/drivers/sqlite3/sqlite3_forge.php @@ -184,7 +184,7 @@ class CI_DB_sqlite3_forge extends CI_DB_forge { return 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '.$this->db->protect_identifiers($column_name) .' '.$column_definition - .($default_value != '' ? ' DEFAULT '.$default_value : '') + .($default_value !== '' ? ' DEFAULT '.$default_value : '') // If NOT NULL is specified, the field must have a DEFAULT value other than NULL .(($null !== NULL && $default_value !== 'NULL') ? ' NOT NULL' : ' NULL'); } diff --git a/system/database/drivers/sqlsrv/sqlsrv_forge.php b/system/database/drivers/sqlsrv/sqlsrv_forge.php index c817c2c5d..1529b2a21 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_forge.php +++ b/system/database/drivers/sqlsrv/sqlsrv_forge.php @@ -155,21 +155,21 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge { $sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '.$this->db->protect_identifiers($column_name); // DROP has everything it needs now. - if ($alter_type == 'DROP') + if ($alter_type === 'DROP') { return $sql; } $sql .= ' '.$column_definition; - if ($default_value != '') + if ($default_value !== '') { $sql .= " DEFAULT '".$default_value."'"; } $sql .= ($null === NULL) ? ' NULL' : ' NOT NULL'; - if ($after_field != '') + if ($after_field !== '') { return $sql.' AFTER '.$this->db->protect_identifiers($after_field); } diff --git a/system/helpers/captcha_helper.php b/system/helpers/captcha_helper.php index b11670658..4676b2a65 100644 --- a/system/helpers/captcha_helper.php +++ b/system/helpers/captcha_helper.php @@ -64,7 +64,7 @@ if ( ! function_exists('create_captcha')) } } - if ($img_path == '' OR $img_url == '' + if ($img_path === '' OR $img_url === '' OR ! @is_dir($img_path) OR ! is_writeable($img_path) OR ! extension_loaded('gd')) { @@ -93,7 +93,7 @@ if ( ! function_exists('create_captcha')) // Do we have a "word" yet? // ----------------------------------- - if ($word == '') + if ($word === '') { $pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $word = ''; @@ -156,7 +156,7 @@ if ( ! function_exists('create_captcha')) // Write the text // ----------------------------------- - $use_font = ($font_path != '' && file_exists($font_path) && function_exists('imagettftext')); + $use_font = ($font_path !== '' && file_exists($font_path) && function_exists('imagettftext')); if ($use_font === FALSE) { $font_size = 5; diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php index 5f0427f7d..c601dc9e5 100644 --- a/system/helpers/date_helper.php +++ b/system/helpers/date_helper.php @@ -50,7 +50,7 @@ if ( ! function_exists('now')) { $CI =& get_instance(); - if (strtolower($CI->config->item('time_reference')) == 'gmt') + if (strtolower($CI->config->item('time_reference')) === 'gmt') { $now = time(); $system_time = mktime(gmdate("H", $now), gmdate("i", $now), gmdate("s", $now), gmdate("m", $now), gmdate("d", $now), gmdate("Y", $now)); @@ -90,12 +90,12 @@ if ( ! function_exists('mdate')) */ function mdate($datestr = '', $time = '') { - if ($datestr == '') + if ($datestr === '') { return ''; } - $time = ($time == '') ? now() : $time; + $time = ($time === '') ? now() : $time; $datestr = str_replace( '%\\', @@ -280,14 +280,14 @@ if ( ! function_exists('days_in_month')) return 0; } - if ( ! is_numeric($year) OR strlen($year) != 4) + if ( ! is_numeric($year) OR strlen($year) !== 4) { $year = date('Y'); } if ($month == 2) { - if ($year % 400 == 0 OR ($year % 4 == 0 && $year % 100 != 0)) + if ($year % 400 === 0 OR ($year % 4 === 0 && $year % 100 !== 0)) { return 29; } @@ -310,7 +310,7 @@ if ( ! function_exists('local_to_gmt')) */ function local_to_gmt($time = '') { - if ($time == '') + if ($time === '') { $time = time(); } @@ -344,14 +344,14 @@ if ( ! function_exists('gmt_to_local')) */ function gmt_to_local($time = '', $timezone = 'UTC', $dst = FALSE) { - if ($time == '') + if ($time === '') { return now(); } $time += timezones($timezone) * 3600; - if ($dst == TRUE) + if ($dst === TRUE) { $time += 3600; } @@ -410,7 +410,7 @@ if ( ! function_exists('unix_to_human')) { $r = date('Y', $time).'-'.date('m', $time).'-'.date('d', $time).' '; - if ($fmt == 'us') + if ($fmt === 'us') { $r .= date('h', $time).':'.date('i', $time); } @@ -424,7 +424,7 @@ if ( ! function_exists('unix_to_human')) $r .= ':'.date('s', $time); } - if ($fmt == 'us') + if ($fmt === 'us') { $r .= ' '.date('A', $time); } @@ -447,7 +447,7 @@ if ( ! function_exists('human_to_unix')) */ function human_to_unix($datestr = '') { - if ($datestr == '') + if ($datestr === '') { return FALSE; } @@ -472,9 +472,9 @@ if ( ! function_exists('human_to_unix')) $hour = (strlen($ex[0]) === 1) ? '0'.$ex[0] : $ex[0]; $min = (strlen($ex[1]) === 1) ? '0'.$ex[1] : $ex[1]; - if (isset($ex['2']) && preg_match('/[0-9]{1,2}/', $ex[2])) + if (isset($ex[2]) && preg_match('/[0-9]{1,2}/', $ex[2])) { - $sec = (strlen($ex[2]) === 1) ? '0'.$ex[2] : $ex[2]; + $sec = (strlen($ex[2]) === 1) ? '0'.$ex[2] : $ex[2]; } else { @@ -482,7 +482,7 @@ if ( ! function_exists('human_to_unix')) $sec = '00'; } - if (isset($split['2'])) + if (isset($split[2])) { $ampm = strtolower($split[2]); @@ -562,7 +562,7 @@ if ( ! function_exists('nice_date')) // Any other kind of string, when converted into UNIX time, // produces "0 seconds after epoc..." is probably bad... // return "Invalid Date". - if (date('U', strtotime($bad_date)) == '0') + if (date('U', strtotime($bad_date)) === '0') { return 'Invalid Date'; } @@ -591,11 +591,11 @@ if ( ! function_exists('timezone_menu')) $CI =& get_instance(); $CI->lang->load('date'); - $default = ($default == 'GMT') ? 'UTC' : $default; + $default = ($default === 'GMT') ? 'UTC' : $default; $menu = '<select name="'.$name.'"'; - if ($class != '') + if ($class !== '') { $menu .= ' class="'.$class.'"'; } @@ -604,7 +604,7 @@ if ( ! function_exists('timezone_menu')) foreach (timezones() as $key => $val) { - $selected = ($default == $key) ? ' selected="selected"' : ''; + $selected = ($default === $key) ? ' selected="selected"' : ''; $menu .= '<option value="'.$key.'"'.$selected.'>'.$CI->lang->line($key)."</option>\n"; } @@ -673,12 +673,12 @@ if ( ! function_exists('timezones')) 'UP14' => +14 ); - if ($tz == '') + if ($tz === '') { return $zones; } - $tz = ($tz == 'GMT') ? 'UTC' : $tz; + $tz = ($tz === 'GMT') ? 'UTC' : $tz; return isset($zones[$tz]) ? $zones[$tz] : 0; } diff --git a/system/helpers/directory_helper.php b/system/helpers/directory_helper.php index bda8fe8bb..e7d3b5e8a 100644 --- a/system/helpers/directory_helper.php +++ b/system/helpers/directory_helper.php @@ -62,7 +62,7 @@ if ( ! function_exists('directory_map')) while (FALSE !== ($file = readdir($fp))) { // Remove '.', '..', and hidden files [optional] - if ( ! trim($file, '.') OR ($hidden == FALSE && $file[0] === '.')) + if ( ! trim($file, '.') OR ($hidden === FALSE && $file[0] === '.')) { continue; } diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php index 470b61ede..9c390a7f7 100644 --- a/system/helpers/download_helper.php +++ b/system/helpers/download_helper.php @@ -51,7 +51,7 @@ if ( ! function_exists('force_download')) */ function force_download($filename = '', $data = '', $set_mime = FALSE) { - if ($filename == '' OR $data == '') + if ($filename === '' OR $data === '') { return FALSE; } diff --git a/system/helpers/file_helper.php b/system/helpers/file_helper.php index fb4503479..0061c4285 100644 --- a/system/helpers/file_helper.php +++ b/system/helpers/file_helper.php @@ -154,7 +154,7 @@ if ( ! function_exists('delete_files')) } @closedir($current_dir); - if ($del_dir == TRUE && $level > 0) + if ($del_dir === TRUE && $level > 0) { return @rmdir($path); } @@ -199,7 +199,7 @@ if ( ! function_exists('get_filenames')) } elseif ($file[0] !== '.') { - $_filedata[] = ($include_path == TRUE) ? $source_dir.$file : $file; + $_filedata[] = ($include_path === TRUE) ? $source_dir.$file : $file; } } closedir($fp); diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index eca6c5f1e..410972187 100644 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.php @@ -52,7 +52,7 @@ if ( ! function_exists('form_open')) { $CI =& get_instance(); - if ($attributes == '') + if ($attributes === '') { $attributes = 'method="post"'; } @@ -325,7 +325,7 @@ if ( ! function_exists('form_dropdown')) $selected = array($_POST[$name]); } - if ($extra != '') $extra = ' '.$extra; + if ($extra !== '') $extra = ' '.$extra; $multiple = (count($selected) > 1 && strpos($extra, 'multiple') === FALSE) ? ' multiple="multiple"' : ''; @@ -378,7 +378,7 @@ if ( ! function_exists('form_checkbox')) { $checked = $data['checked']; - if ($checked == FALSE) + if ($checked === FALSE) { unset($data['checked']); } @@ -388,7 +388,7 @@ if ( ! function_exists('form_checkbox')) } } - if ($checked == TRUE) + if ($checked === TRUE) { $defaults['checked'] = 'checked'; } @@ -506,7 +506,7 @@ if ( ! function_exists('form_label')) $label = '<label'; - if ($id != '') + if ($id !== '') { $label .= ' for="'.$id.'"'; } @@ -540,7 +540,7 @@ if ( ! function_exists('form_fieldset')) function form_fieldset($legend_text = '', $attributes = array()) { $fieldset = '<fieldset'._attributes_to_string($attributes, FALSE).">\n"; - if ($legend_text != '') + if ($legend_text !== '') { return $fieldset.'<legend>'.$legend_text."</legend>\n"; } @@ -623,7 +623,7 @@ if ( ! function_exists('form_prep')) return $str; } - if ($field_name != '') + if ($field_name !== '') { $prepped_fields[$field_name] = $field_name; } @@ -686,7 +686,7 @@ if ( ! function_exists('set_select')) { if ( ! isset($_POST[$field])) { - if (count($_POST) === 0 && $default == TRUE) + if (count($_POST) === 0 && $default === TRUE) { return ' selected="selected"'; } @@ -702,7 +702,7 @@ if ( ! function_exists('set_select')) return ''; } } - elseif (($field == '' OR $value == '') OR ($field != $value)) + elseif (($field === '' OR $value === '') OR ($field !== $value)) { return ''; } @@ -737,7 +737,7 @@ if ( ! function_exists('set_checkbox')) { if ( ! isset($_POST[$field])) { - if (count($_POST) === 0 && $default == TRUE) + if (count($_POST) === 0 && $default === TRUE) { return ' checked="checked"'; } @@ -753,7 +753,7 @@ if ( ! function_exists('set_checkbox')) return ''; } } - elseif (($field == '' OR $value == '') OR ($field != $value)) + elseif (($field === '' OR $value === '') OR ($field !== $value)) { return ''; } @@ -788,7 +788,7 @@ if ( ! function_exists('set_radio')) { if ( ! isset($_POST[$field])) { - if (count($_POST) === 0 && $default == TRUE) + if (count($_POST) === 0 && $default === TRUE) { return ' checked="checked"'; } @@ -806,7 +806,7 @@ if ( ! function_exists('set_radio')) } else { - if (($field == '' OR $value == '') OR ($field != $value)) + if (($field === '' OR $value === '') OR ($field !== $value)) { return ''; } @@ -907,7 +907,7 @@ if ( ! function_exists('_parse_form_attributes')) foreach ($default as $key => $val) { - if ($key == 'value') + if ($key === 'value') { $val = form_prep($val, $default['name']); } @@ -936,12 +936,12 @@ if ( ! function_exists('_attributes_to_string')) { if (is_string($attributes) && strlen($attributes) > 0) { - if ($formtag == TRUE && strpos($attributes, 'method=') === FALSE) + if ($formtag === TRUE && strpos($attributes, 'method=') === FALSE) { $attributes .= ' method="post"'; } - if ($formtag == TRUE && strpos($attributes, 'accept-charset=') === FALSE) + if ($formtag === TRUE && strpos($attributes, 'accept-charset=') === FALSE) { $attributes .= ' accept-charset="'.strtolower(config_item('charset')).'"'; } diff --git a/system/helpers/html_helper.php b/system/helpers/html_helper.php index 92a6db477..68ce70248 100644 --- a/system/helpers/html_helper.php +++ b/system/helpers/html_helper.php @@ -51,7 +51,7 @@ if ( ! function_exists('heading')) */ function heading($data = '', $h = '1', $attributes = '') { - return '<h'.$h.($attributes != '' ? ' ' : '').$attributes.'>'.$data.'</h'.$h.'>'; + return '<h'.$h.($attributes !== '' ? ' ' : '').$attributes.'>'.$data.'</h'.$h.'>'; } } @@ -334,12 +334,12 @@ if ( ! function_exists('link_tag')) $link .= 'rel="'.$rel.'" type="'.$type.'" '; - if ($media != '') + if ($media !== '') { $link .= 'media="'.$media.'" '; } - if ($title != '') + if ($title !== '') { $link .= 'title="'.$title.'" '; } diff --git a/system/helpers/language_helper.php b/system/helpers/language_helper.php index 34f030716..bd567ed79 100644 --- a/system/helpers/language_helper.php +++ b/system/helpers/language_helper.php @@ -53,7 +53,7 @@ if ( ! function_exists('lang')) $CI =& get_instance(); $line = $CI->lang->line($line); - if ($id != '') + if ($id !== '') { $line = '<label for="'.$id.'">'.$line.'</label>'; } diff --git a/system/helpers/smiley_helper.php b/system/helpers/smiley_helper.php index 5e6de08af..b6b2afcf4 100644 --- a/system/helpers/smiley_helper.php +++ b/system/helpers/smiley_helper.php @@ -55,7 +55,7 @@ if ( ! function_exists('smiley_js')) static $do_setup = TRUE; $r = ''; - if ($alias != '' && ! is_array($alias)) + if ($alias !== '' && ! is_array($alias)) { $alias = array($alias => $field_id); } @@ -184,7 +184,7 @@ if ( ! function_exists('parse_smileys')) */ function parse_smileys($str = '', $image_url = '', $smileys = NULL) { - if ($image_url == '' OR ( ! is_array($smileys) && FALSE === ($smileys = _get_smiley_array()))) + if ($image_url === '' OR ( ! is_array($smileys) && FALSE === ($smileys = _get_smiley_array()))) { return $str; } diff --git a/system/helpers/string_helper.php b/system/helpers/string_helper.php index 0c47d440a..4eee2a262 100644 --- a/system/helpers/string_helper.php +++ b/system/helpers/string_helper.php @@ -259,7 +259,7 @@ if ( ! function_exists('alternator')) { static $i; - if (func_num_args() == 0) + if (func_num_args() === 0) { $i = 0; return ''; diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php index e4451ae81..8a1f01b51 100644 --- a/system/helpers/text_helper.php +++ b/system/helpers/text_helper.php @@ -51,7 +51,7 @@ if ( ! function_exists('word_limiter')) */ function word_limiter($str, $limit = 100, $end_char = '…') { - if (trim($str) == '') + if (trim($str) === '') { return $str; } @@ -258,7 +258,7 @@ if ( ! function_exists('word_censor')) foreach ($censored as $badword) { - if ($replacement != '') + if ($replacement !== '') { $str = preg_replace("/({$delim})(".str_replace('\*', '\w*?', preg_quote($badword, '/')).")({$delim})/i", "\\1{$replacement}\\3", $str); } @@ -338,12 +338,12 @@ if ( ! function_exists('highlight_phrase')) */ function highlight_phrase($str, $phrase, $tag_open = '<strong>', $tag_close = '</strong>') { - if ($str == '') + if ($str === '') { return ''; } - if ($phrase != '') + if ($phrase !== '') { return preg_replace('/('.preg_quote($phrase, '/').')/i', $tag_open.'\\1'.$tag_close, $str); } @@ -464,7 +464,7 @@ if ( ! function_exists('word_wrap')) // If $temp contains data it means we had to split up an over-length // word into smaller chunks so we'll add it back to our current line - if ($temp != '') + if ($temp !== '') { $output .= $temp."\n".$line."\n"; } diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php index 0e933c18e..2bd41b04d 100644 --- a/system/helpers/url_helper.php +++ b/system/helpers/url_helper.php @@ -158,12 +158,12 @@ if ( ! function_exists('anchor')) $site_url = site_url($uri); } - if ($title == '') + if ($title === '') { $title = $site_url; } - if ($attributes != '') + if ($attributes !== '') { $attributes = _parse_attributes($attributes); } @@ -192,7 +192,7 @@ if ( ! function_exists('anchor_popup')) $title = (string) $title; $site_url = preg_match('!^\w+://! i', $uri) ? $uri : site_url($uri); - if ($title == '') + if ($title === '') { $title = $site_url; } @@ -213,7 +213,7 @@ if ( ! function_exists('anchor_popup')) unset($attributes[$key]); } - if ($attributes != '') + if ($attributes !== '') { $attributes = _parse_attributes($attributes); } @@ -238,7 +238,7 @@ if ( ! function_exists('mailto')) { $title = (string) $title; - if ($title == '') + if ($title === '') { $title = $email; } @@ -265,7 +265,7 @@ if ( ! function_exists('safe_mailto')) { $title = (string) $title; - if ($title == '') + if ($title === '') { $title = $email; } @@ -279,7 +279,7 @@ if ( ! function_exists('safe_mailto')) $x[] = '"'; - if ($attributes != '') + if ($attributes !== '') { if (is_array($attributes)) { @@ -345,7 +345,7 @@ if ( ! function_exists('safe_mailto')) for ($i = 0, $c = count($x); $i < $c; $i++) { ?>l[<?php echo $i; ?>]='<?php echo $x[$i]; ?>';<?php } ?> for (var i = l.length-1; i >= 0; i=i-1){ - if (l[i].substring(0, 1) == '|') document.write("&#"+unescape(l[i].substring(1))+";"); + if (l[i].substring(0, 1) === '|') document.write("&#"+unescape(l[i].substring(1))+";"); else document.write(unescape(l[i]));} //]]> </script><?php @@ -436,7 +436,7 @@ if ( ! function_exists('prep_url')) */ function prep_url($str = '') { - if ($str === 'http://' OR $str == '') + if ($str === 'http://' OR $str === '') { return ''; } @@ -562,13 +562,13 @@ if ( ! function_exists('_parse_attributes')) { if (is_string($attributes)) { - return ($attributes != '') ? ' '.$attributes : ''; + return ($attributes !== '') ? ' '.$attributes : ''; } $att = ''; foreach ($attributes as $key => $val) { - if ($javascript == TRUE) + if ($javascript === TRUE) { $att .= $key.'='.$val.','; } @@ -578,7 +578,7 @@ if ( ! function_exists('_parse_attributes')) } } - if ($javascript == TRUE && $att != '') + if ($javascript === TRUE && $att !== '') { return substr($att, 0, -1); } diff --git a/system/helpers/xml_helper.php b/system/helpers/xml_helper.php index 958c633dd..1431777d2 100644 --- a/system/helpers/xml_helper.php +++ b/system/helpers/xml_helper.php @@ -54,7 +54,7 @@ if ( ! function_exists('xml_convert')) // ampersands won't get messed up $str = preg_replace('/&#(\d+);/', $temp.'\\1;', $str); - if ($protect_all == TRUE) + if ($protect_all === TRUE) { $str = preg_replace('/&(\w+);/', $temp.'\\1;', $str); } @@ -66,7 +66,7 @@ if ( ! function_exists('xml_convert')) // Decode the temp markers back to entities $str = preg_replace('/'.$temp.'(\d+);/', '&#\\1;', $str); - if ($protect_all == TRUE) + if ($protect_all === TRUE) { return preg_replace('/'.$temp.'(\w+);/', '&\\1;', $str); } diff --git a/system/libraries/Cache/drivers/Cache_file.php b/system/libraries/Cache/drivers/Cache_file.php index f0eb8bdf7..ce2c2b13a 100644 --- a/system/libraries/Cache/drivers/Cache_file.php +++ b/system/libraries/Cache/drivers/Cache_file.php @@ -53,7 +53,7 @@ class CI_Cache_file extends CI_Driver { $CI =& get_instance(); $CI->load->helper('file'); $path = $CI->config->item('cache_path'); - $this->_cache_path = ($path == '') ? APPPATH.'cache/' : $path; + $this->_cache_path = ($path === '') ? APPPATH.'cache/' : $path; } // ------------------------------------------------------------------------ diff --git a/system/libraries/Cache/drivers/Cache_memcached.php b/system/libraries/Cache/drivers/Cache_memcached.php index 1df149c2d..bf90f6197 100644 --- a/system/libraries/Cache/drivers/Cache_memcached.php +++ b/system/libraries/Cache/drivers/Cache_memcached.php @@ -212,7 +212,7 @@ class CI_Cache_memcached extends CI_Driver { $cache_server['weight'] = $this->_memcache_conf['default']['default_weight']; } - if (get_class($this->_memcached) == 'Memcache') + if (get_class($this->_memcached) === 'Memcache') { // Third parameter is persistance and defaults to TRUE. $this->_memcached->addServer( diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php index 92f372b20..969a7610a 100644 --- a/system/libraries/Calendar.php +++ b/system/libraries/Calendar.php @@ -155,7 +155,7 @@ class CI_Calendar { public function generate($year = '', $month = '', $data = array()) { // Set and validate the supplied month/year - if ($year == '') + if ($year === '') { $year = date('Y', $this->local_time); } @@ -168,7 +168,7 @@ class CI_Calendar { $year = '20'.$year; } - if ($month == '') + if ($month === '') { $month = date('m', $this->local_time); } @@ -214,7 +214,7 @@ class CI_Calendar { $out = $this->temp['table_open']."\n\n".$this->temp['heading_row_start']."\n"; // "previous" month link - if ($this->show_next_prev == TRUE) + if ($this->show_next_prev === TRUE) { // Add a trailing slash to the URL if needed $this->next_prev_url = preg_replace('/(.+?)\/*$/', '\\1/', $this->next_prev_url); @@ -224,7 +224,7 @@ class CI_Calendar { } // Heading containing the month/year - $colspan = ($this->show_next_prev == TRUE) ? 5 : 7; + $colspan = ($this->show_next_prev === TRUE) ? 5 : 7; $this->temp['heading_title_cell'] = str_replace('{colspan}', $colspan, str_replace('{heading}', $this->get_month_name($month).' '.$year, $this->temp['heading_title_cell'])); @@ -232,7 +232,7 @@ class CI_Calendar { $out .= $this->temp['heading_title_cell']."\n"; // "next" month link - if ($this->show_next_prev == TRUE) + if ($this->show_next_prev === TRUE) { $adjusted_date = $this->adjust_date($month + 1, $year); $out .= str_replace('{next_url}', $this->next_prev_url.$adjusted_date['year'].'/'.$adjusted_date['month'], $this->temp['heading_next_cell']); @@ -306,7 +306,7 @@ class CI_Calendar { */ public function get_month_name($month) { - if ($this->month_type == 'short') + if ($this->month_type === 'short') { $month_names = array('01' => 'cal_jan', '02' => 'cal_feb', '03' => 'cal_mar', '04' => 'cal_apr', '05' => 'cal_may', '06' => 'cal_jun', '07' => 'cal_jul', '08' => 'cal_aug', '09' => 'cal_sep', '10' => 'cal_oct', '11' => 'cal_nov', '12' => 'cal_dec'); } @@ -333,7 +333,7 @@ class CI_Calendar { */ public function get_day_names($day_type = '') { - if ($day_type != '') + if ($day_type !== '') { $this->day_type = $day_type; } @@ -421,7 +421,7 @@ class CI_Calendar { // Is the year a leap year? if ($month == 2) { - if ($year % 400 == 0 OR ($year % 4 == 0 && $year % 100 != 0)) + if ($year % 400 === 0 OR ($year % 4 === 0 && $year % 100 !== 0)) { return 29; } @@ -480,7 +480,7 @@ class CI_Calendar { { $this->temp = $this->default_template(); - if ($this->template == '') + if ($this->template === '') { return; } diff --git a/system/libraries/Cart.php b/system/libraries/Cart.php index 827050310..c442f88da 100644 --- a/system/libraries/Cart.php +++ b/system/libraries/Cart.php @@ -520,7 +520,7 @@ class CI_Cart { */ public function format_number($n = '') { - return ($n == '') ? '' : number_format( (float) $n, 2, '.', ','); + return ($n === '') ? '' : number_format( (float) $n, 2, '.', ','); } // -------------------------------------------------------------------- diff --git a/system/libraries/Driver.php b/system/libraries/Driver.php index c79698c7b..d67ee2549 100644 --- a/system/libraries/Driver.php +++ b/system/libraries/Driver.php @@ -51,7 +51,7 @@ class CI_Driver_Library { * * @var string */ - protected static $lib_name; + protected $lib_name; /** * The first time a child is used it won't exist, so we instantiate it diff --git a/system/libraries/Email.php b/system/libraries/Email.php index 56d60c802..45866797b 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -104,7 +104,7 @@ class CI_Email { } else { - $this->_smtp_auth = ! ($this->smtp_user == '' && $this->smtp_pass == ''); + $this->_smtp_auth = ! ($this->smtp_user === '' && $this->smtp_pass === ''); $this->_safe_mode = (bool) @ini_get('safe_mode'); } @@ -139,7 +139,7 @@ class CI_Email { } $this->clear(); - $this->_smtp_auth = ! ($this->smtp_user == '' && $this->smtp_pass == ''); + $this->_smtp_auth = ! ($this->smtp_user === '' && $this->smtp_pass === ''); $this->_safe_mode = (bool) @ini_get('safe_mode'); return $this; @@ -201,7 +201,7 @@ class CI_Email { } // prepare the display name - if ($name != '') + if ($name !== '') { // only use Q encoding if there are characters that would require it if ( ! preg_match('/[\200-\377]/', $name)) @@ -242,7 +242,7 @@ class CI_Email { $this->validate_email($this->_str_to_array($replyto)); } - if ($name == '') + if ($name === '') { $name = $replyto; } @@ -333,7 +333,7 @@ class CI_Email { */ public function bcc($bcc, $limit = '') { - if ($limit != '' && is_numeric($limit)) + if ($limit !== '' && is_numeric($limit)) { $this->bcc_batch_mode = TRUE; $this->bcc_batch_size = $limit; @@ -586,7 +586,7 @@ class CI_Email { $this->protocol = strtolower($this->protocol); in_array($this->protocol, $this->_protocols, TRUE) OR $this->protocol = 'mail'; - if ($return == TRUE) + if ($return === TRUE) { return $this->protocol; } @@ -612,7 +612,7 @@ class CI_Email { } } - if ($return == TRUE) + if ($return === TRUE) { return $this->_encoding; } @@ -629,7 +629,7 @@ class CI_Email { { if ($this->mailtype === 'html') { - return (count($this->_attach_name) == 0) ? 'html' : 'html-attach'; + return (count($this->_attach_name) === 0) ? 'html' : 'html-attach'; } elseif ($this->mailtype === 'text' && count($this->_attach_name) > 0) { @@ -750,7 +750,7 @@ class CI_Email { */ protected function _get_alt_message() { - if ($this->alt_message != '') + if ($this->alt_message !== '') { return $this->word_wrap($this->alt_message, '76'); } @@ -778,9 +778,9 @@ class CI_Email { public function word_wrap($str, $charlim = '') { // Se the character limit - if ($charlim == '') + if ($charlim === '') { - $charlim = ($this->wrapchars == '') ? 76 : $this->wrapchars; + $charlim = ($this->wrapchars === '') ? 76 : $this->wrapchars; } // Reduce multiple spaces @@ -838,7 +838,7 @@ class CI_Email { // If $temp contains data it means we had to split up an over-length // word into smaller chunks so we'll add it back to our current line - if ($temp != '') + if ($temp !== '') { $output .= $temp.$this->newline; } @@ -896,7 +896,7 @@ class CI_Email { { $val = trim($val); - if ($val != '') + if ($val !== '') { $this->_header_str .= $key.': '.$val.$this->newline; } @@ -1043,7 +1043,7 @@ class CI_Email { $ctype = $this->_attach_type[$i]; $file_content = ''; - if ($this->_attach_type[$i] == '') + if ($this->_attach_type[$i] === '') { if ( ! file_exists($filename)) { @@ -1099,7 +1099,7 @@ class CI_Email { // Set the character limit // Don't allow over 76, as that will make servers and MUAs barf // all over quoted-printable data - if ($charlim == '' OR $charlim > 76) + if ($charlim === '' OR $charlim > 76) { $charlim = 76; } @@ -1240,7 +1240,7 @@ class CI_Email { */ public function send() { - if ($this->_replyto_flag == FALSE) + if ($this->_replyto_flag === FALSE) { $this->reply_to($this->_headers['From']); } @@ -1284,7 +1284,7 @@ class CI_Email { $set .= ', '.$this->_bcc_array[$i]; } - if ($i == $float) + if ($i === $float) { $chunk[] = substr($set, 1); $float += $this->bcc_batch_size; @@ -1377,7 +1377,7 @@ class CI_Email { */ protected function _send_with_mail() { - if ($this->_safe_mode == TRUE) + if ($this->_safe_mode === TRUE) { return mail($this->_recipients, $this->_subject, $this->_finalbody, $this->_header_str); } @@ -1430,7 +1430,7 @@ class CI_Email { */ protected function _send_with_smtp() { - if ($this->smtp_host == '') + if ($this->smtp_host === '') { $this->_set_error_message('lang:email_no_hostname'); return FALSE; @@ -1452,7 +1452,7 @@ class CI_Email { { foreach ($this->_cc_array as $val) { - if ($val != '') + if ($val !== '') { $this->_send_command('to', $val); } @@ -1463,7 +1463,7 @@ class CI_Email { { foreach ($this->_bcc_array as $val) { - if ($val != '') + if ($val !== '') { $this->_send_command('to', $val); } @@ -1501,7 +1501,7 @@ class CI_Email { */ protected function _smtp_connect() { - $ssl = ($this->smtp_crypto == 'ssl') ? 'ssl://' : NULL; + $ssl = ($this->smtp_crypto === 'ssl') ? 'ssl://' : NULL; $this->_smtp_connect = fsockopen($ssl.$this->smtp_host, $this->smtp_port, @@ -1517,7 +1517,7 @@ class CI_Email { $this->_set_error_message($this->_get_smtp_data()); - if ($this->smtp_crypto == 'tls') + if ($this->smtp_crypto === 'tls') { $this->_send_command('hello'); $this->_send_command('starttls'); @@ -1599,13 +1599,13 @@ class CI_Email { $this->_debug_msg[] = '<pre>'.$cmd.': '.$reply.'</pre>'; - if (substr($reply, 0, 3) != $resp) + if (substr($reply, 0, 3) !== $resp) { $this->_set_error_message('lang:email_smtp_error', $reply); return FALSE; } - if ($cmd == 'quit') + if ($cmd === 'quit') { fclose($this->_smtp_connect); } @@ -1627,7 +1627,7 @@ class CI_Email { return TRUE; } - if ($this->smtp_user == '' && $this->smtp_pass == '') + if ($this->smtp_user === '' && $this->smtp_pass === '') { $this->_set_error_message('lang:email_no_smtp_unpw'); return FALSE; @@ -1699,7 +1699,7 @@ class CI_Email { { $data .= $str; - if ($str[3] == ' ') + if ($str[3] === ' ') { break; } diff --git a/system/libraries/Encrypt.php b/system/libraries/Encrypt.php index 751557fab..959e2eea8 100644 --- a/system/libraries/Encrypt.php +++ b/system/libraries/Encrypt.php @@ -97,9 +97,9 @@ class CI_Encrypt { */ public function get_key($key = '') { - if ($key == '') + if ($key === '') { - if ($this->encryption_key != '') + if ($this->encryption_key !== '') { return $this->encryption_key; } @@ -449,7 +449,7 @@ class CI_Encrypt { */ protected function _get_cipher() { - if ($this->_mcrypt_cipher == '') + if ($this->_mcrypt_cipher === NULL) { return $this->_mcrypt_cipher = MCRYPT_RIJNDAEL_256; } @@ -466,7 +466,7 @@ class CI_Encrypt { */ protected function _get_mode() { - if ($this->_mcrypt_mode == '') + if ($this->_mcrypt_mode === NULL) { return $this->_mcrypt_mode = MCRYPT_MODE_CBC; } diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 67cbfd1a0..225325d6f 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -188,13 +188,13 @@ class CI_Form_validation { } // No fields? Nothing to do... - if ( ! is_string($field) OR ! is_string($rules) OR $field == '') + if ( ! is_string($field) OR ! is_string($rules) OR $field === '') { return $this; } // If the field label wasn't passed we use the field name - $label = ($label == '') ? $field : $label; + $label = ($label === '') ? $field : $label; // Is the field name an array? If it is an array, we break it apart // into its components so that we can fetch the corresponding POST data later @@ -207,7 +207,7 @@ class CI_Form_validation { for ($i = 0, $c = count($matches[0]); $i < $c; $i++) { - if ($matches[1][$i] != '') + if ($matches[1][$i] !== '') { $indexes[] = $matches[1][$i]; } @@ -318,12 +318,12 @@ class CI_Form_validation { return ''; } - if ($prefix == '') + if ($prefix === '') { $prefix = $this->_error_prefix; } - if ($suffix == '') + if ($suffix === '') { $suffix = $this->_error_suffix; } @@ -364,12 +364,12 @@ class CI_Form_validation { return ''; } - if ($prefix == '') + if ($prefix === '') { $prefix = $this->_error_prefix; } - if ($suffix == '') + if ($suffix === '') { $suffix = $this->_error_suffix; } @@ -378,7 +378,7 @@ class CI_Form_validation { $str = ''; foreach ($this->_error_array as $val) { - if ($val != '') + if ($val !== '') { $str .= $prefix.$val.$suffix."\n"; } @@ -417,9 +417,9 @@ class CI_Form_validation { } // Is there a validation rule for the particular URI being accessed? - $uri = ($group == '') ? trim($this->CI->uri->ruri_string(), '/') : $group; + $uri = ($group === '') ? trim($this->CI->uri->ruri_string(), '/') : $group; - if ($uri != '' && isset($this->_config_rules[$uri])) + if ($uri !== '' && isset($this->_config_rules[$uri])) { $this->set_rules($this->_config_rules[$uri]); } @@ -629,7 +629,7 @@ class CI_Form_validation { // We set the $postdata variable with the current data in our master array so that // each cycle of the loop is dealing with the processed data from the last cycle - if ($row['is_array'] == TRUE && is_array($this->_field_data[$row['field']]['postdata'])) + if ($row['is_array'] === TRUE && is_array($this->_field_data[$row['field']]['postdata'])) { // We shouldn't need this safety, but just in case there isn't an array index // associated with this cycle we'll bail out @@ -852,7 +852,7 @@ class CI_Form_validation { return ''; } } - elseif (($field == '' OR $value == '') OR ($field != $value)) + elseif (($field === '' OR $value === '') OR ($field !== $value)) { return ''; } @@ -888,7 +888,7 @@ class CI_Form_validation { return ''; } } - elseif (($field == '' OR $value == '') OR ($field != $value)) + elseif (($field === '' OR $value === '') OR ($field !== $value)) { return ''; } @@ -1040,8 +1040,8 @@ class CI_Form_validation { } return (MB_ENABLED === TRUE) - ? (mb_strlen($str) == $val) - : (strlen($str) == $val); + ? (mb_strlen($str) === $val) + : (strlen($str) === $val); } // -------------------------------------------------------------------- @@ -1254,7 +1254,7 @@ class CI_Form_validation { */ public function is_natural_no_zero($str) { - return ($str != 0 && preg_match('/^[0-9]+$/', $str)); + return ($str !== 0 && preg_match('/^[0-9]+$/', $str)); } // -------------------------------------------------------------------- @@ -1296,7 +1296,7 @@ class CI_Form_validation { return $data; } - if ($this->_safe_form_data == FALSE OR $data === '') + if ($this->_safe_form_data === FALSE OR $data === '') { return $data; } @@ -1314,7 +1314,7 @@ class CI_Form_validation { */ public function prep_url($str = '') { - if ($str === 'http://' OR $str == '') + if ($str === 'http://' OR $str === '') { return ''; } diff --git a/system/libraries/Ftp.php b/system/libraries/Ftp.php index 3cfe1b2b6..461e884fb 100644 --- a/system/libraries/Ftp.php +++ b/system/libraries/Ftp.php @@ -93,7 +93,7 @@ class CI_FTP { if (FALSE === ($this->conn_id = @ftp_connect($this->hostname, $this->port))) { - if ($this->debug == TRUE) + if ($this->debug === TRUE) { $this->_error('ftp_unable_to_connect'); } @@ -102,7 +102,7 @@ class CI_FTP { if ( ! $this->_login()) { - if ($this->debug == TRUE) + if ($this->debug === TRUE) { $this->_error('ftp_unable_to_login'); } @@ -110,7 +110,7 @@ class CI_FTP { } // Set passive mode if needed - if ($this->passive == TRUE) + if ($this->passive === TRUE) { ftp_pasv($this->conn_id, TRUE); } @@ -141,7 +141,7 @@ class CI_FTP { { if ( ! is_resource($this->conn_id)) { - if ($this->debug == TRUE) + if ($this->debug === TRUE) { $this->_error('ftp_no_connection'); } @@ -167,7 +167,7 @@ class CI_FTP { */ public function changedir($path = '', $supress_debug = FALSE) { - if ($path == '' OR ! $this->_is_conn()) + if ($path === '' OR ! $this->_is_conn()) { return FALSE; } @@ -176,7 +176,7 @@ class CI_FTP { if ($result === FALSE) { - if ($this->debug == TRUE && $supress_debug == FALSE) + if ($this->debug === TRUE && $supress_debug === FALSE) { $this->_error('ftp_unable_to_changedir'); } @@ -197,7 +197,7 @@ class CI_FTP { */ public function mkdir($path = '', $permissions = NULL) { - if ($path == '' OR ! $this->_is_conn()) + if ($path === '' OR ! $this->_is_conn()) { return FALSE; } @@ -206,7 +206,7 @@ class CI_FTP { if ($result === FALSE) { - if ($this->debug == TRUE) + if ($this->debug === TRUE) { $this->_error('ftp_unable_to_makdir'); } @@ -260,7 +260,7 @@ class CI_FTP { if ($result === FALSE) { - if ($this->debug == TRUE) + if ($this->debug === TRUE) { $this->_error('ftp_unable_to_upload'); } @@ -307,7 +307,7 @@ class CI_FTP { if ($result === FALSE) { - if ($this->debug == TRUE) + if ($this->debug === TRUE) { $this->_error('ftp_unable_to_download'); } @@ -338,9 +338,9 @@ class CI_FTP { if ($result === FALSE) { - if ($this->debug == TRUE) + if ($this->debug === TRUE) { - $this->_error('ftp_unable_to_' . ($move == FALSE ? 'rename' : 'move')); + $this->_error('ftp_unable_to_' . ($move === FALSE ? 'rename' : 'move')); } return FALSE; } @@ -381,7 +381,7 @@ class CI_FTP { if ($result === FALSE) { - if ($this->debug == TRUE) + if ($this->debug === TRUE) { $this->_error('ftp_unable_to_delete'); } @@ -429,7 +429,7 @@ class CI_FTP { if ($result === FALSE) { - if ($this->debug == TRUE) + if ($this->debug === TRUE) { $this->_error('ftp_unable_to_delete'); } @@ -459,7 +459,7 @@ class CI_FTP { if ($result === FALSE) { - if ($this->debug == TRUE) + if ($this->debug === TRUE) { $this->_error('ftp_unable_to_chmod'); } diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index 0cb189445..4735dfd08 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -466,7 +466,7 @@ class CI_Image_lib { } // Is there a source image? If not, there's no reason to continue - if ($this->source_image == '') + if ($this->source_image === '') { $this->set_error('imglib_source_image_required'); return FALSE; @@ -519,7 +519,7 @@ class CI_Image_lib { * it means we are altering the original. We'll * set the destination filename and path accordingly. */ - if ($this->new_image == '') + if ($this->new_image === '') { $this->dest_image = $this->source_image; $this->dest_folder = $this->source_folder; @@ -562,7 +562,7 @@ class CI_Image_lib { * We'll also split the destination image name * so we can insert the thumbnail marker if needed. */ - if ($this->create_thumb === FALSE OR $this->thumb_marker == '') + if ($this->create_thumb === FALSE OR $this->thumb_marker === '') { $this->thumb_marker = ''; } @@ -581,7 +581,7 @@ class CI_Image_lib { * might not be in correct proportion with the source * image's width/height. We'll recalculate it here. */ - if ($this->maintain_ratio === TRUE && ($this->width != 0 OR $this->height != 0)) + if ($this->maintain_ratio === TRUE && ($this->width !== 0 OR $this->height !== 0)) { $this->image_reproportion(); } @@ -591,12 +591,12 @@ class CI_Image_lib { * If the destination width/height was not submitted we * will use the values from the actual file */ - if ($this->width == '') + if ($this->width === '') { $this->width = $this->orig_width; } - if ($this->height == '') + if ($this->height === '') { $this->height = $this->orig_height; } @@ -604,31 +604,31 @@ class CI_Image_lib { // Set the quality $this->quality = trim(str_replace('%', '', $this->quality)); - if ($this->quality == '' OR $this->quality == 0 OR ! preg_match('/^[0-9]+$/', $this->quality)) + if ($this->quality === '' OR $this->quality === 0 OR ! preg_match('/^[0-9]+$/', $this->quality)) { $this->quality = 90; } // Set the x/y coordinates - $this->x_axis = ($this->x_axis == '' OR ! preg_match('/^[0-9]+$/', $this->x_axis)) ? 0 : $this->x_axis; - $this->y_axis = ($this->y_axis == '' OR ! preg_match('/^[0-9]+$/', $this->y_axis)) ? 0 : $this->y_axis; + is_numeric($this->x_axis) OR $this->x_axis = 0; + is_numeric($this->y_axis) OR $this->y_axis = 0; // Watermark-related Stuff... - if ($this->wm_overlay_path != '') + if ($this->wm_overlay_path !== '') { $this->wm_overlay_path = str_replace('\\', '/', realpath($this->wm_overlay_path)); } - if ($this->wm_shadow_color != '') + if ($this->wm_shadow_color !== '') { $this->wm_use_drop_shadow = TRUE; } - elseif ($this->wm_use_drop_shadow == TRUE && $this->wm_shadow_color == '') + elseif ($this->wm_use_drop_shadow === TRUE && $this->wm_shadow_color === '') { $this->wm_use_drop_shadow = FALSE; } - if ($this->wm_font_path != '') + if ($this->wm_font_path !== '') { $this->wm_use_truetype = TRUE; } @@ -683,14 +683,14 @@ class CI_Image_lib { // Allowed rotation values $degs = array(90, 180, 270, 'vrt', 'hor'); - if ($this->rotation_angle == '' OR ! in_array($this->rotation_angle, $degs)) + if ($this->rotation_angle === '' OR ! in_array($this->rotation_angle, $degs)) { $this->set_error('imglib_rotation_angle_required'); return FALSE; } // Reassign the width and height - if ($this->rotation_angle == 90 OR $this->rotation_angle == 270) + if ($this->rotation_angle === 90 OR $this->rotation_angle === 270) { $this->width = $this->orig_height; $this->height = $this->orig_width; @@ -729,9 +729,9 @@ class CI_Image_lib { // If the target width/height match the source, AND if the new file name is not equal to the old file name // we'll simply make a copy of the original with the new name... assuming dynamic rendering is off. - if ($this->dynamic_output === FALSE && $this->orig_width == $this->width && $this->orig_height == $this->height) + if ($this->dynamic_output === FALSE && $this->orig_width === $this->width && $this->orig_height === $this->height) { - if ($this->source_image != $this->new_image && @copy($this->full_src_path, $this->full_dst_path)) + if ($this->source_image !== $this->new_image && @copy($this->full_src_path, $this->full_dst_path)) { @chmod($this->full_dst_path, FILE_WRITE_MODE); } @@ -740,7 +740,7 @@ class CI_Image_lib { } // Let's set up our values based on the action - if ($action == 'crop') + if ($action === 'crop') { // Reassign the source width/height if cropping $this->orig_width = $this->width; @@ -750,7 +750,7 @@ class CI_Image_lib { if ($this->gd_version() !== FALSE) { $gd_version = str_replace('0', '', $this->gd_version()); - $v2_override = ($gd_version == 2) ? TRUE : FALSE; + $v2_override = ($gd_version === 2); } } else @@ -772,7 +772,7 @@ class CI_Image_lib { * it appears that this is no longer the issue that it was in 2004, so we've removed it, retaining it in the comment * below should that ever prove inaccurate. * - * if ($this->image_library === 'gd2' && function_exists('imagecreatetruecolor') && $v2_override == FALSE) + * if ($this->image_library === 'gd2' && function_exists('imagecreatetruecolor') && $v2_override === FALSE) */ if ($this->image_library === 'gd2' && function_exists('imagecreatetruecolor')) { @@ -787,7 +787,7 @@ class CI_Image_lib { $dst_img = $create($this->width, $this->height); - if ($this->image_type == 3) // png we can actually preserve transparency + if ($this->image_type === 3) // png we can actually preserve transparency { imagealphablending($dst_img, FALSE); imagesavealpha($dst_img, TRUE); @@ -796,7 +796,7 @@ class CI_Image_lib { $copy($dst_img, $src_img, 0, 0, $this->x_axis, $this->y_axis, $this->width, $this->height, $this->orig_width, $this->orig_height); // Show the image - if ($this->dynamic_output == TRUE) + if ($this->dynamic_output === TRUE) { $this->image_display_gd($dst_img); } @@ -828,7 +828,7 @@ class CI_Image_lib { public function image_process_imagemagick($action = 'resize') { // Do we have a vaild library path? - if ($this->library_path == '') + if ($this->library_path === '') { $this->set_error('imglib_libpath_invalid'); return FALSE; @@ -842,11 +842,11 @@ class CI_Image_lib { // Execute the command $cmd = $this->library_path.' -quality '.$this->quality; - if ($action == 'crop') + if ($action === 'crop') { $cmd .= ' -crop '.$this->width.'x'.$this->height.'+'.$this->x_axis.'+'.$this->y_axis.' "'.$this->full_src_path.'" "'.$this->full_dst_path .'" 2>&1'; } - elseif ($action == 'rotate') + elseif ($action === 'rotate') { $angle = ($this->rotation_angle === 'hor' OR $this->rotation_angle === 'vrt') ? '-flop' : '-rotate '.$this->rotation_angle; @@ -886,7 +886,7 @@ class CI_Image_lib { */ public function image_process_netpbm($action = 'resize') { - if ($this->library_path == '') + if ($this->library_path === '') { $this->set_error('imglib_libpath_invalid'); return FALSE; @@ -909,11 +909,11 @@ class CI_Image_lib { break; } - if ($action == 'crop') + if ($action === 'crop') { $cmd_inner = 'pnmcut -left '.$this->x_axis.' -top '.$this->y_axis.' -width '.$this->width.' -height '.$this->height; } - elseif ($action == 'rotate') + elseif ($action === 'rotate') { switch ($this->rotation_angle) { @@ -984,7 +984,7 @@ class CI_Image_lib { $dst_img = imagerotate($src_img, $this->rotation_angle, $white); // Show the image - if ($this->dynamic_output == TRUE) + if ($this->dynamic_output === TRUE) { $this->image_display_gd($dst_img); } @@ -1058,7 +1058,7 @@ class CI_Image_lib { } // Show the image - if ($this->dynamic_output == TRUE) + if ($this->dynamic_output === TRUE) { $this->image_display_gd($src_img); } @@ -1129,10 +1129,10 @@ class CI_Image_lib { $this->wm_vrt_alignment = strtoupper($this->wm_vrt_alignment[0]); $this->wm_hor_alignment = strtoupper($this->wm_hor_alignment[0]); - if ($this->wm_vrt_alignment == 'B') + if ($this->wm_vrt_alignment === 'B') $this->wm_vrt_offset = $this->wm_vrt_offset * -1; - if ($this->wm_hor_alignment == 'R') + if ($this->wm_hor_alignment === 'R') $this->wm_hor_offset = $this->wm_hor_offset * -1; // Set the base x and y axis values @@ -1160,7 +1160,7 @@ class CI_Image_lib { } // Build the finalized image - if ($wm_img_type == 3 && function_exists('imagealphablending')) + if ($wm_img_type === 3 && function_exists('imagealphablending')) { @imagealphablending($src_img, TRUE); } @@ -1183,7 +1183,7 @@ class CI_Image_lib { } // Output the image - if ($this->dynamic_output == TRUE) + if ($this->dynamic_output === TRUE) { $this->image_display_gd($src_img); } @@ -1212,7 +1212,7 @@ class CI_Image_lib { return FALSE; } - if ($this->wm_use_truetype == TRUE && ! file_exists($this->wm_font_path)) + if ($this->wm_use_truetype === TRUE && ! file_exists($this->wm_font_path)) { $this->set_error('imglib_missing_font'); return FALSE; @@ -1228,18 +1228,18 @@ class CI_Image_lib { // invert the offset. Note: The horizontal // offset flips itself automatically - if ($this->wm_vrt_alignment == 'B') + if ($this->wm_vrt_alignment === 'B') $this->wm_vrt_offset = $this->wm_vrt_offset * -1; - if ($this->wm_hor_alignment == 'R') + if ($this->wm_hor_alignment === 'R') $this->wm_hor_offset = $this->wm_hor_offset * -1; // Set font width and height // These are calculated differently depending on // whether we are using the true type font or not - if ($this->wm_use_truetype == TRUE) + if ($this->wm_use_truetype === TRUE) { - if ($this->wm_font_size == '') + if ($this->wm_font_size === '') { $this->wm_font_size = 17; } @@ -1258,7 +1258,7 @@ class CI_Image_lib { $x_axis = $this->wm_hor_offset + $this->wm_padding; $y_axis = $this->wm_vrt_offset + $this->wm_padding; - if ($this->wm_use_drop_shadow == FALSE) + if ($this->wm_use_drop_shadow === FALSE) $this->wm_shadow_distance = 0; $this->wm_vrt_alignment = strtoupper(substr($this->wm_vrt_alignment, 0, 1)); @@ -1316,7 +1316,7 @@ class CI_Image_lib { } // Output the final image - if ($this->dynamic_output == TRUE) + if ($this->dynamic_output === TRUE) { $this->image_display_gd($src_img); } @@ -1344,10 +1344,10 @@ class CI_Image_lib { */ public function image_create_gd($path = '', $image_type = '') { - if ($path == '') + if ($path === '') $path = $this->full_src_path; - if ($image_type == '') + if ($image_type === '') $image_type = $this->image_type; @@ -1494,7 +1494,7 @@ class CI_Image_lib { */ public function image_reproportion() { - if (($this->width == 0 && $this->height == 0) OR $this->orig_width == 0 OR $this->orig_height == 0 + if (($this->width === 0 && $this->height === 0) OR $this->orig_width === 0 OR $this->orig_height === 0 OR ( ! preg_match('/^[0-9]+$/', $this->width) && ! preg_match('/^[0-9]+$/', $this->height)) OR ! preg_match('/^[0-9]+$/', $this->orig_width) OR ! preg_match('/^[0-9]+$/', $this->orig_height)) { @@ -1549,7 +1549,7 @@ class CI_Image_lib { // For now we require GD but we should // find a way to determine this using IM or NetPBM - if ($path == '') + if ($path === '') { $path = $this->full_src_path; } @@ -1564,7 +1564,7 @@ class CI_Image_lib { $types = array(1 => 'gif', 2 => 'jpeg', 3 => 'png'); $mime = (isset($types[$vals[2]])) ? 'image/'.$types[$vals[2]] : 'image/jpg'; - if ($return == TRUE) + if ($return === TRUE) { return array( 'width' => $vals[0], @@ -1620,16 +1620,16 @@ class CI_Image_lib { } } - if ($vals['width'] == 0 OR $vals['height'] == 0) + if ($vals['width'] === 0 OR $vals['height'] === 0) { return $vals; } - if ($vals['new_width'] == 0) + if ($vals['new_width'] === 0) { $vals['new_width'] = ceil($vals['width']*$vals['new_height']/$vals['height']); } - elseif ($vals['new_height'] == 0) + elseif ($vals['new_height'] === 0) { $vals['new_height'] = ceil($vals['new_width']*$vals['height']/$vals['width']); } @@ -1715,14 +1715,14 @@ class CI_Image_lib { { foreach ($msg as $val) { - $msg = ($CI->lang->line($val) == FALSE) ? $val : $CI->lang->line($val); + $msg = ($CI->lang->line($val) === FALSE) ? $val : $CI->lang->line($val); $this->error_msg[] = $msg; log_message('error', $msg); } } else { - $msg = ($CI->lang->line($msg) == FALSE) ? $msg : $CI->lang->line($msg); + $msg = ($CI->lang->line($msg) === FALSE) ? $msg : $CI->lang->line($msg); $this->error_msg[] = $msg; log_message('error', $msg); } diff --git a/system/libraries/Javascript.php b/system/libraries/Javascript.php index dd2df697c..98fec61d3 100644 --- a/system/libraries/Javascript.php +++ b/system/libraries/Javascript.php @@ -615,7 +615,7 @@ class CI_Javascript { { $this->_javascript_location = $external_file; } - elseif ($this->CI->config->item('javascript_location') != '') + elseif ($this->CI->config->item('javascript_location') !== '') { $this->_javascript_location = $this->CI->config->item('javascript_location'); } @@ -667,7 +667,7 @@ class CI_Javascript { protected function _open_script($src = '') { return '<script type="text/javascript" charset="'.strtolower($this->CI->config->item('charset')).'"' - .($src == '' ? '>' : ' src="'.$src.'">'); + .($src === '' ? '>' : ' src="'.$src.'">'); } // -------------------------------------------------------------------- diff --git a/system/libraries/Log.php b/system/libraries/Log.php index 51ce43dc7..baac80121 100644 --- a/system/libraries/Log.php +++ b/system/libraries/Log.php @@ -94,7 +94,7 @@ class CI_Log { { $config =& get_config(); - $this->_log_path = ($config['log_path'] != '') ? $config['log_path'] : APPPATH.'logs/'; + $this->_log_path = ($config['log_path'] !== '') ? $config['log_path'] : APPPATH.'logs/'; if ( ! is_dir($this->_log_path) OR ! is_really_writable($this->_log_path)) { @@ -111,7 +111,7 @@ class CI_Log { $this->_threshold_array = array_flip($config['log_threshold']); } - if ($config['log_date_format'] != '') + if ($config['log_date_format'] !== '') { $this->_date_fmt = $config['log_date_format']; } diff --git a/system/libraries/Migration.php b/system/libraries/Migration.php index 0a88e6926..4391b235d 100644 --- a/system/libraries/Migration.php +++ b/system/libraries/Migration.php @@ -109,7 +109,7 @@ class CI_Migration { } // If not set, set it - $this->_migration_path != '' OR $this->_migration_path = APPPATH.'migrations/'; + $this->_migration_path !== '' OR $this->_migration_path = APPPATH.'migrations/'; // Add trailing slash if not set $this->_migration_path = rtrim($this->_migration_path, '/').'/'; @@ -179,7 +179,7 @@ class CI_Migration { // We now prepare to actually DO the migrations // But first let's make sure that everything is the way it should be - for ($i = $start; $i != $stop; $i += $step) + for ($i = $start; $i !== $stop; $i += $step) { $f = glob(sprintf($this->_migration_path.'%03d_*.php', $i)); diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php index 58f86fa17..a91159c98 100644 --- a/system/libraries/Pagination.php +++ b/system/libraries/Pagination.php @@ -97,7 +97,7 @@ class CI_Pagination { { if ($key === 'anchor_class') { - $this->anchor_class = ($val != '') ? 'class="'.$val.'" ' : ''; + $this->anchor_class = ($val !== '') ? 'class="'.$val.'" ' : ''; } elseif (isset($this->$key)) { @@ -117,7 +117,7 @@ class CI_Pagination { public function create_links() { // If our item count or per-page total is zero there is no need to continue. - if ($this->total_rows == 0 OR $this->per_page == 0) + if ($this->total_rows === 0 OR $this->per_page === 0) { return ''; } @@ -138,25 +138,25 @@ class CI_Pagination { $CI =& get_instance(); // See if we are using a prefix or suffix on links - if ($this->prefix != '' OR $this->suffix != '') + if ($this->prefix !== '' OR $this->suffix !== '') { $this->cur_page = (int) str_replace(array($this->prefix, $this->suffix), '', $CI->uri->segment($this->uri_segment)); } if ($CI->config->item('enable_query_strings') === TRUE OR $this->page_query_string === TRUE) { - if ($CI->input->get($this->query_string_segment) != $base_page) + if ($CI->input->get($this->query_string_segment) !== $base_page) { $this->cur_page = (int) $CI->input->get($this->query_string_segment); } } - elseif ( ! $this->cur_page && $CI->uri->segment($this->uri_segment) != $base_page) + elseif ( ! $this->cur_page && $CI->uri->segment($this->uri_segment) !== $base_page) { $this->cur_page = (int) $CI->uri->segment($this->uri_segment); } // Set current page to 1 if it's not valid or if using page numbers instead of offset - if ( ! is_numeric($this->cur_page) OR ($this->use_page_numbers && $this->cur_page == 0)) + if ( ! is_numeric($this->cur_page) OR ($this->use_page_numbers && $this->cur_page === 0)) { $this->cur_page = $base_page; } @@ -211,22 +211,22 @@ class CI_Pagination { // Render the "First" link if ($this->first_link !== FALSE && $this->cur_page > ($this->num_links + 1)) { - $first_url = ($this->first_url == '') ? $this->base_url : $this->first_url; + $first_url = ($this->first_url === '') ? $this->base_url : $this->first_url; $output .= $this->first_tag_open.'<a '.$this->anchor_class.'href="'.$first_url.'">'.$this->first_link.'</a>'.$this->first_tag_close; } // Render the "previous" link - if ($this->prev_link !== FALSE && $this->cur_page != 1) + if ($this->prev_link !== FALSE && $this->cur_page !== 1) { $i = ($this->use_page_numbers) ? $uri_page_number - 1 : $uri_page_number - $this->per_page; - if ($i == $base_page && $this->first_url != '') + if ($i === $base_page && $this->first_url !== '') { $output .= $this->prev_tag_open.'<a '.$this->anchor_class.'href="'.$this->first_url.'">'.$this->prev_link.'</a>'.$this->prev_tag_close; } else { - $i = ($i == $base_page) ? '' : $this->prefix.$i.$this->suffix; + $i = ($i === $base_page) ? '' : $this->prefix.$i.$this->suffix; $output .= $this->prev_tag_open.'<a '.$this->anchor_class.'href="'.$this->base_url.$i.'">'.$this->prev_link.'</a>'.$this->prev_tag_close; } @@ -242,21 +242,21 @@ class CI_Pagination { if ($i >= $base_page) { - if ($this->cur_page == $loop) + if ($this->cur_page === $loop) { $output .= $this->cur_tag_open.$loop.$this->cur_tag_close; // Current page } else { - $n = ($i == $base_page) ? '' : $i; + $n = ($i === $base_page) ? '' : $i; - if ($n == '' && $this->first_url != '') + if ($n === '' && $this->first_url !== '') { $output .= $this->num_tag_open.'<a '.$this->anchor_class.'href="'.$this->first_url.'">'.$loop.'</a>'.$this->num_tag_close; } else { - $n = ($n == '') ? '' : $this->prefix.$n.$this->suffix; + $n = ($n === '') ? '' : $this->prefix.$n.$this->suffix; $output .= $this->num_tag_open.'<a '.$this->anchor_class.'href="'.$this->base_url.$n.'">'.$loop.'</a>'.$this->num_tag_close; } diff --git a/system/libraries/Parser.php b/system/libraries/Parser.php index a0b60ed97..b64c78254 100644 --- a/system/libraries/Parser.php +++ b/system/libraries/Parser.php @@ -109,7 +109,7 @@ class CI_Parser { */ protected function _parse($template, $data, $return = FALSE) { - if ($template == '') + if ($template === '') { return FALSE; } @@ -121,7 +121,7 @@ class CI_Parser { : $template = $this->_parse_single($key, (string) $val, $template); } - if ($return == FALSE) + if ($return === FALSE) { $this->CI->output->append_output($template); } diff --git a/system/libraries/Profiler.php b/system/libraries/Profiler.php index e219d20f2..aaac0c518 100644 --- a/system/libraries/Profiler.php +++ b/system/libraries/Profiler.php @@ -219,7 +219,7 @@ class CI_Profiler { $show_hide_js = '(<span style="cursor: pointer;" onclick="var s=document.getElementById(\'ci_profiler_queries_db_'.$count.'\').style;s.display=s.display==\'none\'?\'\':\'none\';this.innerHTML=this.innerHTML==\''.$this->CI->lang->line('profiler_section_hide').'\'?\''.$this->CI->lang->line('profiler_section_show').'\':\''.$this->CI->lang->line('profiler_section_hide').'\';">'.$this->CI->lang->line('profiler_section_hide').'</span>)'; - if ($hide_queries != '') + if ($hide_queries !== '') { $show_hide_js = '(<span style="cursor: pointer;" onclick="var s=document.getElementById(\'ci_profiler_queries_db_'.$count.'\').style;s.display=s.display==\'none\'?\'\':\'none\';this.innerHTML=this.innerHTML==\''.$this->CI->lang->line('profiler_section_show').'\'?\''.$this->CI->lang->line('profiler_section_hide').'\':\''.$this->CI->lang->line('profiler_section_show').'\';">'.$this->CI->lang->line('profiler_section_show').'</span>)'; } @@ -315,7 +315,7 @@ class CI_Profiler { ."\n" .'<legend style="color:#009900;"> '.$this->CI->lang->line('profiler_post_data')." </legend>\n"; - if (count($_POST) == 0) + if (count($_POST) === 0) { $output .= '<div style="color:#009900;font-weight:normal;padding:4px 0 4px 0;">'.$this->CI->lang->line('profiler_no_post').'</div>'; } @@ -365,7 +365,7 @@ class CI_Profiler { ."\n" .'<legend style="color:#000;"> '.$this->CI->lang->line('profiler_uri_string')." </legend>\n" .'<div style="color:#000;font-weight:normal;padding:4px 0 4px 0;">' - .($this->CI->uri->uri_string == '' ? $this->CI->lang->line('profiler_no_uri') : $this->CI->uri->uri_string) + .($this->CI->uri->uri_string === '' ? $this->CI->lang->line('profiler_no_uri') : $this->CI->uri->uri_string) .'</div></fieldset>'; } @@ -402,7 +402,7 @@ class CI_Profiler { ."\n" .'<legend style="color:#5a0099;"> '.$this->CI->lang->line('profiler_memory_usage')." </legend>\n" .'<div style="color:#5a0099;font-weight:normal;padding:4px 0 4px 0;">' - .((function_exists('memory_get_usage') && ($usage = memory_get_usage()) != '') ? number_format($usage).' bytes' : $this->CI->lang->line('profiler_no_memory')) + .((function_exists('memory_get_usage') && ($usage = memory_get_usage()) !== '') ? number_format($usage).' bytes' : $this->CI->lang->line('profiler_no_memory')) .'</div></fieldset>'; } diff --git a/system/libraries/Session.php b/system/libraries/Session.php index 4d6aa0ce8..7beedd96b 100644 --- a/system/libraries/Session.php +++ b/system/libraries/Session.php @@ -206,7 +206,7 @@ class CI_Session { $this->$key = (isset($params[$key])) ? $params[$key] : $this->CI->config->item($key); } - if ($this->encryption_key == '') + if ($this->encryption_key === '') { show_error('In order to use the Session class you are required to set an encryption key in your config file.'); } @@ -215,13 +215,13 @@ class CI_Session { $this->CI->load->helper('string'); // Do we need encryption? If so, load the encryption class - if ($this->sess_encrypt_cookie == TRUE) + if ($this->sess_encrypt_cookie === TRUE) { $this->CI->load->library('encrypt'); } // Are we using a database? If so, load it - if ($this->sess_use_database === TRUE && $this->sess_table_name != '') + if ($this->sess_use_database === TRUE && $this->sess_table_name !== '') { $this->CI->load->database(); } @@ -232,7 +232,7 @@ class CI_Session { // Set the session length. If the session expiration is // set to zero we'll set the expiration two years from now. - if ($this->sess_expiration == 0) + if ($this->sess_expiration === 0) { $this->sess_expiration = (60*60*24*365*2); } @@ -283,7 +283,7 @@ class CI_Session { } // Decrypt the cookie data - if ($this->sess_encrypt_cookie == TRUE) + if ($this->sess_encrypt_cookie === TRUE) { $session = $this->CI->encrypt->decode($session); } @@ -320,14 +320,14 @@ class CI_Session { } // Does the IP match? - if ($this->sess_match_ip == TRUE && $session['ip_address'] !== $this->CI->input->ip_address()) + if ($this->sess_match_ip === TRUE && $session['ip_address'] !== $this->CI->input->ip_address()) { $this->sess_destroy(); return FALSE; } // Does the User Agent Match? - if ($this->sess_match_useragent == TRUE && trim($session['user_agent']) !== trim(substr($this->CI->input->user_agent(), 0, 120))) + if ($this->sess_match_useragent === TRUE && trim($session['user_agent']) !== trim(substr($this->CI->input->user_agent(), 0, 120))) { $this->sess_destroy(); return FALSE; @@ -338,12 +338,12 @@ class CI_Session { { $this->CI->db->where('session_id', $session['session_id']); - if ($this->sess_match_ip == TRUE) + if ($this->sess_match_ip === TRUE) { $this->CI->db->where('ip_address', $session['ip_address']); } - if ($this->sess_match_useragent == TRUE) + if ($this->sess_match_useragent === TRUE) { $this->CI->db->where('user_agent', $session['user_agent']); } @@ -359,7 +359,7 @@ class CI_Session { // Is there custom data? If so, add it to the main session array $row = $query->row(); - if (isset($row->user_data) && $row->user_data != '') + if ( ! empty($row->user_data)) { $custom_data = $this->_unserialize($row->user_data); @@ -809,7 +809,7 @@ class CI_Session { // Serialize the userdata for the cookie $cookie_data = $this->_serialize($cookie_data); - if ($this->sess_encrypt_cookie == TRUE) + if ($this->sess_encrypt_cookie === TRUE) { $cookie_data = $this->CI->encrypt->encode($cookie_data); } @@ -929,7 +929,7 @@ class CI_Session { */ protected function _sess_gc() { - if ($this->sess_use_database != TRUE) + if ($this->sess_use_database !== TRUE) { return; } diff --git a/system/libraries/Table.php b/system/libraries/Table.php index f844d6435..0f8404d85 100644 --- a/system/libraries/Table.php +++ b/system/libraries/Table.php @@ -169,7 +169,7 @@ class CI_Table { // will want headings from a one-dimensional array $this->auto_heading = FALSE; - if ($col_limit == 0) + if ($col_limit === 0) { return $array; } @@ -298,7 +298,7 @@ class CI_Table { } elseif (is_array($table_data)) { - $set_heading = (count($this->heading) !== 0 OR $this->auto_heading != FALSE); + $set_heading = (count($this->heading) !== 0 OR $this->auto_heading !== FALSE); $this->_set_from_array($table_data, $set_heading); } } @@ -336,7 +336,7 @@ class CI_Table { foreach ($heading as $key => $val) { - if ($key != 'data') + if ($key !== 'data') { $temp = str_replace('<th', '<th '.$key.'="'.$val.'"', $temp); } @@ -481,7 +481,7 @@ class CI_Table { foreach ($data as $row) { // If a heading hasn't already been set we'll use the first row of the array as the heading - if ($i++ === 0 && count($data) > 1 && count($this->heading) === 0 && $set_heading == TRUE) + if ($i++ === 0 && count($data) > 1 && count($this->heading) === 0 && $set_heading === TRUE) { $this->heading = $this->_prep_args($row); } @@ -501,7 +501,7 @@ class CI_Table { */ protected function _compile_template() { - if ($this->template == NULL) + if ($this->template === NULL) { $this->template = $this->_default_template(); return; diff --git a/system/libraries/Trackback.php b/system/libraries/Trackback.php index 6761f63a5..9a680dc2a 100644 --- a/system/libraries/Trackback.php +++ b/system/libraries/Trackback.php @@ -88,7 +88,7 @@ class CI_Trackback { } // Convert High ASCII Characters - if ($this->convert_ascii == TRUE && in_array($item, array('excerpt', 'title', 'blog_name'))) + if ($this->convert_ascii === TRUE && in_array($item, array('excerpt', 'title', 'blog_name'))) { $$item = $this->convert_ascii($$item); } @@ -106,7 +106,7 @@ class CI_Trackback { { foreach ($ping_url as $url) { - if ($this->process($url, $data) == FALSE) + if ($this->process($url, $data) === FALSE) { $return = FALSE; } @@ -132,7 +132,7 @@ class CI_Trackback { { foreach (array('url', 'title', 'blog_name', 'excerpt') as $val) { - if ( ! isset($_POST[$val]) OR $_POST[$val] == '') + if (empty($_POST[$val])) { $this->set_error('The following required POST variable is missing: '.$val); return FALSE; @@ -140,14 +140,14 @@ class CI_Trackback { $this->data['charset'] = isset($_POST['charset']) ? strtoupper(trim($_POST['charset'])) : 'auto'; - if ($val != 'url' && MB_ENABLED === TRUE) + if ($val !== 'url' && MB_ENABLED === TRUE) { $_POST[$val] = mb_convert_encoding($_POST[$val], $this->charset, $this->data['charset']); } - $_POST[$val] = ($val != 'url') ? $this->convert_xml(strip_tags($_POST[$val])) : strip_tags($_POST[$val]); + $_POST[$val] = ($val !== 'url') ? $this->convert_xml(strip_tags($_POST[$val])) : strip_tags($_POST[$val]); - if ($val == 'excerpt') + if ($val === 'excerpt') { $_POST['excerpt'] = $this->limit_characters($_POST['excerpt']); } diff --git a/system/libraries/Typography.php b/system/libraries/Typography.php index 6aaa993ae..a50934f2c 100644 --- a/system/libraries/Typography.php +++ b/system/libraries/Typography.php @@ -95,7 +95,7 @@ class CI_Typography { */ public function auto_typography($str, $reduce_linebreaks = FALSE) { - if ($str == '') + if ($str === '') { return ''; } @@ -173,7 +173,7 @@ class CI_Typography { $process = ($match[1] === '/'); } - if ($match[1] == '') + if ($match[1] === '') { $this->last_block_element = $match[2]; } @@ -344,7 +344,7 @@ class CI_Typography { */ protected function _format_newlines($str) { - if ($str == '' OR (strpos($str, "\n") === FALSE && ! in_array($this->last_block_element, $this->inner_block_required))) + if ($str === '' OR (strpos($str, "\n") === FALSE && ! in_array($this->last_block_element, $this->inner_block_required))) { return $str; } @@ -356,7 +356,7 @@ class CI_Typography { $str = preg_replace("/([^\n])(\n)([^\n])/", '\\1<br />\\2\\3', $str); // Wrap the whole enchilada in enclosing paragraphs - if ($str != "\n") + if ($str !== "\n") { // We trim off the right-side new line so that the closing </p> tag // will be positioned immediately following the string, matching diff --git a/system/libraries/Unit_test.php b/system/libraries/Unit_test.php index 6ec2dcd5d..a87cf7e14 100644 --- a/system/libraries/Unit_test.php +++ b/system/libraries/Unit_test.php @@ -93,7 +93,7 @@ class CI_Unit_test { */ public function run($test, $expected = TRUE, $test_name = 'undefined', $notes = '') { - if ($this->active == FALSE) + if ($this->active === FALSE) { return FALSE; } @@ -106,7 +106,7 @@ class CI_Unit_test { } else { - $result = ($this->strict == TRUE) ? ($test === $expected) : ($test == $expected); + $result = ($this->strict === TRUE) ? ($test === $expected) : ($test === $expected); $extype = gettype($expected); } @@ -155,13 +155,13 @@ class CI_Unit_test { foreach ($res as $key => $val) { - if ($key == $CI->lang->line('ut_result')) + if ($key === $CI->lang->line('ut_result')) { - if ($val == $CI->lang->line('ut_passed')) + if ($val === $CI->lang->line('ut_passed')) { $val = '<span style="color: #0C0;">'.$val.'</span>'; } - elseif ($val == $CI->lang->line('ut_failed')) + elseif ($val === $CI->lang->line('ut_failed')) { $val = '<span style="color: #C00;">'.$val.'</span>'; } diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php index 7456e922a..bd97a611b 100644 --- a/system/libraries/Upload.php +++ b/system/libraries/Upload.php @@ -223,7 +223,7 @@ class CI_Upload { } // if we're overriding, let's now make sure the new name and type is allowed - if ($this->_file_name_override != '') + if ($this->_file_name_override !== '') { $this->file_name = $this->_prep_filename($this->_file_name_override); @@ -276,7 +276,7 @@ class CI_Upload { } // Remove white spaces in the name - if ($this->remove_spaces == TRUE) + if ($this->remove_spaces === TRUE) { $this->file_name = preg_replace('/\s+/', '_', $this->file_name); } @@ -289,7 +289,7 @@ class CI_Upload { */ $this->orig_name = $this->file_name; - if ($this->overwrite == FALSE) + if ($this->overwrite === FALSE) { $this->file_name = $this->set_filename($this->upload_path, $this->file_name); @@ -397,7 +397,7 @@ class CI_Upload { */ public function set_filename($path, $filename) { - if ($this->encrypt_name == TRUE) + if ($this->encrypt_name === TRUE) { mt_srand(); $filename = md5(uniqid(mt_rand())).$this->file_ext; @@ -420,7 +420,7 @@ class CI_Upload { } } - if ($new_filename == '') + if ($new_filename === '') { $this->set_error('upload_bad_filename'); return FALSE; @@ -545,7 +545,7 @@ class CI_Upload { */ public function set_xss_clean($flag = FALSE) { - $this->xss_clean = ($flag == TRUE); + $this->xss_clean = ($flag === TRUE); } // -------------------------------------------------------------------- @@ -641,7 +641,7 @@ class CI_Upload { */ public function is_allowed_filesize() { - return ($this->max_size == 0 OR $this->max_size > $this->file_size); + return ($this->max_size === 0 OR $this->max_size > $this->file_size); } // -------------------------------------------------------------------- @@ -687,7 +687,7 @@ class CI_Upload { */ public function validate_upload_path() { - if ($this->upload_path == '') + if ($this->upload_path === '') { $this->set_error('upload_no_filepath'); return FALSE; @@ -814,7 +814,7 @@ class CI_Upload { return FALSE; } - if (function_exists('memory_get_usage') && memory_get_usage() && ini_get('memory_limit') != '') + if (function_exists('memory_get_usage') && memory_get_usage() && ini_get('memory_limit')) { $current = ini_get('memory_limit') * 1024 * 1024; @@ -884,14 +884,14 @@ class CI_Upload { { foreach ($msg as $val) { - $msg = ($CI->lang->line($val) == FALSE) ? $val : $CI->lang->line($val); + $msg = ($CI->lang->line($val) === FALSE) ? $val : $CI->lang->line($val); $this->error_msg[] = $msg; log_message('error', $msg); } } else { - $msg = ($CI->lang->line($msg) == FALSE) ? $msg : $CI->lang->line($msg); + $msg = ($CI->lang->line($msg) === FALSE) ? $msg : $CI->lang->line($msg); $this->error_msg[] = $msg; log_message('error', $msg); } @@ -926,7 +926,7 @@ class CI_Upload { { global $mimes; - if (count($this->mimes) == 0) + if (count($this->mimes) === 0) { if (defined('ENVIRONMENT') && is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes.php')) { @@ -960,7 +960,7 @@ class CI_Upload { */ protected function _prep_filename($filename) { - if (strpos($filename, '.') === FALSE OR $this->allowed_types == '*') + if (strpos($filename, '.') === FALSE OR $this->allowed_types === '*') { return $filename; } diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index 0d2533855..6f3542333 100644 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -256,7 +256,7 @@ class CI_Xmlrpc { */ public function set_debug($flag = TRUE) { - $this->debug = ($flag == TRUE); + $this->debug = ($flag === TRUE); } // -------------------------------------------------------------------- @@ -277,7 +277,7 @@ class CI_Xmlrpc { } else { - if (is_array($value[0]) && ($value[1] == 'struct' OR $value[1] == 'array')) + if (is_array($value[0]) && ($value[1] === 'struct' OR $value[1] === 'array')) { while (list($k) = each($value[0])) { @@ -496,7 +496,7 @@ class XML_RPC_Response */ public function __construct($val, $code = 0, $fstr = '') { - if ($code != 0) + if ($code !== 0) { // error $this->errno = $code; @@ -636,11 +636,11 @@ class XML_RPC_Response { $kind = $xmlrpc_val->kindOf(); - if ($kind == 'scalar') + if ($kind === 'scalar') { return $xmlrpc_val->scalarval(); } - elseif ($kind == 'array') + elseif ($kind === 'array') { reset($xmlrpc_val->me); $b = current($xmlrpc_val->me); @@ -652,7 +652,7 @@ class XML_RPC_Response } return $arr; } - elseif ($kind == 'struct') + elseif ($kind === 'struct') { reset($xmlrpc_val->me['struct']); $arr = array(); @@ -680,7 +680,7 @@ class XML_RPC_Response $t = 0; if (preg_match('/([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})/', $time, $regs)) { - $fnc = ($utc == TRUE) ? 'gmmktime' : 'mktime'; + $fnc = ($utc === TRUE) ? 'gmmktime' : 'mktime'; $t = $fnc($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]); } return $t; @@ -873,7 +873,7 @@ class XML_RPC_Message extends CI_Xmlrpc $errstr_v = $v->me['struct']['faultString']; $errno = $errno_v->scalarval(); - if ($errno == 0) + if ($errno === 0) { // FAULT returned, errno needs to reflect that $errno = -1; @@ -921,9 +921,9 @@ class XML_RPC_Message extends CI_Xmlrpc if ($this->xh[$the_parser]['isf'] > 1) return; // Evaluate and check for correct nesting of XML elements - if (count($this->xh[$the_parser]['stack']) == 0) + if (count($this->xh[$the_parser]['stack']) === 0) { - if ($name != 'METHODRESPONSE' && $name != 'METHODCALL') + if ($name !== 'METHODRESPONSE' && $name !== 'METHODCALL') { $this->xh[$the_parser]['isf'] = 2; $this->xh[$the_parser]['isf_reason'] = 'Top level XML-RPC element is missing'; @@ -968,7 +968,7 @@ class XML_RPC_Message extends CI_Xmlrpc case 'DOUBLE': case 'DATETIME.ISO8601': case 'BASE64': - if ($this->xh[$the_parser]['vt'] != 'value') + if ($this->xh[$the_parser]['vt'] !== 'value') { //two data elements inside a value: an error occurred! $this->xh[$the_parser]['isf'] = 2; @@ -1002,7 +1002,7 @@ class XML_RPC_Message extends CI_Xmlrpc // Add current element name to stack, to allow validation of nesting array_unshift($this->xh[$the_parser]['stack'], $name); - $name == 'VALUE' OR $this->xh[$the_parser]['lv'] = 0; + $name === 'VALUE' OR $this->xh[$the_parser]['lv'] = 0; } // -------------------------------------------------------------------- @@ -1045,20 +1045,20 @@ class XML_RPC_Message extends CI_Xmlrpc case 'BASE64': $this->xh[$the_parser]['vt'] = strtolower($name); - if ($name == 'STRING') + if ($name === 'STRING') { $this->xh[$the_parser]['value'] = $this->xh[$the_parser]['ac']; } - elseif ($name == 'DATETIME.ISO8601') + elseif ($name === 'DATETIME.ISO8601') { $this->xh[$the_parser]['vt'] = $this->xmlrpcDateTime; $this->xh[$the_parser]['value'] = $this->xh[$the_parser]['ac']; } - elseif ($name == 'BASE64') + elseif ($name === 'BASE64') { $this->xh[$the_parser]['value'] = base64_decode($this->xh[$the_parser]['ac']); } - elseif ($name == 'BOOLEAN') + elseif ($name === 'BOOLEAN') { // Translated BOOLEAN values to TRUE AND FALSE $this->xh[$the_parser]['value'] = (bool) $this->xh[$the_parser]['ac']; @@ -1093,7 +1093,7 @@ class XML_RPC_Message extends CI_Xmlrpc // build the XML-RPC value out of the data received, and substitute it $temp = new XML_RPC_Values($this->xh[$the_parser]['value'], $this->xh[$the_parser]['vt']); - if (count($this->xh[$the_parser]['valuestack']) && $this->xh[$the_parser]['valuestack'][0]['type'] == 'ARRAY') + if (count($this->xh[$the_parser]['valuestack']) && $this->xh[$the_parser]['valuestack'][0]['type'] === 'ARRAY') { // Array $this->xh[$the_parser]['valuestack'][0]['values'][] = $temp; @@ -1151,9 +1151,9 @@ class XML_RPC_Message extends CI_Xmlrpc if ($this->xh[$the_parser]['isf'] > 1) return; // XML Fault found already // If a value has not been found - if ($this->xh[$the_parser]['lv'] != 3) + if ($this->xh[$the_parser]['lv'] !== 3) { - if ($this->xh[$the_parser]['lv'] == 1) + if ($this->xh[$the_parser]['lv'] === 1) { $this->xh[$the_parser]['lv'] = 2; // Found a value } @@ -1204,7 +1204,7 @@ class XML_RPC_Message extends CI_Xmlrpc { // 'bits' is for the MetaWeblog API image bits // @todo - this needs to be made more general purpose - $array[$key] = ($key == 'bits' OR $this->xss_clean == FALSE) ? $array[$key] : $CI->security->xss_clean($array[$key]); + $array[$key] = ($key === 'bits' OR $this->xss_clean === FALSE) ? $array[$key] : $CI->security->xss_clean($array[$key]); } } @@ -1242,11 +1242,11 @@ class XML_RPC_Message extends CI_Xmlrpc { $kind = $param->kindOf(); - if ($kind == 'scalar') + if ($kind === 'scalar') { return $param->scalarval(); } - elseif ($kind == 'array') + elseif ($kind === 'array') { reset($param->me); $b = current($param->me); @@ -1259,7 +1259,7 @@ class XML_RPC_Message extends CI_Xmlrpc return $arr; } - elseif ($kind == 'struct') + elseif ($kind === 'struct') { reset($param->me['struct']); $arr = array(); @@ -1298,19 +1298,19 @@ class XML_RPC_Values extends CI_Xmlrpc { parent::__construct(); - if ($val != -1 OR $type != '') + if ($val !== -1 OR $type !== '') { - $type = $type == '' ? 'string' : $type; + $type = $type === '' ? 'string' : $type; - if ($this->xmlrpcTypes[$type] == 1) + if ($this->xmlrpcTypes[$type] === 1) { $this->addScalar($val,$type); } - elseif ($this->xmlrpcTypes[$type] == 2) + elseif ($this->xmlrpcTypes[$type] === 2) { $this->addArray($val); } - elseif ($this->xmlrpcTypes[$type] == 3) + elseif ($this->xmlrpcTypes[$type] === 3) { $this->addStruct($val); } @@ -1330,24 +1330,24 @@ class XML_RPC_Values extends CI_Xmlrpc { $typeof = $this->xmlrpcTypes[$type]; - if ($this->mytype == 1) + if ($this->mytype === 1) { echo '<strong>XML_RPC_Values</strong>: scalar can have only one value<br />'; return 0; } - if ($typeof != 1) + if ($typeof !== 1) { echo '<strong>XML_RPC_Values</strong>: not a scalar type (${typeof})<br />'; return 0; } - if ($type == $this->xmlrpcBoolean) + if ($type === $this->xmlrpcBoolean) { $val = (int) (strcasecmp($val,'true') === 0 OR $val === 1 OR ($val === TRUE && strcasecmp($val, 'false'))); } - if ($this->mytype == 2) + if ($this->mytype === 2) { // adding to an array here $ar = $this->me['array']; @@ -1374,7 +1374,7 @@ class XML_RPC_Values extends CI_Xmlrpc */ public function addArray($vals) { - if ($this->mytype != 0) + if ($this->mytype !== 0) { echo '<strong>XML_RPC_Values</strong>: already initialized as a [' . $this->kindOf() . ']<br />'; return 0; @@ -1395,7 +1395,7 @@ class XML_RPC_Values extends CI_Xmlrpc */ public function addStruct($vals) { - if ($this->mytype != 0) + if ($this->mytype !== 0) { echo '<strong>XML_RPC_Values</strong>: already initialized as a [' . $this->kindOf() . ']<br />'; return 0; diff --git a/system/libraries/Xmlrpcs.php b/system/libraries/Xmlrpcs.php index 1853906ea..be930b0f9 100644 --- a/system/libraries/Xmlrpcs.php +++ b/system/libraries/Xmlrpcs.php @@ -208,7 +208,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc // Get Data //------------------------------------- - if ($data == '') + if ($data === '') { $data = $HTTP_RAW_POST_DATA; } @@ -305,7 +305,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc // Check to see if it is a system call $system_call = (strncmp($methName, 'system', 5) === 0); - if ($this->xss_clean == FALSE) + if ($this->xss_clean === FALSE) { $m->xss_clean = FALSE; } @@ -324,7 +324,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc //------------------------------------- $method_parts = explode('.', $this->methods[$methName]['function']); - $objectCall = (isset($method_parts[1]) && $method_parts[1] != ''); + $objectCall = (isset($method_parts[1]) && $method_parts[1] !== ''); if ($system_call === TRUE) { @@ -356,9 +356,9 @@ class CI_Xmlrpcs extends CI_Xmlrpc for ($n = 0, $mc = count($m->params); $n < $mc; $n++) { $p = $m->params[$n]; - $pt = ($p->kindOf() == 'scalar') ? $p->scalarval() : $p->kindOf(); + $pt = ($p->kindOf() === 'scalar') ? $p->scalarval() : $p->kindOf(); - if ($pt != $current_sig[$n+1]) + if ($pt !== $current_sig[$n+1]) { $pno = $n+1; $wanted = $current_sig[$n+1]; @@ -527,7 +527,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc $attempt = $this->_execute($m); - if ($attempt->faultCode() != 0) + if ($attempt->faultCode() !== 0) { return $attempt; } @@ -567,7 +567,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc */ public function do_multicall($call) { - if ($call->kindOf() != 'struct') + if ($call->kindOf() !== 'struct') { return $this->multicall_error('notstruct'); } @@ -577,13 +577,13 @@ class CI_Xmlrpcs extends CI_Xmlrpc } list($scalar_type,$scalar_value)=each($methName->me); - $scalar_type = $scalar_type == $this->xmlrpcI4 ? $this->xmlrpcInt : $scalar_type; + $scalar_type = $scalar_type === $this->xmlrpcI4 ? $this->xmlrpcInt : $scalar_type; - if ($methName->kindOf() != 'scalar' OR $scalar_type != 'string') + if ($methName->kindOf() !== 'scalar' OR $scalar_type !== 'string') { return $this->multicall_error('notstring'); } - elseif ($scalar_value == 'system.multicall') + elseif ($scalar_value === 'system.multicall') { return $this->multicall_error('recursion'); } @@ -591,7 +591,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc { return $this->multicall_error('noparams'); } - elseif ($params->kindOf() != 'array') + elseif ($params->kindOf() !== 'array') { return $this->multicall_error('notarray'); } @@ -606,7 +606,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc $result = $this->_execute($msg); - if ($result->faultCode() != 0) + if ($result->faultCode() !== 0) { return $this->multicall_error($result); } diff --git a/system/libraries/javascript/Jquery.php b/system/libraries/javascript/Jquery.php index 3c9ae1867..44c16b578 100644 --- a/system/libraries/javascript/Jquery.php +++ b/system/libraries/javascript/Jquery.php @@ -416,12 +416,12 @@ class CI_Jquery extends CI_Javascript { $animations = substr($animations, 0, -2); // remove the last ", " - if ($speed != '') + if ($speed !== '') { $speed = ', '.$speed; } - if ($extra != '') + if ($extra !== '') { $extra = ', '.$extra; } @@ -446,7 +446,7 @@ class CI_Jquery extends CI_Javascript { $element = $this->_prep_element($element); $speed = $this->_validate_speed($speed); - if ($callback != '') + if ($callback !== '') { $callback = ", function(){\n{$callback}\n}"; } @@ -471,7 +471,7 @@ class CI_Jquery extends CI_Javascript { $element = $this->_prep_element($element); $speed = $this->_validate_speed($speed); - if ($callback != '') + if ($callback !== '') { $callback = ", function(){\n{$callback}\n}"; } @@ -496,7 +496,7 @@ class CI_Jquery extends CI_Javascript { $element = $this->_prep_element($element); $speed = $this->_validate_speed($speed); - if ($callback != '') + if ($callback !== '') { $callback = ", function(){\n{$callback}\n}"; } @@ -537,7 +537,7 @@ class CI_Jquery extends CI_Javascript { $element = $this->_prep_element($element); $speed = $this->_validate_speed($speed); - if ($callback != '') + if ($callback !== '') { $callback = ", function(){\n{$callback}\n}"; } @@ -562,7 +562,7 @@ class CI_Jquery extends CI_Javascript { $element = $this->_prep_element($element); $speed = $this->_validate_speed($speed); - if ($callback != '') + if ($callback !== '') { $callback = ", function(){\n{$callback}\n}"; } @@ -587,7 +587,7 @@ class CI_Jquery extends CI_Javascript { $element = $this->_prep_element($element); $speed = $this->_validate_speed($speed); - if ($callback != '') + if ($callback !== '') { $callback = ", function(){\n{$callback}\n}"; } @@ -644,7 +644,7 @@ class CI_Jquery extends CI_Javascript { $element = $this->_prep_element($element); $speed = $this->_validate_speed($speed); - if ($callback != '') + if ($callback !== '') { $callback = ", function(){\n{$callback}\n}"; } @@ -672,7 +672,7 @@ class CI_Jquery extends CI_Javascript { $controller = (strpos('://', $controller) === FALSE) ? $controller : $this->CI->config->site_url($controller); // ajaxStart and ajaxStop are better choices here... but this is a stop gap - if ($this->CI->config->item('javascript_ajax_img') == '') + if ($this->CI->config->item('javascript_ajax_img') === '') { $loading_notifier = 'Loading...'; } @@ -685,7 +685,7 @@ class CI_Jquery extends CI_Javascript { ."\t\t$(".$container.').prepend("'.$loading_notifier."\");\n"; // to replace with an image $request_options = ''; - if ($options != '') + if ($options !== '') { $request_options .= ', {' .(is_array($options) ? "'".implode("', '", $options)."'" : "'".str_replace(':', "':'", $options)."'") @@ -709,12 +709,12 @@ class CI_Jquery extends CI_Javascript { */ protected function _zebraTables($class = '', $odd = 'odd', $hover = '') { - $class = ($class != '') ? '.'.$class : ''; + $class = ($class !== '') ? '.'.$class : ''; $zebra = "\t\$(\"table{$class} tbody tr:nth-child(even)\").addClass(\"{$odd}\");"; $this->jquery_code_for_compile[] = $zebra; - if ($hover != '') + if ($hover !== '') { $hover = $this->hover("table{$class} tbody tr", "$(this).addClass('hover');", "$(this).removeClass('hover');"); } @@ -739,7 +739,7 @@ class CI_Jquery extends CI_Javascript { // may want to make this configurable down the road $corner_location = '/plugins/jquery.corner.js'; - if ($corner_style != '') + if ($corner_style !== '') { $corner_style = '"'.$corner_style.'"'; } @@ -972,7 +972,7 @@ class CI_Jquery extends CI_Javascript { */ protected function _prep_element($element) { - if ($element != 'this') + if ($element !== 'this') { $element = '"'.$element.'"'; } |