Skip to content

Commit 92ebfb6

Browse files
committed
Cleanup the core classes
1 parent c59e872 commit 92ebfb6

File tree

15 files changed

+135
-132
lines changed

15 files changed

+135
-132
lines changed

system/core/Benchmark.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,11 @@
2525
* @filesource
2626
*/
2727

28-
// ------------------------------------------------------------------------
29-
3028
/**
3129
* CodeIgniter Benchmark Class
3230
*
3331
* This class enables you to mark points and calculate the time difference
34-
* between them. Memory consumption can also be displayed.
32+
* between them. Memory consumption can also be displayed.
3533
*
3634
* @package CodeIgniter
3735
* @subpackage Libraries
@@ -119,4 +117,4 @@ public function memory_usage()
119117
}
120118

121119
/* End of file Benchmark.php */
122-
/* Location: ./system/core/Benchmark.php */
120+
/* Location: ./system/core/Benchmark.php */

system/core/CodeIgniter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
* Loads the base classes and executes the request.
3232
*
3333
* @package CodeIgniter
34-
* @subpackage codeigniter
34+
* @subpackage CodeIgniter
3535
* @category Front-controller
3636
* @author EllisLab Dev Team
3737
* @link http://codeigniter.com/user_guide/

system/core/Common.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
* Loads the base classes and executes the request.
3232
*
3333
* @package CodeIgniter
34-
* @subpackage codeigniter
34+
* @subpackage CodeIgniter
3535
* @category Common Functions
3636
* @author EllisLab Dev Team
3737
* @link http://codeigniter.com/user_guide/
@@ -57,7 +57,7 @@ function is_php($version = '5.0.0')
5757

5858
if ( ! isset($_is_php[$version]))
5959
{
60-
$_is_php[$version] = (version_compare(PHP_VERSION, $version) < 0) ? FALSE : TRUE;
60+
$_is_php[$version] = (version_compare(PHP_VERSION, $version) >= 0);
6161
}
6262

6363
return $_is_php[$version];
@@ -506,7 +506,7 @@ function _exception_handler($severity, $message, $filepath, $line)
506506
$_error->show_php_error($severity, $message, $filepath, $line);
507507
}
508508

509-
// Should we log the error? No? We're done...
509+
// Should we log the error? No? We're done...
510510
if (config_item('log_threshold') == 0)
511511
{
512512
return;

system/core/Config.php

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
* @filesource
2626
*/
2727

28-
// ------------------------------------------------------------------------
29-
3028
/**
3129
* CodeIgniter Config Class
3230
*
@@ -46,14 +44,14 @@ class CI_Config {
4644
* @var array
4745
*/
4846
public $config = array();
49-
47+
5048
/**
5149
* List of all loaded config files
5250
*
5351
* @var array
5452
*/
5553
public $is_loaded = array();
56-
54+
5755
/**
5856
* List of paths to search when trying to load a config file.
5957
* This must be public as it's used by the Loader class.
@@ -77,9 +75,9 @@ public function __construct()
7775
{
7876
if (isset($_SERVER['HTTP_HOST']))
7977
{
80-
$base_url = ! empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off' ? 'https' : 'http';
81-
$base_url .= '://'. $_SERVER['HTTP_HOST']
82-
. str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);
78+
$base_url = ( ! empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off') ? 'https' : 'http';
79+
$base_url .= '://'.$_SERVER['HTTP_HOST']
80+
.str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);
8381
}
8482
else
8583
{
@@ -96,9 +94,9 @@ public function __construct()
9694
* Load Config File
9795
*
9896
* @param string the config file name
99-
* @param boolean if configuration values should be loaded into their own section
100-
* @param boolean true if errors should just return false, false if an error message should be displayed
101-
* @return boolean if the file was loaded correctly
97+
* @param bool if configuration values should be loaded into their own section
98+
* @param bool true if errors should just return false, false if an error message should be displayed
99+
* @return bool if the file was loaded correctly
102100
*/
103101
public function load($file = '', $use_sections = FALSE, $fail_gracefully = FALSE)
104102
{
@@ -254,8 +252,8 @@ public function site_url($uri = '')
254252
* Base URL
255253
* Returns base_url [. uri_string]
256254
*
257-
* @param string $uri
258-
* @return string
255+
* @param string $uri
256+
* @return string
259257
*/
260258
public function base_url($uri = '')
261259
{
@@ -267,8 +265,8 @@ public function base_url($uri = '')
267265
/**
268266
* Build URI string for use in Config::site_url() and Config::base_url()
269267
*
270-
* @param mixed $uri
271-
* @return string
268+
* @param mixed $uri
269+
* @return string
272270
*/
273271
protected function _uri_string($uri)
274272
{
@@ -345,6 +343,7 @@ public function _assign_to_config($items = array())
345343
}
346344
}
347345
}
346+
348347
}
349348

350349
/* End of file Config.php */

system/core/Controller.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ class CI_Controller {
4848

4949
/**
5050
* Set up controller properties and methods
51+
*
52+
* @return void
5153
*/
5254
public function __construct()
5355
{
@@ -67,14 +69,15 @@ public function __construct()
6769
}
6870

6971
/**
70-
* Return the CI object
72+
* Return the CI object
7173
*
72-
* @return object
74+
* @return object
7375
*/
7476
public static function &get_instance()
7577
{
7678
return self::$instance;
7779
}
80+
7881
}
7982

8083
/* End of file Controller.php */

