@@ -8,7 +8,7 @@ |
||
| 8 | 8 | * @link https://github.com/kenjis/ci-phpunit-test |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | -require __DIR__ . '/Installer.php'; |
|
| 11 | +require __DIR__.'/Installer.php'; |
|
| 12 | 12 | |
| 13 | 13 | $installer = new Installer(); |
| 14 | 14 | $installer->update(); |
@@ -15,17 +15,17 @@ |
||
| 15 | 15 | |
| 16 | 16 | // php install.php -s |
| 17 | 17 | if (isset($argv[1]) && $argv[1] === '-s') { |
| 18 | - $silent = true; |
|
| 18 | + $silent = true; |
|
| 19 | 19 | |
| 20 | - // php install.php -s app |
|
| 21 | - if (isset($argv[2]) && is_dir($argv[2])) { |
|
| 22 | - $app_dir = $argv[2]; |
|
| 23 | - } |
|
| 20 | + // php install.php -s app |
|
| 21 | + if (isset($argv[2]) && is_dir($argv[2])) { |
|
| 22 | + $app_dir = $argv[2]; |
|
| 23 | + } |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | // php install.php app |
| 27 | 27 | if (isset($argv[1]) && is_dir($argv[1])) { |
| 28 | - $app_dir = $argv[1]; |
|
| 28 | + $app_dir = $argv[1]; |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | $installer = new Installer($silent); |
@@ -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 | } |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | /** |
| 234 | 234 | * Fetch an item from the GET array |
| 235 | 235 | * |
| 236 | - * @param mixed $index Index for item to be fetched from $_GET |
|
| 236 | + * @param string $index Index for item to be fetched from $_GET |
|
| 237 | 237 | * @param bool $xss_clean Whether to apply XSS filtering |
| 238 | 238 | * @return mixed |
| 239 | 239 | */ |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | /** |
| 248 | 248 | * Fetch an item from the POST array |
| 249 | 249 | * |
| 250 | - * @param mixed $index Index for item to be fetched from $_POST |
|
| 250 | + * @param string $index Index for item to be fetched from $_POST |
|
| 251 | 251 | * @param bool $xss_clean Whether to apply XSS filtering |
| 252 | 252 | * @return mixed |
| 253 | 253 | */ |
@@ -307,9 +307,9 @@ discard block |
||
| 307 | 307 | /** |
| 308 | 308 | * Fetch an item from the SERVER array |
| 309 | 309 | * |
| 310 | - * @param mixed $index Index for item to be fetched from $_SERVER |
|
| 310 | + * @param string $index Index for item to be fetched from $_SERVER |
|
| 311 | 311 | * @param bool $xss_clean Whether to apply XSS filtering |
| 312 | - * @return mixed |
|
| 312 | + * @return string |
|
| 313 | 313 | */ |
| 314 | 314 | public function server($index, $xss_clean = NULL) |
| 315 | 315 | { |
@@ -892,7 +892,7 @@ discard block |
||
| 892 | 892 | * Allows read access to protected properties |
| 893 | 893 | * |
| 894 | 894 | * @param string $name |
| 895 | - * @return mixed |
|
| 895 | + * @return string|null |
|
| 896 | 896 | */ |
| 897 | 897 | public function __get($name) |
| 898 | 898 | { |
@@ -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, |
@@ -196,29 +196,30 @@ discard block |
||
| 196 | 196 | if (isset($array[$index])) |
| 197 | 197 | { |
| 198 | 198 | $value = $array[$index]; |
| 199 | - } |
|
| 200 | - elseif (($count = preg_match_all('/(?:^[^\[]+)|\[[^]]*\]/', $index, $matches)) > 1) // Does the index contain array notation |
|
| 199 | + } elseif (($count = preg_match_all('/(?:^[^\[]+)|\[[^]]*\]/', $index, $matches)) > 1) { |
|
| 200 | + // Does the index contain array notation |
|
| 201 | 201 | { |
| 202 | 202 | $value = $array; |
| 203 | + } |
|
| 203 | 204 | for ($i = 0; $i < $count; $i++) |
| 204 | 205 | { |
| 205 | 206 | $key = trim($matches[0][$i], '[]'); |
| 206 | - if ($key === '') // Empty notation will return the value as array |
|
| 207 | + if ($key === '') { |
|
| 208 | + // Empty notation will return the value as array |
|
| 207 | 209 | { |
| 208 | 210 | break; |
| 209 | 211 | } |
| 212 | + } |
|
| 210 | 213 | |
| 211 | 214 | if (isset($value[$key])) |
| 212 | 215 | { |
| 213 | 216 | $value = $value[$key]; |
| 214 | - } |
|
| 215 | - else |
|
| 217 | + } else |
|
| 216 | 218 | { |
| 217 | 219 | return NULL; |
| 218 | 220 | } |
| 219 | 221 | } |
| 220 | - } |
|
| 221 | - else |
|
| 222 | + } else |
|
| 222 | 223 | { |
| 223 | 224 | return NULL; |
| 224 | 225 | } |
@@ -403,8 +404,7 @@ discard block |
||
| 403 | 404 | if ( ! is_numeric($expire)) |
| 404 | 405 | { |
| 405 | 406 | $expire = time() - 86500; |
| 406 | - } |
|
| 407 | - else |
|
| 407 | + } else |
|
| 408 | 408 | { |
| 409 | 409 | $expire = ($expire > 0) ? time() + $expire : 0; |
| 410 | 410 | } |
@@ -463,8 +463,7 @@ discard block |
||
| 463 | 463 | if ( ! $this->valid_ip($spoof)) |
| 464 | 464 | { |
| 465 | 465 | $spoof = NULL; |
| 466 | - } |
|
| 467 | - else |
|
| 466 | + } else |
|
| 468 | 467 | { |
| 469 | 468 | break; |
| 470 | 469 | } |
@@ -517,8 +516,7 @@ discard block |
||
| 517 | 516 | } |
| 518 | 517 | |
| 519 | 518 | $sprintf = '%016b%016b%016b%016b%016b%016b%016b%016b'; |
| 520 | - } |
|
| 521 | - else |
|
| 519 | + } else |
|
| 522 | 520 | { |
| 523 | 521 | $ip = explode('.', $this->ip_address); |
| 524 | 522 | $sprintf = '%08b%08b%08b%08b'; |
@@ -538,8 +536,7 @@ discard block |
||
| 538 | 536 | { |
| 539 | 537 | $netaddr[$i] = intval($netaddr[$j], 16); |
| 540 | 538 | } |
| 541 | - } |
|
| 542 | - else |
|
| 539 | + } else |
|
| 543 | 540 | { |
| 544 | 541 | $netaddr = explode('.', $netaddr); |
| 545 | 542 | } |
@@ -620,8 +617,7 @@ discard block |
||
| 620 | 617 | if ($this->_allow_get_array === FALSE) |
| 621 | 618 | { |
| 622 | 619 | $_GET = array(); |
| 623 | - } |
|
| 624 | - elseif (is_array($_GET)) |
|
| 620 | + } elseif (is_array($_GET)) |
|
| 625 | 621 | { |
| 626 | 622 | foreach ($_GET as $key => $val) |
| 627 | 623 | { |
@@ -657,8 +653,7 @@ discard block |
||
| 657 | 653 | if (($cookie_key = $this->_clean_input_keys($key)) !== FALSE) |
| 658 | 654 | { |
| 659 | 655 | $_COOKIE[$cookie_key] = $this->_clean_input_data($val); |
| 660 | - } |
|
| 661 | - else |
|
| 656 | + } else |
|
| 662 | 657 | { |
| 663 | 658 | unset($_COOKIE[$key]); |
| 664 | 659 | } |
@@ -744,8 +739,7 @@ discard block |
||
| 744 | 739 | if ($fatal === TRUE) |
| 745 | 740 | { |
| 746 | 741 | return FALSE; |
| 747 | - } |
|
| 748 | - else |
|
| 742 | + } else |
|
| 749 | 743 | { |
| 750 | 744 | set_status_header(503); |
| 751 | 745 | echo 'Disallowed Key Characters.'; |
@@ -782,8 +776,7 @@ discard block |
||
| 782 | 776 | if (function_exists('apache_request_headers')) |
| 783 | 777 | { |
| 784 | 778 | $this->headers = apache_request_headers(); |
| 785 | - } |
|
| 786 | - else |
|
| 779 | + } else |
|
| 787 | 780 | { |
| 788 | 781 | isset($_SERVER['CONTENT_TYPE']) && $this->headers['Content-Type'] = $_SERVER['CONTENT_TYPE']; |
| 789 | 782 | |
@@ -904,8 +897,7 @@ discard block |
||
| 904 | 897 | { |
| 905 | 898 | isset($this->_raw_input_stream) OR $this->_raw_input_stream = file_get_contents('php://input'); |
| 906 | 899 | return $this->_raw_input_stream; |
| 907 | - } |
|
| 908 | - elseif ($name === 'ip_address') |
|
| 900 | + } elseif ($name === 'ip_address') |
|
| 909 | 901 | { |
| 910 | 902 | return $this->ip_address; |
| 911 | 903 | } |
@@ -47,8 +47,7 @@ discard block |
||
| 47 | 47 | ? $backtrace[$offset+2]['class'] |
| 48 | 48 | : null; |
| 49 | 49 | $function = $backtrace[$offset+2]['function']; |
| 50 | - } |
|
| 51 | - else |
|
| 50 | + } else |
|
| 52 | 51 | { |
| 53 | 52 | $class = null; |
| 54 | 53 | $function = null; |
@@ -59,8 +58,7 @@ discard block |
||
| 59 | 58 | $method = $function; |
| 60 | 59 | $class_method = $class . '::' . $function; |
| 61 | 60 | $function = null; |
| 62 | - } |
|
| 63 | - else |
|
| 61 | + } else |
|
| 64 | 62 | { |
| 65 | 63 | $method = null; |
| 66 | 64 | $class_method = null; |
@@ -33,35 +33,35 @@ discard block |
||
| 33 | 33 | $cwd_backup = getcwd(); |
| 34 | 34 | |
| 35 | 35 | // Load autoloader for ci-phpunit-test |
| 36 | - require __DIR__ . '/autoloader.php'; |
|
| 36 | + require __DIR__.'/autoloader.php'; |
|
| 37 | 37 | |
| 38 | 38 | // Autoloader for PHP-Parser |
| 39 | 39 | // Don't use `require`, because we may have required already |
| 40 | 40 | // in `patcher/bootstrap.php` |
| 41 | - require_once __DIR__ . '/patcher/third_party/PHP-Parser-2.1.1/lib/bootstrap.php'; |
|
| 41 | + require_once __DIR__.'/patcher/third_party/PHP-Parser-2.1.1/lib/bootstrap.php'; |
|
| 42 | 42 | |
| 43 | - require APPPATH . '/tests/TestCase.php'; |
|
| 43 | + require APPPATH.'/tests/TestCase.php'; |
|
| 44 | 44 | |
| 45 | - $db_test_case_file = APPPATH . '/tests/DbTestCase.php'; |
|
| 45 | + $db_test_case_file = APPPATH.'/tests/DbTestCase.php'; |
|
| 46 | 46 | if (is_readable($db_test_case_file)) |
| 47 | 47 | { |
| 48 | 48 | require $db_test_case_file; |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | // Replace a few Common functions |
| 52 | - require __DIR__ . '/replacing/core/Common.php'; |
|
| 53 | - require BASEPATH . 'core/Common.php'; |
|
| 52 | + require __DIR__.'/replacing/core/Common.php'; |
|
| 53 | + require BASEPATH.'core/Common.php'; |
|
| 54 | 54 | |
| 55 | 55 | // Workaround for missing CodeIgniter's error handler |
| 56 | 56 | // See https://github.com/kenjis/ci-phpunit-test/issues/37 |
| 57 | 57 | set_error_handler('_error_handler'); |
| 58 | 58 | |
| 59 | 59 | // Load new functions of CIPHPUnitTest |
| 60 | - require __DIR__ . '/functions.php'; |
|
| 60 | + require __DIR__.'/functions.php'; |
|
| 61 | 61 | // Load ci-phpunit-test CI_Loader |
| 62 | - require __DIR__ . '/replacing/core/Loader.php'; |
|
| 62 | + require __DIR__.'/replacing/core/Loader.php'; |
|
| 63 | 63 | // Load ci-phpunit-test CI_Input |
| 64 | - require __DIR__ . '/replacing/core/Input.php'; |
|
| 64 | + require __DIR__.'/replacing/core/Input.php'; |
|
| 65 | 65 | |
| 66 | 66 | // Change current directroy |
| 67 | 67 | chdir(FCPATH); |
@@ -73,12 +73,12 @@ discard block |
||
| 73 | 73 | * |
| 74 | 74 | * And away we go... |
| 75 | 75 | */ |
| 76 | - require __DIR__ . '/replacing/core/CodeIgniter.php'; |
|
| 76 | + require __DIR__.'/replacing/core/CodeIgniter.php'; |
|
| 77 | 77 | |
| 78 | 78 | self::replaceHelpers(); |
| 79 | 79 | |
| 80 | 80 | // Create CodeIgniter instance |
| 81 | - if (! self::wiredesignzHmvcInstalled()) |
|
| 81 | + if ( ! self::wiredesignzHmvcInstalled()) |
|
| 82 | 82 | { |
| 83 | 83 | new CI_Controller(); |
| 84 | 84 | } |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | |
| 100 | 100 | public static function createCodeIgniterInstance() |
| 101 | 101 | { |
| 102 | - if (! self::wiredesignzHmvcInstalled()) |
|
| 102 | + if ( ! self::wiredesignzHmvcInstalled()) |
|
| 103 | 103 | { |
| 104 | 104 | new CI_Controller(); |
| 105 | 105 | } |
@@ -128,11 +128,11 @@ discard block |
||
| 128 | 128 | protected static function replaceLoader() |
| 129 | 129 | { |
| 130 | 130 | $my_loader_file = |
| 131 | - APPPATH . 'core/' . config_item('subclass_prefix') . 'Loader.php'; |
|
| 131 | + APPPATH.'core/'.config_item('subclass_prefix').'Loader.php'; |
|
| 132 | 132 | |
| 133 | 133 | if (file_exists($my_loader_file)) |
| 134 | 134 | { |
| 135 | - self::$loader_class = config_item('subclass_prefix') . 'Loader'; |
|
| 135 | + self::$loader_class = config_item('subclass_prefix').'Loader'; |
|
| 136 | 136 | if ( ! class_exists(self::$loader_class)) |
| 137 | 137 | { |
| 138 | 138 | require $my_loader_file; |
@@ -151,19 +151,19 @@ discard block |
||
| 151 | 151 | |
| 152 | 152 | protected static function loadHelper($helper) |
| 153 | 153 | { |
| 154 | - $my_helper_file = APPPATH . 'helpers/' . config_item('subclass_prefix') . $helper . '.php'; |
|
| 154 | + $my_helper_file = APPPATH.'helpers/'.config_item('subclass_prefix').$helper.'.php'; |
|
| 155 | 155 | if (file_exists($my_helper_file)) |
| 156 | 156 | { |
| 157 | 157 | require $my_helper_file; |
| 158 | 158 | } |
| 159 | - require __DIR__ . '/replacing/helpers/' . $helper . '.php'; |
|
| 159 | + require __DIR__.'/replacing/helpers/'.$helper.'.php'; |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | public static function setPatcherCacheDir($dir = null) |
| 163 | 163 | { |
| 164 | 164 | if ($dir === null) |
| 165 | 165 | { |
| 166 | - $dir = APPPATH . 'tests/_ci_phpunit_test/tmp/cache'; |
|
| 166 | + $dir = APPPATH.'tests/_ci_phpunit_test/tmp/cache'; |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | MonkeyPatchManager::setCacheDir( |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | * Start the timer... tick tock tick tock... |
| 186 | 186 | * ------------------------------------------------------ |
| 187 | 187 | */ |
| 188 | - $BM =& load_class('Benchmark', 'core'); |
|
| 188 | + $BM = & load_class('Benchmark', 'core'); |
|
| 189 | 189 | CIPHPUnitTestSuperGlobal::set_Global('BM', $BM); |
| 190 | 190 | $BM->mark('total_execution_time_start'); |
| 191 | 191 | $BM->mark('loading_time:_base_classes_start'); |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | * Instantiate the hooks class |
| 196 | 196 | * ------------------------------------------------------ |
| 197 | 197 | */ |
| 198 | - $EXT =& load_class('Hooks', 'core'); |
|
| 198 | + $EXT = & load_class('Hooks', 'core'); |
|
| 199 | 199 | CIPHPUnitTestSuperGlobal::set_Global('EXT', $EXT); |
| 200 | 200 | |
| 201 | 201 | /* |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | * depending on another class that uses it. |
| 216 | 216 | * |
| 217 | 217 | */ |
| 218 | - $CFG =& load_class('Config', 'core'); |
|
| 218 | + $CFG = & load_class('Config', 'core'); |
|
| 219 | 219 | CIPHPUnitTestSuperGlobal::set_Global('CFG', $CFG); |
| 220 | 220 | |
| 221 | 221 | // Do we have any manually set config items in the index.php file? |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | * Instantiate the UTF-8 class |
| 295 | 295 | * ------------------------------------------------------ |
| 296 | 296 | */ |
| 297 | - $UNI =& load_class('Utf8', 'core'); |
|
| 297 | + $UNI = & load_class('Utf8', 'core'); |
|
| 298 | 298 | CIPHPUnitTestSuperGlobal::set_Global('UNI', $UNI); |
| 299 | 299 | |
| 300 | 300 | /* |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | * Instantiate the URI class |
| 303 | 303 | * ------------------------------------------------------ |
| 304 | 304 | */ |
| 305 | - $URI =& load_class('URI', 'core'); |
|
| 305 | + $URI = & load_class('URI', 'core'); |
|
| 306 | 306 | CIPHPUnitTestSuperGlobal::set_Global('URI', $URI); |
| 307 | 307 | |
| 308 | 308 | /* |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | * Instantiate the routing class and set the routing |
| 311 | 311 | * ------------------------------------------------------ |
| 312 | 312 | */ |
| 313 | - $RTR =& load_class('Router', 'core', isset($routing) ? $routing : NULL); |
|
| 313 | + $RTR = & load_class('Router', 'core', isset($routing) ? $routing : NULL); |
|
| 314 | 314 | CIPHPUnitTestSuperGlobal::set_Global('RTR', $RTR); |
| 315 | 315 | |
| 316 | 316 | /* |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | * Instantiate the output class |
| 319 | 319 | * ------------------------------------------------------ |
| 320 | 320 | */ |
| 321 | - $OUT =& load_class('Output', 'core'); |
|
| 321 | + $OUT = & load_class('Output', 'core'); |
|
| 322 | 322 | CIPHPUnitTestSuperGlobal::set_Global('OUT', $OUT); |
| 323 | 323 | |
| 324 | 324 | /* |
@@ -336,7 +336,7 @@ discard block |
||
| 336 | 336 | * Load the security class for xss and csrf support |
| 337 | 337 | * ----------------------------------------------------- |
| 338 | 338 | */ |
| 339 | - $SEC =& load_class('Security', 'core'); |
|
| 339 | + $SEC = & load_class('Security', 'core'); |
|
| 340 | 340 | CIPHPUnitTestSuperGlobal::set_Global('SEC', $SEC); |
| 341 | 341 | |
| 342 | 342 | /* |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | * Load the Input class and sanitize globals |
| 345 | 345 | * ------------------------------------------------------ |
| 346 | 346 | */ |
| 347 | - $IN =& load_class('Input', 'core'); |
|
| 347 | + $IN = & load_class('Input', 'core'); |
|
| 348 | 348 | CIPHPUnitTestSuperGlobal::set_Global('IN', $IN); |
| 349 | 349 | |
| 350 | 350 | /* |
@@ -352,7 +352,7 @@ discard block |
||
| 352 | 352 | * Load the Language class |
| 353 | 353 | * ------------------------------------------------------ |
| 354 | 354 | */ |
| 355 | - $LANG =& load_class('Lang', 'core'); |
|
| 355 | + $LANG = & load_class('Lang', 'core'); |
|
| 356 | 356 | CIPHPUnitTestSuperGlobal::set_Global('LANG', $LANG); |
| 357 | 357 | |
| 358 | 358 | /* |
@@ -375,7 +375,7 @@ discard block |
||
| 375 | 375 | */ |
| 376 | 376 | function &get_instance() |
| 377 | 377 | { |
| 378 | - if (! CIPHPUnitTest::wiredesignzHmvcInstalled()) |
|
| 378 | + if ( ! CIPHPUnitTest::wiredesignzHmvcInstalled()) |
|
| 379 | 379 | { |
| 380 | 380 | return CI_Controller::get_instance(); |
| 381 | 381 | } |
@@ -169,12 +169,10 @@ discard block |
||
| 169 | 169 | file_exists(APPPATH.'vendor/autoload.php') |
| 170 | 170 | ? require_once(APPPATH.'vendor/autoload.php') |
| 171 | 171 | : log_message('error', '$config[\'composer_autoload\'] is set to TRUE but '.APPPATH.'vendor/autoload.php was not found.'); |
| 172 | - } |
|
| 173 | - elseif (file_exists($composer_autoload)) |
|
| 172 | + } elseif (file_exists($composer_autoload)) |
|
| 174 | 173 | { |
| 175 | 174 | require_once($composer_autoload); |
| 176 | - } |
|
| 177 | - else |
|
| 175 | + } else |
|
| 178 | 176 | { |
| 179 | 177 | log_message('error', 'Could not find the specified $config[\'composer_autoload\'] path: '.$composer_autoload); |
| 180 | 178 | } |
@@ -253,8 +251,7 @@ discard block |
||
| 253 | 251 | // This is required for mb_convert_encoding() to strip invalid characters. |
| 254 | 252 | // That's utilized by CI_Utf8, but it's also done for consistency with iconv. |
| 255 | 253 | mb_substitute_character('none'); |
| 256 | - } |
|
| 257 | - else |
|
| 254 | + } else |
|
| 258 | 255 | { |
| 259 | 256 | define('MB_ENABLED', FALSE); |
| 260 | 257 | } |
@@ -267,8 +264,7 @@ discard block |
||
| 267 | 264 | // iconv.internal_encoding is deprecated starting with PHP 5.6 |
| 268 | 265 | // and it's usage triggers E_DEPRECATED messages. |
| 269 | 266 | @ini_set('iconv.internal_encoding', $charset); |
| 270 | - } |
|
| 271 | - else |
|
| 267 | + } else |
|
| 272 | 268 | { |
| 273 | 269 | define('ICONV_ENABLED', FALSE); |
| 274 | 270 | } |
@@ -378,8 +374,7 @@ discard block |
||
| 378 | 374 | if (! CIPHPUnitTest::wiredesignzHmvcInstalled()) |
| 379 | 375 | { |
| 380 | 376 | return CI_Controller::get_instance(); |
| 381 | - } |
|
| 382 | - else |
|
| 377 | + } else |
|
| 383 | 378 | { |
| 384 | 379 | return CI::$APP; |
| 385 | 380 | } |
@@ -424,21 +419,18 @@ discard block |
||
| 424 | 419 | if (empty($class) OR ! file_exists(APPPATH.'controllers/'.$RTR->directory.$class.'.php')) |
| 425 | 420 | { |
| 426 | 421 | $e404 = TRUE; |
| 427 | - } |
|
| 428 | - else |
|
| 422 | + } else |
|
| 429 | 423 | { |
| 430 | 424 | require_once(APPPATH.'controllers/'.$RTR->directory.$class.'.php'); |
| 431 | 425 | |
| 432 | 426 | if ( ! class_exists($class, FALSE) OR $method[0] === '_' OR method_exists('CI_Controller', $method)) |
| 433 | 427 | { |
| 434 | 428 | $e404 = TRUE; |
| 435 | - } |
|
| 436 | - elseif (method_exists($class, '_remap')) |
|
| 429 | + } elseif (method_exists($class, '_remap')) |
|
| 437 | 430 | { |
| 438 | 431 | $params = array($method, array_slice($URI->rsegments, 2)); |
| 439 | 432 | $method = '_remap'; |
| 440 | - } |
|
| 441 | - elseif ( ! method_exists($class, $method)) |
|
| 433 | + } elseif ( ! method_exists($class, $method)) |
|
| 442 | 434 | { |
| 443 | 435 | $e404 = TRUE; |
| 444 | 436 | } |
@@ -490,8 +482,7 @@ discard block |
||
| 490 | 482 | $RTR->directory = ''; |
| 491 | 483 | } |
| 492 | 484 | } |
| 493 | - } |
|
| 494 | - else |
|
| 485 | + } else |
|
| 495 | 486 | { |
| 496 | 487 | $e404 = FALSE; |
| 497 | 488 | } |
@@ -507,8 +498,7 @@ discard block |
||
| 507 | 498 | 1 => $class, |
| 508 | 499 | 2 => $method |
| 509 | 500 | ); |
| 510 | - } |
|
| 511 | - else |
|
| 501 | + } else |
|
| 512 | 502 | { |
| 513 | 503 | show_404($RTR->directory.$class.'/'.$method); |
| 514 | 504 | } |
@@ -13,7 +13,6 @@ |
||
| 13 | 13 | use PhpParser\Node; |
| 14 | 14 | use PhpParser\Node\Stmt\ClassMethod; |
| 15 | 15 | use PhpParser\NodeVisitorAbstract; |
| 16 | - |
|
| 17 | 16 | use Kenjis\MonkeyPatch\Patcher\MethodPatcher; |
| 18 | 17 | |
| 19 | 18 | class NodeVisitor extends NodeVisitorAbstract |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | |
| 25 | 25 | public function enterNode(Node $node) |
| 26 | 26 | { |
| 27 | - $callback = [$this, 'before' . ucfirst($node->getType())]; |
|
| 27 | + $callback = [$this, 'before'.ucfirst($node->getType())]; |
|
| 28 | 28 | if (is_callable($callback)) { |
| 29 | 29 | call_user_func_array($callback, [$node]); |
| 30 | 30 | } |
@@ -32,9 +32,9 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | public function leaveNode(Node $node) |
| 34 | 34 | { |
| 35 | - if (! ($node instanceof ConstFetch)) |
|
| 35 | + if ( ! ($node instanceof ConstFetch)) |
|
| 36 | 36 | { |
| 37 | - $callback = [$this, 'rewrite' . ucfirst($node->getType())]; |
|
| 37 | + $callback = [$this, 'rewrite'.ucfirst($node->getType())]; |
|
| 38 | 38 | if (is_callable($callback)) { |
| 39 | 39 | call_user_func_array($callback, [$node]); |
| 40 | 40 | } |
@@ -47,26 +47,26 @@ discard block |
||
| 47 | 47 | return; |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - if (! ($node->name instanceof Name)) |
|
| 50 | + if ( ! ($node->name instanceof Name)) |
|
| 51 | 51 | { |
| 52 | 52 | return; |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - if (! $node->name->isUnqualified()) |
|
| 55 | + if ( ! $node->name->isUnqualified()) |
|
| 56 | 56 | { |
| 57 | 57 | return; |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - if (! ConstantPatcher::isBlacklisted((string) $node->name)) |
|
| 60 | + if ( ! ConstantPatcher::isBlacklisted((string) $node->name)) |
|
| 61 | 61 | { |
| 62 | 62 | $replacement = new FullyQualified(array()); |
| 63 | 63 | $replacement->set( |
| 64 | - '\__ConstProxy__::get(\'' . (string) $node->name . '\')' |
|
| 64 | + '\__ConstProxy__::get(\''.(string) $node->name.'\')' |
|
| 65 | 65 | ); |
| 66 | 66 | |
| 67 | 67 | $pos = $node->getAttribute('startTokenPos'); |
| 68 | 68 | ConstantPatcher::$replacement[$pos] = |
| 69 | - '\__ConstProxy__::get(\'' . (string) $node->name .'\')'; |
|
| 69 | + '\__ConstProxy__::get(\''.(string) $node->name.'\')'; |
|
| 70 | 70 | |
| 71 | 71 | $node->name = $replacement; |
| 72 | 72 | } |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | $method = isset($info['class_method']) ? $info['class_method'] : $info['function']; |
| 66 | 66 | |
| 67 | 67 | MonkeyPatchManager::log( |
| 68 | - 'invoke_const: ' . $constant . ') on line ' . $line . ' in ' . $file . ' by ' . $method . '()' |
|
| 68 | + 'invoke_const: '.$constant.') on line '.$line.' in '.$file.' by '.$method.'()' |
|
| 69 | 69 | ); |
| 70 | 70 | } |
| 71 | 71 | } |
@@ -111,10 +111,10 @@ discard block |
||
| 111 | 111 | |
| 112 | 112 | if (isset(self::$patches_to_apply[$constant])) |
| 113 | 113 | { |
| 114 | - if (! self::checkCalledMethod($constant)) |
|
| 114 | + if ( ! self::checkCalledMethod($constant)) |
|
| 115 | 115 | { |
| 116 | 116 | MonkeyPatchManager::log( |
| 117 | - 'invoke_const: ' . $constant . ' not patched (out of scope)' |
|
| 117 | + 'invoke_const: '.$constant.' not patched (out of scope)' |
|
| 118 | 118 | ); |
| 119 | 119 | return constant($constant); |
| 120 | 120 | } |
@@ -122,12 +122,12 @@ discard block |
||
| 122 | 122 | |
| 123 | 123 | if (array_key_exists($constant, self::$patches)) |
| 124 | 124 | { |
| 125 | - MonkeyPatchManager::log('invoke_const: ' . $constant . ' patched'); |
|
| 125 | + MonkeyPatchManager::log('invoke_const: '.$constant.' patched'); |
|
| 126 | 126 | return self::$patches[$constant]; |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | MonkeyPatchManager::log( |
| 130 | - 'invoke_const: ' . $constant . ' not patched (no patch)' |
|
| 130 | + 'invoke_const: '.$constant.' not patched (no patch)' |
|
| 131 | 131 | ); |
| 132 | 132 | return constant($constant); |
| 133 | 133 | } |
@@ -10,8 +10,8 @@ |
||
| 10 | 10 | |
| 11 | 11 | namespace Kenjis\MonkeyPatch\Patcher; |
| 12 | 12 | |
| 13 | -require __DIR__ . '/ConstantPatcher/NodeVisitor.php'; |
|
| 14 | -require __DIR__ . '/ConstantPatcher/Proxy.php'; |
|
| 13 | +require __DIR__.'/ConstantPatcher/NodeVisitor.php'; |
|
| 14 | +require __DIR__.'/ConstantPatcher/Proxy.php'; |
|
| 15 | 15 | |
| 16 | 16 | use LogicException; |
| 17 | 17 | |
@@ -173,13 +173,11 @@ |
||
| 173 | 173 | if (is_string($token)) |
| 174 | 174 | { |
| 175 | 175 | $new_source .= $token; |
| 176 | - } |
|
| 177 | - elseif ($i == $replacement['key']) |
|
| 176 | + } elseif ($i == $replacement['key']) |
|
| 178 | 177 | { |
| 179 | 178 | $new_source .= $replacement['value']; |
| 180 | 179 | $replacement = each(self::$replacement); |
| 181 | - } |
|
| 182 | - else |
|
| 180 | + } else |
|
| 183 | 181 | { |
| 184 | 182 | $new_source .= $token[1]; |
| 185 | 183 | } |
@@ -38,12 +38,12 @@ |
||
| 38 | 38 | $real_path = realpath($path); |
| 39 | 39 | if ($real_path === FALSE) |
| 40 | 40 | { |
| 41 | - throw new RuntimeException($path . ' does not exist?'); |
|
| 41 | + throw new RuntimeException($path.' does not exist?'); |
|
| 42 | 42 | } |
| 43 | 43 | if (is_dir($real_path)) |
| 44 | 44 | { |
| 45 | 45 | // Must use DIRECTORY_SEPARATOR for Windows |
| 46 | - $real_path = $real_path . DIRECTORY_SEPARATOR; |
|
| 46 | + $real_path = $real_path.DIRECTORY_SEPARATOR; |
|
| 47 | 47 | } |
| 48 | 48 | $new_paths[] = $excluded ? '-'.$real_path : $real_path; |
| 49 | 49 | } |