@@ -39,8 +39,7 @@ |
||
| 39 | 39 | { |
| 40 | 40 | $CI->db->close(); |
| 41 | 41 | $CI->db = null; |
| 42 | - } |
|
| 43 | - else |
|
| 42 | + } else |
|
| 44 | 43 | { |
| 45 | 44 | // Don't close if SQLite in-memory database |
| 46 | 45 | // If we close it, all tables and stored data will be gone |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | reset_config(); |
| 33 | 33 | |
| 34 | 34 | // Close db connection |
| 35 | - $CI =& get_instance(); |
|
| 35 | + $CI = & get_instance(); |
|
| 36 | 36 | if (isset($CI->db)) |
| 37 | 37 | { |
| 38 | 38 | if ( |
@@ -52,25 +52,25 @@ discard block |
||
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | // Load core classes |
| 55 | - $BM =& load_class('Benchmark', 'core'); |
|
| 55 | + $BM = & load_class('Benchmark', 'core'); |
|
| 56 | 56 | CIPHPUnitTestSuperGlobal::set_Global('BM', $BM); |
| 57 | - $EXT =& load_class('Hooks', 'core'); |
|
| 57 | + $EXT = & load_class('Hooks', 'core'); |
|
| 58 | 58 | CIPHPUnitTestSuperGlobal::set_Global('EXT', $EXT); |
| 59 | - $CFG =& load_class('Config', 'core'); |
|
| 59 | + $CFG = & load_class('Config', 'core'); |
|
| 60 | 60 | CIPHPUnitTestSuperGlobal::set_Global('CFG', $CFG); |
| 61 | - $UNI =& load_class('URI', 'core'); |
|
| 61 | + $UNI = & load_class('URI', 'core'); |
|
| 62 | 62 | CIPHPUnitTestSuperGlobal::set_Global('UNI', $UNI); |
| 63 | 63 | // $URI =& load_class('Utf8', 'core'); |
| 64 | 64 | // CIPHPUnitTestSuperGlobal::set_Global('URI', $URI); |
| 65 | - $RTR =& load_class('Router', 'core'); |
|
| 65 | + $RTR = & load_class('Router', 'core'); |
|
| 66 | 66 | CIPHPUnitTestSuperGlobal::set_Global('RTR', $RTR); |
| 67 | - $OUT =& load_class('Output', 'core'); |
|
| 67 | + $OUT = & load_class('Output', 'core'); |
|
| 68 | 68 | CIPHPUnitTestSuperGlobal::set_Global('OUT', $OUT); |
| 69 | - $SEC =& load_class('Security', 'core'); |
|
| 69 | + $SEC = & load_class('Security', 'core'); |
|
| 70 | 70 | CIPHPUnitTestSuperGlobal::set_Global('SEC', $SEC); |
| 71 | - $IN =& load_class('Input', 'core'); |
|
| 71 | + $IN = & load_class('Input', 'core'); |
|
| 72 | 72 | CIPHPUnitTestSuperGlobal::set_Global('IN', $IN); |
| 73 | - $LANG =& load_class('Lang', 'core'); |
|
| 73 | + $LANG = & load_class('Lang', 'core'); |
|
| 74 | 74 | CIPHPUnitTestSuperGlobal::set_Global('LANG', $LANG); |
| 75 | 75 | |
| 76 | 76 | CIPHPUnitTest::loadLoader(); |
@@ -59,7 +59,7 @@ |
||
| 59 | 59 | { |
| 60 | 60 | $this->unwrap(); |
| 61 | 61 | |
| 62 | - MonkeyPatchManager::log('stream_open: ' . $path); |
|
| 62 | + MonkeyPatchManager::log('stream_open: '.$path); |
|
| 63 | 63 | |
| 64 | 64 | $including = (bool) ($options & self::STREAM_OPEN_FOR_INCLUDE); |
| 65 | 65 | if ($including && $this->shouldPreprocess($path)) { |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | PHPUnit_Framework_TestCase::assertEquals( |
| 55 | 55 | $expected_times, |
| 56 | 56 | $actual_times, |
| 57 | - $class_method . '() expected to be not invoked, but invoked ' . $actual_times . ' times.' |
|
| 57 | + $class_method.'() expected to be not invoked, but invoked '.$actual_times.' times.' |
|
| 58 | 58 | ); |
| 59 | 59 | } |
| 60 | 60 | elseif ($expected_times === '+') |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | PHPUnit_Framework_TestCase::assertGreaterThanOrEqual( |
| 63 | 63 | 1, |
| 64 | 64 | $actual_times, |
| 65 | - $class_method . '() expected to be invoked at least one time, but invoked ' . $actual_times . ' times.' |
|
| 65 | + $class_method.'() expected to be invoked at least one time, but invoked '.$actual_times.' times.' |
|
| 66 | 66 | ); |
| 67 | 67 | } |
| 68 | 68 | else |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | PHPUnit_Framework_TestCase::assertEquals( |
| 71 | 71 | $expected_times, |
| 72 | 72 | $actual_times, |
| 73 | - $class_method . '() expected to be invoked ' . $expected_times . ' times, but invoked ' . $actual_times . ' times.' |
|
| 73 | + $class_method.'() expected to be invoked '.$expected_times.' times, but invoked '.$actual_times.' times.' |
|
| 74 | 74 | ); |
| 75 | 75 | } |
| 76 | 76 | } |
@@ -31,12 +31,10 @@ discard block |
||
| 31 | 31 | if ($invoked === false) |
| 32 | 32 | { |
| 33 | 33 | $actual_times = 0; |
| 34 | - } |
|
| 35 | - elseif ($expected_params === null) |
|
| 34 | + } elseif ($expected_params === null) |
|
| 36 | 35 | { |
| 37 | 36 | $actual_times = count($invocations[$class_method]); |
| 38 | - } |
|
| 39 | - else |
|
| 37 | + } else |
|
| 40 | 38 | { |
| 41 | 39 | $count = 0; |
| 42 | 40 | foreach ($invocations[$class_method] as $actual_params) |
@@ -56,16 +54,14 @@ discard block |
||
| 56 | 54 | $actual_times, |
| 57 | 55 | $class_method . '() expected to be not invoked, but invoked ' . $actual_times . ' times.' |
| 58 | 56 | ); |
| 59 | - } |
|
| 60 | - elseif ($expected_times === '+') |
|
| 57 | + } elseif ($expected_times === '+') |
|
| 61 | 58 | { |
| 62 | 59 | PHPUnit_Framework_TestCase::assertGreaterThanOrEqual( |
| 63 | 60 | 1, |
| 64 | 61 | $actual_times, |
| 65 | 62 | $class_method . '() expected to be invoked at least one time, but invoked ' . $actual_times . ' times.' |
| 66 | 63 | ); |
| 67 | - } |
|
| 68 | - else |
|
| 64 | + } else |
|
| 69 | 65 | { |
| 70 | 66 | PHPUnit_Framework_TestCase::assertEquals( |
| 71 | 67 | $expected_times, |
@@ -18,11 +18,11 @@ |
||
| 18 | 18 | |
| 19 | 19 | if ($class === null) |
| 20 | 20 | { |
| 21 | - $message = 'exit() called in ' . $method . '() function'; |
|
| 21 | + $message = 'exit() called in '.$method.'() function'; |
|
| 22 | 22 | } |
| 23 | 23 | else |
| 24 | 24 | { |
| 25 | - $message = 'exit() called in ' . $class . '::' . $method . '()'; |
|
| 25 | + $message = 'exit() called in '.$class.'::'.$method.'()'; |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | $exception_name = Kenjis\MonkeyPatch\MonkeyPatchManager::getExitExceptionClassname(); |
@@ -19,8 +19,7 @@ |
||
| 19 | 19 | if ($class === null) |
| 20 | 20 | { |
| 21 | 21 | $message = 'exit() called in ' . $method . '() function'; |
| 22 | - } |
|
| 23 | - else |
|
| 22 | + } else |
|
| 24 | 23 | { |
| 25 | 24 | $message = 'exit() called in ' . $class . '::' . $method . '()'; |
| 26 | 25 | } |
@@ -105,7 +105,7 @@ |
||
| 105 | 105 | ob_end_clean(); |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - throw new CIPHPUnitTestRedirectException('Redirect to ' . $uri, $code); |
|
| 108 | + throw new CIPHPUnitTestRedirectException('Redirect to '.$uri, $code); |
|
| 109 | 109 | } |
| 110 | 110 | } |
| 111 | 111 | } |
@@ -63,16 +63,14 @@ discard block |
||
| 63 | 63 | if ($method === 'auto' && isset($_SERVER['SERVER_SOFTWARE']) && strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS') !== FALSE) |
| 64 | 64 | { |
| 65 | 65 | $method = 'refresh'; |
| 66 | - } |
|
| 67 | - elseif ($method !== 'refresh' && (empty($code) OR ! is_numeric($code))) |
|
| 66 | + } elseif ($method !== 'refresh' && (empty($code) OR ! is_numeric($code))) |
|
| 68 | 67 | { |
| 69 | 68 | if (isset($_SERVER['SERVER_PROTOCOL'], $_SERVER['REQUEST_METHOD']) && $_SERVER['SERVER_PROTOCOL'] === 'HTTP/1.1') |
| 70 | 69 | { |
| 71 | 70 | $code = ($_SERVER['REQUEST_METHOD'] !== 'GET') |
| 72 | 71 | ? 303 // reference: http://en.wikipedia.org/wiki/Post/Redirect/Get |
| 73 | 72 | : 307; |
| 74 | - } |
|
| 75 | - else |
|
| 73 | + } else |
|
| 76 | 74 | { |
| 77 | 75 | $code = 302; |
| 78 | 76 | } |
@@ -97,8 +95,7 @@ discard block |
||
| 97 | 95 | if (ENVIRONMENT !== 'testing') |
| 98 | 96 | { |
| 99 | 97 | exit; |
| 100 | - } |
|
| 101 | - else |
|
| 98 | + } else |
|
| 102 | 99 | { |
| 103 | 100 | while (ob_get_level() > 1) |
| 104 | 101 | { |
@@ -25,7 +25,7 @@ |
||
| 25 | 25 | public function test_APPPATH() |
| 26 | 26 | { |
| 27 | 27 | $actual = realpath(APPPATH); |
| 28 | - $expected = realpath(__DIR__ . '/../..'); |
|
| 28 | + $expected = realpath(__DIR__.'/../..'); |
|
| 29 | 29 | $this->assertEquals( |
| 30 | 30 | $expected, |
| 31 | 31 | $actual, |
@@ -102,7 +102,7 @@ |
||
| 102 | 102 | elseif (strpos($class, 'CI_DB') === 0) |
| 103 | 103 | { |
| 104 | 104 | $dir = SYSTEM_PATH.'database'.DIRECTORY_SEPARATOR; |
| 105 | - $file = $dir.str_replace(array('CI_DB','active_record'), array('DB', 'active_rec'), $subclass).'.php'; |
|
| 105 | + $file = $dir.str_replace(array('CI_DB', 'active_record'), array('DB', 'active_rec'), $subclass).'.php'; |
|
| 106 | 106 | } |
| 107 | 107 | else |
| 108 | 108 | { |
@@ -63,8 +63,7 @@ discard block |
||
| 63 | 63 | if (strpos($class, 'Mock_') === 0) |
| 64 | 64 | { |
| 65 | 65 | $class = strtolower(str_replace(array('Mock_', '_'), array('', DIRECTORY_SEPARATOR), $class)); |
| 66 | - } |
|
| 67 | - elseif (strpos($class, 'CI_') === 0) |
|
| 66 | + } elseif (strpos($class, 'CI_') === 0) |
|
| 68 | 67 | { |
| 69 | 68 | $subclass = substr($class, 3); |
| 70 | 69 | |
@@ -72,39 +71,32 @@ discard block |
||
| 72 | 71 | { |
| 73 | 72 | $dir = SYSTEM_PATH.'core'.DIRECTORY_SEPARATOR; |
| 74 | 73 | $class = $subclass; |
| 75 | - } |
|
| 76 | - elseif (in_array($subclass, $ci_libraries)) |
|
| 74 | + } elseif (in_array($subclass, $ci_libraries)) |
|
| 77 | 75 | { |
| 78 | 76 | $dir = SYSTEM_PATH.'libraries'.DIRECTORY_SEPARATOR; |
| 79 | 77 | $class = ($subclass === 'Driver_Library') ? 'Driver' : $subclass; |
| 80 | - } |
|
| 81 | - elseif (in_array($subclass, $ci_drivers)) |
|
| 78 | + } elseif (in_array($subclass, $ci_drivers)) |
|
| 82 | 79 | { |
| 83 | 80 | $dir = SYSTEM_PATH.'libraries'.DIRECTORY_SEPARATOR.$subclass.DIRECTORY_SEPARATOR; |
| 84 | 81 | $class = $subclass; |
| 85 | - } |
|
| 86 | - elseif (in_array(($parent = strtok($subclass, '_')), $ci_drivers)) { |
|
| 82 | + } elseif (in_array(($parent = strtok($subclass, '_')), $ci_drivers)) { |
|
| 87 | 83 | $dir = SYSTEM_PATH.'libraries'.DIRECTORY_SEPARATOR.$parent.DIRECTORY_SEPARATOR.'drivers'.DIRECTORY_SEPARATOR; |
| 88 | 84 | $class = $subclass; |
| 89 | - } |
|
| 90 | - elseif (preg_match('/^CI_DB_(.+)_(.+)_(driver|forge|result|utility)$/', $class, $m) && count($m) === 4) |
|
| 85 | + } elseif (preg_match('/^CI_DB_(.+)_(.+)_(driver|forge|result|utility)$/', $class, $m) && count($m) === 4) |
|
| 91 | 86 | { |
| 92 | 87 | $driver_path = SYSTEM_PATH.'database'.DIRECTORY_SEPARATOR.'drivers'.DIRECTORY_SEPARATOR; |
| 93 | 88 | $dir = $driver_path.$m[1].DIRECTORY_SEPARATOR.'subdrivers'.DIRECTORY_SEPARATOR; |
| 94 | 89 | $file = $dir.$m[1].'_'.$m[2].'_'.$m[3].'.php'; |
| 95 | - } |
|
| 96 | - elseif (preg_match('/^CI_DB_(.+)_(driver|forge|result|utility)$/', $class, $m) && count($m) === 3) |
|
| 90 | + } elseif (preg_match('/^CI_DB_(.+)_(driver|forge|result|utility)$/', $class, $m) && count($m) === 3) |
|
| 97 | 91 | { |
| 98 | 92 | $driver_path = SYSTEM_PATH.'database'.DIRECTORY_SEPARATOR.'drivers'.DIRECTORY_SEPARATOR; |
| 99 | 93 | $dir = $driver_path.$m[1].DIRECTORY_SEPARATOR; |
| 100 | 94 | $file = $dir.$m[1].'_'.$m[2].'.php'; |
| 101 | - } |
|
| 102 | - elseif (strpos($class, 'CI_DB') === 0) |
|
| 95 | + } elseif (strpos($class, 'CI_DB') === 0) |
|
| 103 | 96 | { |
| 104 | 97 | $dir = SYSTEM_PATH.'database'.DIRECTORY_SEPARATOR; |
| 105 | 98 | $file = $dir.str_replace(array('CI_DB','active_record'), array('DB', 'active_rec'), $subclass).'.php'; |
| 106 | - } |
|
| 107 | - else |
|
| 99 | + } else |
|
| 108 | 100 | { |
| 109 | 101 | $class = strtolower($class); |
| 110 | 102 | } |
@@ -113,7 +113,7 @@ |
||
| 113 | 113 | */ |
| 114 | 114 | private static function checkConfigurationFile($file) |
| 115 | 115 | { |
| 116 | - if (!file_exists($file)) { |
|
| 116 | + if ( ! file_exists($file)) { |
|
| 117 | 117 | throw new \RuntimeException("The requested phpunit configuration was not found at $file"); |
| 118 | 118 | } |
| 119 | 119 | |
@@ -52,71 +52,71 @@ |
||
| 52 | 52 | */ |
| 53 | 53 | final class TestSuiteProvider |
| 54 | 54 | { |
| 55 | - /** |
|
| 56 | - * phpunit configuration file |
|
| 57 | - * |
|
| 58 | - * @var string |
|
| 59 | - */ |
|
| 60 | - private static $file; |
|
| 55 | + /** |
|
| 56 | + * phpunit configuration file |
|
| 57 | + * |
|
| 58 | + * @var string |
|
| 59 | + */ |
|
| 60 | + private static $file; |
|
| 61 | 61 | |
| 62 | - /** |
|
| 63 | - * constructor |
|
| 64 | - */ |
|
| 65 | - private function __construct() {} |
|
| 62 | + /** |
|
| 63 | + * constructor |
|
| 64 | + */ |
|
| 65 | + private function __construct() {} |
|
| 66 | 66 | |
| 67 | - /** |
|
| 68 | - * set the phpunit configuration file |
|
| 69 | - * |
|
| 70 | - * @param string $file the path or filename of the phunit configuration file |
|
| 71 | - */ |
|
| 72 | - public static function setConfigurationFile($file) |
|
| 73 | - { |
|
| 74 | - static::$file = $file; |
|
| 75 | - } |
|
| 67 | + /** |
|
| 68 | + * set the phpunit configuration file |
|
| 69 | + * |
|
| 70 | + * @param string $file the path or filename of the phunit configuration file |
|
| 71 | + */ |
|
| 72 | + public static function setConfigurationFile($file) |
|
| 73 | + { |
|
| 74 | + static::$file = $file; |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - /** |
|
| 78 | - * get the phpunit test suite instance |
|
| 79 | - * |
|
| 80 | - * @return PHPUnit_Framework_TestSuite returns the phpunit test suite instance |
|
| 81 | - * @throws FileNotFoundException if the file is not found |
|
| 82 | - */ |
|
| 83 | - public static function suite() |
|
| 84 | - { |
|
| 85 | - $file = static::checkConfigurationFile( |
|
| 86 | - static::getConfigurationFile() |
|
| 87 | - ); |
|
| 77 | + /** |
|
| 78 | + * get the phpunit test suite instance |
|
| 79 | + * |
|
| 80 | + * @return PHPUnit_Framework_TestSuite returns the phpunit test suite instance |
|
| 81 | + * @throws FileNotFoundException if the file is not found |
|
| 82 | + */ |
|
| 83 | + public static function suite() |
|
| 84 | + { |
|
| 85 | + $file = static::checkConfigurationFile( |
|
| 86 | + static::getConfigurationFile() |
|
| 87 | + ); |
|
| 88 | 88 | |
| 89 | - return PHPUnit_Util_Configuration::getInstance($file) |
|
| 90 | - ->getTestSuiteConfiguration(); |
|
| 91 | - } |
|
| 89 | + return PHPUnit_Util_Configuration::getInstance($file) |
|
| 90 | + ->getTestSuiteConfiguration(); |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - /** |
|
| 94 | - * get the phpunit configuration file |
|
| 95 | - * |
|
| 96 | - * @return string |
|
| 97 | - */ |
|
| 98 | - private static function getConfigurationFile() |
|
| 99 | - { |
|
| 100 | - static::$file = isset(static::$file) |
|
| 101 | - ? static::$file |
|
| 102 | - : APPPATH.'tests/phpunit.xml'; |
|
| 93 | + /** |
|
| 94 | + * get the phpunit configuration file |
|
| 95 | + * |
|
| 96 | + * @return string |
|
| 97 | + */ |
|
| 98 | + private static function getConfigurationFile() |
|
| 99 | + { |
|
| 100 | + static::$file = isset(static::$file) |
|
| 101 | + ? static::$file |
|
| 102 | + : APPPATH.'tests/phpunit.xml'; |
|
| 103 | 103 | |
| 104 | - return static::$file; |
|
| 105 | - } |
|
| 104 | + return static::$file; |
|
| 105 | + } |
|
| 106 | 106 | |
| 107 | - /** |
|
| 108 | - * check the given file |
|
| 109 | - * |
|
| 110 | - * @param string $file file to check |
|
| 111 | - * @return string returns the file if it is valid |
|
| 112 | - * @throws FileNotFoundException if the file is not found |
|
| 113 | - */ |
|
| 114 | - private static function checkConfigurationFile($file) |
|
| 115 | - { |
|
| 116 | - if (!file_exists($file)) { |
|
| 117 | - throw new \RuntimeException("The requested phpunit configuration was not found at $file"); |
|
| 118 | - } |
|
| 107 | + /** |
|
| 108 | + * check the given file |
|
| 109 | + * |
|
| 110 | + * @param string $file file to check |
|
| 111 | + * @return string returns the file if it is valid |
|
| 112 | + * @throws FileNotFoundException if the file is not found |
|
| 113 | + */ |
|
| 114 | + private static function checkConfigurationFile($file) |
|
| 115 | + { |
|
| 116 | + if (!file_exists($file)) { |
|
| 117 | + throw new \RuntimeException("The requested phpunit configuration was not found at $file"); |
|
| 118 | + } |
|
| 119 | 119 | |
| 120 | - return $file; |
|
| 121 | - } |
|
| 120 | + return $file; |
|
| 121 | + } |
|
| 122 | 122 | } |
@@ -137,17 +137,17 @@ discard block |
||
| 137 | 137 | */ |
| 138 | 138 | public function __construct() |
| 139 | 139 | { |
| 140 | - $this->_allow_get_array = (config_item('allow_get_array') === TRUE); |
|
| 141 | - $this->_enable_xss = (config_item('global_xss_filtering') === TRUE); |
|
| 142 | - $this->_enable_csrf = (config_item('csrf_protection') === TRUE); |
|
| 143 | - $this->_standardize_newlines = (bool) config_item('standardize_newlines'); |
|
| 140 | + $this->_allow_get_array = (config_item('allow_get_array') === TRUE); |
|
| 141 | + $this->_enable_xss = (config_item('global_xss_filtering') === TRUE); |
|
| 142 | + $this->_enable_csrf = (config_item('csrf_protection') === TRUE); |
|
| 143 | + $this->_standardize_newlines = (bool) config_item('standardize_newlines'); |
|
| 144 | 144 | |
| 145 | - $this->security =& load_class('Security', 'core'); |
|
| 145 | + $this->security = & load_class('Security', 'core'); |
|
| 146 | 146 | |
| 147 | 147 | // Do we need the UTF-8 class? |
| 148 | 148 | if (UTF8_ENABLED === TRUE) |
| 149 | 149 | { |
| 150 | - $this->uni =& load_class('Utf8', 'core'); |
|
| 150 | + $this->uni = & load_class('Utf8', 'core'); |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | // Sanitize global arrays |
@@ -413,7 +413,7 @@ discard block |
||
| 413 | 413 | |
| 414 | 414 | // Save cookie in Output object |
| 415 | 415 | // added by ci-phpunit-test |
| 416 | - $CI =& get_instance(); |
|
| 416 | + $CI = & get_instance(); |
|
| 417 | 417 | $output = $CI->output; |
| 418 | 418 | $output->_cookies[$prefix.$name][] = [ |
| 419 | 419 | 'value' => $value, |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | /** |
| 238 | 238 | * Fetch an item from the GET array |
| 239 | 239 | * |
| 240 | - * @param mixed $index Index for item to be fetched from $_GET |
|
| 240 | + * @param string $index Index for item to be fetched from $_GET |
|
| 241 | 241 | * @param bool $xss_clean Whether to apply XSS filtering |
| 242 | 242 | * @return mixed |
| 243 | 243 | * |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | /** |
| 254 | 254 | * Fetch an item from the POST array |
| 255 | 255 | * |
| 256 | - * @param mixed $index Index for item to be fetched from $_POST |
|
| 256 | + * @param string $index Index for item to be fetched from $_POST |
|
| 257 | 257 | * @param bool $xss_clean Whether to apply XSS filtering |
| 258 | 258 | * @return mixed |
| 259 | 259 | * |
@@ -321,9 +321,9 @@ discard block |
||
| 321 | 321 | /** |
| 322 | 322 | * Fetch an item from the SERVER array |
| 323 | 323 | * |
| 324 | - * @param mixed $index Index for item to be fetched from $_SERVER |
|
| 324 | + * @param string $index Index for item to be fetched from $_SERVER |
|
| 325 | 325 | * @param bool $xss_clean Whether to apply XSS filtering |
| 326 | - * @return mixed |
|
| 326 | + * @return string |
|
| 327 | 327 | * |
| 328 | 328 | * @codeCoverageIgnore |
| 329 | 329 | */ |
@@ -934,7 +934,7 @@ discard block |
||
| 934 | 934 | * Allows read access to protected properties |
| 935 | 935 | * |
| 936 | 936 | * @param string $name |
| 937 | - * @return mixed |
|
| 937 | + * @return string|null |
|
| 938 | 938 | * |
| 939 | 939 | * @codeCoverageIgnore |
| 940 | 940 | */ |
@@ -200,29 +200,30 @@ discard block |
||
| 200 | 200 | if (isset($array[$index])) |
| 201 | 201 | { |
| 202 | 202 | $value = $array[$index]; |
| 203 | - } |
|
| 204 | - elseif (($count = preg_match_all('/(?:^[^\[]+)|\[[^]]*\]/', $index, $matches)) > 1) // Does the index contain array notation |
|
| 203 | + } elseif (($count = preg_match_all('/(?:^[^\[]+)|\[[^]]*\]/', $index, $matches)) > 1) { |
|
| 204 | + // Does the index contain array notation |
|
| 205 | 205 | { |
| 206 | 206 | $value = $array; |
| 207 | + } |
|
| 207 | 208 | for ($i = 0; $i < $count; $i++) |
| 208 | 209 | { |
| 209 | 210 | $key = trim($matches[0][$i], '[]'); |
| 210 | - if ($key === '') // Empty notation will return the value as array |
|
| 211 | + if ($key === '') { |
|
| 212 | + // Empty notation will return the value as array |
|
| 211 | 213 | { |
| 212 | 214 | break; |
| 213 | 215 | } |
| 216 | + } |
|
| 214 | 217 | |
| 215 | 218 | if (isset($value[$key])) |
| 216 | 219 | { |
| 217 | 220 | $value = $value[$key]; |
| 218 | - } |
|
| 219 | - else |
|
| 221 | + } else |
|
| 220 | 222 | { |
| 221 | 223 | return NULL; |
| 222 | 224 | } |
| 223 | 225 | } |
| 224 | - } |
|
| 225 | - else |
|
| 226 | + } else |
|
| 226 | 227 | { |
| 227 | 228 | return NULL; |
| 228 | 229 | } |
@@ -421,8 +422,7 @@ discard block |
||
| 421 | 422 | if ( ! is_numeric($expire)) |
| 422 | 423 | { |
| 423 | 424 | $expire = time() - 86500; |
| 424 | - } |
|
| 425 | - else |
|
| 425 | + } else |
|
| 426 | 426 | { |
| 427 | 427 | $expire = ($expire > 0) ? time() + $expire : 0; |
| 428 | 428 | } |
@@ -483,8 +483,7 @@ discard block |
||
| 483 | 483 | if ( ! $this->valid_ip($spoof)) |
| 484 | 484 | { |
| 485 | 485 | $spoof = NULL; |
| 486 | - } |
|
| 487 | - else |
|
| 486 | + } else |
|
| 488 | 487 | { |
| 489 | 488 | break; |
| 490 | 489 | } |
@@ -537,8 +536,7 @@ discard block |
||
| 537 | 536 | } |
| 538 | 537 | |
| 539 | 538 | $sprintf = '%016b%016b%016b%016b%016b%016b%016b%016b'; |
| 540 | - } |
|
| 541 | - else |
|
| 539 | + } else |
|
| 542 | 540 | { |
| 543 | 541 | $ip = explode('.', $this->ip_address); |
| 544 | 542 | $sprintf = '%08b%08b%08b%08b'; |
@@ -558,8 +556,7 @@ discard block |
||
| 558 | 556 | { |
| 559 | 557 | $netaddr[$j] = intval($netaddr[$j], 16); |
| 560 | 558 | } |
| 561 | - } |
|
| 562 | - else |
|
| 559 | + } else |
|
| 563 | 560 | { |
| 564 | 561 | $netaddr = explode('.', $netaddr); |
| 565 | 562 | } |
@@ -646,8 +643,7 @@ discard block |
||
| 646 | 643 | if ($this->_allow_get_array === FALSE) |
| 647 | 644 | { |
| 648 | 645 | $_GET = array(); |
| 649 | - } |
|
| 650 | - elseif (is_array($_GET)) |
|
| 646 | + } elseif (is_array($_GET)) |
|
| 651 | 647 | { |
| 652 | 648 | foreach ($_GET as $key => $val) |
| 653 | 649 | { |
@@ -683,8 +679,7 @@ discard block |
||
| 683 | 679 | if (($cookie_key = $this->_clean_input_keys($key)) !== FALSE) |
| 684 | 680 | { |
| 685 | 681 | $_COOKIE[$cookie_key] = $this->_clean_input_data($val); |
| 686 | - } |
|
| 687 | - else |
|
| 682 | + } else |
|
| 688 | 683 | { |
| 689 | 684 | unset($_COOKIE[$key]); |
| 690 | 685 | } |
@@ -774,8 +769,7 @@ discard block |
||
| 774 | 769 | if ($fatal === TRUE) |
| 775 | 770 | { |
| 776 | 771 | return FALSE; |
| 777 | - } |
|
| 778 | - else |
|
| 772 | + } else |
|
| 779 | 773 | { |
| 780 | 774 | set_status_header(503); |
| 781 | 775 | echo 'Disallowed Key Characters.'; |
@@ -814,8 +808,7 @@ discard block |
||
| 814 | 808 | if (function_exists('apache_request_headers')) |
| 815 | 809 | { |
| 816 | 810 | $this->headers = apache_request_headers(); |
| 817 | - } |
|
| 818 | - else |
|
| 811 | + } else |
|
| 819 | 812 | { |
| 820 | 813 | isset($_SERVER['CONTENT_TYPE']) && $this->headers['Content-Type'] = $_SERVER['CONTENT_TYPE']; |
| 821 | 814 | |
@@ -944,8 +937,7 @@ discard block |
||
| 944 | 937 | { |
| 945 | 938 | isset($this->_raw_input_stream) OR $this->_raw_input_stream = file_get_contents('php://input'); |
| 946 | 939 | return $this->_raw_input_stream; |
| 947 | - } |
|
| 948 | - elseif ($name === 'ip_address') |
|
| 940 | + } elseif ($name === 'ip_address') |
|
| 949 | 941 | { |
| 950 | 942 | return $this->ip_address; |
| 951 | 943 | } |