system/core/Exceptions.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ class CI_Exceptions {
6565

6666
/**
6767
* Initialize execption class
68+
*
69+
* @return void
6870
*/
6971
public function __construct()
7072
{
@@ -87,7 +89,7 @@ public function __construct()
8789
*/
8890
public function log_exception($severity, $message, $filepath, $line)
8991
{
90-
$severity = ( ! isset($this->levels[$severity])) ? $severity : $this->levels[$severity];
92+
$severity = isset($this->levels[$severity]) ? $this->levels[$severity] : $severity;
9193
log_message('error', 'Severity: '.$severity.' --> '.$message. ' '.$filepath.' '.$line, TRUE);
9294
}
9395

@@ -127,14 +129,14 @@ public function show_404($page = '', $log_error = TRUE)
127129
* @param string the heading
128130
* @param string the message
129131
* @param string the template name
130-
* @param int the status code
132+
* @param int the status code
131133
* @return string
132134
*/
133135
public function show_error($heading, $message, $template = 'error_general', $status_code = 500)
134136
{
135137
set_status_header($status_code);
136138

137-
$message = '<p>'.implode('</p><p>', ( ! is_array($message)) ? array($message) : $message).'</p>';
139+
$message = '<p>'.implode('</p><p>', is_array($message) ? $message : array($message)).'</p>';
138140

139141
if (ob_get_level() > $this->ob_level + 1)
140142
{
@@ -160,7 +162,7 @@ public function show_error($heading, $message, $template = 'error_general', $sta
160162
*/
161163
public function show_php_error($severity, $message, $filepath, $line)
162164
{
163-
$severity = ( ! isset($this->levels[$severity])) ? $severity : $this->levels[$severity];
165+
$severity = isset($this->levels[$severity]) ? $this->levels[$severity] : $severity;
164166
$filepath = str_replace('\\', '/', $filepath);
165167

166168
// For safety reasons we do not show the full file path
@@ -175,7 +177,7 @@ public function show_php_error($severity, $message, $filepath, $line)
175177
ob_end_flush();
176178
}
177179
ob_start();
178-
include(APPPATH.'errors/'.'error_php.php');
180+
include(APPPATH.'errors/error_php.php');
179181
$buffer = ob_get_contents();
180182
ob_end_clean();
181183
echo $buffer;

system/core/Hooks.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ class CI_Hooks {
4444
* @var bool
4545
*/
4646
public $enabled = FALSE;
47-
47+
4848
/**
4949
* List of all hooks set in config/hooks.php
5050
*
5151
* @var array
5252
*/
5353
public $hooks = array();
54-
54+
5555
/**
5656
* Determines wether hook is in progress, used to prevent infinte loops
5757
*
@@ -152,7 +152,7 @@ protected function _run_hook($data)
152152

153153
// If the script being called happens to have the same
154154
// hook call within it a loop can happen
155-
if ($this->in_progress == TRUE)
155+
if ($this->in_progress === TRUE)
156156
{
157157
return;
158158
}

system/core/Input.php

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -44,44 +44,44 @@ class CI_Input {
4444
* @var string
4545
*/
4646
public $ip_address = FALSE;
47-
47+
4848
/**
4949
* user agent (web browser) being used by the current user
5050
*
5151
* @var string
5252
*/
5353
public $user_agent = FALSE;
54-
54+
5555
/**
5656
* If FALSE, then $_GET will be set to an empty array
5757
*
5858
* @var bool
5959
*/
6060
protected $_allow_get_array = TRUE;
61-
61+
6262
/**
6363
* If TRUE, then newlines are standardized
6464
*
6565
* @var bool
6666
*/
6767
protected $_standardize_newlines = TRUE;
68-
68+
6969
/**
7070
* Determines whether the XSS filter is always active when GET, POST or COOKIE data is encountered
7171
* Set automatically based on config setting
7272
*
7373
* @var bool
7474
*/
7575
protected $_enable_xss = FALSE;
76-
76+
7777
/**
7878
* Enables a CSRF cookie token to be set.
7979
* Set automatically based on config setting
8080
*
8181
* @var bool
8282
*/
8383
protected $_enable_csrf = FALSE;
84-
84+
8585
/**
8686
* List of all HTTP request headers
8787
*
@@ -94,6 +94,8 @@ class CI_Input {
9494
*
9595
* Sets whether to globally enable the XSS processing
9696
* and whether to allow the $_GET array
97+
*
98+
* @return void
9799
*/
98100
public function __construct()
99101
{
@@ -438,15 +440,7 @@ protected function _sanitize_globals()
438440
// This is effectively the same as register_globals = off
439441
foreach (array($_GET, $_POST, $_COOKIE) as $global)
440442
{
441-
if ( ! is_array($global))
442-
{
443-
if ( ! in_array($global, $protected))
444-
{
445-
global $$global;
446-
$$global = NULL;
447-
}
448-
}
449-
else
443+
if (is_array($global))
450444
{
451445
foreach ($global as $key => $val)
452446
{
@@ -457,6 +451,11 @@ protected function _sanitize_globals()
457451
}
458452
}
459453
}
454+
elseif ( ! in_array($global, $protected))
455+
{
456+
global $$global;
457+
$$global = NULL;
458+
}
460459
}
461460

462461
// Is $_GET data allowed? If not we'll set the $_GET to an empty array
@@ -605,7 +604,7 @@ protected function _clean_input_keys($str)
605604
* In Apache, you can simply call apache_request_headers(), however for
606605
* people running other webservers the function is undefined.
607606
*
608-
* @param bool XSS cleaning
607+
* @param bool XSS cleaning
609608
* @return array
610609
*/
611610
public function request_headers($xss_clean = FALSE)

0 commit comments

Comments
 (0)