@@ -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; |
@@ -114,7 +114,7 @@ |
||
114 | 114 | * Called after the Controller::beforeFilter() and before the controller action |
115 | 115 | * |
116 | 116 | * @param Controller $controller Controller with components to startup |
117 | - * @return void |
|
117 | + * @return boolean |
|
118 | 118 | * @link http://book.cakephp.org/2.0/en/controllers/components.html#Component::startup |
119 | 119 | */ |
120 | 120 | public function startup(Controller $controller) { |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | $this->_Collection = $collection; |
80 | 80 | $this->settings = $settings; |
81 | 81 | $this->_set($settings); |
82 | - if (!empty($this->components)) { |
|
82 | + if ( ! empty($this->components)) { |
|
83 | 83 | $this->_componentMap = ComponentCollection::normalizeObjectArray($this->components); |
84 | 84 | } |
85 | 85 | } |
@@ -91,8 +91,8 @@ discard block |
||
91 | 91 | * @return mixed A Component object or null. |
92 | 92 | */ |
93 | 93 | public function __get($name) { |
94 | - if (isset($this->_componentMap[$name]) && !isset($this->{$name})) { |
|
95 | - $settings = array_merge((array)$this->_componentMap[$name]['settings'], array('enabled' => false)); |
|
94 | + if (isset($this->_componentMap[$name]) && ! isset($this->{$name})) { |
|
95 | + $settings = array_merge((array) $this->_componentMap[$name]['settings'], array('enabled' => false)); |
|
96 | 96 | $this->{$name} = $this->_Collection->load($this->_componentMap[$name]['class'], $settings); |
97 | 97 | } |
98 | 98 | if (isset($this->{$name})) { |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | * @param string $aro ARO The requesting object identifier. |
56 | 56 | * @param string $aco ACO The controlled object identifier. |
57 | 57 | * @param string $action Action (defaults to *) |
58 | - * @return boolean Success |
|
58 | + * @return boolean|null Success |
|
59 | 59 | */ |
60 | 60 | public function allow($aro, $aco, $action = "*") { |
61 | 61 | } |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | * @param string $aro ARO The requesting object identifier. |
67 | 67 | * @param string $aco ACO The controlled object identifier. |
68 | 68 | * @param string $action Action (defaults to *) |
69 | - * @return boolean Success |
|
69 | + * @return boolean|null Success |
|
70 | 70 | */ |
71 | 71 | public function deny($aro, $aco, $action = "*") { |
72 | 72 | } |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | * @param string $aro ARO The requesting object identifier. |
78 | 78 | * @param string $aco ACO The controlled object identifier. |
79 | 79 | * @param string $action Action (defaults to *) |
80 | - * @return boolean Success |
|
80 | + * @return boolean|null Success |
|
81 | 81 | */ |
82 | 82 | public function inherit($aro, $aco, $action = "*") { |
83 | 83 | } |
@@ -93,8 +93,8 @@ discard block |
||
93 | 93 | * @return boolean Success |
94 | 94 | */ |
95 | 95 | public function check($aro, $aco, $action = null) { |
96 | - if (!$this->config) { |
|
97 | - $this->config = $this->readConfigFile(APP . 'Config' . DS . 'acl.ini.php'); |
|
96 | + if ( ! $this->config) { |
|
97 | + $this->config = $this->readConfigFile(APP.'Config'.DS.'acl.ini.php'); |
|
98 | 98 | } |
99 | 99 | $aclConfig = $this->config; |
100 | 100 | |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | */ |
154 | 154 | public function readConfigFile($filename) { |
155 | 155 | App::uses('IniReader', 'Configure'); |
156 | - $iniFile = new IniReader(dirname($filename) . DS); |
|
156 | + $iniFile = new IniReader(dirname($filename).DS); |
|
157 | 157 | return $iniFile->read(basename($filename)); |
158 | 158 | } |
159 | 159 |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | * @param string $aro ARO The requesting object identifier. |
125 | 125 | * @param string $aco ACO The controlled object identifier. |
126 | 126 | * @param string $action Action (defaults to *) |
127 | - * @return boolean Success |
|
127 | + * @return boolean|null Success |
|
128 | 128 | */ |
129 | 129 | public function allow($aro, $aco, $action = "*") { |
130 | 130 | return $this->Aco->access($this->Aro->resolve($aro), $aco, $action, 'allow'); |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | * @param string $aro ARO The requesting object identifier. |
137 | 137 | * @param string $aco ACO The controlled object identifier. |
138 | 138 | * @param string $action Action (defaults to *) |
139 | - * @return boolean Success |
|
139 | + * @return boolean|null Success |
|
140 | 140 | */ |
141 | 141 | public function deny($aro, $aco, $action = "*") { |
142 | 142 | return $this->Aco->access($this->Aro->resolve($aro), $aco, $action, 'deny'); |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | public function __construct() { |
70 | 70 | $this->options = array( |
71 | 71 | 'policy' => self::DENY, |
72 | - 'config' => APP . 'Config' . DS . 'acl.php', |
|
72 | + 'config' => APP.'Config'.DS.'acl.php', |
|
73 | 73 | ); |
74 | 74 | } |
75 | 75 | |
@@ -80,12 +80,12 @@ discard block |
||
80 | 80 | * @return void |
81 | 81 | */ |
82 | 82 | public function initialize(Component $Component) { |
83 | - if (!empty($Component->settings['adapter'])) { |
|
83 | + if ( ! empty($Component->settings['adapter'])) { |
|
84 | 84 | $this->options = array_merge($this->options, $Component->settings['adapter']); |
85 | 85 | } |
86 | 86 | |
87 | 87 | App::uses('PhpReader', 'Configure'); |
88 | - $Reader = new PhpReader(dirname($this->options['config']) . DS); |
|
88 | + $Reader = new PhpReader(dirname($this->options['config']).DS); |
|
89 | 89 | $config = $Reader->read(basename($this->options['config'])); |
90 | 90 | $this->build($config); |
91 | 91 | $Component->Aco = $this->Aco; |
@@ -108,11 +108,11 @@ discard block |
||
108 | 108 | throw new AclException(__d('cake_dev', 'Neither "allow" nor "deny" rules were provided in configuration.')); |
109 | 109 | } |
110 | 110 | |
111 | - $rules['allow'] = !empty($config['rules']['allow']) ? $config['rules']['allow'] : array(); |
|
112 | - $rules['deny'] = !empty($config['rules']['deny']) ? $config['rules']['deny'] : array(); |
|
113 | - $roles = !empty($config['roles']) ? $config['roles'] : array(); |
|
114 | - $map = !empty($config['map']) ? $config['map'] : array(); |
|
115 | - $alias = !empty($config['alias']) ? $config['alias'] : array(); |
|
111 | + $rules['allow'] = ! empty($config['rules']['allow']) ? $config['rules']['allow'] : array(); |
|
112 | + $rules['deny'] = ! empty($config['rules']['deny']) ? $config['rules']['deny'] : array(); |
|
113 | + $roles = ! empty($config['roles']) ? $config['roles'] : array(); |
|
114 | + $map = ! empty($config['map']) ? $config['map'] : array(); |
|
115 | + $alias = ! empty($config['alias']) ? $config['alias'] : array(); |
|
116 | 116 | |
117 | 117 | $this->Aro = new PhpAro($roles, $map, $alias); |
118 | 118 | $this->Aco = new PhpAco($rules); |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | $prioritizedAros = $this->Aro->roles($aro); |
169 | 169 | |
170 | 170 | if ($action && $action !== "*") { |
171 | - $aco .= '/' . $action; |
|
171 | + $aco .= '/'.$action; |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | $path = $this->Aco->path($aco); |
@@ -179,12 +179,12 @@ discard block |
||
179 | 179 | |
180 | 180 | foreach ($path as $node) { |
181 | 181 | foreach ($prioritizedAros as $aros) { |
182 | - if (!empty($node['allow'])) { |
|
182 | + if ( ! empty($node['allow'])) { |
|
183 | 183 | $allow = $allow || count(array_intersect($node['allow'], $aros)); |
184 | 184 | } |
185 | 185 | |
186 | - if (!empty($node['deny'])) { |
|
187 | - $allow = $allow && !count(array_intersect($node['deny'], $aros)); |
|
186 | + if ( ! empty($node['deny'])) { |
|
187 | + $allow = $allow && ! count(array_intersect($node['deny'], $aros)); |
|
188 | 188 | } |
189 | 189 | } |
190 | 190 | } |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | $root = $this->_tree; |
245 | 245 | $stack = array(array($root, 0)); |
246 | 246 | |
247 | - while (!empty($stack)) { |
|
247 | + while ( ! empty($stack)) { |
|
248 | 248 | list($root, $level) = array_pop($stack); |
249 | 249 | |
250 | 250 | if (empty($path[$level])) { |
@@ -252,12 +252,12 @@ discard block |
||
252 | 252 | } |
253 | 253 | |
254 | 254 | foreach ($root as $node => $elements) { |
255 | - $pattern = '/^' . str_replace(array_keys(self::$modifiers), array_values(self::$modifiers), $node) . '$/'; |
|
255 | + $pattern = '/^'.str_replace(array_keys(self::$modifiers), array_values(self::$modifiers), $node).'$/'; |
|
256 | 256 | |
257 | 257 | if ($node == $aco[$level] || preg_match($pattern, $aco[$level])) { |
258 | 258 | // merge allow/denies with $path of current level |
259 | 259 | foreach (array('allow', 'deny') as $policy) { |
260 | - if (!empty($elements[$policy])) { |
|
260 | + if ( ! empty($elements[$policy])) { |
|
261 | 261 | if (empty($path[$level][$policy])) { |
262 | 262 | $path[$level][$policy] = array(); |
263 | 263 | } |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | } |
267 | 267 | |
268 | 268 | // traverse |
269 | - if (!empty($elements['children']) && isset($aco[$level + 1])) { |
|
269 | + if ( ! empty($elements['children']) && isset($aco[$level + 1])) { |
|
270 | 270 | array_push($stack, array($elements['children'], $level + 1)); |
271 | 271 | } |
272 | 272 | } |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | $tree = &$root; |
293 | 293 | |
294 | 294 | foreach ($aco as $i => $node) { |
295 | - if (!isset($tree[$node])) { |
|
295 | + if ( ! isset($tree[$node])) { |
|
296 | 296 | $tree[$node] = array( |
297 | 297 | 'children' => array(), |
298 | 298 | ); |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | * @param array $aliases |
413 | 413 | */ |
414 | 414 | public function __construct(array $aro = array(), array $map = array(), array $aliases = array()) { |
415 | - if (!empty($map)) { |
|
415 | + if ( ! empty($map)) { |
|
416 | 416 | $this->map = $map; |
417 | 417 | } |
418 | 418 | |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | $aro = $this->resolve($aro); |
436 | 436 | $stack = array(array($aro, 0)); |
437 | 437 | |
438 | - while (!empty($stack)) { |
|
438 | + while ( ! empty($stack)) { |
|
439 | 439 | list($element, $depth) = array_pop($stack); |
440 | 440 | $aros[$depth][] = $element; |
441 | 441 | |
@@ -463,24 +463,24 @@ discard block |
||
463 | 463 | |
464 | 464 | if (is_array($aro)) { |
465 | 465 | if (isset($aro['model']) && isset($aro['foreign_key']) && $aro['model'] === $aroGroup) { |
466 | - $mapped = $aroGroup . '/' . $aro['foreign_key']; |
|
466 | + $mapped = $aroGroup.'/'.$aro['foreign_key']; |
|
467 | 467 | } elseif (isset($aro[$model][$field])) { |
468 | - $mapped = $aroGroup . '/' . $aro[$model][$field]; |
|
468 | + $mapped = $aroGroup.'/'.$aro[$model][$field]; |
|
469 | 469 | } elseif (isset($aro[$field])) { |
470 | - $mapped = $aroGroup . '/' . $aro[$field]; |
|
470 | + $mapped = $aroGroup.'/'.$aro[$field]; |
|
471 | 471 | } |
472 | 472 | } elseif (is_string($aro)) { |
473 | 473 | $aro = ltrim($aro, '/'); |
474 | 474 | |
475 | 475 | if (strpos($aro, '/') === false) { |
476 | - $mapped = $aroGroup . '/' . $aro; |
|
476 | + $mapped = $aroGroup.'/'.$aro; |
|
477 | 477 | } else { |
478 | 478 | list($aroModel, $aroValue) = explode('/', $aro, 2); |
479 | 479 | |
480 | 480 | $aroModel = Inflector::camelize($aroModel); |
481 | 481 | |
482 | 482 | if ($aroModel === $model || $aroModel === $aroGroup) { |
483 | - $mapped = $aroGroup . '/' . $aroValue; |
|
483 | + $mapped = $aroGroup.'/'.$aroValue; |
|
484 | 484 | } |
485 | 485 | } |
486 | 486 | } |
@@ -490,7 +490,7 @@ discard block |
||
490 | 490 | } |
491 | 491 | |
492 | 492 | // is there a matching alias defined (e.g. Role/1 => Role/admin)? |
493 | - if (!empty($this->aliases[$mapped])) { |
|
493 | + if ( ! empty($this->aliases[$mapped])) { |
|
494 | 494 | return $this->aliases[$mapped]; |
495 | 495 | } |
496 | 496 | } |
@@ -505,11 +505,11 @@ discard block |
||
505 | 505 | */ |
506 | 506 | public function addRole(array $aro) { |
507 | 507 | foreach ($aro as $role => $inheritedRoles) { |
508 | - if (!isset($this->_tree[$role])) { |
|
508 | + if ( ! isset($this->_tree[$role])) { |
|
509 | 509 | $this->_tree[$role] = array(); |
510 | 510 | } |
511 | 511 | |
512 | - if (!empty($inheritedRoles)) { |
|
512 | + if ( ! empty($inheritedRoles)) { |
|
513 | 513 | if (is_string($inheritedRoles)) { |
514 | 514 | $inheritedRoles = array_map('trim', explode(',', $inheritedRoles)); |
515 | 515 | } |
@@ -522,14 +522,14 @@ discard block |
||
522 | 522 | $path = ''; |
523 | 523 | |
524 | 524 | foreach ($roles as $roleDependencies) { |
525 | - $path .= implode('|', (array)$roleDependencies) . ' -> '; |
|
525 | + $path .= implode('|', (array) $roleDependencies).' -> '; |
|
526 | 526 | } |
527 | 527 | |
528 | - trigger_error(__d('cake_dev', 'cycle detected when inheriting %s from %s. Path: %s', $role, $dependency, $path . $role)); |
|
528 | + trigger_error(__d('cake_dev', 'cycle detected when inheriting %s from %s. Path: %s', $role, $dependency, $path.$role)); |
|
529 | 529 | continue; |
530 | 530 | } |
531 | 531 | |
532 | - if (!isset($this->_tree[$dependency])) { |
|
532 | + if ( ! isset($this->_tree[$dependency])) { |
|
533 | 533 | $this->_tree[$dependency] = array(); |
534 | 534 | } |
535 | 535 |
@@ -199,7 +199,7 @@ |
||
199 | 199 | * systems like basic and digest auth. |
200 | 200 | * |
201 | 201 | * @param CakeRequest $request Request object. |
202 | - * @return mixed Either false or an array of user information |
|
202 | + * @return boolean Either false or an array of user information |
|
203 | 203 | */ |
204 | 204 | public function getUser(CakeRequest $request) { |
205 | 205 | return false; |
@@ -97,11 +97,11 @@ discard block |
||
97 | 97 | $conditions = $username; |
98 | 98 | } else { |
99 | 99 | $conditions = array( |
100 | - $model . '.' . $fields['username'] => $username |
|
100 | + $model.'.'.$fields['username'] => $username |
|
101 | 101 | ); |
102 | 102 | } |
103 | 103 | |
104 | - if (!empty($this->settings['scope'])) { |
|
104 | + if ( ! empty($this->settings['scope'])) { |
|
105 | 105 | $conditions = array_merge($conditions, $this->settings['scope']); |
106 | 106 | } |
107 | 107 | |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | |
118 | 118 | $user = $result[$model]; |
119 | 119 | if ($password !== null) { |
120 | - if (!$this->passwordHasher()->check($password, $user[$fields['password']])) { |
|
120 | + if ( ! $this->passwordHasher()->check($password, $user[$fields['password']])) { |
|
121 | 121 | return false; |
122 | 122 | } |
123 | 123 | unset($user[$fields['password']]); |
@@ -148,12 +148,12 @@ discard block |
||
148 | 148 | unset($config['className']); |
149 | 149 | } |
150 | 150 | list($plugin, $class) = pluginSplit($class, true); |
151 | - $className = $class . 'PasswordHasher'; |
|
152 | - App::uses($className, $plugin . 'Controller/Component/Auth'); |
|
153 | - if (!class_exists($className)) { |
|
151 | + $className = $class.'PasswordHasher'; |
|
152 | + App::uses($className, $plugin.'Controller/Component/Auth'); |
|
153 | + if ( ! class_exists($className)) { |
|
154 | 154 | throw new CakeException(__d('cake_dev', 'Password hasher class "%s" was not found.', $class)); |
155 | 155 | } |
156 | - if (!is_subclass_of($className, 'AbstractPasswordHasher')) { |
|
156 | + if ( ! is_subclass_of($className, 'AbstractPasswordHasher')) { |
|
157 | 157 | throw new CakeException(__d('cake_dev', 'Password hasher must extend AbstractPasswordHasher class.')); |
158 | 158 | } |
159 | 159 | $this->_passwordHasher = new $className($config); |
@@ -291,7 +291,6 @@ |
||
291 | 291 | /** |
292 | 292 | * Returns true if given variable is set in cookie. |
293 | 293 | * |
294 | - * @param string $var Variable name to check for |
|
295 | 294 | * @return boolean True if variable is there |
296 | 295 | */ |
297 | 296 | public function check($key = null) { |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | $this->_encrypted = $encrypt; |
224 | 224 | $this->_expire($expires); |
225 | 225 | |
226 | - if (!is_array($key)) { |
|
226 | + if ( ! is_array($key)) { |
|
227 | 227 | $key = array($key => $value); |
228 | 228 | } |
229 | 229 | |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | $firstName = $names[0]; |
236 | 236 | $isMultiValue = (is_array($value) || count($names) > 1); |
237 | 237 | |
238 | - if (!isset($this->_values[$this->name][$firstName]) && $isMultiValue) { |
|
238 | + if ( ! isset($this->_values[$this->name][$firstName]) && $isMultiValue) { |
|
239 | 239 | $this->_values[$this->name][$firstName] = array(); |
240 | 240 | } |
241 | 241 | |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | } else { |
249 | 249 | $this->_values[$this->name][$firstName] = $value; |
250 | 250 | } |
251 | - $this->_write('[' . $firstName . ']', $this->_values[$this->name][$firstName]); |
|
251 | + $this->_write('['.$firstName.']', $this->_values[$this->name][$firstName]); |
|
252 | 252 | } |
253 | 253 | $this->_encrypted = true; |
254 | 254 | } |
@@ -278,11 +278,11 @@ discard block |
||
278 | 278 | $names = explode('.', $key, 2); |
279 | 279 | $key = $names[0]; |
280 | 280 | } |
281 | - if (!isset($this->_values[$this->name][$key])) { |
|
281 | + if ( ! isset($this->_values[$this->name][$key])) { |
|
282 | 282 | return null; |
283 | 283 | } |
284 | 284 | |
285 | - if (!empty($names[1])) { |
|
285 | + if ( ! empty($names[1])) { |
|
286 | 286 | return Hash::get($this->_values[$this->name][$key], $names[1]); |
287 | 287 | } |
288 | 288 | return $this->_values[$this->name][$key]; |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | if (isset($this->_values[$this->name][$names[0]])) { |
339 | 339 | $this->_values[$this->name][$names[0]] = Hash::remove($this->_values[$this->name][$names[0]], $names[1]); |
340 | 340 | } |
341 | - $this->_delete('[' . implode('][', $names) . ']'); |
|
341 | + $this->_delete('['.implode('][', $names).']'); |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | /** |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | 'cipher', |
381 | 381 | 'rijndael' |
382 | 382 | ); |
383 | - if (!in_array($type, $availableTypes)) { |
|
383 | + if ( ! in_array($type, $availableTypes)) { |
|
384 | 384 | trigger_error(__d('cake_dev', 'You must use cipher or rijndael for cookie encryption type'), E_USER_WARNING); |
385 | 385 | $type = 'cipher'; |
386 | 386 | } |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | return $this->_expires; |
406 | 406 | } |
407 | 407 | $this->_reset = $this->_expires; |
408 | - if (!$expires) { |
|
408 | + if ( ! $expires) { |
|
409 | 409 | return $this->_expires = 0; |
410 | 410 | } |
411 | 411 | $now = new DateTime(); |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | */ |
427 | 427 | protected function _write($name, $value) { |
428 | 428 | $this->_response->cookie(array( |
429 | - 'name' => $this->name . $name, |
|
429 | + 'name' => $this->name.$name, |
|
430 | 430 | 'value' => $this->_encrypt($value), |
431 | 431 | 'expire' => $this->_expires, |
432 | 432 | 'path' => $this->path, |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | 'httpOnly' => $this->httpOnly |
436 | 436 | )); |
437 | 437 | |
438 | - if (!empty($this->_reset)) { |
|
438 | + if ( ! empty($this->_reset)) { |
|
439 | 439 | $this->_expires = $this->_reset; |
440 | 440 | $this->_reset = null; |
441 | 441 | } |
@@ -449,7 +449,7 @@ discard block |
||
449 | 449 | */ |
450 | 450 | protected function _delete($name) { |
451 | 451 | $this->_response->cookie(array( |
452 | - 'name' => $this->name . $name, |
|
452 | + 'name' => $this->name.$name, |
|
453 | 453 | 'value' => '', |
454 | 454 | 'expire' => time() - 42000, |
455 | 455 | 'path' => $this->path, |
@@ -472,7 +472,7 @@ discard block |
||
472 | 472 | |
473 | 473 | if ($this->_encrypted === true) { |
474 | 474 | $type = $this->_type; |
475 | - $value = "Q2FrZQ==." . base64_encode(Security::$type($value, $this->key, 'encrypt')); |
|
475 | + $value = "Q2FrZQ==.".base64_encode(Security::$type($value, $this->key, 'encrypt')); |
|
476 | 476 | } |
477 | 477 | return $value; |
478 | 478 | } |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | $decrypted = array(); |
488 | 488 | $type = $this->_type; |
489 | 489 | |
490 | - foreach ((array)$values as $name => $value) { |
|
490 | + foreach ((array) $values as $name => $value) { |
|
491 | 491 | if (is_array($value)) { |
492 | 492 | foreach ($value as $key => $val) { |
493 | 493 | $pos = strpos($val, 'Q2FrZQ==.'); |
@@ -537,7 +537,7 @@ discard block |
||
537 | 537 | $array = array(); |
538 | 538 | foreach (explode(',', $string) as $pair) { |
539 | 539 | $key = explode('|', $pair); |
540 | - if (!isset($key[1])) { |
|
540 | + if ( ! isset($key[1])) { |
|
541 | 541 | return $key[0]; |
542 | 542 | } |
543 | 543 | $array[$key[0]] = $key[1]; |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | * Modifies the $_POST and $_SERVER['REQUEST_METHOD'] to simulate a new GET request. |
245 | 245 | * |
246 | 246 | * @param Controller $controller A reference to the controller |
247 | - * @param string|array $url A string or array containing the redirect location |
|
247 | + * @param string|null $url A string or array containing the redirect location |
|
248 | 248 | * @param integer|array $status HTTP Status for redirect |
249 | 249 | * @param boolean $exit |
250 | 250 | * @return void |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | * "304 Not Modified" header. |
281 | 281 | * |
282 | 282 | * @params Controller $controller |
283 | - * @return boolean false if the render process should be aborted |
|
283 | + * @return false|null false if the render process should be aborted |
|
284 | 284 | */ |
285 | 285 | public function beforeRender(Controller $controller) { |
286 | 286 | if ($this->settings['checkHttpCache'] && $this->response->checkNotModified($this->request)) { |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | * Gets Prototype version if call is Ajax, otherwise empty string. |
409 | 409 | * The Prototype library sets a special "Prototype version" HTTP header. |
410 | 410 | * |
411 | - * @return string|boolean When Ajax the prototype version of component making the call otherwise false |
|
411 | + * @return string When Ajax the prototype version of component making the call otherwise false |
|
412 | 412 | */ |
413 | 413 | public function getAjaxVersion() { |
414 | 414 | $httpX = env('HTTP_X_PROTOTYPE_VERSION'); |
@@ -469,7 +469,7 @@ discard block |
||
469 | 469 | * |
470 | 470 | * @param string|array $type Can be null (or no parameter), a string type name, or an |
471 | 471 | * array of types |
472 | - * @return mixed If null or no parameter is passed, returns an array of content |
|
472 | + * @return boolean If null or no parameter is passed, returns an array of content |
|
473 | 473 | * types the client accepts. If a string is passed, returns true |
474 | 474 | * if the client accepts it. If an array is passed, returns true |
475 | 475 | * if the client accepts one or more elements in the array. |
@@ -593,7 +593,7 @@ discard block |
||
593 | 593 | * @param Controller $controller A reference to a controller object |
594 | 594 | * @param string $type Type of response to send (e.g: 'ajax') |
595 | 595 | * @param array $options Array of options to use |
596 | - * @return void |
|
596 | + * @return boolean|null |
|
597 | 597 | * @see RequestHandlerComponent::setContent() |
598 | 598 | * @see RequestHandlerComponent::respondAs() |
599 | 599 | */ |
@@ -655,7 +655,7 @@ discard block |
||
655 | 655 | * Sets the response header based on type map index name. This wraps several methods |
656 | 656 | * available on CakeResponse. It also allows you to use Content-Type aliases. |
657 | 657 | * |
658 | - * @param string|array $type Friendly type name, i.e. 'html' or 'xml', or a full content-type, |
|
658 | + * @param string $type Friendly type name, i.e. 'html' or 'xml', or a full content-type, |
|
659 | 659 | * like 'application/x-shockwave'. |
660 | 660 | * @param array $options If $type is a friendly type name that is associated with |
661 | 661 | * more than one type of content, $index is used to select which content-type to use. |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | $this->_setExtension(); |
135 | 135 | } |
136 | 136 | $this->params = $controller->params; |
137 | - if (!empty($this->settings['viewClassMap'])) { |
|
137 | + if ( ! empty($this->settings['viewClassMap'])) { |
|
138 | 138 | $this->viewClassMap($this->settings['viewClassMap']); |
139 | 139 | } |
140 | 140 | } |
@@ -200,11 +200,11 @@ discard block |
||
200 | 200 | public function startup(Controller $controller) { |
201 | 201 | $controller->request->params['isAjax'] = $this->request->is('ajax'); |
202 | 202 | $isRecognized = ( |
203 | - !in_array($this->ext, array('html', 'htm')) && |
|
203 | + ! in_array($this->ext, array('html', 'htm')) && |
|
204 | 204 | $this->response->getMimeType($this->ext) |
205 | 205 | ); |
206 | 206 | |
207 | - if (!empty($this->ext) && $isRecognized) { |
|
207 | + if ( ! empty($this->ext) && $isRecognized) { |
|
208 | 208 | $this->renderAs($controller, $this->ext); |
209 | 209 | } elseif ($this->request->is('ajax')) { |
210 | 210 | $this->renderAs($controller, 'ajax'); |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | * @return void |
251 | 251 | */ |
252 | 252 | public function beforeRedirect(Controller $controller, $url, $status = null, $exit = true) { |
253 | - if (!$this->request->is('ajax')) { |
|
253 | + if ( ! $this->request->is('ajax')) { |
|
254 | 254 | return; |
255 | 255 | } |
256 | 256 | if (empty($url)) { |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | if (is_array($url)) { |
264 | 264 | $url = Router::url($url + array('base' => false)); |
265 | 265 | } |
266 | - if (!empty($status)) { |
|
266 | + if ( ! empty($status)) { |
|
267 | 267 | $statusCode = $this->response->httpCodes($status); |
268 | 268 | $code = key($statusCode); |
269 | 269 | $this->response->statusCode($code); |
@@ -478,7 +478,7 @@ discard block |
||
478 | 478 | public function accepts($type = null) { |
479 | 479 | $accepted = $this->request->accepts(); |
480 | 480 | |
481 | - if (!$type) { |
|
481 | + if ( ! $type) { |
|
482 | 482 | return $this->mapType($accepted); |
483 | 483 | } |
484 | 484 | if (is_array($type)) { |
@@ -505,7 +505,7 @@ discard block |
||
505 | 505 | * in the request content type will be returned. |
506 | 506 | */ |
507 | 507 | public function requestedWith($type = null) { |
508 | - if (!$this->request->is('post') && !$this->request->is('put')) { |
|
508 | + if ( ! $this->request->is('post') && ! $this->request->is('put')) { |
|
509 | 509 | return null; |
510 | 510 | } |
511 | 511 | if (is_array($type)) { |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | if ($contentType === '') { |
522 | 522 | list($contentType) = explode(';', CakeRequest::header('CONTENT_TYPE')); |
523 | 523 | } |
524 | - if (!$type) { |
|
524 | + if ( ! $type) { |
|
525 | 525 | return $this->mapType($contentType); |
526 | 526 | } |
527 | 527 | if (is_string($type)) { |
@@ -554,17 +554,17 @@ discard block |
||
554 | 554 | } |
555 | 555 | $accepts = $this->mapType(array_shift($acceptRaw)); |
556 | 556 | |
557 | - if (!$type) { |
|
558 | - if (empty($this->ext) && !empty($accepts)) { |
|
557 | + if ( ! $type) { |
|
558 | + if (empty($this->ext) && ! empty($accepts)) { |
|
559 | 559 | return $accepts[0]; |
560 | 560 | } |
561 | 561 | return $this->ext; |
562 | 562 | } |
563 | 563 | |
564 | - $types = (array)$type; |
|
564 | + $types = (array) $type; |
|
565 | 565 | |
566 | 566 | if (count($types) === 1) { |
567 | - if (!empty($this->ext)) { |
|
567 | + if ( ! empty($this->ext)) { |
|
568 | 568 | return in_array($this->ext, $types); |
569 | 569 | } |
570 | 570 | return in_array($types[0], $accepts); |
@@ -618,18 +618,18 @@ discard block |
||
618 | 618 | } else { |
619 | 619 | $viewClass = Inflector::classify($type); |
620 | 620 | } |
621 | - $viewName = $viewClass . 'View'; |
|
622 | - if (!class_exists($viewName)) { |
|
623 | - App::uses($viewName, $pluginDot . 'View'); |
|
621 | + $viewName = $viewClass.'View'; |
|
622 | + if ( ! class_exists($viewName)) { |
|
623 | + App::uses($viewName, $pluginDot.'View'); |
|
624 | 624 | } |
625 | 625 | if (class_exists($viewName)) { |
626 | 626 | $controller->viewClass = $viewClass; |
627 | 627 | } elseif (empty($this->_renderType)) { |
628 | - $controller->viewPath .= DS . $type; |
|
628 | + $controller->viewPath .= DS.$type; |
|
629 | 629 | } else { |
630 | 630 | $controller->viewPath = preg_replace( |
631 | 631 | "/([\/\\\\]{$this->_renderType})$/", |
632 | - DS . $type, |
|
632 | + DS.$type, |
|
633 | 633 | $controller->viewPath |
634 | 634 | ); |
635 | 635 | } |
@@ -642,10 +642,10 @@ discard block |
||
642 | 642 | |
643 | 643 | $helper = ucfirst($type); |
644 | 644 | |
645 | - if (!in_array($helper, $controller->helpers) && empty($controller->helpers[$helper])) { |
|
645 | + if ( ! in_array($helper, $controller->helpers) && empty($controller->helpers[$helper])) { |
|
646 | 646 | App::uses('AppHelper', 'View/Helper'); |
647 | - App::uses($helper . 'Helper', 'View/Helper'); |
|
648 | - if (class_exists($helper . 'Helper')) { |
|
647 | + App::uses($helper.'Helper', 'View/Helper'); |
|
648 | + if (class_exists($helper.'Helper')) { |
|
649 | 649 | $controller->helpers[] = $helper; |
650 | 650 | } |
651 | 651 | } |
@@ -684,16 +684,16 @@ discard block |
||
684 | 684 | } |
685 | 685 | } |
686 | 686 | |
687 | - if (!$type) { |
|
687 | + if ( ! $type) { |
|
688 | 688 | return false; |
689 | 689 | } |
690 | 690 | if (empty($this->request->params['requested'])) { |
691 | 691 | $this->response->type($cType); |
692 | 692 | } |
693 | - if (!empty($options['charset'])) { |
|
693 | + if ( ! empty($options['charset'])) { |
|
694 | 694 | $this->response->charset($options['charset']); |
695 | 695 | } |
696 | - if (!empty($options['attachment'])) { |
|
696 | + if ( ! empty($options['attachment'])) { |
|
697 | 697 | $this->response->download($options['attachment']); |
698 | 698 | } |
699 | 699 | return true; |
@@ -753,7 +753,7 @@ discard block |
||
753 | 753 | * @throws CakeException |
754 | 754 | */ |
755 | 755 | public function addInputType($type, $handler) { |
756 | - if (!is_array($handler) || !isset($handler[0]) || !is_callable($handler[0])) { |
|
756 | + if ( ! is_array($handler) || ! isset($handler[0]) || ! is_callable($handler[0])) { |
|
757 | 757 | throw new CakeException(__d('cake_dev', 'You must give a handler callback.')); |
758 | 758 | } |
759 | 759 | $this->_inputTypeMap[$type] = $handler; |
@@ -767,7 +767,7 @@ discard block |
||
767 | 767 | * @return array|string Returns viewClass when only string $type is set, else array with viewClassMap |
768 | 768 | */ |
769 | 769 | public function viewClassMap($type = null, $viewClass = null) { |
770 | - if (!$viewClass && is_string($type) && isset($this->_viewClassMap[$type])) { |
|
770 | + if ( ! $viewClass && is_string($type) && isset($this->_viewClassMap[$type])) { |
|
771 | 771 | return $this->_viewClassMap[$type]; |
772 | 772 | } |
773 | 773 | if (is_string($type)) { |