@@ -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]; |
@@ -355,7 +355,7 @@ discard block |
||
| 355 | 355 | * Check if HTTP methods are required |
| 356 | 356 | * |
| 357 | 357 | * @param Controller $controller Instantiating controller |
| 358 | - * @return boolean true if $method is required |
|
| 358 | + * @return null|boolean true if $method is required |
|
| 359 | 359 | */ |
| 360 | 360 | protected function _methodsRequired(Controller $controller) { |
| 361 | 361 | foreach (array('Post', 'Get', 'Put', 'Delete') as $method) { |
@@ -378,7 +378,7 @@ discard block |
||
| 378 | 378 | * Check if access requires secure connection |
| 379 | 379 | * |
| 380 | 380 | * @param Controller $controller Instantiating controller |
| 381 | - * @return boolean true if secure connection required |
|
| 381 | + * @return null|boolean true if secure connection required |
|
| 382 | 382 | */ |
| 383 | 383 | protected function _secureRequired(Controller $controller) { |
| 384 | 384 | if (is_array($this->requireSecure) && !empty($this->requireSecure)) { |
@@ -399,7 +399,7 @@ discard block |
||
| 399 | 399 | * Check if authentication is required |
| 400 | 400 | * |
| 401 | 401 | * @param Controller $controller Instantiating controller |
| 402 | - * @return boolean true if authentication required |
|
| 402 | + * @return null|boolean true if authentication required |
|
| 403 | 403 | */ |
| 404 | 404 | protected function _authRequired(Controller $controller) { |
| 405 | 405 | if (is_array($this->requireAuth) && !empty($this->requireAuth) && !empty($this->request->data)) { |
@@ -610,7 +610,7 @@ discard block |
||
| 610 | 610 | * |
| 611 | 611 | * @param Controller $controller Controller to run callback on |
| 612 | 612 | * @param string $method Method to execute |
| 613 | - * @param array $params Parameters to send to method |
|
| 613 | + * @param string[] $params Parameters to send to method |
|
| 614 | 614 | * @return mixed Controller callback method's response |
| 615 | 615 | * @throws BadRequestException When a the blackholeCallback is not callable. |
| 616 | 616 | */ |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | |
| 227 | 227 | $isPost = $this->request->is(array('post', 'put')); |
| 228 | 228 | $isNotRequestAction = ( |
| 229 | - !isset($controller->request->params['requested']) || |
|
| 229 | + ! isset($controller->request->params['requested']) || |
|
| 230 | 230 | $controller->request->params['requested'] != 1 |
| 231 | 231 | ); |
| 232 | 232 | |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | return $this->blackHole($controller, 'auth'); |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | - if (!in_array($this->_action, (array)$this->unlockedActions) && $isPost && $isNotRequestAction) { |
|
| 237 | + if ( ! in_array($this->_action, (array) $this->unlockedActions) && $isPost && $isNotRequestAction) { |
|
| 238 | 238 | if ($this->validatePost && $this->_validatePost($controller) === false) { |
| 239 | 239 | return $this->blackHole($controller, 'auth'); |
| 240 | 240 | } |
@@ -331,7 +331,7 @@ discard block |
||
| 331 | 331 | * @throws BadRequestException |
| 332 | 332 | */ |
| 333 | 333 | public function blackHole(Controller $controller, $error = '') { |
| 334 | - if (!$this->blackHoleCallback) { |
|
| 334 | + if ( ! $this->blackHoleCallback) { |
|
| 335 | 335 | throw new BadRequestException(__d('cake_dev', 'The request has been black-holed')); |
| 336 | 336 | } |
| 337 | 337 | return $this->_callback($controller, $this->blackHoleCallback, array($error)); |
@@ -348,7 +348,7 @@ discard block |
||
| 348 | 348 | if (isset($actions[0]) && is_array($actions[0])) { |
| 349 | 349 | $actions = $actions[0]; |
| 350 | 350 | } |
| 351 | - $this->{'require' . $method} = (empty($actions)) ? array('*') : $actions; |
|
| 351 | + $this->{'require'.$method} = (empty($actions)) ? array('*') : $actions; |
|
| 352 | 352 | } |
| 353 | 353 | |
| 354 | 354 | /** |
@@ -359,12 +359,12 @@ discard block |
||
| 359 | 359 | */ |
| 360 | 360 | protected function _methodsRequired(Controller $controller) { |
| 361 | 361 | foreach (array('Post', 'Get', 'Put', 'Delete') as $method) { |
| 362 | - $property = 'require' . $method; |
|
| 363 | - if (is_array($this->$property) && !empty($this->$property)) { |
|
| 362 | + $property = 'require'.$method; |
|
| 363 | + if (is_array($this->$property) && ! empty($this->$property)) { |
|
| 364 | 364 | $require = $this->$property; |
| 365 | 365 | if (in_array($this->_action, $require) || $this->$property === array('*')) { |
| 366 | - if (!$this->request->is($method)) { |
|
| 367 | - if (!$this->blackHole($controller, $method)) { |
|
| 366 | + if ( ! $this->request->is($method)) { |
|
| 367 | + if ( ! $this->blackHole($controller, $method)) { |
|
| 368 | 368 | return null; |
| 369 | 369 | } |
| 370 | 370 | } |
@@ -381,12 +381,12 @@ discard block |
||
| 381 | 381 | * @return boolean true if secure connection required |
| 382 | 382 | */ |
| 383 | 383 | protected function _secureRequired(Controller $controller) { |
| 384 | - if (is_array($this->requireSecure) && !empty($this->requireSecure)) { |
|
| 384 | + if (is_array($this->requireSecure) && ! empty($this->requireSecure)) { |
|
| 385 | 385 | $requireSecure = $this->requireSecure; |
| 386 | 386 | |
| 387 | 387 | if (in_array($this->_action, $requireSecure) || $this->requireSecure === array('*')) { |
| 388 | - if (!$this->request->is('ssl')) { |
|
| 389 | - if (!$this->blackHole($controller, 'secure')) { |
|
| 388 | + if ( ! $this->request->is('ssl')) { |
|
| 389 | + if ( ! $this->blackHole($controller, 'secure')) { |
|
| 390 | 390 | return null; |
| 391 | 391 | } |
| 392 | 392 | } |
@@ -402,12 +402,12 @@ discard block |
||
| 402 | 402 | * @return boolean true if authentication required |
| 403 | 403 | */ |
| 404 | 404 | protected function _authRequired(Controller $controller) { |
| 405 | - if (is_array($this->requireAuth) && !empty($this->requireAuth) && !empty($this->request->data)) { |
|
| 405 | + if (is_array($this->requireAuth) && ! empty($this->requireAuth) && ! empty($this->request->data)) { |
|
| 406 | 406 | $requireAuth = $this->requireAuth; |
| 407 | 407 | |
| 408 | 408 | if (in_array($this->request->params['action'], $requireAuth) || $this->requireAuth === array('*')) { |
| 409 | - if (!isset($controller->request->data['_Token'])) { |
|
| 410 | - if (!$this->blackHole($controller, 'auth')) { |
|
| 409 | + if ( ! isset($controller->request->data['_Token'])) { |
|
| 410 | + if ( ! $this->blackHole($controller, 'auth')) { |
|
| 411 | 411 | return null; |
| 412 | 412 | } |
| 413 | 413 | } |
@@ -416,17 +416,17 @@ discard block |
||
| 416 | 416 | $tData = $this->Session->read('_Token'); |
| 417 | 417 | |
| 418 | 418 | if ( |
| 419 | - !empty($tData['allowedControllers']) && |
|
| 420 | - !in_array($this->request->params['controller'], $tData['allowedControllers']) || |
|
| 421 | - !empty($tData['allowedActions']) && |
|
| 422 | - !in_array($this->request->params['action'], $tData['allowedActions']) |
|
| 419 | + ! empty($tData['allowedControllers']) && |
|
| 420 | + ! in_array($this->request->params['controller'], $tData['allowedControllers']) || |
|
| 421 | + ! empty($tData['allowedActions']) && |
|
| 422 | + ! in_array($this->request->params['action'], $tData['allowedActions']) |
|
| 423 | 423 | ) { |
| 424 | - if (!$this->blackHole($controller, 'auth')) { |
|
| 424 | + if ( ! $this->blackHole($controller, 'auth')) { |
|
| 425 | 425 | return null; |
| 426 | 426 | } |
| 427 | 427 | } |
| 428 | 428 | } else { |
| 429 | - if (!$this->blackHole($controller, 'auth')) { |
|
| 429 | + if ( ! $this->blackHole($controller, 'auth')) { |
|
| 430 | 430 | return null; |
| 431 | 431 | } |
| 432 | 432 | } |
@@ -447,7 +447,7 @@ discard block |
||
| 447 | 447 | } |
| 448 | 448 | $data = $controller->request->data; |
| 449 | 449 | |
| 450 | - if (!isset($data['_Token']) || !isset($data['_Token']['fields']) || !isset($data['_Token']['unlocked'])) { |
|
| 450 | + if ( ! isset($data['_Token']) || ! isset($data['_Token']['fields']) || ! isset($data['_Token']['unlocked'])) { |
|
| 451 | 451 | return false; |
| 452 | 452 | } |
| 453 | 453 | |
@@ -475,18 +475,18 @@ discard block |
||
| 475 | 475 | unset($fieldList[$i]); |
| 476 | 476 | } |
| 477 | 477 | } |
| 478 | - if (!empty($multi)) { |
|
| 478 | + if ( ! empty($multi)) { |
|
| 479 | 479 | $fieldList += array_unique($multi); |
| 480 | 480 | } |
| 481 | 481 | |
| 482 | 482 | $unlockedFields = array_unique( |
| 483 | - array_merge((array)$this->disabledFields, (array)$this->unlockedFields, $unlocked) |
|
| 483 | + array_merge((array) $this->disabledFields, (array) $this->unlockedFields, $unlocked) |
|
| 484 | 484 | ); |
| 485 | 485 | |
| 486 | 486 | foreach ($fieldList as $i => $key) { |
| 487 | 487 | $isLocked = (is_array($locked) && in_array($key, $locked)); |
| 488 | 488 | |
| 489 | - if (!empty($unlockedFields)) { |
|
| 489 | + if ( ! empty($unlockedFields)) { |
|
| 490 | 490 | foreach ($unlockedFields as $off) { |
| 491 | 491 | $off = explode('.', $off); |
| 492 | 492 | $field = array_values(array_intersect(explode('.', $key), $off)); |
@@ -545,14 +545,14 @@ discard block |
||
| 545 | 545 | $tokenData = array(); |
| 546 | 546 | if ($this->Session->check('_Token')) { |
| 547 | 547 | $tokenData = $this->Session->read('_Token'); |
| 548 | - if (!empty($tokenData['csrfTokens']) && is_array($tokenData['csrfTokens'])) { |
|
| 548 | + if ( ! empty($tokenData['csrfTokens']) && is_array($tokenData['csrfTokens'])) { |
|
| 549 | 549 | $token['csrfTokens'] = $this->_expireTokens($tokenData['csrfTokens']); |
| 550 | 550 | } |
| 551 | 551 | } |
| 552 | 552 | if ($this->csrfUseOnce || empty($token['csrfTokens'])) { |
| 553 | 553 | $token['csrfTokens'][$authKey] = strtotime($this->csrfExpires); |
| 554 | 554 | } |
| 555 | - if (!$this->csrfUseOnce) { |
|
| 555 | + if ( ! $this->csrfUseOnce) { |
|
| 556 | 556 | $csrfTokens = array_keys($token['csrfTokens']); |
| 557 | 557 | $token['key'] = $csrfTokens[0]; |
| 558 | 558 | } |
@@ -577,7 +577,7 @@ discard block |
||
| 577 | 577 | $requestToken = $controller->request->data('_Token.key'); |
| 578 | 578 | if (isset($token['csrfTokens'][$requestToken]) && $token['csrfTokens'][$requestToken] >= time()) { |
| 579 | 579 | if ($this->csrfUseOnce) { |
| 580 | - $this->Session->delete('_Token.csrfTokens.' . $requestToken); |
|
| 580 | + $this->Session->delete('_Token.csrfTokens.'.$requestToken); |
|
| 581 | 581 | } |
| 582 | 582 | return true; |
| 583 | 583 | } |
@@ -615,7 +615,7 @@ discard block |
||
| 615 | 615 | * @throws BadRequestException When a the blackholeCallback is not callable. |
| 616 | 616 | */ |
| 617 | 617 | protected function _callback(Controller $controller, $method, $params = array()) { |
| 618 | - if (!is_callable(array($controller, $method))) { |
|
| 618 | + if ( ! is_callable(array($controller, $method))) { |
|
| 619 | 619 | throw new BadRequestException(__d('cake_dev', 'The request has been black-holed')); |
| 620 | 620 | } |
| 621 | 621 | return call_user_func_array(array(&$controller, $method), empty($params) ? null : $params); |