@@ -66,16 +66,16 @@ |
||
| 66 | 66 | $called_method = 'n/a'; |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - $log_args = function () use ($params) { |
|
| 69 | + $log_args = function() use ($params) { |
|
| 70 | 70 | $output = ''; |
| 71 | 71 | foreach ($params as $arg) { |
| 72 | - $output .= var_export($arg, true) . ', '; |
|
| 72 | + $output .= var_export($arg, true).', '; |
|
| 73 | 73 | } |
| 74 | 74 | $output = rtrim($output, ', '); |
| 75 | 75 | return $output; |
| 76 | 76 | }; |
| 77 | 77 | MonkeyPatchManager::log( |
| 78 | - 'invoke_method: ' . $class.'::'.$method . '(' . $log_args() . ') on line ' . $line . ' in ' . $file . ' by ' . $called_method |
|
| 78 | + 'invoke_method: '.$class.'::'.$method.'('.$log_args().') on line '.$line.' in '.$file.' by '.$called_method |
|
| 79 | 79 | ); |
| 80 | 80 | // var_dump($trace); exit; |
| 81 | 81 | } |
@@ -56,12 +56,10 @@ discard block |
||
| 56 | 56 | if (isset($info['class_method'])) |
| 57 | 57 | { |
| 58 | 58 | $called_method = $info['class_method']; |
| 59 | - } |
|
| 60 | - elseif (isset($info['function'])) |
|
| 59 | + } elseif (isset($info['function'])) |
|
| 61 | 60 | { |
| 62 | 61 | $called_method = $info['function']; |
| 63 | - } |
|
| 64 | - else |
|
| 62 | + } else |
|
| 65 | 63 | { |
| 66 | 64 | $called_method = 'n/a'; |
| 67 | 65 | } |
@@ -88,8 +86,7 @@ discard block |
||
| 88 | 86 | ) |
| 89 | 87 | { |
| 90 | 88 | $patch = self::$patches[$class][$method]; |
| 91 | - } |
|
| 92 | - else |
|
| 89 | + } else |
|
| 93 | 90 | { |
| 94 | 91 | return __GO_TO_ORIG__; |
| 95 | 92 | } |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | $method = isset($info['class_method']) ? $info['class_method'] : $info['function']; |
| 64 | 64 | |
| 65 | 65 | MonkeyPatchManager::log( |
| 66 | - 'invoke_const: ' . $constant . ') on line ' . $line . ' in ' . $file . ' by ' . $method . '()' |
|
| 66 | + 'invoke_const: '.$constant.') on line '.$line.' in '.$file.' by '.$method.'()' |
|
| 67 | 67 | ); |
| 68 | 68 | } |
| 69 | 69 | } |
@@ -106,12 +106,12 @@ discard block |
||
| 106 | 106 | { |
| 107 | 107 | self::logInvocation($constant); |
| 108 | 108 | |
| 109 | - if (! empty(self::$patches_to_apply[$constant])) |
|
| 109 | + if ( ! empty(self::$patches_to_apply[$constant])) |
|
| 110 | 110 | { |
| 111 | - if (! self::checkCalledMethod($constant)) |
|
| 111 | + if ( ! self::checkCalledMethod($constant)) |
|
| 112 | 112 | { |
| 113 | 113 | MonkeyPatchManager::log( |
| 114 | - 'invoke_const: ' . $constant . ' not patched (out of scope)' |
|
| 114 | + 'invoke_const: '.$constant.' not patched (out of scope)' |
|
| 115 | 115 | ); |
| 116 | 116 | return constant($constant); |
| 117 | 117 | } |
@@ -119,12 +119,12 @@ discard block |
||
| 119 | 119 | |
| 120 | 120 | if (array_key_exists($constant, self::$patches)) |
| 121 | 121 | { |
| 122 | - MonkeyPatchManager::log('invoke_const: ' . $constant . ' patched'); |
|
| 122 | + MonkeyPatchManager::log('invoke_const: '.$constant.' patched'); |
|
| 123 | 123 | return self::$patches[$constant]; |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | MonkeyPatchManager::log( |
| 127 | - 'invoke_const: ' . $constant . ' not patched (no patch)' |
|
| 127 | + 'invoke_const: '.$constant.' not patched (no patch)' |
|
| 128 | 128 | ); |
| 129 | 129 | return constant($constant); |
| 130 | 130 | } |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | namespace Kenjis\MonkeyPatch\Patcher; |
| 12 | 12 | |
| 13 | -require __DIR__ . '/../Exception/ExitException.php'; |
|
| 13 | +require __DIR__.'/../Exception/ExitException.php'; |
|
| 14 | 14 | |
| 15 | 15 | class ExitPatcher |
| 16 | 16 | { |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | } |
| 31 | 31 | elseif ($token[0] === T_EXIT) |
| 32 | 32 | { |
| 33 | - if ($tokens[$i+1] === ';') |
|
| 33 | + if ($tokens[$i + 1] === ';') |
|
| 34 | 34 | { |
| 35 | 35 | $new_source .= 'exit__()'; |
| 36 | 36 | } |
@@ -27,20 +27,17 @@ |
||
| 27 | 27 | if (is_string($token)) |
| 28 | 28 | { |
| 29 | 29 | $new_source .= $token; |
| 30 | - } |
|
| 31 | - elseif ($token[0] === T_EXIT) |
|
| 30 | + } elseif ($token[0] === T_EXIT) |
|
| 32 | 31 | { |
| 33 | 32 | if ($tokens[$i+1] === ';') |
| 34 | 33 | { |
| 35 | 34 | $new_source .= 'exit__()'; |
| 36 | - } |
|
| 37 | - else |
|
| 35 | + } else |
|
| 38 | 36 | { |
| 39 | 37 | $new_source .= 'exit__'; |
| 40 | 38 | } |
| 41 | 39 | $patched = true; |
| 42 | - } |
|
| 43 | - else |
|
| 40 | + } else |
|
| 44 | 41 | { |
| 45 | 42 | $new_source .= $token[1]; |
| 46 | 43 | } |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | |
| 45 | 45 | // Support PHPUnit 6.0 |
| 46 | 46 | if (! class_exists('PHPUnit_Util_Configuration')) { |
| 47 | - class_alias('PHPUnit\Util\Configuration', 'PHPUnit_Util_Configuration'); |
|
| 47 | + class_alias('PHPUnit\Util\Configuration', 'PHPUnit_Util_Configuration'); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | /** |
@@ -57,71 +57,71 @@ discard block |
||
| 57 | 57 | */ |
| 58 | 58 | final class TestSuiteProvider |
| 59 | 59 | { |
| 60 | - /** |
|
| 61 | - * phpunit configuration file |
|
| 62 | - * |
|
| 63 | - * @var string |
|
| 64 | - */ |
|
| 65 | - private static $file; |
|
| 60 | + /** |
|
| 61 | + * phpunit configuration file |
|
| 62 | + * |
|
| 63 | + * @var string |
|
| 64 | + */ |
|
| 65 | + private static $file; |
|
| 66 | 66 | |
| 67 | - /** |
|
| 68 | - * constructor |
|
| 69 | - */ |
|
| 70 | - private function __construct() {} |
|
| 67 | + /** |
|
| 68 | + * constructor |
|
| 69 | + */ |
|
| 70 | + private function __construct() {} |
|
| 71 | 71 | |
| 72 | - /** |
|
| 73 | - * set the phpunit configuration file |
|
| 74 | - * |
|
| 75 | - * @param string $file the path or filename of the phunit configuration file |
|
| 76 | - */ |
|
| 77 | - public static function setConfigurationFile($file) |
|
| 78 | - { |
|
| 79 | - static::$file = $file; |
|
| 80 | - } |
|
| 72 | + /** |
|
| 73 | + * set the phpunit configuration file |
|
| 74 | + * |
|
| 75 | + * @param string $file the path or filename of the phunit configuration file |
|
| 76 | + */ |
|
| 77 | + public static function setConfigurationFile($file) |
|
| 78 | + { |
|
| 79 | + static::$file = $file; |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | - /** |
|
| 83 | - * get the phpunit test suite instance |
|
| 84 | - * |
|
| 85 | - * @return PHPUnit_Framework_TestSuite returns the phpunit test suite instance |
|
| 86 | - * @throws FileNotFoundException if the file is not found |
|
| 87 | - */ |
|
| 88 | - public static function suite() |
|
| 89 | - { |
|
| 90 | - $file = static::checkConfigurationFile( |
|
| 91 | - static::getConfigurationFile() |
|
| 92 | - ); |
|
| 82 | + /** |
|
| 83 | + * get the phpunit test suite instance |
|
| 84 | + * |
|
| 85 | + * @return PHPUnit_Framework_TestSuite returns the phpunit test suite instance |
|
| 86 | + * @throws FileNotFoundException if the file is not found |
|
| 87 | + */ |
|
| 88 | + public static function suite() |
|
| 89 | + { |
|
| 90 | + $file = static::checkConfigurationFile( |
|
| 91 | + static::getConfigurationFile() |
|
| 92 | + ); |
|
| 93 | 93 | |
| 94 | - return PHPUnit_Util_Configuration::getInstance($file) |
|
| 95 | - ->getTestSuiteConfiguration(); |
|
| 96 | - } |
|
| 94 | + return PHPUnit_Util_Configuration::getInstance($file) |
|
| 95 | + ->getTestSuiteConfiguration(); |
|
| 96 | + } |
|
| 97 | 97 | |
| 98 | - /** |
|
| 99 | - * get the phpunit configuration file |
|
| 100 | - * |
|
| 101 | - * @return string |
|
| 102 | - */ |
|
| 103 | - private static function getConfigurationFile() |
|
| 104 | - { |
|
| 105 | - static::$file = isset(static::$file) |
|
| 106 | - ? static::$file |
|
| 107 | - : TESTPATH.'phpunit.xml'; |
|
| 98 | + /** |
|
| 99 | + * get the phpunit configuration file |
|
| 100 | + * |
|
| 101 | + * @return string |
|
| 102 | + */ |
|
| 103 | + private static function getConfigurationFile() |
|
| 104 | + { |
|
| 105 | + static::$file = isset(static::$file) |
|
| 106 | + ? static::$file |
|
| 107 | + : TESTPATH.'phpunit.xml'; |
|
| 108 | 108 | |
| 109 | - return static::$file; |
|
| 110 | - } |
|
| 109 | + return static::$file; |
|
| 110 | + } |
|
| 111 | 111 | |
| 112 | - /** |
|
| 113 | - * check the given file |
|
| 114 | - * |
|
| 115 | - * @param string $file file to check |
|
| 116 | - * @return string returns the file if it is valid |
|
| 117 | - * @throws FileNotFoundException if the file is not found |
|
| 118 | - */ |
|
| 119 | - private static function checkConfigurationFile($file) |
|
| 120 | - { |
|
| 121 | - if (!file_exists($file)) { |
|
| 122 | - throw new \RuntimeException("The requested phpunit configuration was not found at $file"); |
|
| 123 | - } |
|
| 112 | + /** |
|
| 113 | + * check the given file |
|
| 114 | + * |
|
| 115 | + * @param string $file file to check |
|
| 116 | + * @return string returns the file if it is valid |
|
| 117 | + * @throws FileNotFoundException if the file is not found |
|
| 118 | + */ |
|
| 119 | + private static function checkConfigurationFile($file) |
|
| 120 | + { |
|
| 121 | + if (!file_exists($file)) { |
|
| 122 | + throw new \RuntimeException("The requested phpunit configuration was not found at $file"); |
|
| 123 | + } |
|
| 124 | 124 | |
| 125 | - return $file; |
|
| 126 | - } |
|
| 125 | + return $file; |
|
| 126 | + } |
|
| 127 | 127 | } |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | use PHPUnit_Util_Configuration; |
| 44 | 44 | |
| 45 | 45 | // Support PHPUnit 6.0 |
| 46 | -if (! class_exists('PHPUnit_Util_Configuration')) { |
|
| 46 | +if ( ! class_exists('PHPUnit_Util_Configuration')) { |
|
| 47 | 47 | class_alias('PHPUnit\Util\Configuration', 'PHPUnit_Util_Configuration'); |
| 48 | 48 | } |
| 49 | 49 | |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | */ |
| 119 | 119 | private static function checkConfigurationFile($file) |
| 120 | 120 | { |
| 121 | - if (!file_exists($file)) { |
|
| 121 | + if ( ! file_exists($file)) { |
|
| 122 | 122 | throw new \RuntimeException("The requested phpunit configuration was not found at $file"); |
| 123 | 123 | } |
| 124 | 124 | |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | { |
| 36 | 36 | if ($this->db === null) |
| 37 | 37 | { |
| 38 | - $CI =& get_instance(); |
|
| 38 | + $CI = & get_instance(); |
|
| 39 | 39 | $CI->load->database(); |
| 40 | 40 | $this->db = $CI->db; |
| 41 | 41 | } |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | { |
| 57 | 57 | $this->checkDbConnId(); |
| 58 | 58 | |
| 59 | - if (! empty($this->insertCache)) |
|
| 59 | + if ( ! empty($this->insertCache)) |
|
| 60 | 60 | { |
| 61 | 61 | foreach ($this->insertCache as $row) |
| 62 | 62 | { |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | $this->db->close(); |
| 84 | 84 | $this->db = null; |
| 85 | 85 | |
| 86 | - $CI =& get_instance(); |
|
| 86 | + $CI = & get_instance(); |
|
| 87 | 87 | $CI->load->database(); |
| 88 | 88 | $this->db = $CI->db; |
| 89 | 89 | } |
@@ -46,8 +46,7 @@ |
||
| 46 | 46 | if ($constructor_params === false) |
| 47 | 47 | { |
| 48 | 48 | $mockBuilder->disableOriginalConstructor(); |
| 49 | - } |
|
| 50 | - elseif (is_array($constructor_params)) |
|
| 49 | + } elseif (is_array($constructor_params)) |
|
| 51 | 50 | { |
| 52 | 51 | $mockBuilder->setConstructorArgs($constructor_params); |
| 53 | 52 | } |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | // Load the mime types |
| 75 | - $mimes =& get_mimes(); |
|
| 75 | + $mimes = & get_mimes(); |
|
| 76 | 76 | |
| 77 | 77 | // Only change the default MIME if we can find one |
| 78 | 78 | if (isset($mimes[$extension])) |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | |
| 118 | 118 | if (TestCase::isTestingEnv()) |
| 119 | 119 | { |
| 120 | - $CI =& get_instance(); |
|
| 120 | + $CI = & get_instance(); |
|
| 121 | 121 | $CI->output->set_header('Content-Type: '.$mime); |
| 122 | 122 | $CI->output->set_header('Content-Disposition: attachment; filename="'.$filename.'"'); |
| 123 | 123 | $CI->output->set_header('Expires: 0'); |
@@ -38,8 +38,7 @@ discard block |
||
| 38 | 38 | if ($filename === '' OR $data === '') |
| 39 | 39 | { |
| 40 | 40 | return; |
| 41 | - } |
|
| 42 | - elseif ($data === NULL) |
|
| 41 | + } elseif ($data === NULL) |
|
| 43 | 42 | { |
| 44 | 43 | if ( ! @is_file($filename) OR ($filesize = @filesize($filename)) === FALSE) |
| 45 | 44 | { |
@@ -49,8 +48,7 @@ discard block |
||
| 49 | 48 | $filepath = $filename; |
| 50 | 49 | $filename = explode('/', str_replace(DIRECTORY_SEPARATOR, '/', $filename)); |
| 51 | 50 | $filename = end($filename); |
| 52 | - } |
|
| 53 | - else |
|
| 51 | + } else |
|
| 54 | 52 | { |
| 55 | 53 | $filesize = strlen($data); |
| 56 | 54 | } |
@@ -137,8 +135,7 @@ discard block |
||
| 137 | 135 | if ( ! TestCase::isTestingEnv()) |
| 138 | 136 | { |
| 139 | 137 | exit($data); |
| 140 | - } |
|
| 141 | - else |
|
| 138 | + } else |
|
| 142 | 139 | { |
| 143 | 140 | echo($data); |
| 144 | 141 | throw new CIPHPUnitTestExitException('exit() from force_download()'); |
@@ -155,8 +152,7 @@ discard block |
||
| 155 | 152 | if ( ! TestCase::isTestingEnv()) |
| 156 | 153 | { |
| 157 | 154 | exit; |
| 158 | - } |
|
| 159 | - else |
|
| 155 | + } else |
|
| 160 | 156 | { |
| 161 | 157 | throw new CIPHPUnitTestExitException('exit() from force_download()'); |
| 162 | 158 | } |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | // Load the mime types |
| 75 | - $mimes =& get_mimes(); |
|
| 75 | + $mimes = & get_mimes(); |
|
| 76 | 76 | |
| 77 | 77 | // Only change the default MIME if we can find one |
| 78 | 78 | if (isset($mimes[$extension])) |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | |
| 118 | 118 | if (TestCase::isTestingEnv()) |
| 119 | 119 | { |
| 120 | - $CI =& get_instance(); |
|
| 120 | + $CI = & get_instance(); |
|
| 121 | 121 | $CI->output->set_header('Content-Type: '.$mime); |
| 122 | 122 | $CI->output->set_header('Content-Disposition: attachment; filename="'.$filename.'"'); |
| 123 | 123 | $CI->output->set_header('Expires: 0'); |
@@ -38,8 +38,7 @@ discard block |
||
| 38 | 38 | if ($filename === '' OR $data === '') |
| 39 | 39 | { |
| 40 | 40 | return; |
| 41 | - } |
|
| 42 | - elseif ($data === NULL) |
|
| 41 | + } elseif ($data === NULL) |
|
| 43 | 42 | { |
| 44 | 43 | if ( ! @is_file($filename) OR ($filesize = @filesize($filename)) === FALSE) |
| 45 | 44 | { |
@@ -49,8 +48,7 @@ discard block |
||
| 49 | 48 | $filepath = $filename; |
| 50 | 49 | $filename = explode('/', str_replace(DIRECTORY_SEPARATOR, '/', $filename)); |
| 51 | 50 | $filename = end($filename); |
| 52 | - } |
|
| 53 | - else |
|
| 51 | + } else |
|
| 54 | 52 | { |
| 55 | 53 | $filesize = strlen($data); |
| 56 | 54 | } |
@@ -137,8 +135,7 @@ discard block |
||
| 137 | 135 | if ( ! TestCase::isTestingEnv()) |
| 138 | 136 | { |
| 139 | 137 | exit($data); |
| 140 | - } |
|
| 141 | - else |
|
| 138 | + } else |
|
| 142 | 139 | { |
| 143 | 140 | echo($data); |
| 144 | 141 | throw new CIPHPUnitTestExitException('exit() from force_download()'); |
@@ -155,8 +152,7 @@ discard block |
||
| 155 | 152 | if ( ! TestCase::isTestingEnv()) |
| 156 | 153 | { |
| 157 | 154 | exit; |
| 158 | - } |
|
| 159 | - else |
|
| 155 | + } else |
|
| 160 | 156 | { |
| 161 | 157 | throw new CIPHPUnitTestExitException('exit() from force_download()'); |
| 162 | 158 | } |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | // Load the mime types |
| 75 | - $mimes =& get_mimes(); |
|
| 75 | + $mimes = & get_mimes(); |
|
| 76 | 76 | |
| 77 | 77 | // Only change the default MIME if we can find one |
| 78 | 78 | if (isset($mimes[$extension])) |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | |
| 118 | 118 | if (TestCase::isTestingEnv()) |
| 119 | 119 | { |
| 120 | - $CI =& get_instance(); |
|
| 120 | + $CI = & get_instance(); |
|
| 121 | 121 | $CI->output->set_header('Content-Type: '.$mime); |
| 122 | 122 | $CI->output->set_header('Content-Disposition: attachment; filename="'.$filename.'"'); |
| 123 | 123 | $CI->output->set_header('Expires: 0'); |
@@ -38,8 +38,7 @@ discard block |
||
| 38 | 38 | if ($filename === '' OR $data === '') |
| 39 | 39 | { |
| 40 | 40 | return; |
| 41 | - } |
|
| 42 | - elseif ($data === NULL) |
|
| 41 | + } elseif ($data === NULL) |
|
| 43 | 42 | { |
| 44 | 43 | if ( ! @is_file($filename) OR ($filesize = @filesize($filename)) === FALSE) |
| 45 | 44 | { |
@@ -49,8 +48,7 @@ discard block |
||
| 49 | 48 | $filepath = $filename; |
| 50 | 49 | $filename = explode('/', str_replace(DIRECTORY_SEPARATOR, '/', $filename)); |
| 51 | 50 | $filename = end($filename); |
| 52 | - } |
|
| 53 | - else |
|
| 51 | + } else |
|
| 54 | 52 | { |
| 55 | 53 | $filesize = strlen($data); |
| 56 | 54 | } |
@@ -137,8 +135,7 @@ discard block |
||
| 137 | 135 | if ( ! TestCase::isTestingEnv()) |
| 138 | 136 | { |
| 139 | 137 | exit($data); |
| 140 | - } |
|
| 141 | - else |
|
| 138 | + } else |
|
| 142 | 139 | { |
| 143 | 140 | echo($data); |
| 144 | 141 | throw new CIPHPUnitTestExitException('exit() from force_download()'); |
@@ -155,8 +152,7 @@ discard block |
||
| 155 | 152 | if ( ! TestCase::isTestingEnv()) |
| 156 | 153 | { |
| 157 | 154 | exit; |
| 158 | - } |
|
| 159 | - else |
|
| 155 | + } else |
|
| 160 | 156 | { |
| 161 | 157 | throw new CIPHPUnitTestExitException('exit() from force_download()'); |
| 162 | 158 | } |