@@ -13,8 +13,6 @@ |
||
13 | 13 | require __DIR__ . '/MethodPatcher/NodeVisitor.php'; |
14 | 14 | require __DIR__ . '/MethodPatcher/PatchManager.php'; |
15 | 15 | |
16 | -use LogicException; |
|
17 | - |
|
18 | 16 | use Kenjis\MonkeyPatch\Patcher\MethodPatcher\NodeVisitor; |
19 | 17 | |
20 | 18 | class MethodPatcher extends AbstractPatcher |
@@ -10,8 +10,8 @@ discard block |
||
10 | 10 | |
11 | 11 | namespace Kenjis\MonkeyPatch\Patcher; |
12 | 12 | |
13 | -require __DIR__ . '/MethodPatcher/NodeVisitor.php'; |
|
14 | -require __DIR__ . '/MethodPatcher/PatchManager.php'; |
|
13 | +require __DIR__.'/MethodPatcher/NodeVisitor.php'; |
|
14 | +require __DIR__.'/MethodPatcher/PatchManager.php'; |
|
15 | 15 | |
16 | 16 | use LogicException; |
17 | 17 | |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | { |
56 | 56 | if ($start_method && $token === '{') |
57 | 57 | { |
58 | - $new_source .= '{ ' . self::CODE; |
|
58 | + $new_source .= '{ '.self::CODE; |
|
59 | 59 | $start_method = false; |
60 | 60 | $replacement = each(self::$replacement); |
61 | 61 | } |
@@ -58,13 +58,11 @@ |
||
58 | 58 | $new_source .= '{ ' . self::CODE; |
59 | 59 | $start_method = false; |
60 | 60 | $replacement = each(self::$replacement); |
61 | - } |
|
62 | - else |
|
61 | + } else |
|
63 | 62 | { |
64 | 63 | $new_source .= $token; |
65 | 64 | } |
66 | - } |
|
67 | - else |
|
65 | + } else |
|
68 | 66 | { |
69 | 67 | $new_source .= $token[1]; |
70 | 68 | } |
@@ -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 |
@@ -20,7 +20,7 @@ |
||
20 | 20 | { |
21 | 21 | public function leaveNode(Node $node) |
22 | 22 | { |
23 | - if (! ($node instanceof ClassMethod)) |
|
23 | + if ( ! ($node instanceof ClassMethod)) |
|
24 | 24 | { |
25 | 25 | return; |
26 | 26 | } |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | * @param string $library Library name |
192 | 192 | * @param array $params Optional parameters to pass to the library class constructor |
193 | 193 | * @param string $object_name An optional object name to assign to |
194 | - * @return object |
|
194 | + * @return CI_Loader |
|
195 | 195 | * |
196 | 196 | * @codeCoverageIgnore |
197 | 197 | */ |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | * @param string $model Model name |
238 | 238 | * @param string $name An optional object name to assign to |
239 | 239 | * @param bool $db_conn An optional database connection configuration to initialize |
240 | - * @return object |
|
240 | + * @return CI_Loader |
|
241 | 241 | * |
242 | 242 | * modified by ci-phpunit-test |
243 | 243 | */ |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | /** |
370 | 370 | * Database Loader |
371 | 371 | * |
372 | - * @param mixed $params Database configuration options |
|
372 | + * @param string|boolean $params Database configuration options |
|
373 | 373 | * @param bool $return Whether to return the database object |
374 | 374 | * @param bool $query_builder Whether to enable Query Builder |
375 | 375 | * (overrides the configuration setting) |
@@ -535,7 +535,7 @@ discard block |
||
535 | 535 | * An associative array or object containing values |
536 | 536 | * to be set, or a value's name if string |
537 | 537 | * @param string $val Value to set, only used if $vars is a string |
538 | - * @return object |
|
538 | + * @return CI_Loader |
|
539 | 539 | * |
540 | 540 | * @codeCoverageIgnore |
541 | 541 | */ |
@@ -609,7 +609,7 @@ discard block |
||
609 | 609 | * Helper Loader |
610 | 610 | * |
611 | 611 | * @param string|string[] $helpers Helper name(s) |
612 | - * @return object |
|
612 | + * @return CI_Loader |
|
613 | 613 | * |
614 | 614 | * @codeCoverageIgnore |
615 | 615 | */ |
@@ -688,7 +688,7 @@ discard block |
||
688 | 688 | * |
689 | 689 | * @uses CI_Loader::helper() |
690 | 690 | * @param string|string[] $helpers Helper name(s) |
691 | - * @return object |
|
691 | + * @return CI_Loader |
|
692 | 692 | * |
693 | 693 | * @codeCoverageIgnore |
694 | 694 | */ |
@@ -706,7 +706,7 @@ discard block |
||
706 | 706 | * |
707 | 707 | * @param string|string[] $files List of language file names to load |
708 | 708 | * @param string Language name |
709 | - * @return object |
|
709 | + * @return CI_Loader |
|
710 | 710 | * |
711 | 711 | * @codeCoverageIgnore |
712 | 712 | */ |
@@ -806,7 +806,7 @@ discard block |
||
806 | 806 | * |
807 | 807 | * @param string $path Path to add |
808 | 808 | * @param bool $view_cascade (default: TRUE) |
809 | - * @return object |
|
809 | + * @return CI_Loader |
|
810 | 810 | * |
811 | 811 | * @codeCoverageIgnore |
812 | 812 | */ |
@@ -854,7 +854,7 @@ discard block |
||
854 | 854 | * added path will be removed removed. |
855 | 855 | * |
856 | 856 | * @param string $path Path to remove |
857 | - * @return object |
|
857 | + * @return CI_Loader |
|
858 | 858 | * |
859 | 859 | * @codeCoverageIgnore |
860 | 860 | */ |
@@ -63,63 +63,63 @@ discard block |
||
63 | 63 | * |
64 | 64 | * @var array |
65 | 65 | */ |
66 | - protected $_ci_view_paths = array(VIEWPATH => TRUE); |
|
66 | + protected $_ci_view_paths = array(VIEWPATH => TRUE); |
|
67 | 67 | |
68 | 68 | /** |
69 | 69 | * List of paths to load libraries from |
70 | 70 | * |
71 | 71 | * @var array |
72 | 72 | */ |
73 | - protected $_ci_library_paths = array(APPPATH, BASEPATH); |
|
73 | + protected $_ci_library_paths = array(APPPATH, BASEPATH); |
|
74 | 74 | |
75 | 75 | /** |
76 | 76 | * List of paths to load models from |
77 | 77 | * |
78 | 78 | * @var array |
79 | 79 | */ |
80 | - protected $_ci_model_paths = array(APPPATH); |
|
80 | + protected $_ci_model_paths = array(APPPATH); |
|
81 | 81 | |
82 | 82 | /** |
83 | 83 | * List of paths to load helpers from |
84 | 84 | * |
85 | 85 | * @var array |
86 | 86 | */ |
87 | - protected $_ci_helper_paths = array(APPPATH, BASEPATH); |
|
87 | + protected $_ci_helper_paths = array(APPPATH, BASEPATH); |
|
88 | 88 | |
89 | 89 | /** |
90 | 90 | * List of cached variables |
91 | 91 | * |
92 | 92 | * @var array |
93 | 93 | */ |
94 | - protected $_ci_cached_vars = array(); |
|
94 | + protected $_ci_cached_vars = array(); |
|
95 | 95 | |
96 | 96 | /** |
97 | 97 | * List of loaded classes |
98 | 98 | * |
99 | 99 | * @var array |
100 | 100 | */ |
101 | - protected $_ci_classes = array(); |
|
101 | + protected $_ci_classes = array(); |
|
102 | 102 | |
103 | 103 | /** |
104 | 104 | * List of loaded models |
105 | 105 | * |
106 | 106 | * @var array |
107 | 107 | */ |
108 | - protected $_ci_models = array(); |
|
108 | + protected $_ci_models = array(); |
|
109 | 109 | |
110 | 110 | /** |
111 | 111 | * List of loaded helpers |
112 | 112 | * |
113 | 113 | * @var array |
114 | 114 | */ |
115 | - protected $_ci_helpers = array(); |
|
115 | + protected $_ci_helpers = array(); |
|
116 | 116 | |
117 | 117 | /** |
118 | 118 | * List of class name mappings |
119 | 119 | * |
120 | 120 | * @var array |
121 | 121 | */ |
122 | - protected $_ci_varmap = array( |
|
122 | + protected $_ci_varmap = array( |
|
123 | 123 | 'unit_test' => 'unit', |
124 | 124 | 'user_agent' => 'agent' |
125 | 125 | ); |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | public function __construct() |
139 | 139 | { |
140 | 140 | $this->_ci_ob_level = ob_get_level(); |
141 | - $this->_ci_classes =& is_loaded(); |
|
141 | + $this->_ci_classes = & is_loaded(); |
|
142 | 142 | |
143 | 143 | log_message('info', 'Loader Class Initialized'); |
144 | 144 | } |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | return $this; |
280 | 280 | } |
281 | 281 | |
282 | - $CI =& get_instance(); |
|
282 | + $CI = & get_instance(); |
|
283 | 283 | if (isset($CI->$name)) |
284 | 284 | { |
285 | 285 | throw new RuntimeException('The model name you are loading is the name of a resource that is already being used: '.$name); |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | public function database($params = '', $return = FALSE, $query_builder = NULL) |
383 | 383 | { |
384 | 384 | // Grab the super object |
385 | - $CI =& get_instance(); |
|
385 | + $CI = & get_instance(); |
|
386 | 386 | |
387 | 387 | // Do we even need to load the database class? |
388 | 388 | if ($return === FALSE && $query_builder === NULL && isset($CI->db) && is_object($CI->db) && ! empty($CI->db->conn_id)) |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | $CI->db = ''; |
403 | 403 | |
404 | 404 | // Load the DB class |
405 | - $CI->db =& DB($params, $query_builder); |
|
405 | + $CI->db = & DB($params, $query_builder); |
|
406 | 406 | return $this; |
407 | 407 | } |
408 | 408 | |
@@ -419,12 +419,12 @@ discard block |
||
419 | 419 | */ |
420 | 420 | public function dbutil($db = NULL, $return = FALSE) |
421 | 421 | { |
422 | - $CI =& get_instance(); |
|
422 | + $CI = & get_instance(); |
|
423 | 423 | |
424 | 424 | if ( ! is_object($db) OR ! ($db instanceof CI_DB)) |
425 | 425 | { |
426 | 426 | class_exists('CI_DB', FALSE) OR $this->database(); |
427 | - $db =& $CI->db; |
|
427 | + $db = & $CI->db; |
|
428 | 428 | } |
429 | 429 | |
430 | 430 | require_once(BASEPATH.'database/DB_utility.php'); |
@@ -453,11 +453,11 @@ discard block |
||
453 | 453 | */ |
454 | 454 | public function dbforge($db = NULL, $return = FALSE) |
455 | 455 | { |
456 | - $CI =& get_instance(); |
|
456 | + $CI = & get_instance(); |
|
457 | 457 | if ( ! is_object($db) OR ! ($db instanceof CI_DB)) |
458 | 458 | { |
459 | 459 | class_exists('CI_DB', FALSE) OR $this->database(); |
460 | - $db =& $CI->db; |
|
460 | + $db = & $CI->db; |
|
461 | 461 | } |
462 | 462 | |
463 | 463 | require_once(BASEPATH.'database/DB_forge.php'); |
@@ -821,7 +821,7 @@ discard block |
||
821 | 821 | $this->_ci_view_paths = array($path.'views/' => $view_cascade) + $this->_ci_view_paths; |
822 | 822 | |
823 | 823 | // Add config file path |
824 | - $config =& $this->_ci_get_component('config'); |
|
824 | + $config = & $this->_ci_get_component('config'); |
|
825 | 825 | $config->_config_paths[] = $path; |
826 | 826 | |
827 | 827 | return $this; |
@@ -860,7 +860,7 @@ discard block |
||
860 | 860 | */ |
861 | 861 | public function remove_package_path($path = '') |
862 | 862 | { |
863 | - $config =& $this->_ci_get_component('config'); |
|
863 | + $config = & $this->_ci_get_component('config'); |
|
864 | 864 | |
865 | 865 | if ($path === '') |
866 | 866 | { |
@@ -963,12 +963,12 @@ discard block |
||
963 | 963 | |
964 | 964 | // This allows anything loaded using $this->load (views, files, etc.) |
965 | 965 | // to become accessible from within the Controller and Model functions. |
966 | - $_ci_CI =& get_instance(); |
|
966 | + $_ci_CI = & get_instance(); |
|
967 | 967 | foreach (get_object_vars($_ci_CI) as $_ci_key => $_ci_var) |
968 | 968 | { |
969 | 969 | if ( ! isset($this->$_ci_key)) |
970 | 970 | { |
971 | - $this->$_ci_key =& $_ci_CI->$_ci_key; |
|
971 | + $this->$_ci_key = & $_ci_CI->$_ci_key; |
|
972 | 972 | } |
973 | 973 | } |
974 | 974 | |
@@ -1110,7 +1110,7 @@ discard block |
||
1110 | 1110 | // return a new instance of the object |
1111 | 1111 | if ($object_name !== NULL) |
1112 | 1112 | { |
1113 | - $CI =& get_instance(); |
|
1113 | + $CI = & get_instance(); |
|
1114 | 1114 | if ( ! isset($CI->$object_name)) |
1115 | 1115 | { |
1116 | 1116 | return $this->_ci_init_library($class, '', $params, $object_name); |
@@ -1173,7 +1173,7 @@ discard block |
||
1173 | 1173 | // return a new instance of the object |
1174 | 1174 | if ($object_name !== NULL) |
1175 | 1175 | { |
1176 | - $CI =& get_instance(); |
|
1176 | + $CI = & get_instance(); |
|
1177 | 1177 | if ( ! isset($CI->$object_name)) |
1178 | 1178 | { |
1179 | 1179 | return $this->_ci_init_library($library_name, $prefix, $params, $object_name); |
@@ -1326,7 +1326,7 @@ discard block |
||
1326 | 1326 | } |
1327 | 1327 | |
1328 | 1328 | // Don't overwrite existing properties |
1329 | - $CI =& get_instance(); |
|
1329 | + $CI = & get_instance(); |
|
1330 | 1330 | if (isset($CI->$object_name)) |
1331 | 1331 | { |
1332 | 1332 | if ($CI->$object_name instanceof $class_name) |
@@ -1477,7 +1477,7 @@ discard block |
||
1477 | 1477 | */ |
1478 | 1478 | protected function &_ci_get_component($component) |
1479 | 1479 | { |
1480 | - $CI =& get_instance(); |
|
1480 | + $CI = & get_instance(); |
|
1481 | 1481 | return $CI->$component; |
1482 | 1482 | } |
1483 | 1483 | } |
@@ -200,16 +200,14 @@ discard block |
||
200 | 200 | if (empty($library)) |
201 | 201 | { |
202 | 202 | return $this; |
203 | - } |
|
204 | - elseif (is_array($library)) |
|
203 | + } elseif (is_array($library)) |
|
205 | 204 | { |
206 | 205 | foreach ($library as $key => $value) |
207 | 206 | { |
208 | 207 | if (is_int($key)) |
209 | 208 | { |
210 | 209 | $this->library($value, $params); |
211 | - } |
|
212 | - else |
|
210 | + } else |
|
213 | 211 | { |
214 | 212 | $this->library($key, $params, $value); |
215 | 213 | } |
@@ -246,8 +244,7 @@ discard block |
||
246 | 244 | if (empty($model)) |
247 | 245 | { |
248 | 246 | return $this; |
249 | - } |
|
250 | - elseif (is_array($model)) |
|
247 | + } elseif (is_array($model)) |
|
251 | 248 | { |
252 | 249 | foreach ($model as $key => $value) |
253 | 250 | { |
@@ -313,8 +310,7 @@ discard block |
||
313 | 310 | { |
314 | 311 | throw new RuntimeException($app_path."Model.php exists, but doesn't declare class CI_Model"); |
315 | 312 | } |
316 | - } |
|
317 | - elseif ( ! class_exists('CI_Model', FALSE)) |
|
313 | + } elseif ( ! class_exists('CI_Model', FALSE)) |
|
318 | 314 | { |
319 | 315 | require_once(BASEPATH.'core'.DIRECTORY_SEPARATOR.'Model.php'); |
320 | 316 | } |
@@ -471,8 +467,7 @@ discard block |
||
471 | 467 | require_once($driver_path); |
472 | 468 | $class = 'CI_DB_'.$db->dbdriver.'_'.$db->subdriver.'_forge'; |
473 | 469 | } |
474 | - } |
|
475 | - else |
|
470 | + } else |
|
476 | 471 | { |
477 | 472 | $class = 'CI_DB_'.$db->dbdriver.'_forge'; |
478 | 473 | } |
@@ -761,16 +756,14 @@ discard block |
||
761 | 756 | if (is_int($key)) |
762 | 757 | { |
763 | 758 | $this->driver($value, $params); |
764 | - } |
|
765 | - else |
|
759 | + } else |
|
766 | 760 | { |
767 | 761 | $this->driver($key, $params, $value); |
768 | 762 | } |
769 | 763 | } |
770 | 764 | |
771 | 765 | return $this; |
772 | - } |
|
773 | - elseif (empty($library)) |
|
766 | + } elseif (empty($library)) |
|
774 | 767 | { |
775 | 768 | return FALSE; |
776 | 769 | } |
@@ -869,8 +862,7 @@ discard block |
||
869 | 862 | array_shift($this->_ci_helper_paths); |
870 | 863 | array_shift($this->_ci_view_paths); |
871 | 864 | array_pop($config->_config_paths); |
872 | - } |
|
873 | - else |
|
865 | + } else |
|
874 | 866 | { |
875 | 867 | $path = rtrim($path, '/').'/'; |
876 | 868 | foreach (array('_ci_library_paths', '_ci_model_paths', '_ci_helper_paths') as $var) |
@@ -934,8 +926,7 @@ discard block |
||
934 | 926 | { |
935 | 927 | $_ci_x = explode('/', $_ci_path); |
936 | 928 | $_ci_file = end($_ci_x); |
937 | - } |
|
938 | - else |
|
929 | + } else |
|
939 | 930 | { |
940 | 931 | $_ci_ext = pathinfo($_ci_view, PATHINFO_EXTENSION); |
941 | 932 | $_ci_file = ($_ci_ext === '') ? $_ci_view.'.php' : $_ci_view; |
@@ -1002,8 +993,7 @@ discard block |
||
1002 | 993 | if ( ! is_php('5.4') && ! ini_get('short_open_tag') && config_item('rewrite_short_tags') === TRUE) |
1003 | 994 | { |
1004 | 995 | echo eval('?>'.preg_replace('/;*\s*\?>/', '; ?>', str_replace('<?=', '<?php echo ', file_get_contents($_ci_path)))); |
1005 | - } |
|
1006 | - else |
|
996 | + } else |
|
1007 | 997 | { |
1008 | 998 | include($_ci_path); // include() vs include_once() allows for multiple views with the same name |
1009 | 999 | } |
@@ -1030,8 +1020,7 @@ discard block |
||
1030 | 1020 | if (ob_get_level() > $this->_ci_ob_level + 1) |
1031 | 1021 | { |
1032 | 1022 | ob_end_flush(); |
1033 | - } |
|
1034 | - else |
|
1023 | + } else |
|
1035 | 1024 | { |
1036 | 1025 | $_ci_CI->output->append_output(ob_get_contents()); |
1037 | 1026 | @ob_end_clean(); |
@@ -1071,8 +1060,7 @@ discard block |
||
1071 | 1060 | |
1072 | 1061 | // Get the filename from the path |
1073 | 1062 | $class = substr($class, $last_slash); |
1074 | - } |
|
1075 | - else |
|
1063 | + } else |
|
1076 | 1064 | { |
1077 | 1065 | $subdir = ''; |
1078 | 1066 | } |
@@ -1210,8 +1198,7 @@ discard block |
||
1210 | 1198 | if (file_exists(TESTPATH.'_ci_phpunit_test/replacing/libraries/'.$file_path.$library_name.'.php')) |
1211 | 1199 | { |
1212 | 1200 | include_once(TESTPATH.'_ci_phpunit_test/replacing/libraries/'.$file_path.$library_name.'.php'); |
1213 | - } |
|
1214 | - else |
|
1201 | + } else |
|
1215 | 1202 | { |
1216 | 1203 | include_once(BASEPATH.'libraries/'.$file_path.$library_name.'.php'); |
1217 | 1204 | } |
@@ -1227,8 +1214,7 @@ discard block |
||
1227 | 1214 | { |
1228 | 1215 | $prefix = config_item('subclass_prefix'); |
1229 | 1216 | break; |
1230 | - } |
|
1231 | - else |
|
1217 | + } else |
|
1232 | 1218 | { |
1233 | 1219 | log_message('debug', $path.' exists, but does not declare '.$subclass); |
1234 | 1220 | } |
@@ -1277,8 +1263,7 @@ discard block |
||
1277 | 1263 | { |
1278 | 1264 | include($path.'config/'.strtolower($class).'.php'); |
1279 | 1265 | $found = TRUE; |
1280 | - } |
|
1281 | - elseif (file_exists($path.'config/'.ucfirst(strtolower($class)).'.php')) |
|
1266 | + } elseif (file_exists($path.'config/'.ucfirst(strtolower($class)).'.php')) |
|
1282 | 1267 | { |
1283 | 1268 | include($path.'config/'.ucfirst(strtolower($class)).'.php'); |
1284 | 1269 | $found = TRUE; |
@@ -1288,8 +1273,7 @@ discard block |
||
1288 | 1273 | { |
1289 | 1274 | include($path.'config/'.ENVIRONMENT.'/'.strtolower($class).'.php'); |
1290 | 1275 | $found = TRUE; |
1291 | - } |
|
1292 | - elseif (file_exists($path.'config/'.ENVIRONMENT.'/'.ucfirst(strtolower($class)).'.php')) |
|
1276 | + } elseif (file_exists($path.'config/'.ENVIRONMENT.'/'.ucfirst(strtolower($class)).'.php')) |
|
1293 | 1277 | { |
1294 | 1278 | include($path.'config/'.ENVIRONMENT.'/'.ucfirst(strtolower($class)).'.php'); |
1295 | 1279 | $found = TRUE; |
@@ -85,8 +85,7 @@ discard block |
||
85 | 85 | if (! self::wiredesignzHmvcInstalled()) |
86 | 86 | { |
87 | 87 | new CI_Controller(); |
88 | - } |
|
89 | - else |
|
88 | + } else |
|
90 | 89 | { |
91 | 90 | new MX_Controller(); |
92 | 91 | } |
@@ -106,8 +105,7 @@ discard block |
||
106 | 105 | if (! self::wiredesignzHmvcInstalled()) |
107 | 106 | { |
108 | 107 | new CI_Controller(); |
109 | - } |
|
110 | - else |
|
108 | + } else |
|
111 | 109 | { |
112 | 110 | new CI(); |
113 | 111 | new MX_Controller(); |
@@ -33,30 +33,30 @@ 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 | - require TESTPATH . 'TestCase.php'; |
|
38 | + require TESTPATH.'TestCase.php'; |
|
39 | 39 | |
40 | - $db_test_case_file = TESTPATH . 'DbTestCase.php'; |
|
40 | + $db_test_case_file = TESTPATH.'DbTestCase.php'; |
|
41 | 41 | if (is_readable($db_test_case_file)) |
42 | 42 | { |
43 | 43 | require $db_test_case_file; |
44 | 44 | } |
45 | 45 | |
46 | 46 | // Replace a few Common functions |
47 | - require __DIR__ . '/replacing/core/Common.php'; |
|
48 | - require BASEPATH . 'core/Common.php'; |
|
47 | + require __DIR__.'/replacing/core/Common.php'; |
|
48 | + require BASEPATH.'core/Common.php'; |
|
49 | 49 | |
50 | 50 | // Workaround for missing CodeIgniter's error handler |
51 | 51 | // See https://github.com/kenjis/ci-phpunit-test/issues/37 |
52 | 52 | set_error_handler('_error_handler'); |
53 | 53 | |
54 | 54 | // Load new functions of CIPHPUnitTest |
55 | - require __DIR__ . '/functions.php'; |
|
55 | + require __DIR__.'/functions.php'; |
|
56 | 56 | // Load ci-phpunit-test CI_Loader |
57 | - require __DIR__ . '/replacing/core/Loader.php'; |
|
57 | + require __DIR__.'/replacing/core/Loader.php'; |
|
58 | 58 | // Load ci-phpunit-test CI_Input |
59 | - require __DIR__ . '/replacing/core/Input.php'; |
|
59 | + require __DIR__.'/replacing/core/Input.php'; |
|
60 | 60 | |
61 | 61 | // Change current directory |
62 | 62 | chdir(FCPATH); |
@@ -68,12 +68,12 @@ discard block |
||
68 | 68 | * |
69 | 69 | * And away we go... |
70 | 70 | */ |
71 | - require __DIR__ . '/replacing/core/CodeIgniter.php'; |
|
71 | + require __DIR__.'/replacing/core/CodeIgniter.php'; |
|
72 | 72 | |
73 | 73 | self::replaceHelpers(); |
74 | 74 | |
75 | 75 | // Create CodeIgniter instance |
76 | - if (! self::wiredesignzHmvcInstalled()) |
|
76 | + if ( ! self::wiredesignzHmvcInstalled()) |
|
77 | 77 | { |
78 | 78 | new CI_Controller(); |
79 | 79 | } |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | |
95 | 95 | public static function createCodeIgniterInstance() |
96 | 96 | { |
97 | - if (! self::wiredesignzHmvcInstalled()) |
|
97 | + if ( ! self::wiredesignzHmvcInstalled()) |
|
98 | 98 | { |
99 | 99 | new CI_Controller(); |
100 | 100 | } |
@@ -123,11 +123,11 @@ discard block |
||
123 | 123 | protected static function replaceLoader() |
124 | 124 | { |
125 | 125 | $my_loader_file = |
126 | - APPPATH . 'core/' . config_item('subclass_prefix') . 'Loader.php'; |
|
126 | + APPPATH.'core/'.config_item('subclass_prefix').'Loader.php'; |
|
127 | 127 | |
128 | 128 | if (file_exists($my_loader_file)) |
129 | 129 | { |
130 | - self::$loader_class = config_item('subclass_prefix') . 'Loader'; |
|
130 | + self::$loader_class = config_item('subclass_prefix').'Loader'; |
|
131 | 131 | if ( ! class_exists(self::$loader_class)) |
132 | 132 | { |
133 | 133 | require $my_loader_file; |
@@ -146,19 +146,19 @@ discard block |
||
146 | 146 | |
147 | 147 | protected static function loadHelper($helper) |
148 | 148 | { |
149 | - $my_helper_file = APPPATH . 'helpers/' . config_item('subclass_prefix') . $helper . '.php'; |
|
149 | + $my_helper_file = APPPATH.'helpers/'.config_item('subclass_prefix').$helper.'.php'; |
|
150 | 150 | if (file_exists($my_helper_file)) |
151 | 151 | { |
152 | 152 | require $my_helper_file; |
153 | 153 | } |
154 | - require __DIR__ . '/replacing/helpers/' . $helper . '.php'; |
|
154 | + require __DIR__.'/replacing/helpers/'.$helper.'.php'; |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | public static function setPatcherCacheDir($dir = null) |
158 | 158 | { |
159 | 159 | if ($dir === null) |
160 | 160 | { |
161 | - $dir = TESTPATH . '_ci_phpunit_test/tmp/cache'; |
|
161 | + $dir = TESTPATH.'_ci_phpunit_test/tmp/cache'; |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | MonkeyPatchManager::setCacheDir( |
@@ -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,23 +47,23 @@ 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 | - $replacement = new FullyQualified('\__ConstProxy__::get(\'' . (string) $node->name . '\')'); |
|
62 | + $replacement = new FullyQualified('\__ConstProxy__::get(\''.(string) $node->name.'\')'); |
|
63 | 63 | |
64 | 64 | $pos = $node->getAttribute('startTokenPos'); |
65 | 65 | ConstantPatcher::$replacement[$pos] = |
66 | - '\__ConstProxy__::get(\'' . (string) $node->name .'\')'; |
|
66 | + '\__ConstProxy__::get(\''.(string) $node->name.'\')'; |
|
67 | 67 | |
68 | 68 | $node->name = $replacement; |
69 | 69 | } |
@@ -15,7 +15,6 @@ |
||
15 | 15 | use PhpParser\Node\Name; |
16 | 16 | use PhpParser\Node\Name\FullyQualified; |
17 | 17 | use PhpParser\NodeVisitorAbstract; |
18 | - |
|
19 | 18 | use Kenjis\MonkeyPatch\Patcher\ConstantPatcher; |
20 | 19 | |
21 | 20 | class NodeVisitor extends NodeVisitorAbstract |
@@ -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 | } |
@@ -38,8 +38,7 @@ |
||
38 | 38 | { |
39 | 39 | $patched = true; |
40 | 40 | $new_source = static::generateNewSource($source); |
41 | - } |
|
42 | - else |
|
41 | + } else |
|
43 | 42 | { |
44 | 43 | $new_source = $source; |
45 | 44 | } |
@@ -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 | } |
@@ -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 | } |