@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | /** |
83 | 83 | * Interactive interface |
84 | 84 | * |
85 | - * @return void |
|
85 | + * @return boolean |
|
86 | 86 | */ |
87 | 87 | protected function _interactive() { |
88 | 88 | $this->hr(); |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | * Assembles and writes database.php |
248 | 248 | * |
249 | 249 | * @param array $configs Configuration settings to use |
250 | - * @return boolean Success |
|
250 | + * @return null|boolean Success |
|
251 | 251 | */ |
252 | 252 | public function bake($configs) { |
253 | 253 | if (!is_dir($this->path)) { |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * @return void |
65 | 65 | */ |
66 | 66 | public function initialize() { |
67 | - $this->path = APP . 'Config' . DS; |
|
67 | + $this->path = APP.'Config'.DS; |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | /** |
@@ -91,10 +91,10 @@ discard block |
||
91 | 91 | $done = false; |
92 | 92 | $dbConfigs = array(); |
93 | 93 | |
94 | - while (!$done) { |
|
94 | + while ( ! $done) { |
|
95 | 95 | $name = ''; |
96 | 96 | |
97 | - while (!$name) { |
|
97 | + while ( ! $name) { |
|
98 | 98 | $name = $this->in(__d('cake_console', "Name:"), null, 'default'); |
99 | 99 | if (preg_match('/[^a-z0-9_]/i', $name)) { |
100 | 100 | $name = ''; |
@@ -115,12 +115,12 @@ discard block |
||
115 | 115 | } |
116 | 116 | |
117 | 117 | $host = ''; |
118 | - while (!$host) { |
|
118 | + while ( ! $host) { |
|
119 | 119 | $host = $this->in(__d('cake_console', 'Database Host:'), null, 'localhost'); |
120 | 120 | } |
121 | 121 | |
122 | 122 | $port = ''; |
123 | - while (!$port) { |
|
123 | + while ( ! $port) { |
|
124 | 124 | $port = $this->in(__d('cake_console', 'Port?'), null, 'n'); |
125 | 125 | } |
126 | 126 | |
@@ -129,16 +129,16 @@ discard block |
||
129 | 129 | } |
130 | 130 | |
131 | 131 | $login = ''; |
132 | - while (!$login) { |
|
132 | + while ( ! $login) { |
|
133 | 133 | $login = $this->in(__d('cake_console', 'User:'), null, 'root'); |
134 | 134 | } |
135 | 135 | $password = ''; |
136 | 136 | $blankPassword = false; |
137 | 137 | |
138 | - while (!$password && !$blankPassword) { |
|
138 | + while ( ! $password && ! $blankPassword) { |
|
139 | 139 | $password = $this->in(__d('cake_console', 'Password:')); |
140 | 140 | |
141 | - if (!$password) { |
|
141 | + if ( ! $password) { |
|
142 | 142 | $blank = $this->in(__d('cake_console', 'The password you supplied was empty. Use an empty password?'), array('y', 'n'), 'n'); |
143 | 143 | if ($blank === 'y') { |
144 | 144 | $blankPassword = true; |
@@ -147,12 +147,12 @@ discard block |
||
147 | 147 | } |
148 | 148 | |
149 | 149 | $database = ''; |
150 | - while (!$database) { |
|
150 | + while ( ! $database) { |
|
151 | 151 | $database = $this->in(__d('cake_console', 'Database Name:'), null, 'cake'); |
152 | 152 | } |
153 | 153 | |
154 | 154 | $prefix = ''; |
155 | - while (!$prefix) { |
|
155 | + while ( ! $prefix) { |
|
156 | 156 | $prefix = $this->in(__d('cake_console', 'Table Prefix?'), null, 'n'); |
157 | 157 | } |
158 | 158 | if (strtolower($prefix) === 'n') { |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | } |
161 | 161 | |
162 | 162 | $encoding = ''; |
163 | - while (!$encoding) { |
|
163 | + while ( ! $encoding) { |
|
164 | 164 | $encoding = $this->in(__d('cake_console', 'Table encoding?'), null, 'n'); |
165 | 165 | } |
166 | 166 | if (strtolower($encoding) === 'n') { |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | |
170 | 170 | $schema = ''; |
171 | 171 | if ($datasource === 'postgres') { |
172 | - while (!$schema) { |
|
172 | + while ( ! $schema) { |
|
173 | 173 | $schema = $this->in(__d('cake_console', 'Table schema?'), null, 'n'); |
174 | 174 | } |
175 | 175 | } |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | |
180 | 180 | $config = compact('name', 'datasource', 'persistent', 'host', 'login', 'password', 'database', 'prefix', 'encoding', 'port', 'schema'); |
181 | 181 | |
182 | - while (!$this->_verify($config)) { |
|
182 | + while ( ! $this->_verify($config)) { |
|
183 | 183 | $this->_interactive(); |
184 | 184 | } |
185 | 185 | |
@@ -250,12 +250,12 @@ discard block |
||
250 | 250 | * @return boolean Success |
251 | 251 | */ |
252 | 252 | public function bake($configs) { |
253 | - if (!is_dir($this->path)) { |
|
253 | + if ( ! is_dir($this->path)) { |
|
254 | 254 | $this->err(__d('cake_console', '%s not found', $this->path)); |
255 | 255 | return false; |
256 | 256 | } |
257 | 257 | |
258 | - $filename = $this->path . 'database.php'; |
|
258 | + $filename = $this->path.'database.php'; |
|
259 | 259 | $oldConfigs = array(); |
260 | 260 | |
261 | 261 | if (file_exists($filename)) { |
@@ -266,17 +266,17 @@ discard block |
||
266 | 266 | foreach ($temp as $configName => $info) { |
267 | 267 | $info = array_merge($this->_defaultConfig, $info); |
268 | 268 | |
269 | - if (!isset($info['schema'])) { |
|
269 | + if ( ! isset($info['schema'])) { |
|
270 | 270 | $info['schema'] = null; |
271 | 271 | } |
272 | - if (!isset($info['encoding'])) { |
|
272 | + if ( ! isset($info['encoding'])) { |
|
273 | 273 | $info['encoding'] = null; |
274 | 274 | } |
275 | - if (!isset($info['port'])) { |
|
275 | + if ( ! isset($info['port'])) { |
|
276 | 276 | $info['port'] = null; |
277 | 277 | } |
278 | 278 | |
279 | - $info['persistent'] = var_export((bool)$info['persistent'], true); |
|
279 | + $info['persistent'] = var_export((bool) $info['persistent'], true); |
|
280 | 280 | |
281 | 281 | $oldConfigs[] = array( |
282 | 282 | 'name' => $configName, |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | } |
343 | 343 | |
344 | 344 | $out .= "}\n"; |
345 | - $filename = $this->path . 'database.php'; |
|
345 | + $filename = $this->path.'database.php'; |
|
346 | 346 | return $this->createFile($filename, $out); |
347 | 347 | } |
348 | 348 | |
@@ -356,13 +356,13 @@ discard block |
||
356 | 356 | $configs = ConnectionManager::enumConnectionObjects(); |
357 | 357 | |
358 | 358 | $useDbConfig = key($configs); |
359 | - if (!is_array($configs) || empty($configs)) { |
|
359 | + if ( ! is_array($configs) || empty($configs)) { |
|
360 | 360 | return $this->execute(); |
361 | 361 | } |
362 | 362 | $connections = array_keys($configs); |
363 | 363 | |
364 | 364 | if (count($connections) > 1) { |
365 | - $useDbConfig = $this->in(__d('cake_console', 'Use Database Config') . ':', $connections, $useDbConfig); |
|
365 | + $useDbConfig = $this->in(__d('cake_console', 'Use Database Config').':', $connections, $useDbConfig); |
|
366 | 366 | } |
367 | 367 | return $useDbConfig; |
368 | 368 | } |
@@ -378,7 +378,7 @@ |
||
378 | 378 | * Parse tokens |
379 | 379 | * |
380 | 380 | * @param string $functionName Function name that indicates translatable string (e.g: '__') |
381 | - * @param array $map Array containing what variables it will find (e.g: category, domain, singular, plural) |
|
381 | + * @param string[] $map Array containing what variables it will find (e.g: category, domain, singular, plural) |
|
382 | 382 | * @return void |
383 | 383 | */ |
384 | 384 | protected function _parse($functionName, $map) { |
@@ -150,17 +150,17 @@ discard block |
||
150 | 150 | * @return void |
151 | 151 | */ |
152 | 152 | public function execute() { |
153 | - if (!empty($this->params['exclude'])) { |
|
153 | + if ( ! empty($this->params['exclude'])) { |
|
154 | 154 | $this->_exclude = explode(',', $this->params['exclude']); |
155 | 155 | } |
156 | - if (isset($this->params['files']) && !is_array($this->params['files'])) { |
|
156 | + if (isset($this->params['files']) && ! is_array($this->params['files'])) { |
|
157 | 157 | $this->_files = explode(',', $this->params['files']); |
158 | 158 | } |
159 | 159 | if (isset($this->params['paths'])) { |
160 | 160 | $this->_paths = explode(',', $this->params['paths']); |
161 | 161 | } elseif (isset($this->params['plugin'])) { |
162 | 162 | $plugin = Inflector::camelize($this->params['plugin']); |
163 | - if (!CakePlugin::loaded($plugin)) { |
|
163 | + if ( ! CakePlugin::loaded($plugin)) { |
|
164 | 164 | CakePlugin::load($plugin); |
165 | 165 | } |
166 | 166 | $this->_paths = array(CakePlugin::path($plugin)); |
@@ -170,44 +170,44 @@ discard block |
||
170 | 170 | } |
171 | 171 | |
172 | 172 | if (isset($this->params['extract-core'])) { |
173 | - $this->_extractCore = !(strtolower($this->params['extract-core']) === 'no'); |
|
173 | + $this->_extractCore = ! (strtolower($this->params['extract-core']) === 'no'); |
|
174 | 174 | } else { |
175 | 175 | $response = $this->in(__d('cake_console', 'Would you like to extract the messages from the CakePHP core?'), array('y', 'n'), 'n'); |
176 | 176 | $this->_extractCore = strtolower($response) === 'y'; |
177 | 177 | } |
178 | 178 | |
179 | - if (!empty($this->params['exclude-plugins']) && $this->_isExtractingApp()) { |
|
179 | + if ( ! empty($this->params['exclude-plugins']) && $this->_isExtractingApp()) { |
|
180 | 180 | $this->_exclude = array_merge($this->_exclude, App::path('plugins')); |
181 | 181 | } |
182 | 182 | |
183 | - if (!empty($this->params['ignore-model-validation']) || (!$this->_isExtractingApp() && empty($plugin))) { |
|
183 | + if ( ! empty($this->params['ignore-model-validation']) || ( ! $this->_isExtractingApp() && empty($plugin))) { |
|
184 | 184 | $this->_extractValidation = false; |
185 | 185 | } |
186 | - if (!empty($this->params['validation-domain'])) { |
|
186 | + if ( ! empty($this->params['validation-domain'])) { |
|
187 | 187 | $this->_validationDomain = $this->params['validation-domain']; |
188 | 188 | } |
189 | 189 | |
190 | 190 | if ($this->_extractCore) { |
191 | 191 | $this->_paths[] = CAKE; |
192 | 192 | $this->_exclude = array_merge($this->_exclude, array( |
193 | - CAKE . 'Test', |
|
194 | - CAKE . 'Console' . DS . 'Templates' |
|
193 | + CAKE.'Test', |
|
194 | + CAKE.'Console'.DS.'Templates' |
|
195 | 195 | )); |
196 | 196 | } |
197 | 197 | |
198 | 198 | if (isset($this->params['output'])) { |
199 | 199 | $this->_output = $this->params['output']; |
200 | 200 | } elseif (isset($this->params['plugin'])) { |
201 | - $this->_output = $this->_paths[0] . DS . 'Locale'; |
|
201 | + $this->_output = $this->_paths[0].DS.'Locale'; |
|
202 | 202 | } else { |
203 | - $message = __d('cake_console', "What is the path you would like to output?\n[Q]uit", $this->_paths[0] . DS . 'Locale'); |
|
203 | + $message = __d('cake_console', "What is the path you would like to output?\n[Q]uit", $this->_paths[0].DS.'Locale'); |
|
204 | 204 | while (true) { |
205 | - $response = $this->in($message, null, rtrim($this->_paths[0], DS) . DS . 'Locale'); |
|
205 | + $response = $this->in($message, null, rtrim($this->_paths[0], DS).DS.'Locale'); |
|
206 | 206 | if (strtoupper($response) === 'Q') { |
207 | 207 | $this->out(__d('cake_console', 'Extract Aborted')); |
208 | 208 | return $this->_stop(); |
209 | 209 | } elseif ($this->_isPathUsable($response)) { |
210 | - $this->_output = $response . DS; |
|
210 | + $this->_output = $response.DS; |
|
211 | 211 | break; |
212 | 212 | } else { |
213 | 213 | $this->err(__d('cake_console', 'The directory path you supplied was not found. Please try again.')); |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | } |
218 | 218 | |
219 | 219 | if (isset($this->params['merge'])) { |
220 | - $this->_merge = !(strtolower($this->params['merge']) === 'no'); |
|
220 | + $this->_merge = ! (strtolower($this->params['merge']) === 'no'); |
|
221 | 221 | } else { |
222 | 222 | $this->out(); |
223 | 223 | $response = $this->in(__d('cake_console', 'Would you like to merge all domain and category strings into the default.pot file?'), array('y', 'n'), 'n'); |
@@ -228,8 +228,8 @@ discard block |
||
228 | 228 | $this->_searchFiles(); |
229 | 229 | } |
230 | 230 | |
231 | - $this->_output = rtrim($this->_output, DS) . DS; |
|
232 | - if (!$this->_isPathUsable($this->_output)) { |
|
231 | + $this->_output = rtrim($this->_output, DS).DS; |
|
232 | + if ( ! $this->_isPathUsable($this->_output)) { |
|
233 | 233 | $this->err(__d('cake_console', 'The output directory %s was not found or writable.', $this->_output)); |
234 | 234 | return $this->_stop(); |
235 | 235 | } |
@@ -280,9 +280,9 @@ discard block |
||
280 | 280 | $this->hr(); |
281 | 281 | $this->out(__d('cake_console', 'Paths:')); |
282 | 282 | foreach ($this->_paths as $path) { |
283 | - $this->out(' ' . $path); |
|
283 | + $this->out(' '.$path); |
|
284 | 284 | } |
285 | - $this->out(__d('cake_console', 'Output Directory: ') . $this->_output); |
|
285 | + $this->out(__d('cake_console', 'Output Directory: ').$this->_output); |
|
286 | 286 | $this->hr(); |
287 | 287 | $this->_extractTokens(); |
288 | 288 | $this->_extractValidationMessages(); |
@@ -322,15 +322,15 @@ discard block |
||
322 | 322 | ->addOption('ignore-model-validation', array( |
323 | 323 | 'boolean' => true, |
324 | 324 | 'default' => false, |
325 | - 'help' => __d('cake_console', 'Ignores validation messages in the $validate property.' . |
|
326 | - ' If this flag is not set and the command is run from the same app directory,' . |
|
325 | + 'help' => __d('cake_console', 'Ignores validation messages in the $validate property.'. |
|
326 | + ' If this flag is not set and the command is run from the same app directory,'. |
|
327 | 327 | ' all messages in model validation rules will be extracted as tokens.') |
328 | 328 | )) |
329 | 329 | ->addOption('validation-domain', array( |
330 | 330 | 'help' => __d('cake_console', 'If set to a value, the localization domain to be used for model validation messages.') |
331 | 331 | )) |
332 | 332 | ->addOption('exclude', array( |
333 | - 'help' => __d('cake_console', 'Comma separated list of directories to exclude.' . |
|
333 | + 'help' => __d('cake_console', 'Comma separated list of directories to exclude.'. |
|
334 | 334 | ' Any path containing a path segment with the provided values will be skipped. E.g. test,vendors') |
335 | 335 | )) |
336 | 336 | ->addOption('overwrite', array( |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | |
360 | 360 | $this->_tokens = array(); |
361 | 361 | foreach ($allTokens as $token) { |
362 | - if (!is_array($token) || ($token[0] != T_WHITESPACE && $token[0] != T_INLINE_HTML)) { |
|
362 | + if ( ! is_array($token) || ($token[0] != T_WHITESPACE && $token[0] != T_INLINE_HTML)) { |
|
363 | 363 | $this->_tokens[] = $token; |
364 | 364 | } |
365 | 365 | } |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | while (($tokenCount - $count) > 1) { |
390 | 390 | $countToken = $this->_tokens[$count]; |
391 | 391 | $firstParenthesis = $this->_tokens[$count + 1]; |
392 | - if (!is_array($countToken)) { |
|
392 | + if ( ! is_array($countToken)) { |
|
393 | 393 | $count++; |
394 | 394 | continue; |
395 | 395 | } |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | $position = $count; |
400 | 400 | $depth = 0; |
401 | 401 | |
402 | - while (!$depth) { |
|
402 | + while ( ! $depth) { |
|
403 | 403 | if ($this->_tokens[$position] === '(') { |
404 | 404 | $depth++; |
405 | 405 | } elseif ($this->_tokens[$position] === ')') { |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | * @return void |
441 | 441 | */ |
442 | 442 | protected function _extractValidationMessages() { |
443 | - if (!$this->_extractValidation) { |
|
443 | + if ( ! $this->_extractValidation) { |
|
444 | 444 | return; |
445 | 445 | } |
446 | 446 | |
@@ -461,19 +461,19 @@ discard block |
||
461 | 461 | */ |
462 | 462 | protected function _extractPluginValidationMessages($plugin = null) { |
463 | 463 | App::uses('AppModel', 'Model'); |
464 | - if (!empty($plugin)) { |
|
465 | - if (!CakePlugin::loaded($plugin)) { |
|
464 | + if ( ! empty($plugin)) { |
|
465 | + if ( ! CakePlugin::loaded($plugin)) { |
|
466 | 466 | return; |
467 | 467 | } |
468 | - App::uses($plugin . 'AppModel', $plugin . '.Model'); |
|
469 | - $plugin = $plugin . '.'; |
|
468 | + App::uses($plugin.'AppModel', $plugin.'.Model'); |
|
469 | + $plugin = $plugin.'.'; |
|
470 | 470 | } |
471 | - $models = App::objects($plugin . 'Model', null, false); |
|
471 | + $models = App::objects($plugin.'Model', null, false); |
|
472 | 472 | |
473 | 473 | foreach ($models as $model) { |
474 | - App::uses($model, $plugin . 'Model'); |
|
474 | + App::uses($model, $plugin.'Model'); |
|
475 | 475 | $reflection = new ReflectionClass($model); |
476 | - if (!$reflection->isSubClassOf('Model')) { |
|
476 | + if ( ! $reflection->isSubClassOf('Model')) { |
|
477 | 477 | continue; |
478 | 478 | } |
479 | 479 | $properties = $reflection->getDefaultProperties(); |
@@ -484,7 +484,7 @@ discard block |
||
484 | 484 | |
485 | 485 | $file = $reflection->getFileName(); |
486 | 486 | $domain = $this->_validationDomain; |
487 | - if (!empty($properties['validationDomain'])) { |
|
487 | + if ( ! empty($properties['validationDomain'])) { |
|
488 | 488 | $domain = $properties['validationDomain']; |
489 | 489 | } |
490 | 490 | foreach ($validate as $field => $rules) { |
@@ -505,7 +505,7 @@ discard block |
||
505 | 505 | * @return void |
506 | 506 | */ |
507 | 507 | protected function _processValidationRules($field, $rules, $file, $domain, $category = 'LC_MESSAGES') { |
508 | - if (!is_array($rules)) { |
|
508 | + if ( ! is_array($rules)) { |
|
509 | 509 | return; |
510 | 510 | } |
511 | 511 | |
@@ -529,7 +529,7 @@ discard block |
||
529 | 529 | $msgid = $this->_formatString(sprintf("'%s'", $msgid)); |
530 | 530 | $details = array( |
531 | 531 | 'file' => $file, |
532 | - 'line' => 'validation for field ' . $field |
|
532 | + 'line' => 'validation for field '.$field |
|
533 | 533 | ); |
534 | 534 | $this->_addTranslation($category, $domain, $msgid, $details); |
535 | 535 | } |
@@ -543,7 +543,7 @@ discard block |
||
543 | 543 | */ |
544 | 544 | protected function _buildFiles() { |
545 | 545 | $paths = $this->_paths; |
546 | - $paths[] = realpath(APP) . DS; |
|
546 | + $paths[] = realpath(APP).DS; |
|
547 | 547 | foreach ($this->_translations as $category => $domains) { |
548 | 548 | foreach ($domains as $domain => $translations) { |
549 | 549 | foreach ($translations as $msgid => $details) { |
@@ -552,10 +552,10 @@ discard block |
||
552 | 552 | $occurrences = array(); |
553 | 553 | foreach ($files as $file => $lines) { |
554 | 554 | $lines = array_unique($lines); |
555 | - $occurrences[] = $file . ':' . implode(';', $lines); |
|
555 | + $occurrences[] = $file.':'.implode(';', $lines); |
|
556 | 556 | } |
557 | 557 | $occurrences = implode("\n#: ", $occurrences); |
558 | - $header = '#: ' . str_replace(DS, '/', str_replace($paths, '', $occurrences)) . "\n"; |
|
558 | + $header = '#: '.str_replace(DS, '/', str_replace($paths, '', $occurrences))."\n"; |
|
559 | 559 | |
560 | 560 | if ($plural === false) { |
561 | 561 | $sentence = "msgid \"{$msgid}\"\n"; |
@@ -586,13 +586,13 @@ discard block |
||
586 | 586 | * @return void |
587 | 587 | */ |
588 | 588 | protected function _store($category, $domain, $header, $sentence) { |
589 | - if (!isset($this->_storage[$category])) { |
|
589 | + if ( ! isset($this->_storage[$category])) { |
|
590 | 590 | $this->_storage[$category] = array(); |
591 | 591 | } |
592 | - if (!isset($this->_storage[$category][$domain])) { |
|
592 | + if ( ! isset($this->_storage[$category][$domain])) { |
|
593 | 593 | $this->_storage[$category][$domain] = array(); |
594 | 594 | } |
595 | - if (!isset($this->_storage[$category][$domain][$sentence])) { |
|
595 | + if ( ! isset($this->_storage[$category][$domain][$sentence])) { |
|
596 | 596 | $this->_storage[$category][$domain][$sentence] = $header; |
597 | 597 | } else { |
598 | 598 | $this->_storage[$category][$domain][$sentence] .= $header; |
@@ -606,22 +606,22 @@ discard block |
||
606 | 606 | */ |
607 | 607 | protected function _writeFiles() { |
608 | 608 | $overwriteAll = false; |
609 | - if (!empty($this->params['overwrite'])) { |
|
609 | + if ( ! empty($this->params['overwrite'])) { |
|
610 | 610 | $overwriteAll = true; |
611 | 611 | } |
612 | 612 | foreach ($this->_storage as $category => $domains) { |
613 | 613 | foreach ($domains as $domain => $sentences) { |
614 | 614 | $output = $this->_writeHeader(); |
615 | 615 | foreach ($sentences as $sentence => $header) { |
616 | - $output .= $header . $sentence; |
|
616 | + $output .= $header.$sentence; |
|
617 | 617 | } |
618 | 618 | |
619 | - $filename = $domain . '.pot'; |
|
619 | + $filename = $domain.'.pot'; |
|
620 | 620 | if ($category === 'LC_MESSAGES') { |
621 | - $File = new File($this->_output . $filename); |
|
621 | + $File = new File($this->_output.$filename); |
|
622 | 622 | } else { |
623 | - new Folder($this->_output . $category, true); |
|
624 | - $File = new File($this->_output . $category . DS . $filename); |
|
623 | + new Folder($this->_output.$category, true); |
|
624 | + $File = new File($this->_output.$category.DS.$filename); |
|
625 | 625 | } |
626 | 626 | $response = ''; |
627 | 627 | while ($overwriteAll === false && $File->exists() && strtoupper($response) !== 'Y') { |
@@ -633,9 +633,9 @@ discard block |
||
633 | 633 | ); |
634 | 634 | if (strtoupper($response) === 'N') { |
635 | 635 | $response = ''; |
636 | - while (!$response) { |
|
637 | - $response = $this->in(__d('cake_console', "What would you like to name this file?"), null, 'new_' . $filename); |
|
638 | - $File = new File($this->_output . $response); |
|
636 | + while ( ! $response) { |
|
637 | + $response = $this->in(__d('cake_console', "What would you like to name this file?"), null, 'new_'.$filename); |
|
638 | + $File = new File($this->_output.$response); |
|
639 | 639 | $filename = $response; |
640 | 640 | } |
641 | 641 | } elseif (strtoupper($response) === 'A') { |
@@ -661,7 +661,7 @@ discard block |
||
661 | 661 | $output .= "msgid \"\"\n"; |
662 | 662 | $output .= "msgstr \"\"\n"; |
663 | 663 | $output .= "\"Project-Id-Version: PROJECT VERSION\\n\"\n"; |
664 | - $output .= "\"POT-Creation-Date: " . date("Y-m-d H:iO") . "\\n\"\n"; |
|
664 | + $output .= "\"POT-Creation-Date: ".date("Y-m-d H:iO")."\\n\"\n"; |
|
665 | 665 | $output .= "\"PO-Revision-Date: YYYY-mm-DD HH:MM+ZZZZ\\n\"\n"; |
666 | 666 | $output .= "\"Last-Translator: NAME <EMAIL@ADDRESS>\\n\"\n"; |
667 | 667 | $output .= "\"Language-Team: LANGUAGE <EMAIL@ADDRESS>\\n\"\n"; |
@@ -761,20 +761,20 @@ discard block |
||
761 | 761 | */ |
762 | 762 | protected function _searchFiles() { |
763 | 763 | $pattern = false; |
764 | - if (!empty($this->_exclude)) { |
|
764 | + if ( ! empty($this->_exclude)) { |
|
765 | 765 | $exclude = array(); |
766 | 766 | foreach ($this->_exclude as $e) { |
767 | 767 | if (DS !== '\\' && $e[0] !== DS) { |
768 | - $e = DS . $e; |
|
768 | + $e = DS.$e; |
|
769 | 769 | } |
770 | 770 | $exclude[] = preg_quote($e, '/'); |
771 | 771 | } |
772 | - $pattern = '/' . implode('|', $exclude) . '/'; |
|
772 | + $pattern = '/'.implode('|', $exclude).'/'; |
|
773 | 773 | } |
774 | 774 | foreach ($this->_paths as $path) { |
775 | 775 | $Folder = new Folder($path); |
776 | 776 | $files = $Folder->findRecursive('.*\.(php|ctp|thtml|inc|tpl)', true); |
777 | - if (!empty($pattern)) { |
|
777 | + if ( ! empty($pattern)) { |
|
778 | 778 | foreach ($files as $i => $file) { |
779 | 779 | if (preg_match($pattern, $file)) { |
780 | 780 | unset($files[$i]); |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | /** |
187 | 187 | * Handles interactive baking |
188 | 188 | * |
189 | - * @return boolean |
|
189 | + * @return false|null |
|
190 | 190 | */ |
191 | 191 | protected function _interactive() { |
192 | 192 | $this->hr(); |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | /** |
368 | 368 | * Populate the _validations array |
369 | 369 | * |
370 | - * @return void |
|
370 | + * @return string[] |
|
371 | 371 | */ |
372 | 372 | public function initValidations() { |
373 | 373 | $options = $choices = array(); |
@@ -670,7 +670,7 @@ discard block |
||
670 | 670 | /** |
671 | 671 | * Interact with the user and confirm associations. |
672 | 672 | * |
673 | - * @param array $model Temporary Model instance. |
|
673 | + * @param Model $model Temporary Model instance. |
|
674 | 674 | * @param array $associations Array of associations to be confirmed. |
675 | 675 | * @return array Array of confirmed associations |
676 | 676 | */ |
@@ -91,9 +91,9 @@ discard block |
||
91 | 91 | $this->_interactive(); |
92 | 92 | } |
93 | 93 | |
94 | - if (!empty($this->args[0])) { |
|
94 | + if ( ! empty($this->args[0])) { |
|
95 | 95 | $this->interactive = false; |
96 | - if (!isset($this->connection)) { |
|
96 | + if ( ! isset($this->connection)) { |
|
97 | 97 | $this->connection = 'default'; |
98 | 98 | } |
99 | 99 | if (strtolower($this->args[0]) === 'all') { |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | * @return Model Model instance |
143 | 143 | */ |
144 | 144 | protected function _getModelObject($className, $table = null) { |
145 | - if (!$table) { |
|
145 | + if ( ! $table) { |
|
146 | 146 | $table = Inflector::tableize($className); |
147 | 147 | } |
148 | 148 | $object = new Model(array('name' => $className, 'table' => $table, 'ds' => $this->connection)); |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | public function inOptions($options, $prompt = null, $default = null) { |
168 | 168 | $valid = false; |
169 | 169 | $max = count($options); |
170 | - while (!$valid) { |
|
170 | + while ( ! $valid) { |
|
171 | 171 | $len = strlen(count($options) + 1); |
172 | 172 | foreach ($options as $i => $option) { |
173 | 173 | $this->out(sprintf("%${len}d. %s", $i + 1, $option)); |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | $useTable = $this->getTable($currentModelName); |
205 | 205 | $db = ConnectionManager::getDataSource($this->connection); |
206 | 206 | $fullTableName = $db->fullTableName($useTable); |
207 | - if (!in_array($useTable, $this->_tables)) { |
|
207 | + if ( ! in_array($useTable, $this->_tables)) { |
|
208 | 208 | $prompt = __d('cake_console', "The table %s doesn't exist or could not be automatically detected\ncontinue anyway?", $useTable); |
209 | 209 | $continue = $this->in($prompt, array('y', 'n')); |
210 | 210 | if (strtolower($continue) === 'n') { |
@@ -221,13 +221,13 @@ discard block |
||
221 | 221 | } catch (Exception $e) { |
222 | 222 | $fields = array($tempModel->primaryKey); |
223 | 223 | } |
224 | - if (!array_key_exists('id', $fields)) { |
|
224 | + if ( ! array_key_exists('id', $fields)) { |
|
225 | 225 | $primaryKey = $this->findPrimaryKey($fields); |
226 | 226 | } |
227 | 227 | |
228 | 228 | if ($knownToExist) { |
229 | 229 | $displayField = $tempModel->hasField(array('name', 'title')); |
230 | - if (!$displayField) { |
|
230 | + if ( ! $displayField) { |
|
231 | 231 | $displayField = $this->findDisplayField($tempModel->schema()); |
232 | 232 | } |
233 | 233 | |
@@ -259,10 +259,10 @@ discard block |
||
259 | 259 | if ($primaryKey !== 'id') { |
260 | 260 | $this->out(__d('cake_console', 'Primary Key: %s', $primaryKey)); |
261 | 261 | } |
262 | - if (!empty($validate)) { |
|
262 | + if ( ! empty($validate)) { |
|
263 | 263 | $this->out(__d('cake_console', 'Validation: %s', print_r($validate, true))); |
264 | 264 | } |
265 | - if (!empty($associations)) { |
|
265 | + if ( ! empty($associations)) { |
|
266 | 266 | $this->out(__d('cake_console', 'Associations:')); |
267 | 267 | $assocKeys = array('belongsTo', 'hasOne', 'hasMany', 'hasAndBelongsToMany'); |
268 | 268 | foreach ($assocKeys as $assocKey) { |
@@ -296,9 +296,9 @@ discard block |
||
296 | 296 | * @return void |
297 | 297 | */ |
298 | 298 | protected function _printAssociation($modelName, $type, $associations) { |
299 | - if (!empty($associations[$type])) { |
|
299 | + if ( ! empty($associations[$type])) { |
|
300 | 300 | for ($i = 0, $len = count($associations[$type]); $i < $len; $i++) { |
301 | - $out = "\t" . $modelName . ' ' . $type . ' ' . $associations[$type][$i]['alias']; |
|
301 | + $out = "\t".$modelName.' '.$type.' '.$associations[$type][$i]['alias']; |
|
302 | 302 | $this->out($out); |
303 | 303 | } |
304 | 304 | } |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | * @return array $validate Array of user selected validations. |
346 | 346 | */ |
347 | 347 | public function doValidation($model) { |
348 | - if (!$model instanceof Model) { |
|
348 | + if ( ! $model instanceof Model) { |
|
349 | 349 | return false; |
350 | 350 | } |
351 | 351 | $fields = $model->schema(); |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | $this->initValidations(); |
358 | 358 | foreach ($fields as $fieldName => $field) { |
359 | 359 | $validation = $this->fieldValidation($fieldName, $field, $model->primaryKey); |
360 | - if (!empty($validation)) { |
|
360 | + if ( ! empty($validation)) { |
|
361 | 361 | $validate[$fieldName] = $validation; |
362 | 362 | } |
363 | 363 | } |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | $optionText = ''; |
413 | 413 | for ($i = 1, $m = $defaultChoice / 2; $i <= $m; $i++) { |
414 | 414 | $line = sprintf("%2d. %s", $i, $this->_validations[$i]); |
415 | - $optionText .= $line . str_repeat(" ", 31 - strlen($line)); |
|
415 | + $optionText .= $line.str_repeat(" ", 31 - strlen($line)); |
|
416 | 416 | if ($m + $i !== $defaultChoice) { |
417 | 417 | $optionText .= sprintf("%2d. %s\n", $m + $i, $this->_validations[$m + $i]); |
418 | 418 | } |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | $prompt = __d('cake_console', "... or enter in a valid regex validation string.\n"); |
426 | 426 | $methods = array_flip($this->_validations); |
427 | 427 | $guess = $defaultChoice; |
428 | - if ($metaData['null'] != 1 && !in_array($fieldName, array($primaryKey, 'created', 'modified', 'updated'))) { |
|
428 | + if ($metaData['null'] != 1 && ! in_array($fieldName, array($primaryKey, 'created', 'modified', 'updated'))) { |
|
429 | 429 | if ($fieldName === 'email') { |
430 | 430 | $guess = $methods['email']; |
431 | 431 | } elseif ($metaData['type'] === 'string' && $metaData['length'] == 36) { |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | $this->out(__d('cake_console', "You have already chosen that validation rule,\nplease choose again")); |
458 | 458 | continue; |
459 | 459 | } |
460 | - if (!isset($this->_validations[$choice]) && is_numeric($choice)) { |
|
460 | + if ( ! isset($this->_validations[$choice]) && is_numeric($choice)) { |
|
461 | 461 | $this->out(__d('cake_console', 'Please make a valid selection.')); |
462 | 462 | continue; |
463 | 463 | } |
@@ -493,7 +493,7 @@ discard block |
||
493 | 493 | * @return array Associations |
494 | 494 | */ |
495 | 495 | public function doAssociations($model) { |
496 | - if (!$model instanceof Model) { |
|
496 | + if ( ! $model instanceof Model) { |
|
497 | 497 | return false; |
498 | 498 | } |
499 | 499 | if ($this->interactive === true) { |
@@ -506,7 +506,7 @@ discard block |
||
506 | 506 | } |
507 | 507 | |
508 | 508 | if (empty($this->_tables)) { |
509 | - $this->_tables = (array)$this->getAllTables(); |
|
509 | + $this->_tables = (array) $this->getAllTables(); |
|
510 | 510 | } |
511 | 511 | |
512 | 512 | $associations = array( |
@@ -545,7 +545,7 @@ discard block |
||
545 | 545 | * @return array Behaviors |
546 | 546 | */ |
547 | 547 | public function doActsAs($model) { |
548 | - if (!$model instanceof Model) { |
|
548 | + if ( ! $model instanceof Model) { |
|
549 | 549 | return false; |
550 | 550 | } |
551 | 551 | $behaviors = array(); |
@@ -582,7 +582,7 @@ discard block |
||
582 | 582 | ); |
583 | 583 | } elseif ($fieldName === 'parent_id') { |
584 | 584 | $associations['belongsTo'][] = array( |
585 | - 'alias' => 'Parent' . $model->name, |
|
585 | + 'alias' => 'Parent'.$model->name, |
|
586 | 586 | 'className' => $model->name, |
587 | 587 | 'foreignKey' => $fieldName, |
588 | 588 | ); |
@@ -604,7 +604,7 @@ discard block |
||
604 | 604 | $tempOtherModel = $this->_getModelObject($this->_modelName($otherTable), $otherTable); |
605 | 605 | $tempFieldNames = array_keys($tempOtherModel->schema(true)); |
606 | 606 | |
607 | - $pattern = '/_' . preg_quote($model->table, '/') . '|' . preg_quote($model->table, '/') . '_/'; |
|
607 | + $pattern = '/_'.preg_quote($model->table, '/').'|'.preg_quote($model->table, '/').'_/'; |
|
608 | 608 | $possibleJoinTable = preg_match($pattern, $otherTable); |
609 | 609 | if ($possibleJoinTable) { |
610 | 610 | continue; |
@@ -619,7 +619,7 @@ discard block |
||
619 | 619 | ); |
620 | 620 | } elseif ($otherTable === $model->table && $fieldName === 'parent_id') { |
621 | 621 | $assoc = array( |
622 | - 'alias' => 'Child' . $model->name, |
|
622 | + 'alias' => 'Child'.$model->name, |
|
623 | 623 | 'className' => $model->name, |
624 | 624 | 'foreignKey' => $fieldName |
625 | 625 | ); |
@@ -645,11 +645,11 @@ discard block |
||
645 | 645 | $foreignKey = $this->_modelKey($model->name); |
646 | 646 | foreach ($this->_tables as $otherTable) { |
647 | 647 | $tableName = null; |
648 | - $offset = strpos($otherTable, $model->table . '_'); |
|
649 | - $otherOffset = strpos($otherTable, '_' . $model->table); |
|
648 | + $offset = strpos($otherTable, $model->table.'_'); |
|
649 | + $otherOffset = strpos($otherTable, '_'.$model->table); |
|
650 | 650 | |
651 | 651 | if ($offset !== false) { |
652 | - $tableName = substr($otherTable, strlen($model->table . '_')); |
|
652 | + $tableName = substr($otherTable, strlen($model->table.'_')); |
|
653 | 653 | } elseif ($otherOffset !== false) { |
654 | 654 | $tableName = substr($otherTable, 0, $otherOffset); |
655 | 655 | } |
@@ -676,7 +676,7 @@ discard block |
||
676 | 676 | */ |
677 | 677 | public function confirmAssociations(Model $model, $associations) { |
678 | 678 | foreach ($associations as $type => $settings) { |
679 | - if (!empty($associations[$type])) { |
|
679 | + if ( ! empty($associations[$type])) { |
|
680 | 680 | foreach ($associations[$type] as $i => $assoc) { |
681 | 681 | $prompt = "{$model->name} {$type} {$assoc['alias']}?"; |
682 | 682 | $response = $this->in($prompt, array('y', 'n'), 'y'); |
@@ -709,7 +709,7 @@ discard block |
||
709 | 709 | $this->out(__d('cake_console', 'What is the association type?')); |
710 | 710 | $assocType = intval($this->inOptions($assocs, __d('cake_console', 'Enter a number'))); |
711 | 711 | |
712 | - $this->out(__d('cake_console', "For the following options be very careful to match your setup exactly.\n" . |
|
712 | + $this->out(__d('cake_console', "For the following options be very careful to match your setup exactly.\n". |
|
713 | 713 | "Any spelling mistakes will cause errors.")); |
714 | 714 | $this->hr(); |
715 | 715 | |
@@ -717,7 +717,7 @@ discard block |
||
717 | 717 | $className = $this->in(__d('cake_console', 'What className will %s use?', $alias), null, $alias); |
718 | 718 | |
719 | 719 | if ($assocType === 0) { |
720 | - if (!empty($possibleKeys[$model->table])) { |
|
720 | + if ( ! empty($possibleKeys[$model->table])) { |
|
721 | 721 | $showKeys = $possibleKeys[$model->table]; |
722 | 722 | } else { |
723 | 723 | $showKeys = null; |
@@ -727,7 +727,7 @@ discard block |
||
727 | 727 | $otherTable = Inflector::tableize($className); |
728 | 728 | if (in_array($otherTable, $this->_tables)) { |
729 | 729 | if ($assocType < 3) { |
730 | - if (!empty($possibleKeys[$otherTable])) { |
|
730 | + if ( ! empty($possibleKeys[$otherTable])) { |
|
731 | 731 | $showKeys = $possibleKeys[$otherTable]; |
732 | 732 | } else { |
733 | 733 | $showKeys = null; |
@@ -741,19 +741,19 @@ discard block |
||
741 | 741 | } |
742 | 742 | $suggestedForeignKey = $this->_modelKey($model->name); |
743 | 743 | } |
744 | - if (!empty($showKeys)) { |
|
744 | + if ( ! empty($showKeys)) { |
|
745 | 745 | $this->out(__d('cake_console', 'A helpful List of possible keys')); |
746 | 746 | $foreignKey = $this->inOptions($showKeys, __d('cake_console', 'What is the foreignKey?')); |
747 | 747 | $foreignKey = $showKeys[intval($foreignKey)]; |
748 | 748 | } |
749 | - if (!isset($foreignKey)) { |
|
749 | + if ( ! isset($foreignKey)) { |
|
750 | 750 | $foreignKey = $this->in(__d('cake_console', 'What is the foreignKey? Specify your own.'), null, $suggestedForeignKey); |
751 | 751 | } |
752 | 752 | if ($assocType === 3) { |
753 | 753 | $associationForeignKey = $this->in(__d('cake_console', 'What is the associationForeignKey?'), null, $this->_modelKey($model->name)); |
754 | 754 | $joinTable = $this->in(__d('cake_console', 'What is the joinTable?')); |
755 | 755 | } |
756 | - $associations[$assocs[$assocType]] = array_values((array)$associations[$assocs[$assocType]]); |
|
756 | + $associations[$assocs[$assocType]] = array_values((array) $associations[$assocs[$assocType]]); |
|
757 | 757 | $count = count($associations[$assocs[$assocType]]); |
758 | 758 | $i = ($count > 0) ? $count : 0; |
759 | 759 | $associations[$assocs[$assocType]][$i]['alias'] = $alias; |
@@ -796,7 +796,7 @@ discard block |
||
796 | 796 | */ |
797 | 797 | public function bake($name, $data = array()) { |
798 | 798 | if ($name instanceof Model) { |
799 | - if (!$data) { |
|
799 | + if ( ! $data) { |
|
800 | 800 | $data = array(); |
801 | 801 | $data['associations'] = $this->doAssociations($name); |
802 | 802 | $data['validate'] = $this->doValidation($name); |
@@ -823,7 +823,7 @@ discard block |
||
823 | 823 | |
824 | 824 | $pluginPath = ''; |
825 | 825 | if ($this->plugin) { |
826 | - $pluginPath = $this->plugin . '.'; |
|
826 | + $pluginPath = $this->plugin.'.'; |
|
827 | 827 | } |
828 | 828 | |
829 | 829 | $this->Template->set($data); |
@@ -834,8 +834,8 @@ discard block |
||
834 | 834 | $out = $this->Template->generate('classes', 'model'); |
835 | 835 | |
836 | 836 | $path = $this->getPath(); |
837 | - $filename = $path . $name . '.php'; |
|
838 | - $this->out("\n" . __d('cake_console', 'Baking model class for %s...', $name), 1, Shell::QUIET); |
|
837 | + $filename = $path.$name.'.php'; |
|
838 | + $this->out("\n".__d('cake_console', 'Baking model class for %s...', $name), 1, Shell::QUIET); |
|
839 | 839 | $this->createFile($filename, $out); |
840 | 840 | ClassRegistry::flush(); |
841 | 841 | return $out; |
@@ -893,7 +893,7 @@ discard block |
||
893 | 893 | } |
894 | 894 | |
895 | 895 | if ($this->interactive === true) { |
896 | - if (!isset($useDbConfig)) { |
|
896 | + if ( ! isset($useDbConfig)) { |
|
897 | 897 | $useDbConfig = $this->connection; |
898 | 898 | } |
899 | 899 | $db = ConnectionManager::getDataSource($useDbConfig); |
@@ -919,7 +919,7 @@ discard block |
||
919 | 919 | * @return array Array of tables in the database. |
920 | 920 | */ |
921 | 921 | public function getAllTables($useDbConfig = null) { |
922 | - if (!isset($useDbConfig)) { |
|
922 | + if ( ! isset($useDbConfig)) { |
|
923 | 923 | $useDbConfig = $this->connection; |
924 | 924 | } |
925 | 925 | |
@@ -929,7 +929,7 @@ discard block |
||
929 | 929 | $usePrefix = empty($db->config['prefix']) ? '' : $db->config['prefix']; |
930 | 930 | if ($usePrefix) { |
931 | 931 | foreach ($db->listSources() as $table) { |
932 | - if (!strncmp($table, $usePrefix, strlen($usePrefix))) { |
|
932 | + if ( ! strncmp($table, $usePrefix, strlen($usePrefix))) { |
|
933 | 933 | $tables[] = substr($table, strlen($usePrefix)); |
934 | 934 | } |
935 | 935 | } |
@@ -955,8 +955,8 @@ discard block |
||
955 | 955 | |
956 | 956 | $enteredModel = ''; |
957 | 957 | |
958 | - while (!$enteredModel) { |
|
959 | - $enteredModel = $this->in(__d('cake_console', "Enter a number from the list above,\n" . |
|
958 | + while ( ! $enteredModel) { |
|
959 | + $enteredModel = $this->in(__d('cake_console', "Enter a number from the list above,\n". |
|
960 | 960 | "type in the name of another model, or 'q' to exit"), null, 'q'); |
961 | 961 | |
962 | 962 | if ($enteredModel === 'q') { |
@@ -964,8 +964,8 @@ discard block |
||
964 | 964 | return $this->_stop(); |
965 | 965 | } |
966 | 966 | |
967 | - if (!$enteredModel || intval($enteredModel) > count($this->_modelNames)) { |
|
968 | - $this->err(__d('cake_console', "The model name you supplied was empty,\n" . |
|
967 | + if ( ! $enteredModel || intval($enteredModel) > count($this->_modelNames)) { |
|
968 | + $this->err(__d('cake_console', "The model name you supplied was empty,\n". |
|
969 | 969 | "or the number you selected was not an option. Please try again.")); |
970 | 970 | $enteredModel = ''; |
971 | 971 | } |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * Checks that given project path does not already exist, and |
40 | 40 | * finds the app directory in it. Then it calls bake() with that information. |
41 | 41 | * |
42 | - * @return mixed |
|
42 | + * @return string|null |
|
43 | 43 | */ |
44 | 44 | public function execute() { |
45 | 45 | $project = null; |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | * @param string $path Project path |
163 | 163 | * @param string $skel Path to copy from |
164 | 164 | * @param string $skip array of directories to skip when copying |
165 | - * @return mixed |
|
165 | + * @return boolean|null |
|
166 | 166 | */ |
167 | 167 | public function bake($path, $skel = null, $skip = array('empty')) { |
168 | 168 | if (!$skel && !empty($this->params['skel'])) { |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | * |
312 | 312 | * @param string $path Project path |
313 | 313 | * @param boolean $hardCode Whether or not define calls should be hardcoded. |
314 | - * @return boolean Success |
|
314 | + * @return boolean|null Success |
|
315 | 315 | */ |
316 | 316 | public function corePath($path, $hardCode = true) { |
317 | 317 | if (dirname($path) !== CAKE_CORE_INCLUDE_PATH) { |
@@ -50,21 +50,21 @@ discard block |
||
50 | 50 | if (empty($appContents)) { |
51 | 51 | $suggestedPath = rtrim(APP, DS); |
52 | 52 | } else { |
53 | - $suggestedPath = APP . 'myapp'; |
|
53 | + $suggestedPath = APP.'myapp'; |
|
54 | 54 | } |
55 | 55 | } |
56 | 56 | |
57 | - while (!$project) { |
|
57 | + while ( ! $project) { |
|
58 | 58 | $prompt = __d('cake_console', "What is the path to the project you want to bake?"); |
59 | 59 | $project = $this->in($prompt, null, $suggestedPath); |
60 | 60 | } |
61 | 61 | |
62 | - if ($project && !Folder::isAbsolute($project) && isset($_SERVER['PWD'])) { |
|
63 | - $project = $_SERVER['PWD'] . DS . $project; |
|
62 | + if ($project && ! Folder::isAbsolute($project) && isset($_SERVER['PWD'])) { |
|
63 | + $project = $_SERVER['PWD'].DS.$project; |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | $response = false; |
67 | - while (!$response && is_dir($project) === true && file_exists($project . 'Config' . 'core.php')) { |
|
67 | + while ( ! $response && is_dir($project) === true && file_exists($project.'Config'.'core.php')) { |
|
68 | 68 | $prompt = __d('cake_console', '<warning>A project already exists in this location:</warning> %s Overwrite?', $project); |
69 | 69 | $response = $this->in($prompt, array('y', 'n'), 'n'); |
70 | 70 | if (strtolower($response) === 'n') { |
@@ -79,14 +79,14 @@ discard block |
||
79 | 79 | if ($this->securitySalt($path) === true) { |
80 | 80 | $this->out(__d('cake_console', ' * Random hash key created for \'Security.salt\'')); |
81 | 81 | } else { |
82 | - $this->err(__d('cake_console', 'Unable to generate random hash for \'Security.salt\', you should change it in %s', APP . 'Config' . DS . 'core.php')); |
|
82 | + $this->err(__d('cake_console', 'Unable to generate random hash for \'Security.salt\', you should change it in %s', APP.'Config'.DS.'core.php')); |
|
83 | 83 | $success = false; |
84 | 84 | } |
85 | 85 | |
86 | 86 | if ($this->securityCipherSeed($path) === true) { |
87 | 87 | $this->out(__d('cake_console', ' * Random seed created for \'Security.cipherSeed\'')); |
88 | 88 | } else { |
89 | - $this->err(__d('cake_console', 'Unable to generate random seed for \'Security.cipherSeed\', you should change it in %s', APP . 'Config' . DS . 'core.php')); |
|
89 | + $this->err(__d('cake_console', 'Unable to generate random seed for \'Security.cipherSeed\', you should change it in %s', APP.'Config'.DS.'core.php')); |
|
90 | 90 | $success = false; |
91 | 91 | } |
92 | 92 | |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | $this->out(__d('cake_console', ' * CAKE_CORE_INCLUDE_PATH set to %s in %s', CAKE_CORE_INCLUDE_PATH, 'webroot/index.php')); |
118 | 118 | $this->out(__d('cake_console', ' * CAKE_CORE_INCLUDE_PATH set to %s in %s', CAKE_CORE_INCLUDE_PATH, 'webroot/test.php')); |
119 | 119 | } else { |
120 | - $this->err(__d('cake_console', 'Unable to set CAKE_CORE_INCLUDE_PATH, you should change it in %s', $path . 'webroot' . DS . 'index.php')); |
|
120 | + $this->err(__d('cake_console', 'Unable to set CAKE_CORE_INCLUDE_PATH, you should change it in %s', $path.'webroot'.DS.'index.php')); |
|
121 | 121 | $success = false; |
122 | 122 | } |
123 | 123 | if ($success && $hardCode) { |
@@ -125,9 +125,9 @@ discard block |
||
125 | 125 | } |
126 | 126 | |
127 | 127 | $Folder = new Folder($path); |
128 | - if (!$Folder->chmod($path . 'tmp', 0777)) { |
|
129 | - $this->err(__d('cake_console', 'Could not set permissions on %s', $path . DS . 'tmp')); |
|
130 | - $this->out('chmod -R 0777 ' . $path . DS . 'tmp'); |
|
128 | + if ( ! $Folder->chmod($path.'tmp', 0777)) { |
|
129 | + $this->err(__d('cake_console', 'Could not set permissions on %s', $path.DS.'tmp')); |
|
130 | + $this->out('chmod -R 0777 '.$path.DS.'tmp'); |
|
131 | 131 | $success = false; |
132 | 132 | } |
133 | 133 | if ($success) { |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | public function cakeOnIncludePath() { |
148 | 148 | $paths = explode(PATH_SEPARATOR, ini_get('include_path')); |
149 | 149 | foreach ($paths as $path) { |
150 | - if (file_exists($path . DS . 'Cake' . DS . 'bootstrap.php')) { |
|
150 | + if (file_exists($path.DS.'Cake'.DS.'bootstrap.php')) { |
|
151 | 151 | return true; |
152 | 152 | } |
153 | 153 | } |
@@ -165,23 +165,23 @@ discard block |
||
165 | 165 | * @return mixed |
166 | 166 | */ |
167 | 167 | public function bake($path, $skel = null, $skip = array('empty')) { |
168 | - if (!$skel && !empty($this->params['skel'])) { |
|
168 | + if ( ! $skel && ! empty($this->params['skel'])) { |
|
169 | 169 | $skel = $this->params['skel']; |
170 | 170 | } |
171 | - while (!$skel) { |
|
171 | + while ( ! $skel) { |
|
172 | 172 | $skel = $this->in( |
173 | 173 | __d('cake_console', "What is the path to the directory layout you wish to copy?"), |
174 | 174 | null, |
175 | - CAKE . 'Console' . DS . 'Templates' . DS . 'skel' |
|
175 | + CAKE.'Console'.DS.'Templates'.DS.'skel' |
|
176 | 176 | ); |
177 | - if (!$skel) { |
|
177 | + if ( ! $skel) { |
|
178 | 178 | $this->err(__d('cake_console', 'The directory path you supplied was empty. Please try again.')); |
179 | 179 | } else { |
180 | 180 | while (is_dir($skel) === false) { |
181 | 181 | $skel = $this->in( |
182 | 182 | __d('cake_console', 'Directory path does not exist please choose another:'), |
183 | 183 | null, |
184 | - CAKE . 'Console' . DS . 'Templates' . DS . 'skel' |
|
184 | + CAKE.'Console'.DS.'Templates'.DS.'skel' |
|
185 | 185 | ); |
186 | 186 | } |
187 | 187 | } |
@@ -189,8 +189,8 @@ discard block |
||
189 | 189 | |
190 | 190 | $app = basename($path); |
191 | 191 | |
192 | - $this->out(__d('cake_console', '<info>Skel Directory</info>: ') . $skel); |
|
193 | - $this->out(__d('cake_console', '<info>Will be copied to</info>: ') . $path); |
|
192 | + $this->out(__d('cake_console', '<info>Skel Directory</info>: ').$skel); |
|
193 | + $this->out(__d('cake_console', '<info>Will be copied to</info>: ').$path); |
|
194 | 194 | $this->hr(); |
195 | 195 | |
196 | 196 | $looksGood = $this->in(__d('cake_console', 'Look okay?'), array('y', 'n', 'q'), 'y'); |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | switch (strtolower($looksGood)) { |
199 | 199 | case 'y': |
200 | 200 | $Folder = new Folder($skel); |
201 | - if (!empty($this->params['empty'])) { |
|
201 | + if ( ! empty($this->params['empty'])) { |
|
202 | 202 | $skip = array(); |
203 | 203 | } |
204 | 204 | |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | } |
213 | 213 | |
214 | 214 | foreach ($Folder->messages() as $message) { |
215 | - $this->out(String::wrap(' * ' . $message), 1, Shell::VERBOSE); |
|
215 | + $this->out(String::wrap(' * '.$message), 1, Shell::VERBOSE); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | return true; |
@@ -234,11 +234,11 @@ discard block |
||
234 | 234 | * @return boolean success |
235 | 235 | */ |
236 | 236 | public function consolePath($path) { |
237 | - $File = new File($path . 'Console' . DS . 'cake.php'); |
|
237 | + $File = new File($path.'Console'.DS.'cake.php'); |
|
238 | 238 | $contents = $File->read(); |
239 | 239 | if (preg_match('/(__CAKE_PATH__)/', $contents, $match)) { |
240 | 240 | $root = strpos(CAKE_CORE_INCLUDE_PATH, '/') === 0 ? " \$ds . '" : "'"; |
241 | - $replacement = $root . str_replace(DS, "' . \$ds . '", trim(CAKE_CORE_INCLUDE_PATH, DS)) . "'"; |
|
241 | + $replacement = $root.str_replace(DS, "' . \$ds . '", trim(CAKE_CORE_INCLUDE_PATH, DS))."'"; |
|
242 | 242 | $result = str_replace($match[0], $replacement, $contents); |
243 | 243 | if ($File->write($result)) { |
244 | 244 | return true; |
@@ -255,11 +255,11 @@ discard block |
||
255 | 255 | * @return boolean Success |
256 | 256 | */ |
257 | 257 | public function securitySalt($path) { |
258 | - $File = new File($path . 'Config' . DS . 'core.php'); |
|
258 | + $File = new File($path.'Config'.DS.'core.php'); |
|
259 | 259 | $contents = $File->read(); |
260 | 260 | if (preg_match('/([\s]*Configure::write\(\'Security.salt\',[\s\'A-z0-9]*\);)/', $contents, $match)) { |
261 | 261 | $string = Security::generateAuthKey(); |
262 | - $result = str_replace($match[0], "\t" . 'Configure::write(\'Security.salt\', \'' . $string . '\');', $contents); |
|
262 | + $result = str_replace($match[0], "\t".'Configure::write(\'Security.salt\', \''.$string.'\');', $contents); |
|
263 | 263 | if ($File->write($result)) { |
264 | 264 | return true; |
265 | 265 | } |
@@ -275,12 +275,12 @@ discard block |
||
275 | 275 | * @return boolean Success |
276 | 276 | */ |
277 | 277 | public function securityCipherSeed($path) { |
278 | - $File = new File($path . 'Config' . DS . 'core.php'); |
|
278 | + $File = new File($path.'Config'.DS.'core.php'); |
|
279 | 279 | $contents = $File->read(); |
280 | 280 | if (preg_match('/([\s]*Configure::write\(\'Security.cipherSeed\',[\s\'A-z0-9]*\);)/', $contents, $match)) { |
281 | 281 | App::uses('Security', 'Utility'); |
282 | 282 | $string = substr(bin2hex(Security::generateAuthKey()), 0, 30); |
283 | - $result = str_replace($match[0], "\t" . 'Configure::write(\'Security.cipherSeed\', \'' . $string . '\');', $contents); |
|
283 | + $result = str_replace($match[0], "\t".'Configure::write(\'Security.cipherSeed\', \''.$string.'\');', $contents); |
|
284 | 284 | if ($File->write($result)) { |
285 | 285 | return true; |
286 | 286 | } |
@@ -297,10 +297,10 @@ discard block |
||
297 | 297 | */ |
298 | 298 | public function cachePrefix($dir) { |
299 | 299 | $app = basename($dir); |
300 | - $File = new File($dir . 'Config' . DS . 'core.php'); |
|
300 | + $File = new File($dir.'Config'.DS.'core.php'); |
|
301 | 301 | $contents = $File->read(); |
302 | 302 | if (preg_match('/(\$prefix = \'myapp_\';)/', $contents, $match)) { |
303 | - $result = str_replace($match[0], '$prefix = \'' . $app . '_\';', $contents); |
|
303 | + $result = str_replace($match[0], '$prefix = \''.$app.'_\';', $contents); |
|
304 | 304 | return $File->write($result); |
305 | 305 | } |
306 | 306 | return false; |
@@ -315,12 +315,12 @@ discard block |
||
315 | 315 | */ |
316 | 316 | public function corePath($path, $hardCode = true) { |
317 | 317 | if (dirname($path) !== CAKE_CORE_INCLUDE_PATH) { |
318 | - $filename = $path . 'webroot' . DS . 'index.php'; |
|
319 | - if (!$this->_replaceCorePath($filename, $hardCode)) { |
|
318 | + $filename = $path.'webroot'.DS.'index.php'; |
|
319 | + if ( ! $this->_replaceCorePath($filename, $hardCode)) { |
|
320 | 320 | return false; |
321 | 321 | } |
322 | - $filename = $path . 'webroot' . DS . 'test.php'; |
|
323 | - if (!$this->_replaceCorePath($filename, $hardCode)) { |
|
322 | + $filename = $path.'webroot'.DS.'test.php'; |
|
323 | + if ( ! $this->_replaceCorePath($filename, $hardCode)) { |
|
324 | 324 | return false; |
325 | 325 | } |
326 | 326 | return true; |
@@ -338,16 +338,16 @@ discard block |
||
338 | 338 | $contents = file_get_contents($filename); |
339 | 339 | |
340 | 340 | $root = strpos(CAKE_CORE_INCLUDE_PATH, '/') === 0 ? " DS . '" : "'"; |
341 | - $corePath = $root . str_replace(DS, "' . DS . '", trim(CAKE_CORE_INCLUDE_PATH, DS)) . "'"; |
|
341 | + $corePath = $root.str_replace(DS, "' . DS . '", trim(CAKE_CORE_INCLUDE_PATH, DS))."'"; |
|
342 | 342 | |
343 | 343 | $result = str_replace('__CAKE_PATH__', $corePath, $contents, $count); |
344 | 344 | if ($hardCode) { |
345 | 345 | $result = str_replace('//define(\'CAKE_CORE', 'define(\'CAKE_CORE', $result); |
346 | 346 | } |
347 | - if (!file_put_contents($filename, $result)) { |
|
347 | + if ( ! file_put_contents($filename, $result)) { |
|
348 | 348 | return false; |
349 | 349 | } |
350 | - return (bool)$count; |
|
350 | + return (bool) $count; |
|
351 | 351 | } |
352 | 352 | |
353 | 353 | /** |
@@ -357,11 +357,11 @@ discard block |
||
357 | 357 | * @return boolean Success |
358 | 358 | */ |
359 | 359 | public function cakeAdmin($name) { |
360 | - $path = (empty($this->configPath)) ? APP . 'Config' . DS : $this->configPath; |
|
361 | - $File = new File($path . 'core.php'); |
|
360 | + $path = (empty($this->configPath)) ? APP.'Config'.DS : $this->configPath; |
|
361 | + $File = new File($path.'core.php'); |
|
362 | 362 | $contents = $File->read(); |
363 | 363 | if (preg_match('%(\s*[/]*Configure::write\(\'Routing.prefixes\',[\s\'a-z,\)\(]*\);)%', $contents, $match)) { |
364 | - $result = str_replace($match[0], "\n" . 'Configure::write(\'Routing.prefixes\', array(\'' . $name . '\'));', $contents); |
|
364 | + $result = str_replace($match[0], "\n".'Configure::write(\'Routing.prefixes\', array(\''.$name.'\'));', $contents); |
|
365 | 365 | if ($File->write($result)) { |
366 | 366 | Configure::write('Routing.prefixes', array($name)); |
367 | 367 | return true; |
@@ -378,9 +378,9 @@ discard block |
||
378 | 378 | public function getPrefix() { |
379 | 379 | $admin = ''; |
380 | 380 | $prefixes = Configure::read('Routing.prefixes'); |
381 | - if (!empty($prefixes)) { |
|
381 | + if ( ! empty($prefixes)) { |
|
382 | 382 | if (count($prefixes) === 1) { |
383 | - return $prefixes[0] . '_'; |
|
383 | + return $prefixes[0].'_'; |
|
384 | 384 | } |
385 | 385 | if ($this->interactive) { |
386 | 386 | $this->out(); |
@@ -390,11 +390,11 @@ discard block |
||
390 | 390 | foreach ($prefixes as $i => $prefix) { |
391 | 391 | $options[] = $i + 1; |
392 | 392 | if ($this->interactive) { |
393 | - $this->out($i + 1 . '. ' . $prefix); |
|
393 | + $this->out($i + 1.'. '.$prefix); |
|
394 | 394 | } |
395 | 395 | } |
396 | 396 | $selection = $this->in(__d('cake_console', 'Please choose a prefix to bake with.'), $options, 1); |
397 | - return $prefixes[$selection - 1] . '_'; |
|
397 | + return $prefixes[$selection - 1].'_'; |
|
398 | 398 | } |
399 | 399 | if ($this->interactive) { |
400 | 400 | $this->hr(); |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | '/app/Config/core.php')); |
404 | 404 | $this->out(__d('cake_console', 'What would you like the prefix route to be?')); |
405 | 405 | $this->out(__d('cake_console', 'Example: %s', 'www.example.com/admin/controller')); |
406 | - while (!$admin) { |
|
406 | + while ( ! $admin) { |
|
407 | 407 | $admin = $this->in(__d('cake_console', 'Enter a routing prefix:'), null, 'admin'); |
408 | 408 | } |
409 | 409 | if ($this->cakeAdmin($admin) !== true) { |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | '/app/Config/core.php')); |
414 | 414 | return $this->_stop(); |
415 | 415 | } |
416 | - return $admin . '_'; |
|
416 | + return $admin.'_'; |
|
417 | 417 | } |
418 | 418 | return ''; |
419 | 419 | } |
@@ -436,7 +436,7 @@ discard block |
||
436 | 436 | 'short' => 't', |
437 | 437 | 'help' => __d('cake_console', 'Theme to use when baking code.') |
438 | 438 | ))->addOption('skel', array( |
439 | - 'default' => current(App::core('Console')) . 'Templates' . DS . 'skel', |
|
439 | + 'default' => current(App::core('Console')).'Templates'.DS.'skel', |
|
440 | 440 | 'help' => __d('cake_console', 'The directory layout to use for the new application skeleton. Defaults to cake/Console/Templates/skel of CakePHP used to create the project.') |
441 | 441 | )); |
442 | 442 | } |
@@ -108,7 +108,7 @@ |
||
108 | 108 | * @param string|array $one A string or an array of data. |
109 | 109 | * @param string|array $two Value in case $one is a string (which then works as the key). |
110 | 110 | * Unused if $one is an associative array, otherwise serves as the values to $one's keys. |
111 | - * @return void |
|
111 | + * @return false|null |
|
112 | 112 | */ |
113 | 113 | public function set($one, $two = null) { |
114 | 114 | if (is_array($one)) { |
@@ -63,14 +63,14 @@ discard block |
||
63 | 63 | |
64 | 64 | $plugins = App::objects('plugin'); |
65 | 65 | foreach ($plugins as $plugin) { |
66 | - $paths[] = $this->_pluginPath($plugin) . 'Console' . DS; |
|
66 | + $paths[] = $this->_pluginPath($plugin).'Console'.DS; |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | $core = current(App::core('Console')); |
70 | 70 | $separator = DS === '/' ? '/' : '\\\\'; |
71 | - $core = preg_replace('#shells' . $separator . '$#', '', $core); |
|
71 | + $core = preg_replace('#shells'.$separator.'$#', '', $core); |
|
72 | 72 | |
73 | - $Folder = new Folder($core . 'Templates' . DS . 'default'); |
|
73 | + $Folder = new Folder($core.'Templates'.DS.'default'); |
|
74 | 74 | |
75 | 75 | $contents = $Folder->read(); |
76 | 76 | $themeFolders = $contents[0]; |
@@ -78,23 +78,23 @@ discard block |
||
78 | 78 | $paths[] = $core; |
79 | 79 | |
80 | 80 | foreach ($paths as $i => $path) { |
81 | - $paths[$i] = rtrim($path, DS) . DS; |
|
81 | + $paths[$i] = rtrim($path, DS).DS; |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | $themes = array(); |
85 | 85 | foreach ($paths as $path) { |
86 | - $Folder = new Folder($path . 'Templates', false); |
|
86 | + $Folder = new Folder($path.'Templates', false); |
|
87 | 87 | $contents = $Folder->read(); |
88 | 88 | $subDirs = $contents[0]; |
89 | 89 | foreach ($subDirs as $dir) { |
90 | 90 | if (empty($dir) || preg_match('@^skel$|_skel$@', $dir)) { |
91 | 91 | continue; |
92 | 92 | } |
93 | - $Folder = new Folder($path . 'Templates' . DS . $dir); |
|
93 | + $Folder = new Folder($path.'Templates'.DS.$dir); |
|
94 | 94 | $contents = $Folder->read(); |
95 | 95 | $subDirs = $contents[0]; |
96 | 96 | if (array_intersect($contents[0], $themeFolders)) { |
97 | - $templateDir = $path . 'Templates' . DS . $dir . DS; |
|
97 | + $templateDir = $path.'Templates'.DS.$dir.DS; |
|
98 | 98 | $themes[$dir] = $templateDir; |
99 | 99 | } |
100 | 100 | } |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | $data = array($one => $two); |
122 | 122 | } |
123 | 123 | |
124 | - if (!$data) { |
|
124 | + if ( ! $data) { |
|
125 | 125 | return false; |
126 | 126 | } |
127 | 127 | $this->templateVars = $data + $this->templateVars; |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | $paths = array_values($this->templatePaths); |
169 | 169 | return $paths[0]; |
170 | 170 | } |
171 | - if (!empty($this->params['theme']) && isset($this->templatePaths[$this->params['theme']])) { |
|
171 | + if ( ! empty($this->params['theme']) && isset($this->templatePaths[$this->params['theme']])) { |
|
172 | 172 | return $this->templatePaths[$this->params['theme']]; |
173 | 173 | } |
174 | 174 | |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | $i = 1; |
181 | 181 | $indexedPaths = array(); |
182 | 182 | foreach ($this->templatePaths as $key => $path) { |
183 | - $this->out($i . '. ' . $key); |
|
183 | + $this->out($i.'. '.$key); |
|
184 | 184 | $indexedPaths[$i] = $path; |
185 | 185 | $i++; |
186 | 186 | } |
@@ -200,12 +200,12 @@ discard block |
||
200 | 200 | * @return string filename will exit program if template is not found. |
201 | 201 | */ |
202 | 202 | protected function _findTemplate($path, $directory, $filename) { |
203 | - $themeFile = $path . $directory . DS . $filename . '.ctp'; |
|
203 | + $themeFile = $path.$directory.DS.$filename.'.ctp'; |
|
204 | 204 | if (file_exists($themeFile)) { |
205 | 205 | return $themeFile; |
206 | 206 | } |
207 | 207 | foreach ($this->templatePaths as $path) { |
208 | - $templatePath = $path . $directory . DS . $filename . '.ctp'; |
|
208 | + $templatePath = $path.$directory.DS.$filename.'.ctp'; |
|
209 | 209 | if (file_exists($templatePath)) { |
210 | 210 | return $templatePath; |
211 | 211 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | /** |
82 | 82 | * Execution method always used for tasks |
83 | 83 | * |
84 | - * @return mixed |
|
84 | + * @return null|boolean |
|
85 | 85 | */ |
86 | 86 | public function execute() { |
87 | 87 | parent::execute(); |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | * |
343 | 343 | * @param string $action Action to bake |
344 | 344 | * @param string $content Content to write |
345 | - * @return boolean Success |
|
345 | + * @return null|boolean Success |
|
346 | 346 | */ |
347 | 347 | public function bake($action, $content = '') { |
348 | 348 | if ($content === true) { |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | if (empty($this->args[0])) { |
92 | 92 | return; |
93 | 93 | } |
94 | - if (!isset($this->connection)) { |
|
94 | + if ( ! isset($this->connection)) { |
|
95 | 95 | $this->connection = 'default'; |
96 | 96 | } |
97 | 97 | $action = null; |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | if (isset($this->args[2])) { |
109 | 109 | $action = $this->args[2]; |
110 | 110 | } |
111 | - if (!$action) { |
|
111 | + if ( ! $action) { |
|
112 | 112 | $action = $this->template; |
113 | 113 | } |
114 | 114 | if ($action) { |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | */ |
134 | 134 | protected function _methodsToBake() { |
135 | 135 | $methods = array_diff( |
136 | - array_map('strtolower', get_class_methods($this->controllerName . 'Controller')), |
|
136 | + array_map('strtolower', get_class_methods($this->controllerName.'Controller')), |
|
137 | 137 | array_map('strtolower', get_class_methods('AppController')) |
138 | 138 | ); |
139 | 139 | $scaffoldActions = false; |
@@ -143,15 +143,15 @@ discard block |
||
143 | 143 | } |
144 | 144 | $adminRoute = $this->Project->getPrefix(); |
145 | 145 | foreach ($methods as $i => $method) { |
146 | - if ($adminRoute && !empty($this->params['admin'])) { |
|
146 | + if ($adminRoute && ! empty($this->params['admin'])) { |
|
147 | 147 | if ($scaffoldActions) { |
148 | - $methods[$i] = $adminRoute . $method; |
|
148 | + $methods[$i] = $adminRoute.$method; |
|
149 | 149 | continue; |
150 | 150 | } elseif (strpos($method, $adminRoute) === false) { |
151 | 151 | unset($methods[$i]); |
152 | 152 | } |
153 | 153 | } |
154 | - if ($method[0] === '_' || $method === strtolower($this->controllerName . 'Controller')) { |
|
154 | + if ($method[0] === '_' || $method === strtolower($this->controllerName.'Controller')) { |
|
155 | 155 | unset($methods[$i]); |
156 | 156 | } |
157 | 157 | } |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | App::uses($model, 'Model'); |
179 | 179 | if (class_exists($model)) { |
180 | 180 | $vars = $this->_loadController(); |
181 | - if (!$actions) { |
|
181 | + if ( ! $actions) { |
|
182 | 182 | $actions = $this->_methodsToBake(); |
183 | 183 | } |
184 | 184 | $this->bakeActions($actions, $vars); |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | $regularActions = $this->scaffoldActions; |
230 | 230 | $adminActions = array(); |
231 | 231 | foreach ($regularActions as $action) { |
232 | - $adminActions[] = $admin . $action; |
|
232 | + $adminActions[] = $admin.$action; |
|
233 | 233 | } |
234 | 234 | $this->bakeActions($adminActions, $vars); |
235 | 235 | } |
@@ -251,19 +251,19 @@ discard block |
||
251 | 251 | * @return array Returns an variables to be made available to a view template |
252 | 252 | */ |
253 | 253 | protected function _loadController() { |
254 | - if (!$this->controllerName) { |
|
254 | + if ( ! $this->controllerName) { |
|
255 | 255 | $this->err(__d('cake_console', 'Controller not found')); |
256 | 256 | } |
257 | 257 | |
258 | 258 | $plugin = null; |
259 | 259 | if ($this->plugin) { |
260 | - $plugin = $this->plugin . '.'; |
|
260 | + $plugin = $this->plugin.'.'; |
|
261 | 261 | } |
262 | 262 | |
263 | - $controllerClassName = $this->controllerName . 'Controller'; |
|
264 | - App::uses($controllerClassName, $plugin . 'Controller'); |
|
265 | - if (!class_exists($controllerClassName)) { |
|
266 | - $file = $controllerClassName . '.php'; |
|
263 | + $controllerClassName = $this->controllerName.'Controller'; |
|
264 | + App::uses($controllerClassName, $plugin.'Controller'); |
|
265 | + if ( ! class_exists($controllerClassName)) { |
|
266 | + $file = $controllerClassName.'.php'; |
|
267 | 267 | $this->err(__d('cake_console', "The file '%s' could not be found.\nIn order to bake a view, you'll need to first create the controller.", $file)); |
268 | 268 | return $this->_stop(); |
269 | 269 | } |
@@ -315,9 +315,9 @@ discard block |
||
315 | 315 | */ |
316 | 316 | public function customAction() { |
317 | 317 | $action = ''; |
318 | - while (!$action) { |
|
318 | + while ( ! $action) { |
|
319 | 319 | $action = $this->in(__d('cake_console', 'Action Name? (use lowercase_underscored function name)')); |
320 | - if (!$action) { |
|
320 | + if ( ! $action) { |
|
321 | 321 | $this->out(__d('cake_console', 'The action name you supplied was empty. Please try again.')); |
322 | 322 | } |
323 | 323 | } |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | $this->hr(); |
328 | 328 | $this->out(__d('cake_console', 'Controller Name: %s', $this->controllerName)); |
329 | 329 | $this->out(__d('cake_console', 'Action Name: %s', $action)); |
330 | - $this->out(__d('cake_console', 'Path: %s', $this->getPath() . $this->controllerName . DS . Inflector::underscore($action) . ".ctp")); |
|
330 | + $this->out(__d('cake_console', 'Path: %s', $this->getPath().$this->controllerName.DS.Inflector::underscore($action).".ctp")); |
|
331 | 331 | $this->hr(); |
332 | 332 | $looksGood = $this->in(__d('cake_console', 'Look okay?'), array('y', 'n'), 'y'); |
333 | 333 | if (strtolower($looksGood) === 'y') { |
@@ -351,9 +351,9 @@ discard block |
||
351 | 351 | if (empty($content)) { |
352 | 352 | return false; |
353 | 353 | } |
354 | - $this->out("\n" . __d('cake_console', 'Baking `%s` view file...', $action), 1, Shell::QUIET); |
|
354 | + $this->out("\n".__d('cake_console', 'Baking `%s` view file...', $action), 1, Shell::QUIET); |
|
355 | 355 | $path = $this->getPath(); |
356 | - $filename = $path . $this->controllerName . DS . Inflector::underscore($action) . '.ctp'; |
|
356 | + $filename = $path.$this->controllerName.DS.Inflector::underscore($action).'.ctp'; |
|
357 | 357 | return $this->createFile($filename, $content); |
358 | 358 | } |
359 | 359 | |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | * @return string content from template |
366 | 366 | */ |
367 | 367 | public function getContent($action, $vars = null) { |
368 | - if (!$vars) { |
|
368 | + if ( ! $vars) { |
|
369 | 369 | $vars = $this->_loadController(); |
370 | 370 | } |
371 | 371 | |
@@ -389,18 +389,18 @@ discard block |
||
389 | 389 | if ($action != $this->template && in_array($action, $this->noTemplateActions)) { |
390 | 390 | return false; |
391 | 391 | } |
392 | - if (!empty($this->template) && $action != $this->template) { |
|
392 | + if ( ! empty($this->template) && $action != $this->template) { |
|
393 | 393 | return $this->template; |
394 | 394 | } |
395 | 395 | $themePath = $this->Template->getThemePath(); |
396 | - if (file_exists($themePath . 'views' . DS . $action . '.ctp')) { |
|
396 | + if (file_exists($themePath.'views'.DS.$action.'.ctp')) { |
|
397 | 397 | return $action; |
398 | 398 | } |
399 | 399 | $template = $action; |
400 | 400 | $prefixes = Configure::read('Routing.prefixes'); |
401 | - foreach ((array)$prefixes as $prefix) { |
|
401 | + foreach ((array) $prefixes as $prefix) { |
|
402 | 402 | if (strpos($template, $prefix) !== false) { |
403 | - $template = str_replace($prefix . '_', '', $template); |
|
403 | + $template = str_replace($prefix.'_', '', $template); |
|
404 | 404 | } |
405 | 405 | } |
406 | 406 | if (in_array($template, array('add', 'edit'))) { |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | /** |
41 | 41 | * get the option parser for the test suite. |
42 | 42 | * |
43 | - * @return void |
|
43 | + * @return ConsoleOptionParser |
|
44 | 44 | */ |
45 | 45 | public function getOptionParser() { |
46 | 46 | $parser = new ConsoleOptionParser($this->name); |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | * @param string $file |
337 | 337 | * @param string $category |
338 | 338 | * @param boolean $throwOnMissingFile |
339 | - * @return array array(type, case) |
|
339 | + * @return false|string array(type, case) |
|
340 | 340 | * @throws Exception |
341 | 341 | */ |
342 | 342 | protected function _mapFileToCase($file, $category, $throwOnMissingFile = true) { |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | public function initialize() { |
171 | 171 | $this->_dispatcher = new CakeTestSuiteDispatcher(); |
172 | 172 | $success = $this->_dispatcher->loadTestFramework(); |
173 | - if (!$success) { |
|
173 | + if ( ! $success) { |
|
174 | 174 | throw new Exception(__d('cake_dev', 'Please install PHPUnit framework v3.7 <info>(http://www.phpunit.de)</info>')); |
175 | 175 | } |
176 | 176 | } |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | $params = $this->params; |
223 | 223 | unset($params['help']); |
224 | 224 | |
225 | - if (!empty($params['no-colors'])) { |
|
225 | + if ( ! empty($params['no-colors'])) { |
|
226 | 226 | unset($params['no-colors'], $params['colors']); |
227 | 227 | } else { |
228 | 228 | $params['colors'] = true; |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | if ($value === false) { |
233 | 233 | continue; |
234 | 234 | } |
235 | - $options[] = '--' . $param; |
|
235 | + $options[] = '--'.$param; |
|
236 | 236 | if (is_string($value)) { |
237 | 237 | $options[] = $value; |
238 | 238 | } |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | $title = "App Test Cases:"; |
291 | 291 | $category = 'app'; |
292 | 292 | } elseif ($plugin) { |
293 | - $title = Inflector::humanize($plugin) . " Test Cases:"; |
|
293 | + $title = Inflector::humanize($plugin)." Test Cases:"; |
|
294 | 294 | $category = $plugin; |
295 | 295 | } |
296 | 296 | |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | * @throws Exception |
341 | 341 | */ |
342 | 342 | protected function _mapFileToCase($file, $category, $throwOnMissingFile = true) { |
343 | - if (!$category || (substr($file, -4) !== '.php')) { |
|
343 | + if ( ! $category || (substr($file, -4) !== '.php')) { |
|
344 | 344 | return false; |
345 | 345 | } |
346 | 346 | |
@@ -377,9 +377,9 @@ discard block |
||
377 | 377 | $testCase = str_replace(DS, '/', $file); |
378 | 378 | $testCase = preg_replace('@.*lib/Cake/@', '', $file); |
379 | 379 | $testCase[0] = strtoupper($testCase[0]); |
380 | - $testFile = CAKE . 'Test/Case/' . $testCase . 'Test.php'; |
|
380 | + $testFile = CAKE.'Test/Case/'.$testCase.'Test.php'; |
|
381 | 381 | |
382 | - if (!file_exists($testFile) && $throwOnMissingFile) { |
|
382 | + if ( ! file_exists($testFile) && $throwOnMissingFile) { |
|
383 | 383 | throw new Exception(__d('cake_dev', 'Test case %s not found', $testFile)); |
384 | 384 | } |
385 | 385 | |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | } |
388 | 388 | |
389 | 389 | if ($category === 'app') { |
390 | - $testFile = str_replace(APP, APP . 'Test/Case/', $file) . 'Test.php'; |
|
390 | + $testFile = str_replace(APP, APP.'Test/Case/', $file).'Test.php'; |
|
391 | 391 | } else { |
392 | 392 | $testFile = preg_replace( |
393 | 393 | "@((?:plugins|Plugin)[\\/]{$category}[\\/])(.*)$@", |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | ); |
397 | 397 | } |
398 | 398 | |
399 | - if (!file_exists($testFile) && $throwOnMissingFile) { |
|
399 | + if ( ! file_exists($testFile) && $throwOnMissingFile) { |
|
400 | 400 | throw new Exception(__d('cake_dev', 'Test case %s not found', $testFile)); |
401 | 401 | } |
402 | 402 |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | * Writes a message to the output stream. |
233 | 233 | * |
234 | 234 | * @param string $message Message to write. |
235 | - * @return boolean success |
|
235 | + * @return integer success |
|
236 | 236 | */ |
237 | 237 | protected function _write($message) { |
238 | 238 | return fwrite($this->_output, $message); |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | * Get/Set the output type to use. The output type how formatting tags are treated. |
283 | 283 | * |
284 | 284 | * @param integer $type The output type to use. Should be one of the class constants. |
285 | - * @return mixed Either null or the value if getting. |
|
285 | + * @return integer|null Either null or the value if getting. |
|
286 | 286 | */ |
287 | 287 | public function outputAs($type = null) { |
288 | 288 | if ($type === null) { |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | public function __construct($stream = 'php://stdout') { |
162 | 162 | $this->_output = fopen($stream, 'w'); |
163 | 163 | |
164 | - if (DS === '\\' && !(bool)env('ANSICON')) { |
|
164 | + if (DS === '\\' && ! (bool) env('ANSICON')) { |
|
165 | 165 | $this->_outputAs = self::PLAIN; |
166 | 166 | } |
167 | 167 | } |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | if (is_array($message)) { |
179 | 179 | $message = implode(self::LF, $message); |
180 | 180 | } |
181 | - return $this->_write($this->styleText($message . str_repeat(self::LF, $newlines))); |
|
181 | + return $this->_write($this->styleText($message.str_repeat(self::LF, $newlines))); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | /** |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | } |
194 | 194 | if ($this->_outputAs == self::PLAIN) { |
195 | 195 | $tags = implode('|', array_keys(self::$_styles)); |
196 | - return preg_replace('#</?(?:' . $tags . ')>#', '', $text); |
|
196 | + return preg_replace('#</?(?:'.$tags.')>#', '', $text); |
|
197 | 197 | } |
198 | 198 | return preg_replace_callback( |
199 | 199 | '/<(?P<tag>[a-z0-9-_]+)>(?P<text>.*?)<\/(\1)>/ims', array($this, '_replaceTags'), $text |
@@ -209,14 +209,14 @@ discard block |
||
209 | 209 | protected function _replaceTags($matches) { |
210 | 210 | $style = $this->styles($matches['tag']); |
211 | 211 | if (empty($style)) { |
212 | - return '<' . $matches['tag'] . '>' . $matches['text'] . '</' . $matches['tag'] . '>'; |
|
212 | + return '<'.$matches['tag'].'>'.$matches['text'].'</'.$matches['tag'].'>'; |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | $styleInfo = array(); |
216 | - if (!empty($style['text']) && isset(self::$_foregroundColors[$style['text']])) { |
|
216 | + if ( ! empty($style['text']) && isset(self::$_foregroundColors[$style['text']])) { |
|
217 | 217 | $styleInfo[] = self::$_foregroundColors[$style['text']]; |
218 | 218 | } |
219 | - if (!empty($style['background']) && isset(self::$_backgroundColors[$style['background']])) { |
|
219 | + if ( ! empty($style['background']) && isset(self::$_backgroundColors[$style['background']])) { |
|
220 | 220 | $styleInfo[] = self::$_backgroundColors[$style['background']]; |
221 | 221 | } |
222 | 222 | unset($style['text'], $style['background']); |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | $styleInfo[] = self::$_options[$option]; |
226 | 226 | } |
227 | 227 | } |
228 | - return "\033[" . implode($styleInfo, ';') . 'm' . $matches['text'] . "\033[0m"; |
|
228 | + return "\033[".implode($styleInfo, ';').'m'.$matches['text']."\033[0m"; |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | /** |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | * Lazy loads models using the loadModel() method if declared in $uses |
256 | 256 | * |
257 | 257 | * @param string $name |
258 | - * @return void |
|
258 | + * @return boolean|null |
|
259 | 259 | */ |
260 | 260 | public function __isset($name) { |
261 | 261 | if (is_array($this->uses)) { |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | * |
274 | 274 | * @param string $modelClass Name of model class to load |
275 | 275 | * @param mixed $id Initial ID the instanced model class should have |
276 | - * @return mixed true when single model found and instance created, error returned if model not found. |
|
276 | + * @return boolean true when single model found and instance created, error returned if model not found. |
|
277 | 277 | * @throws MissingModelException if the model class cannot be found. |
278 | 278 | */ |
279 | 279 | public function loadModel($modelClass = null, $id = null) { |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | * |
366 | 366 | * `return $this->dispatchShell('schema', 'create', 'i18n', '--dry');` |
367 | 367 | * |
368 | - * @return mixed The return of the other shell. |
|
368 | + * @return boolean The return of the other shell. |
|
369 | 369 | * @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::dispatchShell |
370 | 370 | */ |
371 | 371 | public function dispatchShell() { |
@@ -497,7 +497,7 @@ discard block |
||
497 | 497 | * @param string $prompt Prompt text. |
498 | 498 | * @param string|array $options Array or string of options. |
499 | 499 | * @param string $default Default input value. |
500 | - * @return mixed Either the default value, or the user-provided input. |
|
500 | + * @return string|null Either the default value, or the user-provided input. |
|
501 | 501 | * @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::in |
502 | 502 | */ |
503 | 503 | public function in($prompt, $options = null, $default = null) { |
@@ -535,7 +535,7 @@ discard block |
||
535 | 535 | * @param string $prompt Prompt text. |
536 | 536 | * @param string|array $options Array or string of options. |
537 | 537 | * @param string $default Default input value. |
538 | - * @return Either the default value, or the user-provided input. |
|
538 | + * @return null|string the default value, or the user-provided input. |
|
539 | 539 | */ |
540 | 540 | protected function _getInput($prompt, $options, $default) { |
541 | 541 | if (!is_array($options)) { |
@@ -690,7 +690,7 @@ discard block |
||
690 | 690 | * |
691 | 691 | * @param string $path Where to put the file. |
692 | 692 | * @param string $contents Content to put in the file. |
693 | - * @return boolean Success |
|
693 | + * @return null|boolean Success |
|
694 | 694 | * @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::createFile |
695 | 695 | */ |
696 | 696 | public function createFile($path, $contents) { |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | * @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell |
177 | 177 | */ |
178 | 178 | public function __construct($stdout = null, $stderr = null, $stdin = null) { |
179 | - if (!$this->name) { |
|
179 | + if ( ! $this->name) { |
|
180 | 180 | $this->name = Inflector::camelize(str_replace(array('Shell', 'Task'), '', get_class($this))); |
181 | 181 | } |
182 | 182 | $this->Tasks = new TaskCollection($this); |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | if ($this->tasks !== null && $this->tasks !== false) { |
191 | 191 | $this->_mergeVars(array('tasks'), $parent, true); |
192 | 192 | } |
193 | - if (!empty($this->uses)) { |
|
193 | + if ( ! empty($this->uses)) { |
|
194 | 194 | $this->_mergeVars(array('uses'), $parent, false); |
195 | 195 | } |
196 | 196 | } |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | */ |
230 | 230 | protected function _welcome() { |
231 | 231 | $this->out(); |
232 | - $this->out(__d('cake_console', '<info>Welcome to CakePHP %s Console</info>', 'v' . Configure::version())); |
|
232 | + $this->out(__d('cake_console', '<info>Welcome to CakePHP %s Console</info>', 'v'.Configure::version())); |
|
233 | 233 | $this->hr(); |
234 | 234 | $this->out(__d('cake_console', 'App : %s', APP_DIR)); |
235 | 235 | $this->out(__d('cake_console', 'Path: %s', APP)); |
@@ -281,20 +281,20 @@ discard block |
||
281 | 281 | $modelClass = $this->modelClass; |
282 | 282 | } |
283 | 283 | |
284 | - $this->uses = ($this->uses) ? (array)$this->uses : array(); |
|
285 | - if (!in_array($modelClass, $this->uses)) { |
|
284 | + $this->uses = ($this->uses) ? (array) $this->uses : array(); |
|
285 | + if ( ! in_array($modelClass, $this->uses)) { |
|
286 | 286 | $this->uses[] = $modelClass; |
287 | 287 | } |
288 | 288 | |
289 | 289 | list($plugin, $modelClass) = pluginSplit($modelClass, true); |
290 | - if (!isset($this->modelClass)) { |
|
290 | + if ( ! isset($this->modelClass)) { |
|
291 | 291 | $this->modelClass = $modelClass; |
292 | 292 | } |
293 | 293 | |
294 | 294 | $this->{$modelClass} = ClassRegistry::init(array( |
295 | - 'class' => $plugin . $modelClass, 'alias' => $modelClass, 'id' => $id |
|
295 | + 'class' => $plugin.$modelClass, 'alias' => $modelClass, 'id' => $id |
|
296 | 296 | )); |
297 | - if (!$this->{$modelClass}) { |
|
297 | + if ( ! $this->{$modelClass}) { |
|
298 | 298 | throw new MissingModelException($modelClass); |
299 | 299 | } |
300 | 300 | return true; |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | if ($this->tasks === true || empty($this->tasks) || empty($this->Tasks)) { |
310 | 310 | return true; |
311 | 311 | } |
312 | - $this->_taskMap = TaskCollection::normalizeObjectArray((array)$this->tasks); |
|
312 | + $this->_taskMap = TaskCollection::normalizeObjectArray((array) $this->tasks); |
|
313 | 313 | $this->taskNames = array_merge($this->taskNames, array_keys($this->_taskMap)); |
314 | 314 | return true; |
315 | 315 | } |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | public function hasMethod($name) { |
336 | 336 | try { |
337 | 337 | $method = new ReflectionMethod($this, $name); |
338 | - if (!$method->isPublic() || substr($name, 0, 1) === '_') { |
|
338 | + if ( ! $method->isPublic() || substr($name, 0, 1) === '_') { |
|
339 | 339 | return false; |
340 | 340 | } |
341 | 341 | if ($method->getDeclaringClass()->name === 'Shell') { |
@@ -414,14 +414,14 @@ discard block |
||
414 | 414 | return false; |
415 | 415 | } |
416 | 416 | |
417 | - if (!empty($this->params['quiet'])) { |
|
417 | + if ( ! empty($this->params['quiet'])) { |
|
418 | 418 | $this->_useLogger(false); |
419 | 419 | } |
420 | - if (!empty($this->params['plugin'])) { |
|
420 | + if ( ! empty($this->params['plugin'])) { |
|
421 | 421 | CakePlugin::load($this->params['plugin']); |
422 | 422 | } |
423 | 423 | $this->command = $command; |
424 | - if (!empty($this->params['help'])) { |
|
424 | + if ( ! empty($this->params['help'])) { |
|
425 | 425 | return $this->_displayHelp($command); |
426 | 426 | } |
427 | 427 | |
@@ -451,7 +451,7 @@ discard block |
||
451 | 451 | */ |
452 | 452 | protected function _displayHelp($command) { |
453 | 453 | $format = 'text'; |
454 | - if (!empty($this->args[0]) && $this->args[0] === 'xml') { |
|
454 | + if ( ! empty($this->args[0]) && $this->args[0] === 'xml') { |
|
455 | 455 | $format = 'xml'; |
456 | 456 | $this->stdout->outputAs(ConsoleOutput::RAW); |
457 | 457 | } else { |
@@ -468,7 +468,7 @@ discard block |
||
468 | 468 | * @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::getOptionParser |
469 | 469 | */ |
470 | 470 | public function getOptionParser() { |
471 | - $name = ($this->plugin ? $this->plugin . '.' : '') . $this->name; |
|
471 | + $name = ($this->plugin ? $this->plugin.'.' : '').$this->name; |
|
472 | 472 | $parser = new ConsoleOptionParser($name); |
473 | 473 | return $parser; |
474 | 474 | } |
@@ -483,8 +483,8 @@ discard block |
||
483 | 483 | if (empty($this->{$name}) && in_array($name, $this->taskNames)) { |
484 | 484 | $properties = $this->_taskMap[$name]; |
485 | 485 | $this->{$name} = $this->Tasks->load($properties['class'], $properties['settings']); |
486 | - $this->{$name}->args =& $this->args; |
|
487 | - $this->{$name}->params =& $this->params; |
|
486 | + $this->{$name}->args = & $this->args; |
|
487 | + $this->{$name}->params = & $this->params; |
|
488 | 488 | $this->{$name}->initialize(); |
489 | 489 | $this->{$name}->loadTasks(); |
490 | 490 | } |
@@ -501,7 +501,7 @@ discard block |
||
501 | 501 | * @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::in |
502 | 502 | */ |
503 | 503 | public function in($prompt, $options = null, $default = null) { |
504 | - if (!$this->interactive) { |
|
504 | + if ( ! $this->interactive) { |
|
505 | 505 | return $default; |
506 | 506 | } |
507 | 507 | $originalOptions = $options; |
@@ -522,7 +522,7 @@ discard block |
||
522 | 522 | array_map('strtoupper', $options), |
523 | 523 | $options |
524 | 524 | ); |
525 | - while ($in === '' || !in_array($in, $options)) { |
|
525 | + while ($in === '' || ! in_array($in, $options)) { |
|
526 | 526 | $in = $this->_getInput($prompt, $originalOptions, $default); |
527 | 527 | } |
528 | 528 | } |
@@ -538,16 +538,16 @@ discard block |
||
538 | 538 | * @return Either the default value, or the user-provided input. |
539 | 539 | */ |
540 | 540 | protected function _getInput($prompt, $options, $default) { |
541 | - if (!is_array($options)) { |
|
541 | + if ( ! is_array($options)) { |
|
542 | 542 | $printOptions = ''; |
543 | 543 | } else { |
544 | - $printOptions = '(' . implode('/', $options) . ')'; |
|
544 | + $printOptions = '('.implode('/', $options).')'; |
|
545 | 545 | } |
546 | 546 | |
547 | 547 | if ($default === null) { |
548 | - $this->stdout->write('<question>' . $prompt . '</question>' . " $printOptions \n" . '> ', 0); |
|
548 | + $this->stdout->write('<question>'.$prompt.'</question>'." $printOptions \n".'> ', 0); |
|
549 | 549 | } else { |
550 | - $this->stdout->write('<question>' . $prompt . '</question>' . " $printOptions \n" . "[$default] > ", 0); |
|
550 | + $this->stdout->write('<question>'.$prompt.'</question>'." $printOptions \n"."[$default] > ", 0); |
|
551 | 551 | } |
552 | 552 | $result = $this->stdin->read(); |
553 | 553 | |
@@ -601,10 +601,10 @@ discard block |
||
601 | 601 | */ |
602 | 602 | public function out($message = null, $newlines = 1, $level = Shell::NORMAL) { |
603 | 603 | $currentLevel = Shell::NORMAL; |
604 | - if (!empty($this->params['verbose'])) { |
|
604 | + if ( ! empty($this->params['verbose'])) { |
|
605 | 605 | $currentLevel = Shell::VERBOSE; |
606 | 606 | } |
607 | - if (!empty($this->params['quiet'])) { |
|
607 | + if ( ! empty($this->params['quiet'])) { |
|
608 | 608 | $currentLevel = Shell::QUIET; |
609 | 609 | } |
610 | 610 | if ($level <= $currentLevel) { |
@@ -663,7 +663,7 @@ discard block |
||
663 | 663 | public function error($title, $message = null) { |
664 | 664 | $this->err(__d('cake_console', '<error>Error:</error> %s', $title)); |
665 | 665 | |
666 | - if (!empty($message)) { |
|
666 | + if ( ! empty($message)) { |
|
667 | 667 | $this->err($message); |
668 | 668 | } |
669 | 669 | return $this->_stop(1); |
@@ -694,7 +694,7 @@ discard block |
||
694 | 694 | * @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::createFile |
695 | 695 | */ |
696 | 696 | public function createFile($path, $contents) { |
697 | - $path = str_replace(DS . DS, DS, $path); |
|
697 | + $path = str_replace(DS.DS, DS, $path); |
|
698 | 698 | |
699 | 699 | $this->out(); |
700 | 700 | |
@@ -734,10 +734,10 @@ discard block |
||
734 | 734 | if (class_exists('PHPUnit_Framework_TestCase')) { |
735 | 735 | return true; |
736 | 736 | //@codingStandardsIgnoreStart |
737 | - } elseif (@include 'PHPUnit' . DS . 'Autoload.php') { |
|
737 | + } elseif (@include 'PHPUnit'.DS.'Autoload.php') { |
|
738 | 738 | //@codingStandardsIgnoreEnd |
739 | 739 | return true; |
740 | - } elseif (App::import('Vendor', 'phpunit', array('file' => 'PHPUnit' . DS . 'Autoload.php'))) { |
|
740 | + } elseif (App::import('Vendor', 'phpunit', array('file' => 'PHPUnit'.DS.'Autoload.php'))) { |
|
741 | 741 | return true; |
742 | 742 | } |
743 | 743 | |
@@ -761,8 +761,8 @@ discard block |
||
761 | 761 | */ |
762 | 762 | public function shortPath($file) { |
763 | 763 | $shortPath = str_replace(ROOT, null, $file); |
764 | - $shortPath = str_replace('..' . DS, '', $shortPath); |
|
765 | - return str_replace(DS . DS, DS, $shortPath); |
|
764 | + $shortPath = str_replace('..'.DS, '', $shortPath); |
|
765 | + return str_replace(DS.DS, DS, $shortPath); |
|
766 | 766 | } |
767 | 767 | |
768 | 768 | /** |
@@ -802,7 +802,7 @@ discard block |
||
802 | 802 | * @return string Singular model key |
803 | 803 | */ |
804 | 804 | protected function _modelKey($name) { |
805 | - return Inflector::underscore($name) . '_id'; |
|
805 | + return Inflector::underscore($name).'_id'; |
|
806 | 806 | } |
807 | 807 | |
808 | 808 | /** |
@@ -865,7 +865,7 @@ discard block |
||
865 | 865 | if (CakePlugin::loaded($pluginName)) { |
866 | 866 | return CakePlugin::path($pluginName); |
867 | 867 | } |
868 | - return current(App::path('plugins')) . $pluginName . DS; |
|
868 | + return current(App::path('plugins')).$pluginName.DS; |
|
869 | 869 | } |
870 | 870 | |
871 | 871 | /** |
@@ -877,7 +877,7 @@ discard block |
||
877 | 877 | * @return void |
878 | 878 | */ |
879 | 879 | protected function _useLogger($enable = true) { |
880 | - if (!$enable) { |
|
880 | + if ( ! $enable) { |
|
881 | 881 | CakeLog::drop('stdout'); |
882 | 882 | CakeLog::drop('stderr'); |
883 | 883 | return; |