@@ -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 | } |
@@ -12,36 +12,36 @@ |
||
12 | 12 | if (class_exists('PhpParser\Autoloader')) { |
13 | 13 | if (class_exists('PhpParser\Node\Identifier')) { |
14 | 14 | // PHP-Parser 4.x |
15 | - require __DIR__ . '/4.x/MonkeyPatchManager.php'; |
|
15 | + require __DIR__.'/4.x/MonkeyPatchManager.php'; |
|
16 | 16 | } |
17 | - elseif (method_exists('PhpParser\Node\Name','set')) { |
|
17 | + elseif (method_exists('PhpParser\Node\Name', 'set')) { |
|
18 | 18 | // PHP-Parser 2.x |
19 | - require __DIR__ . '/2.x/MonkeyPatchManager.php'; |
|
19 | + require __DIR__.'/2.x/MonkeyPatchManager.php'; |
|
20 | 20 | } else { |
21 | 21 | // PHP-Parser 3.x |
22 | - require __DIR__ . '/3.x/MonkeyPatchManager.php'; |
|
22 | + require __DIR__.'/3.x/MonkeyPatchManager.php'; |
|
23 | 23 | } |
24 | 24 | } |
25 | 25 | // If you don't use Composer |
26 | 26 | else { |
27 | 27 | if (version_compare(PHP_VERSION, '5.5.0', '>=')) { |
28 | 28 | // Use PHP-Parser 3.x |
29 | - require __DIR__ . '/third_party/PHP-Parser-3.1.5/lib/bootstrap.php'; |
|
30 | - require __DIR__ . '/3.x/MonkeyPatchManager.php'; |
|
29 | + require __DIR__.'/third_party/PHP-Parser-3.1.5/lib/bootstrap.php'; |
|
30 | + require __DIR__.'/3.x/MonkeyPatchManager.php'; |
|
31 | 31 | } else { |
32 | 32 | // Use PHP-Parser 2.x |
33 | - require __DIR__ . '/third_party/PHP-Parser-2.1.1/lib/bootstrap.php'; |
|
34 | - require __DIR__ . '/2.x/MonkeyPatchManager.php'; |
|
33 | + require __DIR__.'/third_party/PHP-Parser-2.1.1/lib/bootstrap.php'; |
|
34 | + require __DIR__.'/2.x/MonkeyPatchManager.php'; |
|
35 | 35 | } |
36 | 36 | } |
37 | 37 | |
38 | -require __DIR__ . '/IncludeStream.php'; |
|
39 | -require __DIR__ . '/PathChecker.php'; |
|
40 | -require __DIR__ . '/MonkeyPatch.php'; |
|
41 | -require __DIR__ . '/Cache.php'; |
|
42 | -require __DIR__ . '/InvocationVerifier.php'; |
|
38 | +require __DIR__.'/IncludeStream.php'; |
|
39 | +require __DIR__.'/PathChecker.php'; |
|
40 | +require __DIR__.'/MonkeyPatch.php'; |
|
41 | +require __DIR__.'/Cache.php'; |
|
42 | +require __DIR__.'/InvocationVerifier.php'; |
|
43 | 43 | |
44 | -require __DIR__ . '/functions/exit__.php'; |
|
44 | +require __DIR__.'/functions/exit__.php'; |
|
45 | 45 | |
46 | 46 | const __GO_TO_ORIG__ = '__GO_TO_ORIG__'; |
47 | 47 |
@@ -13,8 +13,7 @@ |
||
13 | 13 | if (class_exists('PhpParser\Node\Identifier')) { |
14 | 14 | // PHP-Parser 4.x |
15 | 15 | require __DIR__ . '/4.x/MonkeyPatchManager.php'; |
16 | - } |
|
17 | - elseif (method_exists('PhpParser\Node\Name','set')) { |
|
16 | + } elseif (method_exists('PhpParser\Node\Name','set')) { |
|
18 | 17 | // PHP-Parser 2.x |
19 | 18 | require __DIR__ . '/2.x/MonkeyPatchManager.php'; |
20 | 19 | } else { |
@@ -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 | } |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * |
33 | 33 | * @param string $classname |
34 | 34 | * @param array $params [method_name => return_value] |
35 | - * @param mixed $constructor_params false: disable constructor, array: constructor params |
|
35 | + * @param boolean $constructor_params false: disable constructor, array: constructor params |
|
36 | 36 | * |
37 | 37 | * @return mixed PHPUnit mock object |
38 | 38 | */ |
@@ -95,6 +95,10 @@ discard block |
||
95 | 95 | return $mock; |
96 | 96 | } |
97 | 97 | |
98 | + /** |
|
99 | + * @param string $method |
|
100 | + * @param string $with |
|
101 | + */ |
|
98 | 102 | protected function _verify($mock, $method, $params = null, $expects, $with) |
99 | 103 | { |
100 | 104 | $invocation = $mock->expects($expects) |
@@ -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 | } |
@@ -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 | } |