diff --git a/lib/Cake/Console/Command/AclShell.php b/lib/Cake/Console/Command/AclShell.php index 364947e79..081eaf349 100644 --- a/lib/Cake/Console/Command/AclShell.php +++ b/lib/Cake/Console/Command/AclShell.php @@ -82,7 +82,7 @@ class AclShell extends AppShell { $out .= __d('cake_console', 'Current ACL Classname: %s', $class) . "\n"; $out .= "--------------------------------------------------\n"; $this->err($out); - $this->_stop(); + return $this->_stop(); } if ($this->command) { diff --git a/lib/Cake/Console/Command/ApiShell.php b/lib/Cake/Console/Command/ApiShell.php index 584d24638..200b67b8b 100644 --- a/lib/Cake/Console/Command/ApiShell.php +++ b/lib/Cake/Console/Command/ApiShell.php @@ -100,7 +100,7 @@ class ApiShell extends AppShell { if (isset($this->params['method'])) { if (!isset($parsed[$this->params['method']])) { $this->err(__d('cake_console', '%s::%s() could not be found', $class, $this->params['method'])); - $this->_stop(); + return $this->_stop(); } $method = $parsed[$this->params['method']]; $this->out($class . '::' . $method['method'] . $method['parameters']); diff --git a/lib/Cake/Console/Command/BakeShell.php b/lib/Cake/Console/Command/BakeShell.php index e4095d9cb..f8bafb1dd 100644 --- a/lib/Cake/Console/Command/BakeShell.php +++ b/lib/Cake/Console/Command/BakeShell.php @@ -123,8 +123,7 @@ class BakeShell extends AppShell { $this->Test->execute(); break; case 'Q': - exit(0); - break; + return $this->_stop(); default: $this->out(__d('cake_console', 'You have made an invalid selection. Please choose a type of class to Bake by entering D, M, V, F, T, or C.')); } diff --git a/lib/Cake/Console/Command/ConsoleShell.php b/lib/Cake/Console/Command/ConsoleShell.php index e6ee110cd..7b97f89db 100644 --- a/lib/Cake/Console/Command/ConsoleShell.php +++ b/lib/Cake/Console/Command/ConsoleShell.php @@ -172,7 +172,7 @@ class ConsoleShell extends AppShell { switch ($command) { case 'help': $this->help(); - break; + break; case 'quit': case 'exit': return true; @@ -182,7 +182,7 @@ class ConsoleShell extends AppShell { foreach ($this->models as $model) { $this->out(" - {$model}"); } - break; + break; case preg_match("/^(\w+) bind (\w+) (\w+)/", $command, $tmp): foreach ($tmp as $data) { $data = strip_tags($data); @@ -200,7 +200,7 @@ class ConsoleShell extends AppShell { } else { $this->out(__d('cake_console', "Please verify you are using valid models and association types")); } - break; + break; case preg_match("/^(\w+) unbind (\w+) (\w+)/", $command, $tmp): foreach ($tmp as $data) { $data = strip_tags($data); @@ -228,7 +228,7 @@ class ConsoleShell extends AppShell { } else { $this->out(__d('cake_console', "Please verify you are using valid models, valid current association, and valid association types")); } - break; + break; case (strpos($command, "->find") > 0): // Remove any bad info $command = strip_tags($command); @@ -285,7 +285,7 @@ class ConsoleShell extends AppShell { $this->out(__d('cake_console', "%s is not a valid model", $modelToCheck)); } - break; + break; case (strpos($command, '->save') > 0): // Validate the model we're trying to save here $command = strip_tags($command); @@ -302,7 +302,7 @@ class ConsoleShell extends AppShell { //@codingStandardsIgnoreEnd $this->out(__d('cake_console', 'Saved record for %s', $modelToSave)); } - break; + break; case preg_match("/^(\w+) columns/", $command, $tmp): $modelToCheck = strip_tags(str_replace($this->badCommandChars, "", $tmp[1])); @@ -321,31 +321,30 @@ class ConsoleShell extends AppShell { } else { $this->out(__d('cake_console', "Please verify that you selected a valid model")); } - break; + break; case preg_match("/^routes\s+reload/i", $command, $tmp): if (!$this->_loadRoutes()) { $this->err(__d('cake_console', "There was an error loading the routes config. Please check that the file exists and is free of parse errors.")); break; } $this->out(__d('cake_console', "Routes configuration reloaded, %d routes connected", count(Router::$routes))); - break; + break; case preg_match("/^routes\s+show/i", $command, $tmp): $this->out(print_r(Hash::combine(Router::$routes, '{n}.template', '{n}.defaults'), true)); - break; + break; case (preg_match("/^route\s+(\(.*\))$/i", $command, $tmp) == true): //@codingStandardsIgnoreStart if ($url = eval('return array' . $tmp[1] . ';')) { //@codingStandardsIgnoreEnd $this->out(Router::url($url)); } - break; + break; case preg_match("/^route\s+(.*)/i", $command, $tmp): $this->out(var_export(Router::parse($tmp[1]), true)); - break; + break; default: $this->out(__d('cake_console', "Invalid command")); $this->out(); - break; } $command = ''; } diff --git a/lib/Cake/Console/Command/I18nShell.php b/lib/Cake/Console/Command/I18nShell.php index bcfca62c4..c0782ba4e 100644 --- a/lib/Cake/Console/Command/I18nShell.php +++ b/lib/Cake/Console/Command/I18nShell.php @@ -76,16 +76,15 @@ class I18nShell extends AppShell { switch ($choice) { case 'e': $this->Extract->execute(); - break; + break; case 'i': $this->initdb(); - break; + break; case 'h': $this->out($this->OptionParser->help()); - break; + break; case 'q': - exit(0); - break; + return $this->_stop(); default: $this->out(__d('cake_console', 'You have made an invalid selection. Please choose a command to execute by entering E, I, H, or Q.')); } diff --git a/lib/Cake/Console/Command/SchemaShell.php b/lib/Cake/Console/Command/SchemaShell.php index 02ad7dd18..30c6f3340 100644 --- a/lib/Cake/Console/Command/SchemaShell.php +++ b/lib/Cake/Console/Command/SchemaShell.php @@ -106,12 +106,11 @@ class SchemaShell extends AppShell { $File = new File($this->Schema->path . DS . $this->params['file']); if ($File->exists()) { $this->out($File->read()); - $this->_stop(); - } else { - $file = $this->Schema->path . DS . $this->params['file']; - $this->err(__d('cake_console', 'Schema file (%s) could not be found.', $file)); - $this->_stop(); + return $this->_stop(); } + $file = $this->Schema->path . DS . $this->params['file']; + $this->err(__d('cake_console', 'Schema file (%s) could not be found.', $file)); + return $this->_stop(); } /** @@ -191,11 +190,10 @@ class SchemaShell extends AppShell { if ($this->Schema->write($content)) { $this->out(__d('cake_console', 'Schema file: %s generated', $content['file'])); - $this->_stop(); - } else { - $this->err(__d('cake_console', 'Schema file: %s generated')); - $this->_stop(); + return $this->_stop(); } + $this->err(__d('cake_console', 'Schema file: %s generated')); + return $this->_stop(); } /** @@ -212,7 +210,7 @@ class SchemaShell extends AppShell { $Schema = $this->Schema->load(); if (!$Schema) { $this->err(__d('cake_console', 'Schema could not be loaded')); - $this->_stop(); + return $this->_stop(); } if (!empty($this->params['write'])) { if ($this->params['write'] == 1) { @@ -236,10 +234,10 @@ class SchemaShell extends AppShell { if ($File->write($contents)) { $this->out(__d('cake_console', 'SQL dump file created in %s', $File->pwd())); - $this->_stop(); + return $this->_stop(); } else { $this->err(__d('cake_console', 'SQL dump could not be created')); - $this->_stop(); + return $this->_stop(); } } $this->out($contents); @@ -297,7 +295,7 @@ class SchemaShell extends AppShell { $this->err(__d('cake_console', 'The chosen schema could not be loaded. Attempted to load:')); $this->err(__d('cake_console', 'File: %s', $this->Schema->path . DS . $this->Schema->file)); $this->err(__d('cake_console', 'Name: %s', $this->Schema->name)); - $this->_stop(); + return $this->_stop(); } $table = null; if (isset($this->args[1])) { @@ -330,13 +328,13 @@ class SchemaShell extends AppShell { } if (empty($drop) || empty($create)) { $this->out(__d('cake_console', 'Schema is up to date.')); - $this->_stop(); + return $this->_stop(); } $this->out("\n" . __d('cake_console', 'The following table(s) will be dropped.')); $this->out(array_keys($drop)); - if ('y' == $this->in(__d('cake_console', 'Are you sure you want to drop the table(s)?'), array('y', 'n'), 'n')) { + if ($this->in(__d('cake_console', 'Are you sure you want to drop the table(s)?'), array('y', 'n'), 'n') === 'y') { $this->out(__d('cake_console', 'Dropping table(s).')); $this->_run($drop, 'drop', $Schema); } @@ -344,7 +342,7 @@ class SchemaShell extends AppShell { $this->out("\n" . __d('cake_console', 'The following table(s) will be created.')); $this->out(array_keys($create)); - if ('y' == $this->in(__d('cake_console', 'Are you sure you want to create the table(s)?'), array('y', 'n'), 'y')) { + if ($this->in(__d('cake_console', 'Are you sure you want to create the table(s)?'), array('y', 'n'), 'y') === 'y') { $this->out(__d('cake_console', 'Creating table(s).')); $this->_run($create, 'create', $Schema); } @@ -390,12 +388,12 @@ class SchemaShell extends AppShell { if (empty($contents)) { $this->out(__d('cake_console', 'Schema is up to date.')); - $this->_stop(); + return $this->_stop(); } $this->out("\n" . __d('cake_console', 'The following statements will run.')); $this->out(array_map('trim', $contents)); - if ('y' == $this->in(__d('cake_console', 'Are you sure you want to alter the tables?'), array('y', 'n'), 'n')) { + if ($this->in(__d('cake_console', 'Are you sure you want to alter the tables?'), array('y', 'n'), 'n') === 'y') { $this->out(); $this->out(__d('cake_console', 'Updating Database...')); $this->_run($contents, 'update', $Schema); diff --git a/lib/Cake/Console/Command/Task/ControllerTask.php b/lib/Cake/Console/Command/Task/ControllerTask.php index 5305c733b..b50266852 100644 --- a/lib/Cake/Console/Command/Task/ControllerTask.php +++ b/lib/Cake/Console/Command/Task/ControllerTask.php @@ -289,7 +289,7 @@ class ControllerTask extends BakeTask { App::uses($modelImport, $plugin . 'Model'); if (!class_exists($modelImport)) { $this->err(__d('cake_console', 'You must have a model for this class to build basic methods. Please try again.')); - $this->_stop(); + return $this->_stop(); } $modelObj = ClassRegistry::init($currentModelName); diff --git a/lib/Cake/Console/Command/Task/DbConfigTask.php b/lib/Cake/Console/Command/Task/DbConfigTask.php index 55076d5fc..d0e4572ac 100644 --- a/lib/Cake/Console/Command/Task/DbConfigTask.php +++ b/lib/Cake/Console/Command/Task/DbConfigTask.php @@ -77,7 +77,7 @@ class DbConfigTask extends AppShell { public function execute() { if (empty($this->args)) { $this->_interactive(); - $this->_stop(); + return $this->_stop(); } } diff --git a/lib/Cake/Console/Command/Task/ExtractTask.php b/lib/Cake/Console/Command/Task/ExtractTask.php index c9fece3f3..4648c1e47 100644 --- a/lib/Cake/Console/Command/Task/ExtractTask.php +++ b/lib/Cake/Console/Command/Task/ExtractTask.php @@ -207,7 +207,7 @@ class ExtractTask extends AppShell { $response = $this->in($message, null, rtrim($this->_paths[0], DS) . DS . 'Locale'); if (strtoupper($response) === 'Q') { $this->out(__d('cake_console', 'Extract Aborted')); - $this->_stop(); + return $this->_stop(); } elseif ($this->_isPathUsable($response)) { $this->_output = $response . DS; break; diff --git a/lib/Cake/Console/Command/Task/FixtureTask.php b/lib/Cake/Console/Command/Task/FixtureTask.php index b1e743157..a3e217052 100644 --- a/lib/Cake/Console/Command/Task/FixtureTask.php +++ b/lib/Cake/Console/Command/Task/FixtureTask.php @@ -325,7 +325,7 @@ class FixtureTask extends BakeTask { case 'integer': case 'float': $insert = $i + 1; - break; + break; case 'string': case 'binary': $isPrimaryUuid = ( @@ -340,22 +340,22 @@ class FixtureTask extends BakeTask { $insert = substr($insert, 0, (int)$fieldInfo['length'] - 2); } } - break; + break; case 'timestamp': $insert = time(); - break; + break; case 'datetime': $insert = date('Y-m-d H:i:s'); - break; + break; case 'date': $insert = date('Y-m-d'); - break; + break; case 'time': $insert = date('H:i:s'); - break; + break; case 'boolean': $insert = 1; - break; + break; case 'text': $insert = "Lorem ipsum dolor sit amet, aliquet feugiat."; $insert .= " Convallis morbi fringilla gravida,"; @@ -364,7 +364,7 @@ class FixtureTask extends BakeTask { $insert .= " vestibulum massa neque ut et, id hendrerit sit,"; $insert .= " feugiat in taciti enim proin nibh, tempor dignissim, rhoncus"; $insert .= " duis vestibulum nunc mattis convallis."; - break; + break; } $record[$field] = $insert; } diff --git a/lib/Cake/Console/Command/Task/ModelTask.php b/lib/Cake/Console/Command/Task/ModelTask.php index b614daa68..0317a05a9 100644 --- a/lib/Cake/Console/Command/Task/ModelTask.php +++ b/lib/Cake/Console/Command/Task/ModelTask.php @@ -681,7 +681,7 @@ class ModelTask extends BakeTask { $prompt = "{$model->name} {$type} {$assoc['alias']}?"; $response = $this->in($prompt, array('y', 'n'), 'y'); - if ('n' == strtolower($response)) { + if (strtolower($response) === 'n') { unset($associations[$type][$i]); } elseif ($type === 'hasMany') { unset($associations['hasOne'][$i]); @@ -938,7 +938,7 @@ class ModelTask extends BakeTask { } if (empty($tables)) { $this->err(__d('cake_console', 'Your database does not have any tables.')); - $this->_stop(); + return $this->_stop(); } return $tables; } @@ -960,7 +960,7 @@ class ModelTask extends BakeTask { if ($enteredModel === 'q') { $this->out(__d('cake_console', 'Exit')); - $this->_stop(); + return $this->_stop(); } if (!$enteredModel || intval($enteredModel) > count($this->_modelNames)) { diff --git a/lib/Cake/Console/Command/Task/PluginTask.php b/lib/Cake/Console/Command/Task/PluginTask.php index c64cdcaf3..4db5b7d3b 100644 --- a/lib/Cake/Console/Command/Task/PluginTask.php +++ b/lib/Cake/Console/Command/Task/PluginTask.php @@ -65,9 +65,8 @@ class PluginTask extends AppShell { $this->out(__d('cake_console', 'Plugin: %s already exists, no action taken', $plugin)); $this->out(__d('cake_console', 'Path: %s', $pluginPath)); return false; - } else { - $this->_interactive($plugin); } + $this->_interactive($plugin); } else { return $this->_interactive(); } diff --git a/lib/Cake/Console/Command/Task/ProjectTask.php b/lib/Cake/Console/Command/Task/ProjectTask.php index 68c788e37..5b4f4de16 100644 --- a/lib/Cake/Console/Command/Task/ProjectTask.php +++ b/lib/Cake/Console/Command/Task/ProjectTask.php @@ -368,12 +368,9 @@ class ProjectTask extends AppShell { if ($File->write($result)) { Configure::write('Routing.prefixes', array($name)); return true; - } else { - return false; } - } else { - return false; } + return false; } /** @@ -417,7 +414,7 @@ class ProjectTask extends AppShell { $this->out(__d('cake_console', 'You need to enable %s in %s to use prefix routing.', 'Configure::write(\'Routing.prefixes\', array(\'admin\'))', '/app/Config/core.php')); - $this->_stop(); + return $this->_stop(); } return $admin . '_'; } diff --git a/lib/Cake/Console/Command/Task/ViewTask.php b/lib/Cake/Console/Command/Task/ViewTask.php index 15906bbdb..37c6f5228 100644 --- a/lib/Cake/Console/Command/Task/ViewTask.php +++ b/lib/Cake/Console/Command/Task/ViewTask.php @@ -267,7 +267,7 @@ class ViewTask extends BakeTask { if (!class_exists($controllerClassName)) { $file = $controllerClassName . '.php'; $this->err(__d('cake_console', "The file '%s' could not be found.\nIn order to bake a view, you'll need to first create the controller.", $file)); - $this->_stop(); + return $this->_stop(); } $controllerObj = new $controllerClassName(); $controllerObj->plugin = $this->plugin; @@ -334,10 +334,9 @@ class ViewTask extends BakeTask { $looksGood = $this->in(__d('cake_console', 'Look okay?'), array('y', 'n'), 'y'); if (strtolower($looksGood) === 'y') { $this->bake($action, ' '); - $this->_stop(); - } else { - $this->out(__d('cake_console', 'Bake Aborted.')); + return $this->_stop(); } + $this->out(__d('cake_console', 'Bake Aborted.')); } /** diff --git a/lib/Cake/Console/ConsoleErrorHandler.php b/lib/Cake/Console/ConsoleErrorHandler.php index c0ec663a8..1165031d9 100644 --- a/lib/Cake/Console/ConsoleErrorHandler.php +++ b/lib/Cake/Console/ConsoleErrorHandler.php @@ -60,7 +60,7 @@ class ConsoleErrorHandler { $exception->getMessage(), $exception->getTraceAsString() )); - $this->_stop($exception->getCode() ? $exception->getCode() : 1); + return $this->_stop($exception->getCode() ? $exception->getCode() : 1); } /** @@ -88,7 +88,7 @@ class ConsoleErrorHandler { } if ($log === LOG_ERR) { - $this->_stop(1); + return $this->_stop(1); } } diff --git a/lib/Cake/Console/Shell.php b/lib/Cake/Console/Shell.php index 71e66d581..8053813be 100644 --- a/lib/Cake/Console/Shell.php +++ b/lib/Cake/Console/Shell.php @@ -547,7 +547,7 @@ class Shell extends Object { $result = $this->stdin->read(); if ($result === false) { - $this->_stop(1); + return $this->_stop(1); } $result = trim($result); @@ -661,7 +661,7 @@ class Shell extends Object { if (!empty($message)) { $this->err($message); } - $this->_stop(1); + return $this->_stop(1); } /** @@ -699,7 +699,7 @@ class Shell extends Object { if (strtolower($key) === 'q') { $this->out(__d('cake_console', 'Quitting.'), 2); - $this->_stop(); + return $this->_stop(); } elseif (strtolower($key) !== 'y') { $this->out(__d('cake_console', 'Skip `%s`', $path), 2); return false; diff --git a/lib/Cake/Console/ShellDispatcher.php b/lib/Cake/Console/ShellDispatcher.php index c039db205..0be88001c 100644 --- a/lib/Cake/Console/ShellDispatcher.php +++ b/lib/Cake/Console/ShellDispatcher.php @@ -65,7 +65,7 @@ class ShellDispatcher { */ public static function run($argv) { $dispatcher = new ShellDispatcher($argv); - $dispatcher->_stop($dispatcher->dispatch() === false ? 1 : 0); + return $dispatcher->_stop($dispatcher->dispatch() === false ? 1 : 0); } /** diff --git a/lib/Cake/Controller/Component/Auth/FormAuthenticate.php b/lib/Cake/Controller/Component/Auth/FormAuthenticate.php index 78e5cbbc4..d1da01f27 100644 --- a/lib/Cake/Controller/Component/Auth/FormAuthenticate.php +++ b/lib/Cake/Controller/Component/Auth/FormAuthenticate.php @@ -61,7 +61,7 @@ class FormAuthenticate extends BaseAuthenticate { /** * Authenticates the identity contained in a request. Will use the `settings.userModel`, and `settings.fields` * to find POST data that is used to find a matching record in the `settings.userModel`. Will return false if - * there is no post data, either username or password is missing, of if the scope conditions have not been met. + * there is no post data, either username or password is missing, or if the scope conditions have not been met. * * @param CakeRequest $request The request that contains login information. * @param CakeResponse $response Unused response object. diff --git a/lib/Cake/Controller/Scaffold.php b/lib/Cake/Controller/Scaffold.php index 27aecb8ed..c63ab7b32 100644 --- a/lib/Cake/Controller/Scaffold.php +++ b/lib/Cake/Controller/Scaffold.php @@ -250,13 +250,11 @@ class Scaffold { $success ); return $this->_sendMessage($message); - } else { - return $this->controller->afterScaffoldSaveError($action); - } - } else { - if ($this->_validSession) { - $this->controller->Session->setFlash(__d('cake', 'Please correct errors below.')); } + return $this->controller->afterScaffoldSaveError($action); + } + if ($this->_validSession) { + $this->controller->Session->setFlash(__d('cake', 'Please correct errors below.')); } } @@ -309,14 +307,13 @@ class Scaffold { if ($this->ScaffoldModel->delete()) { $message = __d('cake', 'The %1$s with id: %2$s has been deleted.', Inflector::humanize($this->modelClass), $id); return $this->_sendMessage($message); - } else { - $message = __d('cake', - 'There was an error deleting the %1$s with id: %2$s', - Inflector::humanize($this->modelClass), - $id - ); - return $this->_sendMessage($message); } + $message = __d('cake', + 'There was an error deleting the %1$s with id: %2$s', + Inflector::humanize($this->modelClass), + $id + ); + return $this->_sendMessage($message); } elseif ($this->controller->scaffoldError('delete') === false) { return $this->_scaffoldError(); } @@ -388,21 +385,21 @@ class Scaffold { case 'index': case 'list': $this->_scaffoldIndex($request); - break; + break; case 'view': $this->_scaffoldView($request); - break; + break; case 'add': case 'create': $this->_scaffoldSave($request, 'add'); - break; + break; case 'edit': case 'update': $this->_scaffoldSave($request, 'edit'); - break; + break; case 'delete': $this->_scaffoldDelete($request); - break; + break; } } else { throw new MissingActionException(array( diff --git a/lib/Cake/Core/App.php b/lib/Cake/Core/App.php index 9d0309bea..fad7b83a1 100644 --- a/lib/Cake/Core/App.php +++ b/lib/Cake/Core/App.php @@ -535,6 +535,9 @@ class App { if (!isset(self::$_classMap[$className])) { return false; } + if (strpos($className, '..') !== false) { + return false; + } $parts = explode('.', self::$_classMap[$className], 2); list($plugin, $package) = count($parts) > 1 ? $parts : array(null, current($parts)); diff --git a/lib/Cake/Error/ErrorHandler.php b/lib/Cake/Error/ErrorHandler.php index 117c76fbd..c8333bb82 100644 --- a/lib/Cake/Error/ErrorHandler.php +++ b/lib/Cake/Error/ErrorHandler.php @@ -219,14 +219,13 @@ class ErrorHandler { 'path' => Debugger::trimPath($file) ); return Debugger::getInstance()->outputError($data); - } else { - $message = $error . ' (' . $code . '): ' . $description . ' in [' . $file . ', line ' . $line . ']'; - if (!empty($errorConfig['trace'])) { - $trace = Debugger::trace(array('start' => 1, 'format' => 'log')); - $message .= "\nTrace:\n" . $trace . "\n"; - } - return CakeLog::write($log, $message); } + $message = $error . ' (' . $code . '): ' . $description . ' in [' . $file . ', line ' . $line . ']'; + if (!empty($errorConfig['trace'])) { + $trace = Debugger::trace(array('start' => 1, 'format' => 'log')); + $message .= "\nTrace:\n" . $trace . "\n"; + } + return CakeLog::write($log, $message); } /** @@ -275,28 +274,28 @@ class ErrorHandler { case E_USER_ERROR: $error = 'Fatal Error'; $log = LOG_ERR; - break; + break; case E_WARNING: case E_USER_WARNING: case E_COMPILE_WARNING: case E_RECOVERABLE_ERROR: $error = 'Warning'; $log = LOG_WARNING; - break; + break; case E_NOTICE: case E_USER_NOTICE: $error = 'Notice'; $log = LOG_NOTICE; - break; + break; case E_STRICT: $error = 'Strict'; $log = LOG_NOTICE; - break; + break; case E_DEPRECATED: case E_USER_DEPRECATED: $error = 'Deprecated'; $log = LOG_NOTICE; - break; + break; } return array($error, $log); } diff --git a/lib/Cake/Model/Behavior/TreeBehavior.php b/lib/Cake/Model/Behavior/TreeBehavior.php index 310aa4c78..8bbf55dbd 100644 --- a/lib/Cake/Model/Behavior/TreeBehavior.php +++ b/lib/Cake/Model/Behavior/TreeBehavior.php @@ -822,17 +822,16 @@ class TreeBehavior extends ModelBehavior { array($Model->escapeField() => $id) ); return $Model->delete($id); - } else { - $edge = $this->_getMax($Model, $scope, $right, $recursive); - if ($node[$right] == $edge) { - $edge = $edge - 2; - } - $Model->id = $id; - return $Model->save( - array($left => $edge + 1, $right => $edge + 2, $parent => null), - array('callbacks' => false, 'validate' => false) - ); } + $edge = $this->_getMax($Model, $scope, $right, $recursive); + if ($node[$right] == $edge) { + $edge = $edge - 2; + } + $Model->id = $id; + return $Model->save( + array($left => $edge + 1, $right => $edge + 2, $parent => null), + array('callbacks' => false, 'validate' => false) + ); } /** diff --git a/lib/Cake/Model/Datasource/DataSource.php b/lib/Cake/Model/Datasource/DataSource.php index 9d091599e..e30353fd5 100644 --- a/lib/Cake/Model/Datasource/DataSource.php +++ b/lib/Cake/Model/Datasource/DataSource.php @@ -357,7 +357,7 @@ class DataSource extends Object { } } $type = $model->getColumnType($model->primaryKey); - break; + break; case '{$__cakeForeignKey__$}': foreach ($model->associations() as $name) { foreach ($model->$name as $assocName => $assoc) { @@ -389,7 +389,7 @@ class DataSource extends Object { } } } - break; + break; } if (empty($val) && $val !== '0') { return false; diff --git a/lib/Cake/Model/Datasource/Database/Mysql.php b/lib/Cake/Model/Datasource/Database/Mysql.php index 5eee65dfe..e456ea744 100644 --- a/lib/Cake/Model/Datasource/Database/Mysql.php +++ b/lib/Cake/Model/Datasource/Database/Mysql.php @@ -200,17 +200,16 @@ class Mysql extends DboSource { if (!$result) { $result->closeCursor(); return array(); - } else { - $tables = array(); - - while ($line = $result->fetch(PDO::FETCH_NUM)) { - $tables[] = $line[0]; - } - - $result->closeCursor(); - parent::listSources($tables); - return $tables; } + $tables = array(); + + while ($line = $result->fetch(PDO::FETCH_NUM)) { + $tables[] = $line[0]; + } + + $result->closeCursor(); + parent::listSources($tables); + return $tables; } /** @@ -521,13 +520,13 @@ class Mysql extends DboSource { } $colList[] = $alter; } - break; + break; case 'drop': foreach ($column as $field => $col) { $col['name'] = $field; $colList[] = 'DROP ' . $this->name($field); } - break; + break; case 'change': foreach ($column as $field => $col) { if (!isset($col['name'])) { @@ -535,7 +534,7 @@ class Mysql extends DboSource { } $colList[] = 'CHANGE ' . $this->name($field) . ' ' . $this->buildColumn($col); } - break; + break; } } $colList = array_merge($colList, $this->_alterIndexes($curTable, $indexes)); @@ -684,24 +683,23 @@ class Mysql extends DboSource { if (!$result) { $result->closeCursor(); return array(); - } else { - $tables = array(); - foreach ($result as $row) { - $tables[$row['Name']] = (array)$row; - unset($tables[$row['Name']]['queryString']); - if (!empty($row['Collation'])) { - $charset = $this->getCharsetName($row['Collation']); - if ($charset) { - $tables[$row['Name']]['charset'] = $charset; - } + } + $tables = array(); + foreach ($result as $row) { + $tables[$row['Name']] = (array)$row; + unset($tables[$row['Name']]['queryString']); + if (!empty($row['Collation'])) { + $charset = $this->getCharsetName($row['Collation']); + if ($charset) { + $tables[$row['Name']]['charset'] = $charset; } } - $result->closeCursor(); - if (is_string($name) && isset($tables[$name])) { - return $tables[$name]; - } - return $tables; } + $result->closeCursor(); + if (is_string($name) && isset($tables[$name])) { + return $tables[$name]; + } + return $tables; } /** diff --git a/lib/Cake/Model/Datasource/Database/Postgres.php b/lib/Cake/Model/Datasource/Database/Postgres.php index 342427f3c..43039000b 100644 --- a/lib/Cake/Model/Datasource/Database/Postgres.php +++ b/lib/Cake/Model/Datasource/Database/Postgres.php @@ -305,9 +305,8 @@ class Postgres extends DboSource { } if (isset($this->_sequenceMap[$table][$field])) { return $this->_sequenceMap[$table][$field]; - } else { - return "{$table}_{$field}_seq"; } + return "{$table}_{$field}_seq"; } /** @@ -521,13 +520,13 @@ class Postgres extends DboSource { $col['name'] = $field; $colList[] = 'ADD COLUMN ' . $this->buildColumn($col); } - break; + break; case 'drop': foreach ($column as $field => $col) { $col['name'] = $field; $colList[] = 'DROP COLUMN ' . $this->name($field); } - break; + break; case 'change': foreach ($column as $field => $col) { if (!isset($col['name'])) { @@ -557,7 +556,7 @@ class Postgres extends DboSource { } } - break; + break; } } if (isset($indexes['drop']['PRIMARY'])) { @@ -753,21 +752,19 @@ class Postgres extends DboSource { switch ($type) { case 'bool': $resultRow[$table][$column] = is_null($row[$index]) ? null : $this->boolean($row[$index]); - break; + break; case 'binary': case 'bytea': $resultRow[$table][$column] = is_null($row[$index]) ? null : stream_get_contents($row[$index]); - break; + break; default: $resultRow[$table][$column] = $row[$index]; - break; } } return $resultRow; - } else { - $this->_result->closeCursor(); - return false; } + $this->_result->closeCursor(); + return false; } /** @@ -793,7 +790,6 @@ class Postgres extends DboSource { break; default: $result = (bool)$data; - break; } if ($quote) { diff --git a/lib/Cake/Model/Datasource/Database/Sqlite.php b/lib/Cake/Model/Datasource/Database/Sqlite.php index 6d3e15fcd..eabcb0876 100644 --- a/lib/Cake/Model/Datasource/Database/Sqlite.php +++ b/lib/Cake/Model/Datasource/Database/Sqlite.php @@ -362,10 +362,9 @@ class Sqlite extends DboSource { } } return $resultRow; - } else { - $this->_result->closeCursor(); - return false; } + $this->_result->closeCursor(); + return false; } /** diff --git a/lib/Cake/Model/Datasource/Database/Sqlserver.php b/lib/Cake/Model/Datasource/Database/Sqlserver.php index d342bb0b0..6845fad00 100644 --- a/lib/Cake/Model/Datasource/Database/Sqlserver.php +++ b/lib/Cake/Model/Datasource/Database/Sqlserver.php @@ -172,17 +172,16 @@ class Sqlserver extends DboSource { if (!$result) { $result->closeCursor(); return array(); - } else { - $tables = array(); - - while ($line = $result->fetch(PDO::FETCH_NUM)) { - $tables[] = $line[0]; - } - - $result->closeCursor(); - parent::listSources($tables); - return $tables; } + $tables = array(); + + while ($line = $result->fetch(PDO::FETCH_NUM)) { + $tables[] = $line[0]; + } + + $result->closeCursor(); + parent::listSources($tables); + return $tables; } /** @@ -318,9 +317,8 @@ class Sqlserver extends DboSource { $result[] = $prepend . $fields[$i]; } return $result; - } else { - return $fields; } + return $fields; } /** @@ -539,10 +537,8 @@ class Sqlserver extends DboSource { "; } elseif (strpos($limit, 'FETCH') !== false) { return "SELECT {$fields} FROM {$table} {$alias} {$joins} {$conditions} {$group} {$order} {$limit}"; - } else { - return "SELECT {$limit} {$fields} FROM {$table} {$alias} {$joins} {$conditions} {$group} {$order}"; } - break; + return "SELECT {$limit} {$fields} FROM {$table} {$alias} {$joins} {$conditions} {$group} {$order}"; case "schema": extract($data); diff --git a/lib/Cake/Model/Datasource/DboSource.php b/lib/Cake/Model/Datasource/DboSource.php index 7bc3a048b..2944f64f7 100644 --- a/lib/Cake/Model/Datasource/DboSource.php +++ b/lib/Cake/Model/Datasource/DboSource.php @@ -592,25 +592,23 @@ class DboSource extends DataSource { $recursive = $params[5 + $off]; } return $args[2]->find('all', compact('conditions', 'fields', 'order', 'limit', 'page', 'recursive')); + } + if (isset($params[3 + $off])) { + $recursive = $params[3 + $off]; + } + return $args[2]->find('first', compact('conditions', 'fields', 'order', 'recursive')); + } + if (isset($args[1]) && $args[1] === true) { + return $this->fetchAll($args[0], true); + } elseif (isset($args[1]) && !is_array($args[1])) { + return $this->fetchAll($args[0], false); + } elseif (isset($args[1]) && is_array($args[1])) { + if (isset($args[2])) { + $cache = $args[2]; } else { - if (isset($params[3 + $off])) { - $recursive = $params[3 + $off]; - } - return $args[2]->find('first', compact('conditions', 'fields', 'order', 'recursive')); - } - } else { - if (isset($args[1]) && $args[1] === true) { - return $this->fetchAll($args[0], true); - } elseif (isset($args[1]) && !is_array($args[1])) { - return $this->fetchAll($args[0], false); - } elseif (isset($args[1]) && is_array($args[1])) { - if (isset($args[2])) { - $cache = $args[2]; - } else { - $cache = true; - } - return $this->fetchAll($args[0], $args[1], array('cache' => $cache)); + $cache = true; } + return $this->fetchAll($args[0], $args[1], array('cache' => $cache)); } } @@ -632,9 +630,8 @@ class DboSource extends DataSource { $this->fetchVirtualField($resultRow); } return $resultRow; - } else { - return null; } + return null; } /** @@ -1569,7 +1566,7 @@ class DboSource extends DataSource { } return true; } - break; + break; case 'hasMany': $assocData['fields'] = $this->fields($linkModel, $association, $assocData['fields']); if (!empty($assocData['foreignKey'])) { @@ -1585,7 +1582,7 @@ class DboSource extends DataSource { 'offset' => $assocData['offset'], 'group' => null ); - break; + break; case 'hasAndBelongsToMany': $joinFields = array(); $joinAssoc = null; @@ -1622,7 +1619,7 @@ class DboSource extends DataSource { 'conditions' => $this->getConstraint('hasAndBelongsToMany', $model, $linkModel, $joinAlias, $assocData, $association) )) ); - break; + break; } if (isset($query)) { return $this->buildStatement($query, $model); @@ -2596,22 +2593,22 @@ class DboSource extends DataSource { switch ($operator) { case '=': $operator = 'IN'; - break; + break; case '!=': case '<>': $operator = 'NOT IN'; - break; + break; } $value = "({$value})"; } elseif ($null || $value === 'NULL') { switch ($operator) { case '=': $operator = 'IS'; - break; + break; case '!=': case '<>': $operator = 'IS NOT'; - break; + break; } } if ($virtual) { diff --git a/lib/Cake/Model/Model.php b/lib/Cake/Model/Model.php index 6e73f16f0..6f7c95bc7 100644 --- a/lib/Cake/Model/Model.php +++ b/lib/Cake/Model/Model.php @@ -1058,34 +1058,34 @@ class Model extends Object implements CakeEventListener { switch ($key) { case 'fields': $data = ''; - break; + break; case 'foreignKey': $data = (($type === 'belongsTo') ? Inflector::underscore($assocKey) : Inflector::singularize($this->table)) . '_id'; - break; + break; case 'associationForeignKey': $data = Inflector::singularize($this->{$class}->table) . '_id'; - break; + break; case 'with': $data = Inflector::camelize(Inflector::singularize($this->{$type}[$assocKey]['joinTable'])); $dynamicWith = true; - break; + break; case 'joinTable': $tables = array($this->table, $this->{$class}->table); sort($tables); $data = $tables[0] . '_' . $tables[1]; - break; + break; case 'className': $data = $class; - break; + break; case 'unique': $data = true; - break; + break; } $this->{$type}[$assocKey][$key] = $data; } @@ -1255,11 +1255,11 @@ class Model extends Object implements CakeEventListener { isset($data['meridian']) && !empty($data['hour']) && $data['hour'] != 12 && - 'pm' == $data['meridian'] + $data['meridian'] === 'pm' ) { $data['hour'] = $data['hour'] + 12; } - if (isset($data['hour']) && isset($data['meridian']) && $data['hour'] == 12 && 'am' == $data['meridian']) { + if (isset($data['hour']) && isset($data['meridian']) && $data['hour'] == 12 && $data['meridian'] === 'am') { $data['hour'] = '00'; } if ($type === 'time') { @@ -2303,7 +2303,7 @@ class Model extends Object implements CakeEventListener { $validationErrors[$association] = $this->{$association}->validationErrors; } $return[$association] = $validates; - break; + break; case 'hasMany': foreach ($values as $i => $value) { if (isset($values[$i][$association])) { @@ -2319,7 +2319,7 @@ class Model extends Object implements CakeEventListener { $validates = false; } $return[$association] = $_return; - break; + break; } } } diff --git a/lib/Cake/Model/Permission.php b/lib/Cake/Model/Permission.php index 61044445a..16572eb57 100644 --- a/lib/Cake/Model/Permission.php +++ b/lib/Cake/Model/Permission.php @@ -123,33 +123,32 @@ class Permission extends AppModel { if (empty($perms)) { continue; - } else { - $perms = Hash::extract($perms, '{n}.' . $this->alias); - foreach ($perms as $perm) { - if ($action === '*') { + } + $perms = Hash::extract($perms, '{n}.' . $this->alias); + foreach ($perms as $perm) { + if ($action === '*') { - foreach ($permKeys as $key) { - if (!empty($perm)) { - if ($perm[$key] == -1) { - return false; - } elseif ($perm[$key] == 1) { - $inherited[$key] = 1; - } + foreach ($permKeys as $key) { + if (!empty($perm)) { + if ($perm[$key] == -1) { + return false; + } elseif ($perm[$key] == 1) { + $inherited[$key] = 1; } } + } - if (count($inherited) === count($permKeys)) { + if (count($inherited) === count($permKeys)) { + return true; + } + } else { + switch ($perm['_' . $action]) { + case -1: + return false; + case 0: + continue; + case 1: return true; - } - } else { - switch ($perm['_' . $action]) { - case -1: - return false; - case 0: - continue; - case 1: - return true; - } } } } diff --git a/lib/Cake/Model/Validator/CakeValidationRule.php b/lib/Cake/Model/Validator/CakeValidationRule.php index d9df05f7b..1f8134fb7 100644 --- a/lib/Cake/Model/Validator/CakeValidationRule.php +++ b/lib/Cake/Model/Validator/CakeValidationRule.php @@ -148,9 +148,8 @@ class CakeValidationRule { if (in_array($this->required, array('create', 'update'), true)) { if ($this->required === 'create' && !$this->isUpdate() || $this->required === 'update' && $this->isUpdate()) { return true; - } else { - return false; } + return false; } return $this->required; diff --git a/lib/Cake/Network/CakeRequest.php b/lib/Cake/Network/CakeRequest.php index 38b71e1fd..7bd386c39 100644 --- a/lib/Cake/Network/CakeRequest.php +++ b/lib/Cake/Network/CakeRequest.php @@ -257,7 +257,15 @@ class CakeRequest implements ArrayAccess { list($uri) = explode('?', $uri, 2); } if (empty($uri) || $uri === '/' || $uri === '//' || $uri === '/index.php') { - return '/'; + $uri = '/'; + } + $endsWithIndex = '/webroot/index.php'; + $endsWithLength = strlen($endsWithIndex); + if ( + strlen($uri) >= $endsWithLength && + substr($uri, -$endsWithLength) === $endsWithIndex + ) { + $uri = '/'; } return $uri; } @@ -265,7 +273,12 @@ class CakeRequest implements ArrayAccess { /** * Returns a base URL and sets the proper webroot * + * If CakePHP is called with index.php in the URL even though + * URL Rewriting is activated (and thus not needed) it swallows + * the unnecessary part from $base to prevent issue #3318. + * * @return string Base URL + * @link https://cakephp.lighthouseapp.com/projects/42648-cakephp/tickets/3318 */ protected function _base() { $dir = $webroot = null; @@ -283,6 +296,10 @@ class CakeRequest implements ArrayAccess { if (!$baseUrl) { $base = dirname(env('PHP_SELF')); + $indexPos = strpos($base, '/webroot/index.php'); + if ($indexPos !== false) { + $base = substr($base, 0, $indexPos) . '/webroot'; + } if ($webroot === 'webroot' && $webroot === basename($base)) { $base = dirname($base); } @@ -295,6 +312,7 @@ class CakeRequest implements ArrayAccess { } $base = implode('/', array_map('rawurlencode', explode('/', $base))); $this->webroot = $base . '/'; + return $this->base = $base; } diff --git a/lib/Cake/Network/CakeSocket.php b/lib/Cake/Network/CakeSocket.php index 231261187..43f5318c4 100644 --- a/lib/Cake/Network/CakeSocket.php +++ b/lib/Cake/Network/CakeSocket.php @@ -382,11 +382,10 @@ class CakeSocket { if ($enableCryptoResult === true) { $this->encrypted = $enable; return true; - } else { - $errorMessage = __d('cake_dev', 'Unable to perform enableCrypto operation on CakeSocket'); - $this->setLastError(null, $errorMessage); - throw new SocketException($errorMessage); } + $errorMessage = __d('cake_dev', 'Unable to perform enableCrypto operation on CakeSocket'); + $this->setLastError(null, $errorMessage); + throw new SocketException($errorMessage); } } diff --git a/lib/Cake/Network/Email/CakeEmail.php b/lib/Cake/Network/Email/CakeEmail.php index 09db74a68..308404f14 100644 --- a/lib/Cake/Network/Email/CakeEmail.php +++ b/lib/Cake/Network/Email/CakeEmail.php @@ -1092,8 +1092,6 @@ class CakeEmail { $content = implode("\n", $content) . "\n"; } - $this->_textMessage = $this->_htmlMessage = ''; - $this->_createBoundary(); $this->_message = $this->_render($this->_wrap($content)); $contents = $this->transportClass()->send($this); @@ -1477,9 +1475,12 @@ class CakeEmail { * @return array Email body ready to be sent */ protected function _render($content) { + $this->_textMessage = $this->_htmlMessage = ''; + $content = implode("\n", $content); $rendered = $this->_renderTemplates($content); + $this->_createBoundary(); $msg = array(); $contentIds = array_filter((array)Hash::extract($this->_attachments, '{s}.contentId')); @@ -1649,9 +1650,8 @@ class CakeEmail { $charset = strtoupper($this->charset); if (array_key_exists($charset, $this->_contentTypeCharset)) { return strtoupper($this->_contentTypeCharset[$charset]); - } else { - return strtoupper($this->charset); } + return strtoupper($this->charset); } } diff --git a/lib/Cake/Test/Case/Model/Behavior/AclBehaviorTest.php b/lib/Cake/Test/Case/Model/Behavior/AclBehaviorTest.php index 85234fa08..a971fb507 100644 --- a/lib/Cake/Test/Case/Model/Behavior/AclBehaviorTest.php +++ b/lib/Cake/Test/Case/Model/Behavior/AclBehaviorTest.php @@ -87,9 +87,8 @@ class AclPerson extends CakeTestModel { } if (!$motherId) { return null; - } else { - return array('AclPerson' => array('id' => $motherId)); } + return array('AclPerson' => array('id' => $motherId)); } } diff --git a/lib/Cake/Test/Case/Model/Behavior/ContainableBehaviorTest.php b/lib/Cake/Test/Case/Model/Behavior/ContainableBehaviorTest.php index 1829e3911..57a390069 100644 --- a/lib/Cake/Test/Case/Model/Behavior/ContainableBehaviorTest.php +++ b/lib/Cake/Test/Case/Model/Behavior/ContainableBehaviorTest.php @@ -3672,11 +3672,10 @@ class ContainableBehaviorTest extends CakeTestCase { if (!is_array($Model)) { $result = $Model->containments($contain); return $this->_containments($result['models']); - } else { - $result = $Model; - foreach ($result as $i => $containment) { - $result[$i] = array_diff_key($containment, array('instance' => true)); - } + } + $result = $Model; + foreach ($result as $i => $containment) { + $result[$i] = array_diff_key($containment, array('instance' => true)); } return $result; } diff --git a/lib/Cake/Test/Case/Model/BehaviorCollectionTest.php b/lib/Cake/Test/Case/Model/BehaviorCollectionTest.php index c11940cef..58a667baa 100644 --- a/lib/Cake/Test/Case/Model/BehaviorCollectionTest.php +++ b/lib/Cake/Test/Case/Model/BehaviorCollectionTest.php @@ -142,15 +142,15 @@ class TestBehavior extends ModelBehavior { switch ($settings['afterSave']) { case 'on': $model->data[$model->alias]['aftersave'] = $string; - break; + break; case 'test': unset($model->data[$model->alias]['name']); - break; + break; case 'test2': return false; case 'modify': $model->data[$model->alias]['name'] .= ' ' . $string; - break; + break; } } @@ -241,7 +241,7 @@ class TestBehavior extends ModelBehavior { switch ($settings['afterDelete']) { case 'on': echo 'afterDelete success'; - break; + break; } } diff --git a/lib/Cake/Test/Case/Network/CakeRequestTest.php b/lib/Cake/Test/Case/Network/CakeRequestTest.php index 07804d824..b8cc214e8 100644 --- a/lib/Cake/Test/Case/Network/CakeRequestTest.php +++ b/lib/Cake/Test/Case/Network/CakeRequestTest.php @@ -29,6 +29,12 @@ App::uses('CakeRequest', 'Network'); */ class TestCakeRequest extends CakeRequest { +/** + * reConstruct method + * + * @param string $url + * @param bool $parseEnvironment + */ public function reConstruct($url = 'some/path', $parseEnvironment = true) { $this->_base(); if (empty($url)) { @@ -49,10 +55,13 @@ class TestCakeRequest extends CakeRequest { } +/** + * Class CakeRequestTest + */ class CakeRequestTest extends CakeTestCase { /** - * setup callback + * Setup callback * * @return void */ @@ -69,7 +78,7 @@ class CakeRequestTest extends CakeTestCase { } /** - * tearDown + * TearDown * * @return void */ @@ -82,7 +91,7 @@ class CakeRequestTest extends CakeTestCase { } /** - * test that the autoparse = false constructor works. + * Test that the autoparse = false constructor works. * * @return void */ @@ -95,7 +104,7 @@ class CakeRequestTest extends CakeTestCase { } /** - * test construction + * Test construction * * @return void */ @@ -153,7 +162,7 @@ class CakeRequestTest extends CakeTestCase { } /** - * test addParams() method + * Test addParams() method * * @return void */ @@ -170,7 +179,7 @@ class CakeRequestTest extends CakeTestCase { } /** - * test splicing in paths. + * Test splicing in paths. * * @return void */ @@ -190,7 +199,7 @@ class CakeRequestTest extends CakeTestCase { } /** - * test parsing POST data into the object. + * Test parsing POST data into the object. * * @return void */ @@ -241,7 +250,7 @@ class CakeRequestTest extends CakeTestCase { } /** - * test parsing PUT data into the object. + * Test parsing PUT data into the object. * * @return void */ @@ -315,7 +324,7 @@ class CakeRequestTest extends CakeTestCase { } /** - * test parsing json PUT data into the object. + * Test parsing json PUT data into the object. * * @return void */ @@ -332,7 +341,7 @@ class CakeRequestTest extends CakeTestCase { } /** - * test parsing of FILES array + * Test parsing of FILES array * * @return void */ @@ -621,7 +630,7 @@ class CakeRequestTest extends CakeTestCase { } /** - * test method overrides coming in from POST data. + * Test method overrides coming in from POST data. * * @return void */ @@ -640,7 +649,7 @@ class CakeRequestTest extends CakeTestCase { } /** - * test the clientIp method. + * Test the clientIp method. * * @return void */ @@ -663,7 +672,7 @@ class CakeRequestTest extends CakeTestCase { } /** - * test the referer function. + * Test the referrer function. * * @return void */ @@ -782,7 +791,7 @@ class CakeRequestTest extends CakeTestCase { } /** - * test the method() method. + * Test the method() method. * * @return void */ @@ -794,7 +803,7 @@ class CakeRequestTest extends CakeTestCase { } /** - * test host retrieval. + * Test host retrieval. * * @return void */ @@ -806,7 +815,7 @@ class CakeRequestTest extends CakeTestCase { } /** - * test domain retrieval. + * Test domain retrieval. * * @return void */ @@ -821,7 +830,7 @@ class CakeRequestTest extends CakeTestCase { } /** - * test getting subdomains for a host. + * Test getting subdomains for a host. * * @return void */ @@ -842,7 +851,7 @@ class CakeRequestTest extends CakeTestCase { } /** - * test ajax, flash and friends + * Test ajax, flash and friends * * @return void */ @@ -876,7 +885,7 @@ class CakeRequestTest extends CakeTestCase { } /** - * test __call expcetions + * Test __call exceptions * * @expectedException CakeException * @return void @@ -887,7 +896,7 @@ class CakeRequestTest extends CakeTestCase { } /** - * test is(ssl) + * Test is(ssl) * * @return void */ @@ -920,7 +929,7 @@ class CakeRequestTest extends CakeTestCase { } /** - * test getting request params with object properties. + * Test getting request params with object properties. * * @return void */ @@ -955,7 +964,7 @@ class CakeRequestTest extends CakeTestCase { } /** - * test the array access implementation + * Test the array access implementation * * @return void */ @@ -986,7 +995,7 @@ class CakeRequestTest extends CakeTestCase { } /** - * test adding detectors and having them work. + * Test adding detectors and having them work. * * @return void */ @@ -1043,16 +1052,17 @@ class CakeRequestTest extends CakeTestCase { } /** - * helper function for testing callbacks. + * Helper function for testing callbacks. * - * @return void + * @param $request + * @return bool */ public function detectCallback($request) { return (bool)$request->return; } /** - * test getting headers + * Test getting headers * * @return void */ @@ -1066,7 +1076,7 @@ class CakeRequestTest extends CakeTestCase { } /** - * test accepts() with and without parameters + * Test accepts() with and without parameters * * @return void */ @@ -1151,7 +1161,7 @@ class CakeRequestTest extends CakeTestCase { } /** - * testBaseUrlAndWebrootWithModRewrite method + * Test baseUrl and webroot with ModRewrite * * @return void */ @@ -1220,7 +1230,7 @@ class CakeRequestTest extends CakeTestCase { } /** - * testBaseUrlwithModRewriteAlias method + * Test baseUrl with ModRewrite alias * * @return void */ @@ -1248,7 +1258,71 @@ class CakeRequestTest extends CakeTestCase { } /** - * test base, webroot, and url parsing when there is no url rewriting + * Test base, webroot, url and here parsing when there is url rewriting but + * CakePHP gets called with index.php in url nonetheless. + * + * Tests uri with + * - index.php/ + * - index.php/ + * - index.php/apples/ + * - index.php/bananas/eat/tasty_banana + * + * @link https://cakephp.lighthouseapp.com/projects/42648-cakephp/tickets/3318 + */ + public function testBaseUrlWithModRewriteAndIndexPhp() { + $_SERVER['REQUEST_URI'] = '/cakephp/app/webroot/index.php'; + $_SERVER['PHP_SELF'] = '/cakephp/app/webroot/index.php'; + unset($_SERVER['PATH_INFO']); + $request = new CakeRequest(); + + $this->assertEquals('/cakephp', $request->base); + $this->assertEquals('/cakephp/', $request->webroot); + $this->assertEquals('', $request->url); + $this->assertEquals('/cakephp/', $request->here); + + $_SERVER['REQUEST_URI'] = '/cakephp/app/webroot/index.php/'; + $_SERVER['PHP_SELF'] = '/cakephp/app/webroot/index.php/'; + $_SERVER['PATH_INFO'] = '/'; + $request = new CakeRequest(); + + $this->assertEquals('/cakephp', $request->base); + $this->assertEquals('/cakephp/', $request->webroot); + $this->assertEquals('', $request->url); + $this->assertEquals('/cakephp/', $request->here); + + $_SERVER['REQUEST_URI'] = '/cakephp/app/webroot/index.php/apples'; + $_SERVER['PHP_SELF'] = '/cakephp/app/webroot/index.php/apples'; + $_SERVER['PATH_INFO'] = '/apples'; + $request = new CakeRequest(); + + $this->assertEquals('/cakephp', $request->base); + $this->assertEquals('/cakephp/', $request->webroot); + $this->assertEquals('apples', $request->url); + $this->assertEquals('/cakephp/apples', $request->here); + + $_SERVER['REQUEST_URI'] = '/cakephp/app/webroot/index.php/melons/share/'; + $_SERVER['PHP_SELF'] = '/cakephp/app/webroot/index.php/melons/share/'; + $_SERVER['PATH_INFO'] = '/melons/share/'; + $request = new CakeRequest(); + + $this->assertEquals('/cakephp', $request->base); + $this->assertEquals('/cakephp/', $request->webroot); + $this->assertEquals('melons/share/', $request->url); + $this->assertEquals('/cakephp/melons/share/', $request->here); + + $_SERVER['REQUEST_URI'] = '/cakephp/app/webroot/index.php/bananas/eat/tasty_banana'; + $_SERVER['PHP_SELF'] = '/cakephp/app/webroot/index.php/bananas/eat/tasty_banana'; + $_SERVER['PATH_INFO'] = '/bananas/eat/tasty_banana'; + $request = new CakeRequest(); + + $this->assertEquals('/cakephp', $request->base); + $this->assertEquals('/cakephp/', $request->webroot); + $this->assertEquals('bananas/eat/tasty_banana', $request->url); + $this->assertEquals('/cakephp/bananas/eat/tasty_banana', $request->here); + } + +/** + * Test base, webroot, and url parsing when there is no url rewriting * * @return void */ @@ -1272,7 +1346,7 @@ class CakeRequestTest extends CakeTestCase { } /** - * testBaseUrlAndWebrootWithBaseUrl method + * Test baseUrl and webroot with baseUrl * * @return void */ @@ -1321,7 +1395,7 @@ class CakeRequestTest extends CakeTestCase { } /** - * test baseUrl with no rewrite and using the top level index.php. + * Test baseUrl with no rewrite and using the top level index.php. * * @return void */ @@ -1359,7 +1433,7 @@ class CakeRequestTest extends CakeTestCase { } /** - * test baseUrl with no rewrite, and using the app/webroot/index.php file as is normal with virtual hosts. + * Test baseUrl with no rewrite, and using the app/webroot/index.php file as is normal with virtual hosts. * * @return void */ @@ -1405,9 +1479,9 @@ class CakeRequestTest extends CakeTestCase { } /** - * generator for environment configurations + * Generator for environment configurations * - * @return void + * @return array Environment array */ public static function environmentGenerator() { return array( @@ -1779,9 +1853,12 @@ class CakeRequestTest extends CakeTestCase { } /** - * testEnvironmentDetection method + * Test environment detection * * @dataProvider environmentGenerator + * @param $name + * @param $env + * @param $expected * @return void */ public function testEnvironmentDetection($name, $env, $expected) { @@ -1798,7 +1875,7 @@ class CakeRequestTest extends CakeTestCase { } /** - * test the query() method + * Test the query() method * * @return void */ @@ -1816,7 +1893,7 @@ class CakeRequestTest extends CakeTestCase { } /** - * test the query() method with arrays passed via $_GET + * Test the query() method with arrays passed via $_GET * * @return void */ @@ -1857,7 +1934,7 @@ class CakeRequestTest extends CakeTestCase { } /** - * test the data() method reading + * Test the data() method reading * * @return void */ @@ -1876,7 +1953,7 @@ class CakeRequestTest extends CakeTestCase { } /** - * test writing with data() + * Test writing with data() * * @return void */ @@ -1898,7 +1975,7 @@ class CakeRequestTest extends CakeTestCase { } /** - * test writing falsey values. + * Test writing falsey values. * * @return void */ @@ -1919,7 +1996,7 @@ class CakeRequestTest extends CakeTestCase { } /** - * test accept language + * Test accept language * * @return void */ @@ -1962,7 +2039,7 @@ class CakeRequestTest extends CakeTestCase { } /** - * test the here() method + * Test the here() method * * @return void */ @@ -2065,7 +2142,7 @@ XML; } /** - * TestOnlyAllow + * Test onlyAllow method * * @return void */ @@ -2080,7 +2157,7 @@ XML; } /** - * TestOnlyAllow throwing exception + * Test onlyAllow throwing exception * */ public function testOnlyAllowException() { diff --git a/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php b/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php index 750e6b1d2..c6a6e45ee 100644 --- a/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php +++ b/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php @@ -65,6 +65,14 @@ class TestCakeEmail extends CakeEmail { return $this->_encode($text); } +/** + * Render to protected method + * + */ + public function render($content) { + return $this->_render($content); + } + } /* @@ -1578,6 +1586,22 @@ class CakeEmailTest extends CakeTestCase { $this->assertSame($expected, $result); } +/** + * testRender method + * + * @return void + */ + public function testRenderWithLayoutAndAttachment() { + $this->CakeEmail->emailFormat('html'); + $this->CakeEmail->template('html', 'default'); + $this->CakeEmail->attachments(array(CAKE . 'basics.php')); + $result = $this->CakeEmail->render(array()); + $this->assertNotEmpty($result); + + $result = $this->CakeEmail->getBoundary(); + $this->assertNotEmpty($result); + } + /** * testConstructWithConfigArray method * diff --git a/lib/Cake/TestSuite/CakeTestSuiteCommand.php b/lib/Cake/TestSuite/CakeTestSuiteCommand.php index 5d919020f..ab8fca7c2 100644 --- a/lib/Cake/TestSuite/CakeTestSuiteCommand.php +++ b/lib/Cake/TestSuite/CakeTestSuiteCommand.php @@ -122,9 +122,8 @@ class CakeTestSuiteCommand extends PHPUnit_TextUI_Command { exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT); } elseif (!isset($result) || $result->errorCount() > 0) { exit(PHPUnit_TextUI_TestRunner::EXCEPTION_EXIT); - } else { - exit(PHPUnit_TextUI_TestRunner::FAILURE_EXIT); } + exit(PHPUnit_TextUI_TestRunner::FAILURE_EXIT); } } diff --git a/lib/Cake/TestSuite/Fixture/CakeTestModel.php b/lib/Cake/TestSuite/Fixture/CakeTestModel.php index 0a0e25645..6e456c1cf 100644 --- a/lib/Cake/TestSuite/Fixture/CakeTestModel.php +++ b/lib/Cake/TestSuite/Fixture/CakeTestModel.php @@ -47,10 +47,9 @@ class CakeTestModel extends Model { case (is_string($queryData['fields']) && !($queryData['fields'] == $pk || $queryData['fields'] == $aliasedPk)) || (is_array($queryData['fields']) && !(array_key_exists($pk, $queryData['fields']) || array_key_exists($aliasedPk, $queryData['fields']))): - break; + break; default: $queryData['order'] = array($this->alias . '.' . $this->primaryKey => 'ASC'); - break; } return $queryData; } diff --git a/lib/Cake/Utility/CakeTime.php b/lib/Cake/Utility/CakeTime.php index a626794ff..422161a58 100644 --- a/lib/Cake/Utility/CakeTime.php +++ b/lib/Cake/Utility/CakeTime.php @@ -97,14 +97,13 @@ class CakeTime { * * @param string $name Variable name * @param mixes $value Variable value + * @return void */ public function __set($name, $value) { switch ($name) { case 'niceFormat': self::${$name} = $value; break; - default: - break; } } diff --git a/lib/Cake/Utility/Debugger.php b/lib/Cake/Utility/Debugger.php index 68417015c..871bd31b7 100644 --- a/lib/Cake/Utility/Debugger.php +++ b/lib/Cake/Utility/Debugger.php @@ -230,24 +230,24 @@ class Debugger { case E_USER_ERROR: $error = 'Fatal Error'; $level = LOG_ERR; - break; + break; case E_WARNING: case E_USER_WARNING: case E_COMPILE_WARNING: case E_RECOVERABLE_ERROR: $error = 'Warning'; $level = LOG_WARNING; - break; + break; case E_NOTICE: case E_USER_NOTICE: $error = 'Notice'; $level = LOG_NOTICE; - break; + break; case E_DEPRECATED: case E_USER_DEPRECATED: $error = 'Deprecated'; $level = LOG_NOTICE; - break; + break; default: return; } diff --git a/lib/Cake/Utility/Folder.php b/lib/Cake/Utility/Folder.php index f50465b2e..ca6c4128d 100644 --- a/lib/Cake/Utility/Folder.php +++ b/lib/Cake/Utility/Folder.php @@ -516,11 +516,10 @@ class Folder { umask($old); $this->_messages[] = __d('cake_dev', '%s created', $pathname); return true; - } else { - umask($old); - $this->_errors[] = __d('cake_dev', '%s NOT created', $pathname); - return false; } + umask($old); + $this->_errors[] = __d('cake_dev', '%s NOT created', $pathname); + return false; } } return false; @@ -810,9 +809,8 @@ class Folder { if (!empty($newparts)) { array_pop($newparts); continue; - } else { - return false; } + return false; } $newparts[] = $part; } diff --git a/lib/Cake/Utility/Hash.php b/lib/Cake/Utility/Hash.php index 607158b94..a0f64ebee 100644 --- a/lib/Cake/Utility/Hash.php +++ b/lib/Cake/Utility/Hash.php @@ -54,7 +54,6 @@ class Hash { } else { return null; } - } return $data; } diff --git a/lib/Cake/Utility/Inflector.php b/lib/Cake/Utility/Inflector.php index 6fc6400cf..aa1faeda1 100644 --- a/lib/Cake/Utility/Inflector.php +++ b/lib/Cake/Utility/Inflector.php @@ -308,7 +308,7 @@ class Inflector { } else { self::$_transliteration = $rules + self::$_transliteration; } - break; + break; default: foreach ($rules as $rule => $pattern) { @@ -334,7 +334,6 @@ class Inflector { } } self::${$var}['rules'] = $rules + self::${$var}['rules']; - break; } } diff --git a/lib/Cake/Utility/Validation.php b/lib/Cake/Utility/Validation.php index 222e51a4d..f40e80915 100644 --- a/lib/Cake/Utility/Validation.php +++ b/lib/Cake/Utility/Validation.php @@ -255,7 +255,6 @@ class Validation { break; default: self::$errors[] = __d('cake_dev', 'You must define the $operator parameter for Validation::comparison()'); - break; } return false; } @@ -822,9 +821,8 @@ class Validation { protected static function _check($check, $regex) { if (is_string($regex) && preg_match($regex, $check)) { return true; - } else { - return false; } + return false; } /** diff --git a/lib/Cake/View/Helper.php b/lib/Cake/View/Helper.php index 52f779601..4a4b17da9 100644 --- a/lib/Cake/View/Helper.php +++ b/lib/Cake/View/Helper.php @@ -662,18 +662,16 @@ class Helper extends Object { switch ($field) { case '_method': $name = $field; - break; + break; default: $name = 'data[' . implode('][', $this->entity()) . ']'; - break; } if (is_array($options)) { $options[$key] = $name; return $options; - } else { - return $name; } + return $name; } /** @@ -729,9 +727,8 @@ class Helper extends Object { if (is_array($options)) { $options[$key] = $result; return $options; - } else { - return $result; } + return $result; } /** @@ -920,7 +917,7 @@ class Helper extends Object { do { $oldstring = $this->_cleaned; $this->_cleaned = preg_replace('#]*>#i', "", $this->_cleaned); - } while ($oldstring != $this->_cleaned); + } while ($oldstring !== $this->_cleaned); $this->_cleaned = str_replace(array("&", "<", ">"), array("&amp;", "&lt;", "&gt;"), $this->_cleaned); } diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index f997325e4..2db90cc19 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -205,9 +205,8 @@ class FormHelper extends AppHelper { return $this->fieldset[$model]['fields']; } elseif (isset($this->fieldset[$model]['fields'][$field])) { return $this->fieldset[$model]['fields'][$field]; - } else { - return isset($object->hasAndBelongsToMany[$field]) ? array('type' => 'multiple') : null; } + return isset($object->hasAndBelongsToMany[$field]) ? array('type' => 'multiple') : null; } if ($key === 'errors' && !isset($this->validationErrors[$model])) { @@ -232,10 +231,9 @@ class FormHelper extends AppHelper { if ($key === 'validates') { if (empty($field)) { return $this->fieldset[$model]['validates']; - } else { - return isset($this->fieldset[$model]['validates'][$field]) ? - $this->fieldset[$model]['validates'] : null; } + return isset($this->fieldset[$model]['validates'][$field]) ? + $this->fieldset[$model]['validates'] : null; } } @@ -407,7 +405,7 @@ class FormHelper extends AppHelper { switch (strtolower($options['type'])) { case 'get': $htmlAttributes['method'] = 'get'; - break; + break; case 'file': $htmlAttributes['enctype'] = 'multipart/form-data'; $options['type'] = ($created) ? 'put' : 'post'; @@ -420,7 +418,6 @@ class FormHelper extends AppHelper { )); default: $htmlAttributes['method'] = 'post'; - break; } $this->requestType = strtolower($options['type']); @@ -734,9 +731,8 @@ class FormHelper extends AppHelper { $tag = is_string($options['wrap']) ? $options['wrap'] : 'div'; unset($options['wrap']); return $this->Html->tag($tag, $error, $options); - } else { - return $error; } + return $error; } /** @@ -2464,16 +2460,16 @@ class FormHelper extends AppHelper { $selects[] = $this->year( $fieldName, $minYear, $maxYear, $attrs['Year'] ); - break; + break; case 'M': $attrs['Month']['value'] = $month; $attrs['Month']['monthNames'] = $monthNames; $selects[] = $this->month($fieldName, $attrs['Month']); - break; + break; case 'D': $attrs['Day']['value'] = $day; $selects[] = $this->day($fieldName, $attrs['Day']); - break; + break; } } $opt = implode($separator, $selects); @@ -2485,7 +2481,7 @@ class FormHelper extends AppHelper { $attrs['Minute']['value'] = $min; $opt .= $this->hour($fieldName, true, $attrs['Hour']) . ':' . $this->minute($fieldName, $attrs['Minute']); - break; + break; case '12': $attrs['Hour']['value'] = $hour; $attrs['Minute']['value'] = $min; @@ -2493,7 +2489,7 @@ class FormHelper extends AppHelper { $opt .= $this->hour($fieldName, false, $attrs['Hour']) . ':' . $this->minute($fieldName, $attrs['Minute']) . ' ' . $this->meridian($fieldName, $attrs['Meridian']); - break; + break; } return $opt; } @@ -2581,9 +2577,8 @@ class FormHelper extends AppHelper { if (is_array($options)) { $options[$key] = $name; return $options; - } else { - return $name; } + return $name; } return parent::_name($options, $field, $key); } @@ -2727,20 +2722,20 @@ class FormHelper extends AppHelper { $data[sprintf('%02d', $i)] = sprintf('%02d', $i); $i += $interval; } - break; + break; case 'hour': for ($i = 1; $i <= 12; $i++) { $data[sprintf('%02d', $i)] = $i; } - break; + break; case 'hour24': for ($i = 0; $i <= 23; $i++) { $data[sprintf('%02d', $i)] = $i; } - break; + break; case 'meridian': $data = array('am' => 'am', 'pm' => 'pm'); - break; + break; case 'day': $min = 1; $max = 31; @@ -2755,7 +2750,7 @@ class FormHelper extends AppHelper { for ($i = $min; $i <= $max; $i++) { $data[sprintf('%02d', $i)] = $i; } - break; + break; case 'month': if ($options['monthNames'] === true) { $data['01'] = __d('cake', 'January'); @@ -2777,7 +2772,7 @@ class FormHelper extends AppHelper { $data[sprintf("%02s", $m)] = strftime("%m", mktime(1, 1, 1, $m, 1, 1999)); } } - break; + break; case 'year': $current = intval(date('Y')); @@ -2799,7 +2794,7 @@ class FormHelper extends AppHelper { if ($options['order'] !== 'asc') { $data = array_reverse($data, true); } - break; + break; } $this->_options[$name] = $data; return $this->_options[$name]; diff --git a/lib/Cake/View/Helper/HtmlHelper.php b/lib/Cake/View/Helper/HtmlHelper.php index 83de4f430..6249f7978 100644 --- a/lib/Cake/View/Helper/HtmlHelper.php +++ b/lib/Cake/View/Helper/HtmlHelper.php @@ -289,9 +289,8 @@ class HtmlHelper extends AppHelper { if (empty($options['block'])) { return $out; - } else { - $this->_View->append($options['block'], $out); } + $this->_View->append($options['block'], $out); } /** @@ -473,9 +472,8 @@ class HtmlHelper extends AppHelper { if (empty($options['block'])) { return $out; - } else { - $this->_View->append($options['block'], $out); } + $this->_View->append($options['block'], $out); } /** @@ -696,9 +694,8 @@ class HtmlHelper extends AppHelper { } } return implode($separator, $out); - } else { - return null; } + return null; } /** diff --git a/lib/Cake/View/Helper/JqueryEngineHelper.php b/lib/Cake/View/Helper/JqueryEngineHelper.php index 0bbc07c60..b72144a0c 100644 --- a/lib/Cake/View/Helper/JqueryEngineHelper.php +++ b/lib/Cake/View/Helper/JqueryEngineHelper.php @@ -235,7 +235,7 @@ class JqueryEngineHelper extends JsBaseEngineHelper { case 'slideDown': case 'slideUp': $effect = ".$name($speed);"; - break; + break; } return $this->selection . $effect; } diff --git a/lib/Cake/View/Helper/JsBaseEngineHelper.php b/lib/Cake/View/Helper/JsBaseEngineHelper.php index 23c91616d..a7afce88c 100644 --- a/lib/Cake/View/Helper/JsBaseEngineHelper.php +++ b/lib/Cake/View/Helper/JsBaseEngineHelper.php @@ -147,25 +147,24 @@ abstract class JsBaseEngineHelper extends AppHelper { switch (true) { case (is_array($val) || is_object($val)): $val = $this->object($val); - break; + break; case ($val === null): $val = 'null'; - break; + break; case (is_bool($val)): $val = ($val === true) ? 'true' : 'false'; - break; + break; case (is_int($val)): $val = $val; - break; + break; case (is_float($val)): $val = sprintf("%.11f", $val); - break; + break; default: $val = $this->escape($val); if ($quoteString) { $val = '"' . $val . '"'; } - break; } return $val; } diff --git a/lib/Cake/View/Helper/MootoolsEngineHelper.php b/lib/Cake/View/Helper/MootoolsEngineHelper.php index e5058bac5..5d66cf2e5 100644 --- a/lib/Cake/View/Helper/MootoolsEngineHelper.php +++ b/lib/Cake/View/Helper/MootoolsEngineHelper.php @@ -205,10 +205,10 @@ class MootoolsEngineHelper extends JsBaseEngineHelper { switch ($name) { case 'hide': $effect = 'setStyle("display", "none")'; - break; + break; case 'show': $effect = 'setStyle("display", "")'; - break; + break; case 'fadeIn': case 'fadeOut': case 'slideIn': @@ -219,7 +219,7 @@ class MootoolsEngineHelper extends JsBaseEngineHelper { $effect .= "set(\"$effectName\", {duration:$speed})."; } $effect .= "$effectName(\"$direction\")"; - break; + break; } return $this->selection . '.' . $effect . ';'; } diff --git a/lib/Cake/View/Helper/PaginatorHelper.php b/lib/Cake/View/Helper/PaginatorHelper.php index 78add68ac..d3ffb1503 100644 --- a/lib/Cake/View/Helper/PaginatorHelper.php +++ b/lib/Cake/View/Helper/PaginatorHelper.php @@ -507,22 +507,21 @@ class PaginatorHelper extends AppHelper { } $link = $this->link($title, $url, compact('escape', 'model') + $options); return $this->Html->tag($tag, $link, compact('class')); - } else { - unset($options['rel']); - if (!$tag) { - if ($disabledTag) { - $tag = $disabledTag; - $disabledTag = null; - } else { - $tag = $_defaults['tag']; - } - } - if ($disabledTag) { - $title = $this->Html->tag($disabledTag, $title, compact('escape') + $options); - return $this->Html->tag($tag, $title, compact('class')); - } - return $this->Html->tag($tag, $title, compact('escape', 'class') + $options); } + unset($options['rel']); + if (!$tag) { + if ($disabledTag) { + $tag = $disabledTag; + $disabledTag = null; + } else { + $tag = $_defaults['tag']; + } + } + if ($disabledTag) { + $title = $this->Html->tag($disabledTag, $title, compact('escape') + $options); + return $this->Html->tag($tag, $title, compact('class')); + } + return $this->Html->tag($tag, $title, compact('escape', 'class') + $options); } /** @@ -644,10 +643,10 @@ class PaginatorHelper extends AppHelper { } $out = $start . $options['separator'][0] . $end . $options['separator'][1]; $out .= $paging['count']; - break; + break; case 'pages': $out = $paging['page'] . $options['separator'] . $paging['pageCount']; - break; + break; default: $map = array( '%page%' => $paging['page'], @@ -664,7 +663,6 @@ class PaginatorHelper extends AppHelper { '{:page}', '{:pages}', '{:current}', '{:count}', '{:start}', '{:end}', '{:model}' ); $out = str_replace($newKeys, array_values($map), $out); - break; } return $out; } diff --git a/lib/Cake/View/Helper/PrototypeEngineHelper.php b/lib/Cake/View/Helper/PrototypeEngineHelper.php index 1807cb765..c20a9f781 100644 --- a/lib/Cake/View/Helper/PrototypeEngineHelper.php +++ b/lib/Cake/View/Helper/PrototypeEngineHelper.php @@ -212,17 +212,17 @@ class PrototypeEngineHelper extends JsBaseEngineHelper { case 'hide': case 'show': $effect = $this->selection . '.' . $name . '();'; - break; + break; case 'slideIn': case 'slideOut': $name = ($name === 'slideIn') ? 'slideDown' : 'slideUp'; $effect = 'Effect.' . $name . '(' . $this->selection . $optionString . ');'; - break; + break; case 'fadeIn': case 'fadeOut': $name = ($name === 'fadeIn') ? 'appear' : 'fade'; $effect = $this->selection . '.' . $name . '(' . substr($optionString, 2) . ');'; - break; + break; } return $effect; } diff --git a/lib/Cake/View/Helper/RssHelper.php b/lib/Cake/View/Helper/RssHelper.php index b3706767f..f1e22faaf 100644 --- a/lib/Cake/View/Helper/RssHelper.php +++ b/lib/Cake/View/Helper/RssHelper.php @@ -208,7 +208,7 @@ class RssHelper extends AppHelper { switch ($key) { case 'pubDate' : $val = $this->time($val); - break; + break; case 'category' : if (is_array($val) && !empty($val[0])) { foreach ($val as $category) { @@ -224,7 +224,7 @@ class RssHelper extends AppHelper { } elseif (is_array($val) && isset($val['domain'])) { $attrib['domain'] = $val['domain']; } - break; + break; case 'link': case 'guid': case 'comments': @@ -234,7 +234,7 @@ class RssHelper extends AppHelper { $val = $val['url']; } $val = $this->url($val, true); - break; + break; case 'source': if (is_array($val) && isset($val['url'])) { $attrib['url'] = $this->url($val['url'], true); @@ -243,7 +243,7 @@ class RssHelper extends AppHelper { $attrib['url'] = $this->url($val[0], true); $val = $val[1]; } - break; + break; case 'enclosure': if (is_string($val['url']) && is_file(WWW_ROOT . $val['url']) && file_exists(WWW_ROOT . $val['url'])) { if (!isset($val['length']) && strpos($val['url'], '://') === false) { @@ -256,7 +256,7 @@ class RssHelper extends AppHelper { $val['url'] = $this->url($val['url'], true); $attrib = $val; $val = null; - break; + break; default: $attrib = $att; } diff --git a/lib/Cake/View/Helper/TimeHelper.php b/lib/Cake/View/Helper/TimeHelper.php index 175dd002a..a5edd8ef3 100644 --- a/lib/Cake/View/Helper/TimeHelper.php +++ b/lib/Cake/View/Helper/TimeHelper.php @@ -75,10 +75,9 @@ class TimeHelper extends AppHelper { switch ($name) { case 'niceFormat': $this->_engine->{$name} = $value; - break; + break; default: $this->{$name} = $value; - break; } } diff --git a/lib/Cake/View/View.php b/lib/Cake/View/View.php index e5234d44e..962d8168f 100644 --- a/lib/Cake/View/View.php +++ b/lib/Cake/View/View.php @@ -564,9 +564,8 @@ class View extends Object { //@codingStandardsIgnoreEnd unset($out); return false; - } else { - return substr($out, strlen($match[0])); } + return substr($out, strlen($match[0])); } } diff --git a/lib/Cake/basics.php b/lib/Cake/basics.php index 7cb44859e..40a943946 100644 --- a/lib/Cake/basics.php +++ b/lib/Cake/basics.php @@ -404,13 +404,13 @@ if (!function_exists('cache')) { switch (strtolower($target)) { case 'cache': $filename = CACHE . $path; - break; + break; case 'public': $filename = WWW_ROOT . $path; - break; + break; case 'tmp': $filename = TMP . $path; - break; + break; } $timediff = $expires - $now; $filetime = false; @@ -472,29 +472,6 @@ if (!function_exists('clearCache')) { return false; } - foreach ($files as $file) { - if (is_file($file) && strrpos($file, DS . 'empty') !== strlen($file) - 6) { - //@codingStandardsIgnoreStart - @unlink($file); - //@codingStandardsIgnoreEnd - } - } - return true; - } else { - $cache = array( - CACHE . $type . DS . '*' . $params . $ext, - CACHE . $type . DS . '*' . $params . '_*' . $ext - ); - $files = array(); - while ($search = array_shift($cache)) { - $results = glob($search); - if ($results !== false) { - $files = array_merge($files, $results); - } - } - if (empty($files)) { - return false; - } foreach ($files as $file) { if (is_file($file) && strrpos($file, DS . 'empty') !== strlen($file) - 6) { //@codingStandardsIgnoreStart @@ -504,6 +481,29 @@ if (!function_exists('clearCache')) { } return true; } + $cache = array( + CACHE . $type . DS . '*' . $params . $ext, + CACHE . $type . DS . '*' . $params . '_*' . $ext + ); + $files = array(); + while ($search = array_shift($cache)) { + $results = glob($search); + if ($results !== false) { + $files = array_merge($files, $results); + } + } + if (empty($files)) { + return false; + } + foreach ($files as $file) { + if (is_file($file) && strrpos($file, DS . 'empty') !== strlen($file) - 6) { + //@codingStandardsIgnoreStart + @unlink($file); + //@codingStandardsIgnoreEnd + } + } + return true; + } elseif (is_array($params)) { foreach ($params as $file) { clearCache($file, $type, $ext);