mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
commit
2841611c0f
66 changed files with 213 additions and 236 deletions
|
@ -61,9 +61,8 @@ class ApcEngine extends CacheEngine {
|
|||
* @return boolean True if the data was successfully cached, false on failure
|
||||
*/
|
||||
public function write($key, $value, $duration) {
|
||||
if ($duration == 0) {
|
||||
$expires = 0;
|
||||
} else {
|
||||
$expires = 0;
|
||||
if ($duration) {
|
||||
$expires = time() + $duration;
|
||||
}
|
||||
apc_store($key . '_expires', $expires, $duration);
|
||||
|
|
|
@ -598,7 +598,7 @@ class AclShell extends AppShell {
|
|||
* @return array Variables
|
||||
*/
|
||||
protected function _dataVars($type = null) {
|
||||
if ($type == null) {
|
||||
if (!$type) {
|
||||
$type = $this->args[0];
|
||||
}
|
||||
$vars = array();
|
||||
|
|
|
@ -73,12 +73,13 @@ class ApiShell extends AppShell {
|
|||
$path = $this->paths['core'];
|
||||
}
|
||||
|
||||
if (count($this->args) == 1) {
|
||||
$file = $type;
|
||||
$class = Inflector::camelize($type);
|
||||
} elseif (count($this->args) > 1) {
|
||||
$count = count($this->args);
|
||||
if ($count > 1) {
|
||||
$file = Inflector::underscore($this->args[1]);
|
||||
$class = Inflector::camelize($this->args[1]);
|
||||
} elseif ($count) {
|
||||
$file = $type;
|
||||
$class = Inflector::camelize($type);
|
||||
}
|
||||
$objects = App::objects('class', $path);
|
||||
if (in_array($class, $objects)) {
|
||||
|
|
|
@ -182,7 +182,7 @@ class ConsoleShell extends AppShell {
|
|||
$this->out(" - {$model}");
|
||||
}
|
||||
break;
|
||||
case (preg_match("/^(\w+) bind (\w+) (\w+)/", $command, $tmp) == true):
|
||||
case preg_match("/^(\w+) bind (\w+) (\w+)/", $command, $tmp):
|
||||
foreach ($tmp as $data) {
|
||||
$data = strip_tags($data);
|
||||
$data = str_replace($this->badCommandChars, "", $data);
|
||||
|
@ -200,7 +200,7 @@ class ConsoleShell extends AppShell {
|
|||
$this->out(__d('cake_console', "Please verify you are using valid models and association types"));
|
||||
}
|
||||
break;
|
||||
case (preg_match("/^(\w+) unbind (\w+) (\w+)/", $command, $tmp) == true):
|
||||
case preg_match("/^(\w+) unbind (\w+) (\w+)/", $command, $tmp):
|
||||
foreach ($tmp as $data) {
|
||||
$data = strip_tags($data);
|
||||
$data = str_replace($this->badCommandChars, "", $data);
|
||||
|
@ -298,7 +298,7 @@ class ConsoleShell extends AppShell {
|
|||
$this->out(__d('cake_console', 'Saved record for %s', $modelToSave));
|
||||
}
|
||||
break;
|
||||
case (preg_match("/^(\w+) columns/", $command, $tmp) == true):
|
||||
case preg_match("/^(\w+) columns/", $command, $tmp):
|
||||
$modelToCheck = strip_tags(str_replace($this->badCommandChars, "", $tmp[1]));
|
||||
|
||||
if ($this->_isValidModel($modelToCheck)) {
|
||||
|
@ -315,22 +315,22 @@ class ConsoleShell extends AppShell {
|
|||
$this->out(__d('cake_console', "Please verify that you selected a valid model"));
|
||||
}
|
||||
break;
|
||||
case (preg_match("/^routes\s+reload/i", $command, $tmp) == true):
|
||||
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;
|
||||
case (preg_match("/^routes\s+show/i", $command, $tmp) == true):
|
||||
case preg_match("/^routes\s+show/i", $command, $tmp):
|
||||
$this->out(print_r(Hash::combine(Router::$routes, '{n}.template', '{n}.defaults'), true));
|
||||
break;
|
||||
case (preg_match("/^route\s+(\(.*\))$/i", $command, $tmp) == true):
|
||||
case preg_match("/^route\s+(\(.*\))$/i", $command, $tmp):
|
||||
if ($url = eval('return array' . $tmp[1] . ';')) {
|
||||
$this->out(Router::url($url));
|
||||
}
|
||||
break;
|
||||
case (preg_match("/^route\s+(.*)/i", $command, $tmp) == true):
|
||||
case preg_match("/^route\s+(.*)/i", $command, $tmp):
|
||||
$this->out(var_export(Router::parse($tmp[1]), true));
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -395,7 +395,7 @@ class ControllerTask extends BakeTask {
|
|||
}
|
||||
$this->__tables = $this->Model->getAllTables($useDbConfig);
|
||||
|
||||
if ($this->interactive == true) {
|
||||
if ($this->interactive) {
|
||||
$this->out(__d('cake_console', 'Possible Controllers based on your current database:'));
|
||||
$this->hr();
|
||||
$this->_controllerNames = array();
|
||||
|
@ -419,14 +419,14 @@ class ControllerTask extends BakeTask {
|
|||
$controllers = $this->listAll($useDbConfig);
|
||||
$enteredController = '';
|
||||
|
||||
while ($enteredController == '') {
|
||||
while (!$enteredController) {
|
||||
$enteredController = $this->in(__d('cake_console', "Enter a number from the list above,\ntype in the name of another controller, or 'q' to exit"), null, 'q');
|
||||
if ($enteredController === 'q') {
|
||||
$this->out(__d('cake_console', 'Exit'));
|
||||
return $this->_stop();
|
||||
}
|
||||
|
||||
if ($enteredController == '' || intval($enteredController) > count($controllers)) {
|
||||
if (!$enteredController || intval($enteredController) > count($controllers)) {
|
||||
$this->err(__d('cake_console', "The Controller name you supplied was empty,\nor the number you selected was not an option. Please try again."));
|
||||
$enteredController = '';
|
||||
}
|
||||
|
|
|
@ -92,10 +92,10 @@ class DbConfigTask extends AppShell {
|
|||
$done = false;
|
||||
$dbConfigs = array();
|
||||
|
||||
while ($done == false) {
|
||||
while (!$done) {
|
||||
$name = '';
|
||||
|
||||
while ($name == '') {
|
||||
while (!$name) {
|
||||
$name = $this->in(__d('cake_console', "Name:"), null, 'default');
|
||||
if (preg_match('/[^a-z0-9_]/i', $name)) {
|
||||
$name = '';
|
||||
|
@ -116,12 +116,12 @@ class DbConfigTask extends AppShell {
|
|||
}
|
||||
|
||||
$host = '';
|
||||
while ($host == '') {
|
||||
while (!$host) {
|
||||
$host = $this->in(__d('cake_console', 'Database Host:'), null, 'localhost');
|
||||
}
|
||||
|
||||
$port = '';
|
||||
while ($port == '') {
|
||||
while (!$port) {
|
||||
$port = $this->in(__d('cake_console', 'Port?'), null, 'n');
|
||||
}
|
||||
|
||||
|
@ -130,16 +130,16 @@ class DbConfigTask extends AppShell {
|
|||
}
|
||||
|
||||
$login = '';
|
||||
while ($login == '') {
|
||||
while (!$login) {
|
||||
$login = $this->in(__d('cake_console', 'User:'), null, 'root');
|
||||
}
|
||||
$password = '';
|
||||
$blankPassword = false;
|
||||
|
||||
while ($password == '' && $blankPassword == false) {
|
||||
while (!$password && !$blankPassword) {
|
||||
$password = $this->in(__d('cake_console', 'Password:'));
|
||||
|
||||
if ($password == '') {
|
||||
if (!$password) {
|
||||
$blank = $this->in(__d('cake_console', 'The password you supplied was empty. Use an empty password?'), array('y', 'n'), 'n');
|
||||
if ($blank == 'y') {
|
||||
$blankPassword = true;
|
||||
|
@ -148,12 +148,12 @@ class DbConfigTask extends AppShell {
|
|||
}
|
||||
|
||||
$database = '';
|
||||
while ($database == '') {
|
||||
while (!$database) {
|
||||
$database = $this->in(__d('cake_console', 'Database Name:'), null, 'cake');
|
||||
}
|
||||
|
||||
$prefix = '';
|
||||
while ($prefix == '') {
|
||||
while (!$prefix) {
|
||||
$prefix = $this->in(__d('cake_console', 'Table Prefix?'), null, 'n');
|
||||
}
|
||||
if (strtolower($prefix) == 'n') {
|
||||
|
@ -161,7 +161,7 @@ class DbConfigTask extends AppShell {
|
|||
}
|
||||
|
||||
$encoding = '';
|
||||
while ($encoding == '') {
|
||||
while (!$encoding) {
|
||||
$encoding = $this->in(__d('cake_console', 'Table encoding?'), null, 'n');
|
||||
}
|
||||
if (strtolower($encoding) == 'n') {
|
||||
|
@ -170,7 +170,7 @@ class DbConfigTask extends AppShell {
|
|||
|
||||
$schema = '';
|
||||
if ($datasource == 'postgres') {
|
||||
while ($schema == '') {
|
||||
while (!$schema) {
|
||||
$schema = $this->in(__d('cake_console', 'Table schema?'), null, 'n');
|
||||
}
|
||||
}
|
||||
|
@ -180,7 +180,7 @@ class DbConfigTask extends AppShell {
|
|||
|
||||
$config = compact('name', 'datasource', 'persistent', 'host', 'login', 'password', 'database', 'prefix', 'encoding', 'port', 'schema');
|
||||
|
||||
while ($this->_verify($config) == false) {
|
||||
while (!$this->_verify($config)) {
|
||||
$this->_interactive();
|
||||
}
|
||||
|
||||
|
@ -277,11 +277,7 @@ class DbConfigTask extends AppShell {
|
|||
$info['port'] = null;
|
||||
}
|
||||
|
||||
if ($info['persistent'] === false) {
|
||||
$info['persistent'] = 'false';
|
||||
} else {
|
||||
$info['persistent'] = ($info['persistent'] == true) ? 'true' : 'false';
|
||||
}
|
||||
$info['persistent'] = var_export((bool)$info['persistent'], true);
|
||||
|
||||
$oldConfigs[] = array(
|
||||
'name' => $configName,
|
||||
|
|
|
@ -391,7 +391,7 @@ class ExtractTask extends AppShell {
|
|||
$position = $count;
|
||||
$depth = 0;
|
||||
|
||||
while ($depth == 0) {
|
||||
while (!$depth) {
|
||||
if ($this->_tokens[$position] == '(') {
|
||||
$depth++;
|
||||
} elseif ($this->_tokens[$position] == ')') {
|
||||
|
@ -480,7 +480,7 @@ class ExtractTask extends AppShell {
|
|||
}
|
||||
|
||||
$dims = Hash::dimensions($rules);
|
||||
if ($dims == 1 || ($dims == 2 && isset($rules['message']))) {
|
||||
if ($dims === 1 || ($dims === 2 && isset($rules['message']))) {
|
||||
$rules = array($rules);
|
||||
}
|
||||
|
||||
|
@ -591,7 +591,7 @@ class ExtractTask extends AppShell {
|
|||
);
|
||||
if (strtoupper($response) === 'N') {
|
||||
$response = '';
|
||||
while ($response == '') {
|
||||
while (!$response) {
|
||||
$response = $this->in(__d('cake_console', "What would you like to name this file?"), null, 'new_' . $filename);
|
||||
$File = new File($this->_output . $response);
|
||||
$filename = $response;
|
||||
|
|
|
@ -472,16 +472,14 @@ class ModelTask extends BakeTask {
|
|||
}
|
||||
|
||||
if ($choice != $defaultChoice) {
|
||||
$validate[$validatorName] = $choice;
|
||||
if (is_numeric($choice) && isset($this->_validations[$choice])) {
|
||||
$validate[$validatorName] = $this->_validations[$choice];
|
||||
} else {
|
||||
$validate[$validatorName] = $choice;
|
||||
}
|
||||
}
|
||||
if ($this->interactive == true && $choice != $defaultChoice) {
|
||||
$anotherValidator = 'n';
|
||||
if ($this->interactive && $choice != $defaultChoice) {
|
||||
$anotherValidator = $this->in(__d('cake_console', 'Would you like to add another validation rule?'), array('y', 'n'), 'n');
|
||||
} else {
|
||||
$anotherValidator = 'n';
|
||||
}
|
||||
}
|
||||
return $validate;
|
||||
|
@ -583,7 +581,7 @@ class ModelTask extends BakeTask {
|
|||
|
||||
$pattern = '/_' . preg_quote($model->table, '/') . '|' . preg_quote($model->table, '/') . '_/';
|
||||
$possibleJoinTable = preg_match($pattern, $otherTable);
|
||||
if ($possibleJoinTable == true) {
|
||||
if ($possibleJoinTable) {
|
||||
continue;
|
||||
}
|
||||
foreach ($modelFieldsTemp as $fieldName => $field) {
|
||||
|
@ -780,7 +778,7 @@ class ModelTask extends BakeTask {
|
|||
*/
|
||||
public function bake($name, $data = array()) {
|
||||
if (is_object($name)) {
|
||||
if ($data == false) {
|
||||
if (!$data) {
|
||||
$data = array();
|
||||
$data['associations'] = $this->doAssociations($name);
|
||||
$data['validate'] = $this->doValidation($name);
|
||||
|
@ -935,7 +933,7 @@ class ModelTask extends BakeTask {
|
|||
|
||||
$enteredModel = '';
|
||||
|
||||
while ($enteredModel == '') {
|
||||
while (!$enteredModel) {
|
||||
$enteredModel = $this->in(__d('cake_console', "Enter a number from the list above,\n" .
|
||||
"type in the name of another model, or 'q' to exit"), null, 'q');
|
||||
|
||||
|
@ -944,18 +942,17 @@ class ModelTask extends BakeTask {
|
|||
$this->_stop();
|
||||
}
|
||||
|
||||
if ($enteredModel == '' || intval($enteredModel) > count($this->_modelNames)) {
|
||||
if (!$enteredModel || intval($enteredModel) > count($this->_modelNames)) {
|
||||
$this->err(__d('cake_console', "The model name you supplied was empty,\n" .
|
||||
"or the number you selected was not an option. Please try again."));
|
||||
$enteredModel = '';
|
||||
}
|
||||
}
|
||||
if (intval($enteredModel) > 0 && intval($enteredModel) <= count($this->_modelNames)) {
|
||||
$currentModelName = $this->_modelNames[intval($enteredModel) - 1];
|
||||
} else {
|
||||
$currentModelName = $enteredModel;
|
||||
return $this->_modelNames[intval($enteredModel) - 1];
|
||||
}
|
||||
return $currentModelName;
|
||||
|
||||
return $enteredModel;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -66,7 +66,7 @@ class ProjectTask extends AppShell {
|
|||
}
|
||||
|
||||
$response = false;
|
||||
while ($response == false && is_dir($project) === true && file_exists($project . 'Config' . 'core.php')) {
|
||||
while (!$response && is_dir($project) === true && file_exists($project . 'Config' . 'core.php')) {
|
||||
$prompt = __d('cake_console', '<warning>A project already exists in this location:</warning> %s Overwrite?', $project);
|
||||
$response = $this->in($prompt, array('y', 'n'), 'n');
|
||||
if (strtolower($response) === 'n') {
|
||||
|
@ -349,10 +349,7 @@ class ProjectTask extends AppShell {
|
|||
if (!file_put_contents($filename, $result)) {
|
||||
return false;
|
||||
}
|
||||
if ($count == 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return (bool)$count;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -387,7 +384,7 @@ class ProjectTask extends AppShell {
|
|||
$admin = '';
|
||||
$prefixes = Configure::read('Routing.prefixes');
|
||||
if (!empty($prefixes)) {
|
||||
if (count($prefixes) == 1) {
|
||||
if (count($prefixes) === 1) {
|
||||
return $prefixes[0] . '_';
|
||||
}
|
||||
if ($this->interactive) {
|
||||
|
@ -409,7 +406,7 @@ class ProjectTask extends AppShell {
|
|||
$this->out(__d('cake_console', 'You need to enable Configure::write(\'Routing.prefixes\',array(\'admin\')) in /app/Config/core.php to use prefix routing.'));
|
||||
$this->out(__d('cake_console', 'What would you like the prefix route to be?'));
|
||||
$this->out(__d('cake_console', 'Example: www.example.com/admin/controller'));
|
||||
while ($admin == '') {
|
||||
while (!$admin) {
|
||||
$admin = $this->in(__d('cake_console', 'Enter a routing prefix:'), null, 'admin');
|
||||
}
|
||||
if ($this->cakeAdmin($admin) !== true) {
|
||||
|
|
|
@ -123,7 +123,7 @@ class TemplateTask extends AppShell {
|
|||
$data = array($one => $two);
|
||||
}
|
||||
|
||||
if ($data == null) {
|
||||
if (!$data) {
|
||||
return false;
|
||||
}
|
||||
$this->templateVars = $data + $this->templateVars;
|
||||
|
@ -166,7 +166,7 @@ class TemplateTask extends AppShell {
|
|||
* @return string returns the path to the selected theme.
|
||||
*/
|
||||
public function getThemePath() {
|
||||
if (count($this->templatePaths) == 1) {
|
||||
if (count($this->templatePaths) === 1) {
|
||||
$paths = array_values($this->templatePaths);
|
||||
return $paths[0];
|
||||
}
|
||||
|
|
|
@ -83,15 +83,16 @@ class TestTask extends BakeTask {
|
|||
*/
|
||||
public function execute() {
|
||||
parent::execute();
|
||||
if (empty($this->args)) {
|
||||
$count = count($this->args);
|
||||
if (!$count) {
|
||||
$this->_interactive();
|
||||
}
|
||||
|
||||
if (count($this->args) == 1) {
|
||||
if ($count === 1) {
|
||||
$this->_interactive($this->args[0]);
|
||||
}
|
||||
|
||||
if (count($this->args) > 1) {
|
||||
if ($count > 1) {
|
||||
$type = Inflector::classify($this->args[0]);
|
||||
if ($this->bake($type, $this->args[1])) {
|
||||
$this->out('<success>Done</success>');
|
||||
|
|
|
@ -316,9 +316,9 @@ class ViewTask extends BakeTask {
|
|||
*/
|
||||
public function customAction() {
|
||||
$action = '';
|
||||
while ($action == '') {
|
||||
while (!$action) {
|
||||
$action = $this->in(__d('cake_console', 'Action Name? (use lowercase_underscored function name)'));
|
||||
if ($action == '') {
|
||||
if (!$action) {
|
||||
$this->out(__d('cake_console', 'The action name you supplied was empty. Please try again.'));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ class ConsoleErrorHandler {
|
|||
$message = __d('cake_console', '%s in [%s, line %s]', $description, $file, $line);
|
||||
$stderr->write(__d('cake_console', "<error>%s Error:</error> %s\n", $name, $message));
|
||||
|
||||
if (Configure::read('debug') == 0) {
|
||||
if (!Configure::read('debug')) {
|
||||
CakeLog::write($log, $message);
|
||||
}
|
||||
|
||||
|
|
|
@ -154,7 +154,7 @@ class Shell extends Object {
|
|||
* @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell
|
||||
*/
|
||||
public function __construct($stdout = null, $stderr = null, $stdin = null) {
|
||||
if ($this->name == null) {
|
||||
if (!$this->name) {
|
||||
$this->name = Inflector::camelize(str_replace(array('Shell', 'Task'), '', get_class($this)));
|
||||
}
|
||||
$this->Tasks = new TaskCollection($this);
|
||||
|
@ -162,13 +162,13 @@ class Shell extends Object {
|
|||
$this->stdout = $stdout;
|
||||
$this->stderr = $stderr;
|
||||
$this->stdin = $stdin;
|
||||
if ($this->stdout == null) {
|
||||
if (!$this->stdout) {
|
||||
$this->stdout = new ConsoleOutput('php://stdout');
|
||||
}
|
||||
if ($this->stderr == null) {
|
||||
if (!$this->stderr) {
|
||||
$this->stderr = new ConsoleOutput('php://stderr');
|
||||
}
|
||||
if ($this->stdin == null) {
|
||||
if (!$this->stdin) {
|
||||
$this->stdin = new ConsoleInput('php://stdin');
|
||||
}
|
||||
$this->_useLogger();
|
||||
|
@ -325,7 +325,7 @@ class Shell extends Object {
|
|||
*/
|
||||
public function dispatchShell() {
|
||||
$args = func_get_args();
|
||||
if (is_string($args[0]) && count($args) == 1) {
|
||||
if (is_string($args[0]) && count($args) === 1) {
|
||||
$args = explode(' ', $args[0]);
|
||||
}
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ class IniAcl extends Object implements AclInterface {
|
|||
* @return boolean Success
|
||||
*/
|
||||
public function check($aro, $aco, $action = null) {
|
||||
if ($this->config == null) {
|
||||
if (!$this->config) {
|
||||
$this->config = $this->readConfigFile(APP . 'Config' . DS . 'acl.ini.php');
|
||||
}
|
||||
$aclConfig = $this->config;
|
||||
|
|
|
@ -170,11 +170,11 @@ class PhpAcl extends Object implements AclInterface {
|
|||
foreach ($path as $depth => $node) {
|
||||
foreach ($prioritizedAros as $aros) {
|
||||
if (!empty($node['allow'])) {
|
||||
$allow = $allow || count(array_intersect($node['allow'], $aros)) > 0;
|
||||
$allow = $allow || count(array_intersect($node['allow'], $aros));
|
||||
}
|
||||
|
||||
if (!empty($node['deny'])) {
|
||||
$allow = $allow && count(array_intersect($node['deny'], $aros)) == 0;
|
||||
$allow = $allow && !count(array_intersect($node['deny'], $aros));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -391,7 +391,7 @@ class CookieComponent extends Component {
|
|||
}
|
||||
$this->_reset = $this->_expires;
|
||||
|
||||
if ($expires == 0) {
|
||||
if (!$expires) {
|
||||
return $this->_expires = 0;
|
||||
}
|
||||
|
||||
|
@ -517,7 +517,7 @@ class CookieComponent extends Component {
|
|||
$first = substr($string, 0, 1);
|
||||
if ($first === '{' || $first === '[') {
|
||||
$ret = json_decode($string, true);
|
||||
return ($ret != null) ? $ret : $string;
|
||||
return ($ret) ? $ret : $string;
|
||||
}
|
||||
$array = array();
|
||||
foreach (explode(',', $string) as $pair) {
|
||||
|
|
|
@ -316,7 +316,7 @@ class EmailComponent extends Component {
|
|||
foreach ($this->headers as $key => $value) {
|
||||
$headers['X-' . $key] = $value;
|
||||
}
|
||||
if ($this->date != false) {
|
||||
if ($this->date) {
|
||||
$headers['Date'] = $this->date;
|
||||
}
|
||||
$lib->setHeaders($headers);
|
||||
|
|
|
@ -314,7 +314,7 @@ class SecurityComponent extends Component {
|
|||
* @throws BadRequestException
|
||||
*/
|
||||
public function blackHole(Controller $controller, $error = '') {
|
||||
if ($this->blackHoleCallback == null) {
|
||||
if (!$this->blackHoleCallback) {
|
||||
throw new BadRequestException(__d('cake_dev', 'The request has been black-holed'));
|
||||
}
|
||||
return $this->_callback($controller, $this->blackHoleCallback, array($error));
|
||||
|
|
|
@ -319,7 +319,7 @@ class Controller extends Object implements CakeEventListener {
|
|||
$this->name = substr(get_class($this), 0, -10);
|
||||
}
|
||||
|
||||
if ($this->viewPath == null) {
|
||||
if (!$this->viewPath) {
|
||||
$this->viewPath = $this->name;
|
||||
}
|
||||
|
||||
|
@ -454,7 +454,7 @@ class Controller extends Object implements CakeEventListener {
|
|||
$this->passedArgs = array_merge($request->params['pass'], $request->params['named']);
|
||||
}
|
||||
|
||||
if (array_key_exists('return', $request->params) && $request->params['return'] == 1) {
|
||||
if (!empty($request->params['return']) && $request->params['return'] == 1) {
|
||||
$this->autoRender = false;
|
||||
}
|
||||
if (!empty($request->params['bare'])) {
|
||||
|
@ -966,14 +966,15 @@ class Controller extends Object implements CakeEventListener {
|
|||
* @link http://book.cakephp.org/2.0/en/controllers.html#Controller::referer
|
||||
*/
|
||||
public function referer($default = null, $local = false) {
|
||||
if ($this->request) {
|
||||
$referer = $this->request->referer($local);
|
||||
if ($referer == '/' && $default != null) {
|
||||
return Router::url($default, true);
|
||||
}
|
||||
return $referer;
|
||||
if(!$this->request) {
|
||||
return '/';
|
||||
}
|
||||
return '/';
|
||||
|
||||
$referer = $this->request->referer($local);
|
||||
if ($referer == '/' && $default) {
|
||||
return Router::url($default, true);
|
||||
}
|
||||
return $referer;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1061,7 +1062,7 @@ class Controller extends Object implements CakeEventListener {
|
|||
$cond[$key] = $value;
|
||||
}
|
||||
}
|
||||
if ($bool != null && strtoupper($bool) != 'AND') {
|
||||
if ($bool && strtoupper($bool) != 'AND') {
|
||||
$cond = array($bool => $cond);
|
||||
}
|
||||
return $cond;
|
||||
|
|
|
@ -146,7 +146,7 @@ class Scaffold {
|
|||
$this->controller->viewClass = 'Scaffold';
|
||||
}
|
||||
$this->_validSession = (
|
||||
isset($this->controller->Session) && $this->controller->Session->valid() != false
|
||||
isset($this->controller->Session) && $this->controller->Session->valid()
|
||||
);
|
||||
$this->_scaffold($request);
|
||||
}
|
||||
|
|
|
@ -607,7 +607,7 @@ class App {
|
|||
extract($parent, EXTR_OVERWRITE);
|
||||
}
|
||||
|
||||
if ($name == null && $file == null) {
|
||||
if (!$name && !$file) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -201,7 +201,7 @@ class ExceptionRenderer {
|
|||
*/
|
||||
public function error400($error) {
|
||||
$message = $error->getMessage();
|
||||
if (Configure::read('debug') == 0 && $error instanceof CakeException) {
|
||||
if (!Configure::read('debug') && $error instanceof CakeException) {
|
||||
$message = __d('cake', 'Not Found');
|
||||
}
|
||||
$url = $this->controller->request->here();
|
||||
|
@ -223,7 +223,7 @@ class ExceptionRenderer {
|
|||
*/
|
||||
public function error500($error) {
|
||||
$message = $error->getMessage();
|
||||
if (Configure::read('debug') == 0) {
|
||||
if (!Configure::read('debug')) {
|
||||
$message = __d('cake', 'An Internal Error Has Occurred.');
|
||||
}
|
||||
$url = $this->controller->request->here();
|
||||
|
|
|
@ -405,7 +405,7 @@ class I18n {
|
|||
$header = unpack("L1magic/L1version/L1count/L1o_msg/L1o_trn", $header);
|
||||
extract($header);
|
||||
|
||||
if ((dechex($magic) == '950412de' || dechex($magic) == 'ffffffff950412de') && $version == 0) {
|
||||
if ((dechex($magic) == '950412de' || dechex($magic) == 'ffffffff950412de') && !$version) {
|
||||
for ($n = 0; $n < $count; $n++) {
|
||||
$r = unpack("L1len/L1offs", substr($data, $o_msg + $n * 8, 8));
|
||||
$msgid = substr($data, $r["offs"], $r["len"]);
|
||||
|
|
|
@ -338,7 +338,7 @@ class TranslateBehavior extends ModelBehavior {
|
|||
* @return boolean true.
|
||||
*/
|
||||
public function beforeSave(Model $Model, $options = array()) {
|
||||
if (isset($options['validate']) && $options['validate'] == false) {
|
||||
if (isset($options['validate']) && !$options['validate']) {
|
||||
unset($this->runtime[$Model->alias]['beforeSave']);
|
||||
}
|
||||
if (isset($this->runtime[$Model->alias]['beforeSave'])) {
|
||||
|
|
|
@ -355,17 +355,16 @@ class TreeBehavior extends ModelBehavior {
|
|||
$recursive = $overrideRecursive;
|
||||
}
|
||||
|
||||
if ($keyPath == null && $valuePath == null && $Model->hasField($Model->displayField)) {
|
||||
$fields = null;
|
||||
if (!$keyPath && !$valuePath && $Model->hasField($Model->displayField)) {
|
||||
$fields = array($Model->primaryKey, $Model->displayField, $left, $right);
|
||||
} else {
|
||||
$fields = null;
|
||||
}
|
||||
|
||||
if ($keyPath == null) {
|
||||
if (!$keyPath) {
|
||||
$keyPath = '{n}.' . $Model->alias . '.' . $Model->primaryKey;
|
||||
}
|
||||
|
||||
if ($valuePath == null) {
|
||||
if (!$valuePath) {
|
||||
$valuePath = array('%s%s', '{n}.tree_prefix', '{n}.' . $Model->alias . '.' . $Model->displayField);
|
||||
|
||||
} elseif (is_string($valuePath)) {
|
||||
|
@ -645,9 +644,8 @@ class TreeBehavior extends ModelBehavior {
|
|||
$db = ConnectionManager::getDataSource($Model->useDbConfig);
|
||||
foreach ($Model->find('all', array('conditions' => $scope, 'fields' => array($Model->primaryKey, $parent), 'order' => $left)) as $array) {
|
||||
$path = $this->getPath($Model, $array[$Model->alias][$Model->primaryKey]);
|
||||
if ($path == null || count($path) < 2) {
|
||||
$parentId = null;
|
||||
} else {
|
||||
$parentId = null;
|
||||
if (count($path) > 1) {
|
||||
$parentId = $path[count($path) - 2][$Model->alias][$Model->primaryKey];
|
||||
}
|
||||
$Model->updateAll(array($parent => $db->value($parentId, $parent)), array($Model->escapeField() => $array[$Model->alias][$Model->primaryKey]));
|
||||
|
@ -800,7 +798,7 @@ class TreeBehavior extends ModelBehavior {
|
|||
$scope, 'OR' => array($Model->escapeField($left) => $i, $Model->escapeField($right) => $i)
|
||||
)));
|
||||
if ($count != 1) {
|
||||
if ($count == 0) {
|
||||
if (!$count) {
|
||||
$errors[] = array('index', $i, 'missing');
|
||||
} else {
|
||||
$errors[] = array('index', $i, 'duplicate');
|
||||
|
|
|
@ -131,7 +131,7 @@ class CakeSession {
|
|||
self::$time = time();
|
||||
|
||||
$checkAgent = Configure::read('Session.checkAgent');
|
||||
if (($checkAgent === true || $checkAgent === null) && env('HTTP_USER_AGENT') != null) {
|
||||
if (($checkAgent === true || $checkAgent === null) && env('HTTP_USER_AGENT')) {
|
||||
self::$_userAgent = md5(env('HTTP_USER_AGENT') . Configure::read('Security.salt'));
|
||||
}
|
||||
self::_setPath($base);
|
||||
|
@ -247,7 +247,7 @@ class CakeSession {
|
|||
public static function delete($name) {
|
||||
if (self::check($name)) {
|
||||
self::_overwrite($_SESSION, Hash::remove($_SESSION, $name));
|
||||
return (self::check($name) == false);
|
||||
return !self::check($name);
|
||||
}
|
||||
self::_setError(2, __d('cake_dev', "%s doesn't exist", $name));
|
||||
return false;
|
||||
|
@ -660,7 +660,7 @@ class CakeSession {
|
|||
*/
|
||||
public static function renew() {
|
||||
if (session_id()) {
|
||||
if (session_id() != '' || isset($_COOKIE[session_name()])) {
|
||||
if (session_id() || isset($_COOKIE[session_name()])) {
|
||||
setcookie(Configure::read('Session.cookie'), '', time() - 42000, self::$path);
|
||||
}
|
||||
session_regenerate_id(true);
|
||||
|
|
|
@ -186,7 +186,7 @@ class Mysql extends DboSource {
|
|||
*/
|
||||
public function listSources($data = null) {
|
||||
$cache = parent::listSources();
|
||||
if ($cache != null) {
|
||||
if ($cache) {
|
||||
return $cache;
|
||||
}
|
||||
$result = $this->_execute('SHOW TABLES FROM ' . $this->name($this->config['database']));
|
||||
|
@ -300,7 +300,7 @@ class Mysql extends DboSource {
|
|||
public function describe($model) {
|
||||
$key = $this->fullTableName($model, false);
|
||||
$cache = parent::describe($key);
|
||||
if ($cache != null) {
|
||||
if ($cache) {
|
||||
return $cache;
|
||||
}
|
||||
$table = $this->fullTableName($model);
|
||||
|
@ -352,7 +352,7 @@ class Mysql extends DboSource {
|
|||
return parent::update($model, $fields, $values, $conditions);
|
||||
}
|
||||
|
||||
if ($values == null) {
|
||||
if (!$values) {
|
||||
$combined = $fields;
|
||||
} else {
|
||||
$combined = array_combine($fields, $values);
|
||||
|
@ -453,6 +453,7 @@ class Mysql extends DboSource {
|
|||
if (!isset($index[$idx->Key_name]['column'])) {
|
||||
$col = array();
|
||||
$index[$idx->Key_name]['column'] = $idx->Column_name;
|
||||
|
||||
if ($idx->Index_type === 'FULLTEXT') {
|
||||
$index[$idx->Key_name]['type'] = strtolower($idx->Index_type);
|
||||
} else {
|
||||
|
@ -654,7 +655,7 @@ class Mysql extends DboSource {
|
|||
if (in_array($col, array('date', 'time', 'datetime', 'timestamp'))) {
|
||||
return $col;
|
||||
}
|
||||
if (($col === 'tinyint' && $limit == 1) || $col === 'boolean') {
|
||||
if (($col === 'tinyint' && $limit === 1) || $col === 'boolean') {
|
||||
return 'boolean';
|
||||
}
|
||||
if (strpos($col, 'bigint') !== false || $col === 'bigint') {
|
||||
|
|
|
@ -149,7 +149,7 @@ class Postgres extends DboSource {
|
|||
public function listSources($data = null) {
|
||||
$cache = parent::listSources();
|
||||
|
||||
if ($cache != null) {
|
||||
if ($cache) {
|
||||
return $cache;
|
||||
}
|
||||
|
||||
|
@ -159,17 +159,17 @@ class Postgres extends DboSource {
|
|||
|
||||
if (!$result) {
|
||||
return array();
|
||||
} else {
|
||||
$tables = array();
|
||||
|
||||
foreach ($result as $item) {
|
||||
$tables[] = $item->name;
|
||||
}
|
||||
|
||||
$result->closeCursor();
|
||||
parent::listSources($tables);
|
||||
return $tables;
|
||||
}
|
||||
|
||||
$tables = array();
|
||||
|
||||
foreach ($result as $item) {
|
||||
$tables[] = $item->name;
|
||||
}
|
||||
|
||||
$result->closeCursor();
|
||||
parent::listSources($tables);
|
||||
return $tables;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -695,7 +695,7 @@ class Postgres extends DboSource {
|
|||
if ($col == 'uuid') {
|
||||
return 36;
|
||||
}
|
||||
if ($limit != null) {
|
||||
if ($limit) {
|
||||
return intval($limit);
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -139,7 +139,7 @@ class Sqlite extends DboSource {
|
|||
*/
|
||||
public function listSources($data = null) {
|
||||
$cache = parent::listSources();
|
||||
if ($cache != null) {
|
||||
if ($cache) {
|
||||
return $cache;
|
||||
}
|
||||
|
||||
|
@ -147,14 +147,14 @@ class Sqlite extends DboSource {
|
|||
|
||||
if (!$result || empty($result)) {
|
||||
return array();
|
||||
} else {
|
||||
$tables = array();
|
||||
foreach ($result as $table) {
|
||||
$tables[] = $table[0]['name'];
|
||||
}
|
||||
parent::listSources($tables);
|
||||
return $tables;
|
||||
}
|
||||
|
||||
$tables = array();
|
||||
foreach ($result as $table) {
|
||||
$tables[] = $table[0]['name'];
|
||||
}
|
||||
parent::listSources($tables);
|
||||
return $tables;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -166,7 +166,7 @@ class Sqlite extends DboSource {
|
|||
public function describe($model) {
|
||||
$table = $this->fullTableName($model, false, false);
|
||||
$cache = parent::describe($table);
|
||||
if ($cache != null) {
|
||||
if ($cache) {
|
||||
return $cache;
|
||||
}
|
||||
$fields = array();
|
||||
|
|
|
@ -187,7 +187,7 @@ class Sqlserver extends DboSource {
|
|||
public function describe($model) {
|
||||
$table = $this->fullTableName($model, false);
|
||||
$cache = parent::describe($table);
|
||||
if ($cache != null) {
|
||||
if ($cache) {
|
||||
return $cache;
|
||||
}
|
||||
$fields = array();
|
||||
|
@ -622,7 +622,7 @@ class Sqlserver extends DboSource {
|
|||
*/
|
||||
public function insertMulti($table, $fields, $values) {
|
||||
$primaryKey = $this->_getPrimaryKey($table);
|
||||
$hasPrimaryKey = $primaryKey != null && (
|
||||
$hasPrimaryKey = $primaryKey && (
|
||||
(is_array($fields) && in_array($primaryKey, $fields)
|
||||
|| (is_string($fields) && strpos($fields, $this->startQuote . $primaryKey . $this->endQuote) !== false))
|
||||
);
|
||||
|
@ -735,7 +735,7 @@ class Sqlserver extends DboSource {
|
|||
*/
|
||||
protected function _execute($sql, $params = array(), $prepareOptions = array()) {
|
||||
$this->_lastAffected = false;
|
||||
if (strncasecmp($sql, 'SELECT', 6) == 0 || preg_match('/^EXEC(?:UTE)?\s/mi', $sql) > 0) {
|
||||
if (strncasecmp($sql, 'SELECT', 6) === 0 || preg_match('/^EXEC(?:UTE)?\s/mi', $sql) > 0) {
|
||||
$prepareOptions += array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL);
|
||||
return parent::_execute($sql, $params, $prepareOptions);
|
||||
}
|
||||
|
|
|
@ -671,7 +671,7 @@ class DboSource extends DataSource {
|
|||
|
||||
if ($this->hasResult()) {
|
||||
$first = $this->fetchRow();
|
||||
if ($first != null) {
|
||||
if ($first) {
|
||||
$out[] = $first;
|
||||
}
|
||||
while ($item = $this->fetchResult()) {
|
||||
|
@ -984,7 +984,7 @@ class DboSource extends DataSource {
|
|||
public function create(Model $model, $fields = null, $values = null) {
|
||||
$id = null;
|
||||
|
||||
if ($fields == null) {
|
||||
if (!$fields) {
|
||||
unset($fields, $values);
|
||||
$fields = array_keys($model->data);
|
||||
$values = array_values($model->data);
|
||||
|
@ -1054,7 +1054,7 @@ class DboSource extends DataSource {
|
|||
|
||||
if ($model->recursive == -1) {
|
||||
$_associations = array();
|
||||
} elseif ($model->recursive == 0) {
|
||||
} elseif ($model->recursive === 0) {
|
||||
unset($_associations[2], $_associations[3]);
|
||||
}
|
||||
|
||||
|
@ -1408,10 +1408,9 @@ class DboSource extends DataSource {
|
|||
}
|
||||
}
|
||||
if (!isset($data[$association])) {
|
||||
if ($merge[0][$association] != null) {
|
||||
$data[$association] = array();
|
||||
if ($merge[0][$association]) {
|
||||
$data[$association] = $merge[0][$association];
|
||||
} else {
|
||||
$data[$association] = array();
|
||||
}
|
||||
} else {
|
||||
if (is_array($merge[0][$association])) {
|
||||
|
@ -1821,7 +1820,7 @@ class DboSource extends DataSource {
|
|||
* @return boolean Success
|
||||
*/
|
||||
public function update(Model $model, $fields = array(), $values = null, $conditions = null) {
|
||||
if ($values == null) {
|
||||
if (!$values) {
|
||||
$combined = $fields;
|
||||
} else {
|
||||
$combined = array_combine($fields, $values);
|
||||
|
@ -2514,7 +2513,7 @@ class DboSource extends DataSource {
|
|||
$data = $this->_parseKey($model, trim($key), $value);
|
||||
}
|
||||
|
||||
if ($data != null) {
|
||||
if ($data) {
|
||||
$out[] = $data;
|
||||
$data = null;
|
||||
}
|
||||
|
|
|
@ -727,7 +727,7 @@ class Model extends Object implements CakeEventListener {
|
|||
$this->useTable = Inflector::tableize($this->name);
|
||||
}
|
||||
|
||||
if ($this->displayField == null) {
|
||||
if (!$this->displayField) {
|
||||
unset($this->displayField);
|
||||
}
|
||||
$this->table = $this->useTable;
|
||||
|
@ -1400,7 +1400,7 @@ class Model extends Object implements CakeEventListener {
|
|||
$this->schema();
|
||||
}
|
||||
|
||||
if ($this->_schema != null) {
|
||||
if ($this->_schema) {
|
||||
return isset($this->_schema[$name]);
|
||||
}
|
||||
return false;
|
||||
|
@ -1454,7 +1454,7 @@ class Model extends Object implements CakeEventListener {
|
|||
* or false if none $field exist.
|
||||
*/
|
||||
public function getVirtualField($field = null) {
|
||||
if ($field == null) {
|
||||
if (!$field) {
|
||||
return empty($this->virtualFields) ? false : $this->virtualFields;
|
||||
}
|
||||
if ($this->isVirtualField($field)) {
|
||||
|
@ -1510,7 +1510,7 @@ class Model extends Object implements CakeEventListener {
|
|||
public function read($fields = null, $id = null) {
|
||||
$this->validationErrors = array();
|
||||
|
||||
if ($id != null) {
|
||||
if ($id) {
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
|
@ -1526,9 +1526,8 @@ class Model extends Object implements CakeEventListener {
|
|||
'fields' => $fields
|
||||
));
|
||||
return $this->data;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2573,7 +2572,7 @@ class Model extends Object implements CakeEventListener {
|
|||
* @return boolean True if such a record exists
|
||||
*/
|
||||
public function hasAny($conditions = null) {
|
||||
return ($this->find('count', array('conditions' => $conditions, 'recursive' => -1)) != false);
|
||||
return (bool)$this->find('count', array('conditions' => $conditions, 'recursive' => -1));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2991,7 +2990,7 @@ class Model extends Object implements CakeEventListener {
|
|||
if (!empty($this->id)) {
|
||||
$fields[$this->alias . '.' . $this->primaryKey . ' !='] = $this->id;
|
||||
}
|
||||
return ($this->find('count', array('conditions' => $fields, 'recursive' => -1)) == 0);
|
||||
return !$this->find('count', array('conditions' => $fields, 'recursive' => -1));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3162,7 +3161,7 @@ class Model extends Object implements CakeEventListener {
|
|||
public function setDataSource($dataSource = null) {
|
||||
$oldConfig = $this->useDbConfig;
|
||||
|
||||
if ($dataSource != null) {
|
||||
if ($dataSource) {
|
||||
$this->useDbConfig = $dataSource;
|
||||
}
|
||||
$db = ConnectionManager::getDataSource($this->useDbConfig);
|
||||
|
@ -3208,7 +3207,7 @@ class Model extends Object implements CakeEventListener {
|
|||
* @return array Associations
|
||||
*/
|
||||
public function getAssociated($type = null) {
|
||||
if ($type == null) {
|
||||
if (!$type) {
|
||||
$associated = array();
|
||||
foreach ($this->_associations as $assoc) {
|
||||
if (!empty($this->{$assoc})) {
|
||||
|
|
|
@ -81,7 +81,7 @@ class Permission extends AppModel {
|
|||
* @return boolean Success (true if ARO has access to action in ACO, false otherwise)
|
||||
*/
|
||||
public function check($aro, $aco, $action = "*") {
|
||||
if ($aro == null || $aco == null) {
|
||||
if (!$aro || !$aco) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -89,12 +89,12 @@ class Permission extends AppModel {
|
|||
$aroPath = $this->Aro->node($aro);
|
||||
$acoPath = $this->Aco->node($aco);
|
||||
|
||||
if (empty($aroPath) || empty($acoPath)) {
|
||||
if (!$aroPath || !$acoPath) {
|
||||
trigger_error(__d('cake_dev', "DbAcl::check() - Failed ARO/ACO node lookup in permissions check. Node references:\nAro: ") . print_r($aro, true) . "\nAco: " . print_r($aco, true), E_USER_WARNING);
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($acoPath == null || $acoPath == array()) {
|
||||
if (!$acoPath) {
|
||||
trigger_error(__d('cake_dev', "DbAcl::check() - Failed ACO node lookup in permissions check. Node references:\nAro: ") . print_r($aro, true) . "\nAco: " . print_r($aco, true), E_USER_WARNING);
|
||||
return false;
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ class Permission extends AppModel {
|
|||
$permKeys = $this->getAcoKeys($this->schema());
|
||||
$save = array();
|
||||
|
||||
if ($perms == false) {
|
||||
if (!$perms) {
|
||||
trigger_error(__d('cake_dev', 'DbAcl::allow() - Invalid node'), E_USER_WARNING);
|
||||
return false;
|
||||
}
|
||||
|
@ -198,7 +198,7 @@ class Permission extends AppModel {
|
|||
}
|
||||
list($save['aro_id'], $save['aco_id']) = array($perms['aro'], $perms['aco']);
|
||||
|
||||
if ($perms['link'] != null && !empty($perms['link'])) {
|
||||
if ($perms['link'] && !empty($perms['link'])) {
|
||||
$save['id'] = $perms['link'][0][$this->alias]['id'];
|
||||
} else {
|
||||
unset($save['id']);
|
||||
|
|
|
@ -366,17 +366,17 @@ class CakeRequest implements ArrayAccess {
|
|||
* @return string The client IP.
|
||||
*/
|
||||
public function clientIp($safe = true) {
|
||||
if (!$safe && env('HTTP_X_FORWARDED_FOR') != null) {
|
||||
if (!$safe && env('HTTP_X_FORWARDED_FOR')) {
|
||||
$ipaddr = preg_replace('/(?:,.*)/', '', env('HTTP_X_FORWARDED_FOR'));
|
||||
} else {
|
||||
if (env('HTTP_CLIENT_IP') != null) {
|
||||
if (env('HTTP_CLIENT_IP')) {
|
||||
$ipaddr = env('HTTP_CLIENT_IP');
|
||||
} else {
|
||||
$ipaddr = env('REMOTE_ADDR');
|
||||
}
|
||||
}
|
||||
|
||||
if (env('HTTP_CLIENTADDRESS') != null) {
|
||||
if (env('HTTP_CLIENTADDRESS')) {
|
||||
$tmpipaddr = env('HTTP_CLIENTADDRESS');
|
||||
|
||||
if (!empty($tmpipaddr)) {
|
||||
|
|
|
@ -790,7 +790,7 @@ class CakeResponse {
|
|||
unset($this->_cacheDirectives['public']);
|
||||
$this->maxAge($time);
|
||||
}
|
||||
if ($time == null) {
|
||||
if (!$time) {
|
||||
$this->_setCacheControl();
|
||||
}
|
||||
return (bool)$public;
|
||||
|
|
|
@ -121,7 +121,7 @@ class CakeSocket {
|
|||
* @throws SocketException
|
||||
*/
|
||||
public function connect() {
|
||||
if ($this->connection != null) {
|
||||
if ($this->connection) {
|
||||
$this->disconnect();
|
||||
}
|
||||
|
||||
|
@ -130,7 +130,7 @@ class CakeSocket {
|
|||
$scheme = 'ssl://';
|
||||
}
|
||||
|
||||
if ($this->config['persistent'] == true) {
|
||||
if ($this->config['persistent']) {
|
||||
$this->connection = @pfsockopen($scheme . $this->config['host'], $this->config['port'], $errNum, $errStr, $this->config['timeout']);
|
||||
} else {
|
||||
$this->connection = @fsockopen($scheme . $this->config['host'], $this->config['port'], $errNum, $errStr, $this->config['timeout']);
|
||||
|
|
|
@ -108,7 +108,7 @@ class HttpResponse implements ArrayAccess {
|
|||
return $headers[$name];
|
||||
}
|
||||
foreach ($headers as $key => $value) {
|
||||
if (strcasecmp($key, $name) == 0) {
|
||||
if (strcasecmp($key, $name) === 0) {
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
@ -361,7 +361,7 @@ class HttpResponse implements ArrayAccess {
|
|||
$escape[] = chr(127);
|
||||
}
|
||||
|
||||
if ($hex == false) {
|
||||
if (!$hex) {
|
||||
return $escape;
|
||||
}
|
||||
foreach ($escape as $key => $char) {
|
||||
|
|
|
@ -944,7 +944,7 @@ class HttpSocket extends CakeSocket {
|
|||
$escape[] = chr(127);
|
||||
}
|
||||
|
||||
if ($hex == false) {
|
||||
if (!$hex) {
|
||||
return $escape;
|
||||
}
|
||||
foreach ($escape as $key => $char) {
|
||||
|
|
|
@ -74,7 +74,7 @@ class RedirectRoute extends CakeRoute {
|
|||
$this->response = new CakeResponse();
|
||||
}
|
||||
$redirect = $this->redirect;
|
||||
if (count($this->redirect) == 1 && !isset($this->redirect['controller'])) {
|
||||
if (count($this->redirect) === 1 && !isset($this->redirect['controller'])) {
|
||||
$redirect = $this->redirect[0];
|
||||
}
|
||||
if (isset($this->options['persist']) && is_array($redirect)) {
|
||||
|
|
|
@ -434,7 +434,7 @@ class Router {
|
|||
$options = array_merge(array('default' => false, 'reset' => false, 'greedy' => true), $options);
|
||||
}
|
||||
|
||||
if ($options['reset'] == true || self::$_namedConfig['rules'] === false) {
|
||||
if ($options['reset'] || self::$_namedConfig['rules'] === false) {
|
||||
self::$_namedConfig['rules'] = array();
|
||||
}
|
||||
|
||||
|
@ -1090,7 +1090,7 @@ class Router {
|
|||
* @return string base url with plugin name removed if present
|
||||
*/
|
||||
public static function stripPlugin($base, $plugin = null) {
|
||||
if ($plugin != null) {
|
||||
if ($plugin) {
|
||||
$base = preg_replace('/(?:' . $plugin . ')/', '', $base);
|
||||
$base = str_replace('//', '', $base);
|
||||
$pos1 = strrpos($base, '/');
|
||||
|
|
|
@ -58,7 +58,7 @@ class ModelWriteTest extends BaseModelTest {
|
|||
$lastInsertId = $TestModel->JoinAsJoinB->getLastInsertID();
|
||||
$data['id'] = $lastInsertId;
|
||||
$this->assertEquals(array('JoinAsJoinB' => $data), $result);
|
||||
$this->assertTrue($lastInsertId != null);
|
||||
$this->assertTrue($lastInsertId);
|
||||
|
||||
$result = $TestModel->JoinAsJoinB->findById(1);
|
||||
$expected = array(
|
||||
|
|
|
@ -980,7 +980,7 @@ class CakeRequestTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
public function detectCallback($request) {
|
||||
return $request->return == true;
|
||||
return (bool)$request->return;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1168,7 +1168,7 @@ class CakeEmailTest extends CakeTestCase {
|
|||
$this->CakeEmail->emailFormat('html');
|
||||
$server = env('SERVER_NAME') ? env('SERVER_NAME') : 'localhost';
|
||||
|
||||
if (env('SERVER_PORT') != null && env('SERVER_PORT') != 80) {
|
||||
if (env('SERVER_PORT') && env('SERVER_PORT') != 80) {
|
||||
$server .= ':' . env('SERVER_PORT');
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ class CakeTestSuiteCommand extends PHPUnit_TextUI_Command {
|
|||
);
|
||||
}
|
||||
|
||||
if (count($suite) == 0) {
|
||||
if (!count($suite)) {
|
||||
$skeleton = new PHPUnit_Util_Skeleton_Test(
|
||||
$suite->getName(),
|
||||
$this->arguments['testFile']
|
||||
|
|
|
@ -200,7 +200,7 @@ class CakeFixtureManager {
|
|||
return;
|
||||
}
|
||||
$fixtures = $test->fixtures;
|
||||
if (empty($fixtures) || $test->autoFixtures == false) {
|
||||
if (empty($fixtures) || !$test->autoFixtures) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -71,10 +71,10 @@ class CakeTextReporter extends CakeBaseReporter {
|
|||
* @return void
|
||||
*/
|
||||
public function paintFooter($result) {
|
||||
if ($result->failureCount() + $result->errorCount() == 0) {
|
||||
echo "\nOK\n";
|
||||
} else {
|
||||
if ($result->failureCount() + $result->errorCount()) {
|
||||
echo "FAILURES!!!\n";
|
||||
} else {
|
||||
echo "\nOK\n";
|
||||
}
|
||||
|
||||
echo "Test cases run: " . $result->count() .
|
||||
|
|
|
@ -296,8 +296,8 @@ class CakeNumber {
|
|||
$result = $options['before'] = $options['after'] = null;
|
||||
|
||||
$symbolKey = 'whole';
|
||||
if ($value == 0) {
|
||||
if ($options['zero'] !== 0) {
|
||||
if (!$value) {
|
||||
if ($options['zero'] !== 0 ) {
|
||||
return $options['zero'];
|
||||
}
|
||||
} elseif ($value < 1 && $value > -1) {
|
||||
|
|
|
@ -745,7 +745,7 @@ class CakeTime {
|
|||
$years = floor($months / 12);
|
||||
$months = $months - ($years * 12);
|
||||
}
|
||||
if ($future['m'] < $past['m'] && $future['Y'] - $past['Y'] == 1) {
|
||||
if ($future['m'] < $past['m'] && $future['Y'] - $past['Y'] === 1) {
|
||||
$years--;
|
||||
}
|
||||
|
||||
|
@ -766,7 +766,7 @@ class CakeTime {
|
|||
}
|
||||
}
|
||||
|
||||
if ($months == 0 && $years >= 1 && $diff < ($years * 31536000)) {
|
||||
if (!$months && $years >= 1 && $diff < ($years * 31536000)) {
|
||||
$months = 11;
|
||||
$years--;
|
||||
}
|
||||
|
@ -795,7 +795,7 @@ class CakeTime {
|
|||
}
|
||||
$diff = $futureTime - $pastTime;
|
||||
|
||||
if ($diff == 0) {
|
||||
if (!$diff) {
|
||||
return __d('cake', 'just now', 'just now');
|
||||
}
|
||||
|
||||
|
@ -903,7 +903,7 @@ class CakeTime {
|
|||
*/
|
||||
public static function gmt($dateString = null) {
|
||||
$time = time();
|
||||
if ($dateString != null) {
|
||||
if ($dateString) {
|
||||
$time = self::fromString($dateString);
|
||||
}
|
||||
return gmmktime(
|
||||
|
|
|
@ -474,7 +474,7 @@ class Debugger {
|
|||
case 'float':
|
||||
return '(float) ' . $var;
|
||||
case 'string':
|
||||
if (trim($var) == '') {
|
||||
if (!trim($var)) {
|
||||
return "''";
|
||||
}
|
||||
return "'" . $var . "'";
|
||||
|
|
|
@ -302,7 +302,7 @@ class File {
|
|||
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::info
|
||||
*/
|
||||
public function info() {
|
||||
if ($this->info == null) {
|
||||
if (!$this->info) {
|
||||
$this->info = pathinfo($this->path);
|
||||
}
|
||||
if (!isset($this->info['filename'])) {
|
||||
|
@ -324,7 +324,7 @@ class File {
|
|||
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::ext
|
||||
*/
|
||||
public function ext() {
|
||||
if ($this->info == null) {
|
||||
if (!$this->info) {
|
||||
$this->info();
|
||||
}
|
||||
if (isset($this->info['extension'])) {
|
||||
|
@ -340,7 +340,7 @@ class File {
|
|||
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::name
|
||||
*/
|
||||
public function name() {
|
||||
if ($this->info == null) {
|
||||
if (!$this->info) {
|
||||
$this->info();
|
||||
}
|
||||
if (isset($this->info['extension'])) {
|
||||
|
|
|
@ -425,7 +425,7 @@ class Folder {
|
|||
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::tree
|
||||
*/
|
||||
public function tree($path = null, $exceptions = false, $type = null) {
|
||||
if ($path == null) {
|
||||
if (!$path) {
|
||||
$path = $this->path;
|
||||
}
|
||||
$files = array();
|
||||
|
|
|
@ -108,7 +108,7 @@ class Security {
|
|||
}
|
||||
}
|
||||
|
||||
if ($type == 'sha1' || $type == null) {
|
||||
if (!$type || $type == 'sha1') {
|
||||
if (function_exists('sha1')) {
|
||||
$return = sha1($string);
|
||||
return $return;
|
||||
|
|
|
@ -349,7 +349,7 @@ class Set {
|
|||
$context = array('trace' => array(null), 'item' => $context, 'key' => $key);
|
||||
}
|
||||
if ($token === '..') {
|
||||
if (count($context['trace']) == 1) {
|
||||
if (count($context['trace']) === 1) {
|
||||
$context['trace'][] = $context['key'];
|
||||
}
|
||||
$parent = implode('/', $context['trace']) . '/.';
|
||||
|
@ -373,7 +373,7 @@ class Set {
|
|||
);
|
||||
} elseif (is_array($context['item'])
|
||||
&& array_key_exists($token, $context['item'])
|
||||
&& !(strval($key) === strval($token) && count($tokens) == 1 && $tokens[0] === '.')) {
|
||||
&& !(strval($key) === strval($token) && count($tokens) === 1 && $tokens[0] === '.')) {
|
||||
$items = $context['item'][$token];
|
||||
if (!is_array($items)) {
|
||||
$items = array($items);
|
||||
|
@ -827,7 +827,7 @@ class Set {
|
|||
}
|
||||
}
|
||||
|
||||
if ($groupPath != null) {
|
||||
if ($groupPath) {
|
||||
$group = Set::extract($data, $groupPath);
|
||||
if (!empty($group)) {
|
||||
$c = count($keys);
|
||||
|
|
|
@ -134,7 +134,7 @@ class String {
|
|||
}
|
||||
if ($tmpOffset !== -1) {
|
||||
$buffer .= substr($data, $offset, ($tmpOffset - $offset));
|
||||
if ($data{$tmpOffset} == $separator && $depth == 0) {
|
||||
if (!$depth && $data{$tmpOffset} == $separator) {
|
||||
$results[] = $buffer;
|
||||
$buffer = '';
|
||||
} else {
|
||||
|
|
|
@ -860,7 +860,7 @@ class Validation {
|
|||
if ($deep !== true) {
|
||||
return true;
|
||||
}
|
||||
if ($check == 0) {
|
||||
if (!$check) {
|
||||
return false;
|
||||
}
|
||||
$sum = 0;
|
||||
|
@ -875,7 +875,7 @@ class Validation {
|
|||
$sum += ($number < 10) ? $number : $number - 9;
|
||||
}
|
||||
|
||||
return ($sum % 10 == 0);
|
||||
return ($sum % 10 === 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -500,7 +500,7 @@ class Helper extends Object {
|
|||
|
||||
// Either 'body' or 'date.month' type inputs.
|
||||
if (
|
||||
($count === 1 && $this->_modelScope && $setScope == false) ||
|
||||
($count === 1 && $this->_modelScope && !$setScope) ||
|
||||
(
|
||||
$count === 2 &&
|
||||
in_array($lastPart, $this->_fieldSuffixes) &&
|
||||
|
@ -526,12 +526,11 @@ class Helper extends Object {
|
|||
|
||||
$isHabtm = (
|
||||
isset($this->fieldset[$this->_modelScope]['fields'][$parts[0]]['type']) &&
|
||||
$this->fieldset[$this->_modelScope]['fields'][$parts[0]]['type'] === 'multiple' &&
|
||||
$count == 1
|
||||
$this->fieldset[$this->_modelScope]['fields'][$parts[0]]['type'] === 'multiple'
|
||||
);
|
||||
|
||||
// habtm models are special
|
||||
if ($count == 1 && $isHabtm) {
|
||||
if ($count === 1 && $isHabtm) {
|
||||
$this->_association = $parts[0];
|
||||
$entity = $parts[0] . '.' . $parts[0];
|
||||
} else {
|
||||
|
@ -750,7 +749,7 @@ class Helper extends Object {
|
|||
* @return array Array of options with $key set.
|
||||
*/
|
||||
public function addClass($options = array(), $class = null, $key = 'class') {
|
||||
if (isset($options[$key]) && trim($options[$key]) != '') {
|
||||
if (isset($options[$key]) && trim($options[$key])) {
|
||||
$options[$key] .= ' ' . $class;
|
||||
} else {
|
||||
$options[$key] = $class;
|
||||
|
|
|
@ -59,7 +59,7 @@ class CacheHelper extends AppHelper {
|
|||
* @return boolean
|
||||
*/
|
||||
protected function _enabled() {
|
||||
return (($this->_View->cacheAction != false)) && (Configure::read('Cache.check') === true);
|
||||
return $this->_View->cacheAction && (Configure::read('Cache.check') === true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -148,7 +148,7 @@ class CacheHelper extends AppHelper {
|
|||
$cacheTime = $cacheAction;
|
||||
}
|
||||
|
||||
if ($cacheTime != '' && $cacheTime > 0) {
|
||||
if ($cacheTime && $cacheTime > 0) {
|
||||
$cached = $this->_parseOutput($out);
|
||||
try {
|
||||
$this->_writeFile($cached, $cacheTime, $useCallbacks);
|
||||
|
@ -312,7 +312,7 @@ class CacheHelper extends AppHelper {
|
|||
Router::setRequestInfo($controller->request);
|
||||
$this->request = $request;';
|
||||
|
||||
if ($useCallbacks == true) {
|
||||
if ($useCallbacks) {
|
||||
$file .= '
|
||||
$controller->constructClasses();
|
||||
$controller->startupProcess();';
|
||||
|
|
|
@ -412,7 +412,7 @@ class FormHelper extends AppHelper {
|
|||
$action = $this->url($options['action']);
|
||||
unset($options['type'], $options['action']);
|
||||
|
||||
if ($options['default'] == false) {
|
||||
if (!$options['default']) {
|
||||
if (!isset($options['onsubmit'])) {
|
||||
$options['onsubmit'] = '';
|
||||
}
|
||||
|
@ -1289,7 +1289,7 @@ class FormHelper extends AppHelper {
|
|||
'value' => ($options['hiddenField'] !== true ? $options['hiddenField'] : '0'),
|
||||
'secure' => false
|
||||
);
|
||||
if (isset($options['disabled']) && $options['disabled'] == true) {
|
||||
if (isset($options['disabled']) && $options['disabled']) {
|
||||
$hiddenOptions['disabled'] = 'disabled';
|
||||
}
|
||||
$output = $this->hidden($fieldName, $hiddenOptions);
|
||||
|
@ -1870,7 +1870,7 @@ class FormHelper extends AppHelper {
|
|||
// Secure the field if there are options, or its a multi select.
|
||||
// Single selects with no options don't submit, but multiselects do.
|
||||
if (
|
||||
(!isset($secure) || $secure == true) &&
|
||||
(!isset($secure) || $secure) &&
|
||||
empty($attributes['disabled']) &&
|
||||
(!empty($attributes['multiple']) || $hasOptions)
|
||||
) {
|
||||
|
@ -2235,7 +2235,7 @@ class FormHelper extends AppHelper {
|
|||
} elseif ($time[0] >= 12) {
|
||||
$meridian = 'pm';
|
||||
}
|
||||
if ($time[0] == 0 && $timeFormat == '12') {
|
||||
if (!$time[0] && $timeFormat == '12') {
|
||||
$time[0] = 12;
|
||||
}
|
||||
$hour = $min = null;
|
||||
|
|
|
@ -359,7 +359,7 @@ class HtmlHelper extends AppHelper {
|
|||
$confirmMessage = str_replace("'", "\'", $confirmMessage);
|
||||
$confirmMessage = str_replace('"', '\"', $confirmMessage);
|
||||
$options['onclick'] = "return confirm('{$confirmMessage}');";
|
||||
} elseif (isset($options['default']) && $options['default'] == false) {
|
||||
} elseif (isset($options['default']) && !$options['default']) {
|
||||
if (isset($options['onclick'])) {
|
||||
$options['onclick'] .= ' event.returnValue = false; return false;';
|
||||
} else {
|
||||
|
@ -441,7 +441,7 @@ class HtmlHelper extends AppHelper {
|
|||
if ($rel == 'import') {
|
||||
$out = sprintf($this->_tags['style'], $this->_parseAttributes($options, array('inline', 'block'), '', ' '), '@import url(' . $url . ');');
|
||||
} else {
|
||||
if ($rel == null) {
|
||||
if (!$rel) {
|
||||
$rel = 'stylesheet';
|
||||
}
|
||||
$out = sprintf($this->_tags['css'], $rel, $url, $this->_parseAttributes($options, array('inline', 'block'), '', ' '));
|
||||
|
@ -701,7 +701,7 @@ class HtmlHelper extends AppHelper {
|
|||
} else {
|
||||
$elementContent = $this->link($crumb[0], $crumb[1], $crumb[2]);
|
||||
}
|
||||
if ($which == 0) {
|
||||
if (!$which) {
|
||||
$options['class'] = 'first';
|
||||
} elseif ($which == $crumbCount - 1) {
|
||||
$options['class'] = 'last';
|
||||
|
@ -951,13 +951,12 @@ class HtmlHelper extends AppHelper {
|
|||
if (isset($options['escape'])) {
|
||||
$text = h($text);
|
||||
}
|
||||
if ($class != null && !empty($class)) {
|
||||
if ($class && !empty($class)) {
|
||||
$options['class'] = $class;
|
||||
}
|
||||
$tag = 'para';
|
||||
if ($text === null) {
|
||||
$tag = 'parastart';
|
||||
} else {
|
||||
$tag = 'para';
|
||||
}
|
||||
return sprintf($this->_tags[$tag], $this->_parseAttributes($options, null, ' ', ''), $text);
|
||||
}
|
||||
|
@ -1116,9 +1115,9 @@ class HtmlHelper extends AppHelper {
|
|||
if (is_array($item)) {
|
||||
$item = $key . $this->nestedList($item, $options, $itemOptions, $tag);
|
||||
}
|
||||
if (isset($itemOptions['even']) && $index % 2 == 0) {
|
||||
if (isset($itemOptions['even']) && $index % 2 === 0) {
|
||||
$itemOptions['class'] = $itemOptions['even'];
|
||||
} elseif (isset($itemOptions['odd']) && $index % 2 != 0) {
|
||||
} elseif (isset($itemOptions['odd']) && $index % 2 !== 0) {
|
||||
$itemOptions['class'] = $itemOptions['odd'];
|
||||
}
|
||||
$out .= sprintf($this->_tags['li'], $this->_parseAttributes($itemOptions, array('even', 'odd'), ' ', ''), $item);
|
||||
|
|
|
@ -338,7 +338,7 @@ class JsHelper extends AppHelper {
|
|||
} else {
|
||||
$data = array($one => $two);
|
||||
}
|
||||
if ($data == null) {
|
||||
if (!$data) {
|
||||
return false;
|
||||
}
|
||||
$this->_jsVars = array_merge($this->_jsVars, $data);
|
||||
|
|
|
@ -526,12 +526,7 @@ class PaginatorHelper extends AppHelper {
|
|||
*/
|
||||
protected function _hasPage($model, $page) {
|
||||
$params = $this->params($model);
|
||||
if (!empty($params)) {
|
||||
if ($params["{$page}Page"] == true) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return !empty($params) && $params[$page . 'Page'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -541,7 +536,7 @@ class PaginatorHelper extends AppHelper {
|
|||
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/paginator.html#PaginatorHelper::defaultModel
|
||||
*/
|
||||
public function defaultModel() {
|
||||
if ($this->_defaultModel != null) {
|
||||
if ($this->_defaultModel) {
|
||||
return $this->_defaultModel;
|
||||
}
|
||||
if (empty($this->request->params['paging'])) {
|
||||
|
@ -583,7 +578,7 @@ class PaginatorHelper extends AppHelper {
|
|||
$options);
|
||||
|
||||
$paging = $this->params($options['model']);
|
||||
if ($paging['pageCount'] == 0) {
|
||||
if (!$paging['pageCount']) {
|
||||
$paging['pageCount'] = 1;
|
||||
}
|
||||
$start = 0;
|
||||
|
|
|
@ -167,7 +167,7 @@ class RssHelper extends AppHelper {
|
|||
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/rss.html#RssHelper::items
|
||||
*/
|
||||
public function items($items, $callback = null) {
|
||||
if ($callback != null) {
|
||||
if ($callback) {
|
||||
$items = array_map($callback, $items);
|
||||
}
|
||||
|
||||
|
|
|
@ -134,7 +134,7 @@ class SessionHelper extends AppHelper {
|
|||
$class = $flash['params']['class'];
|
||||
}
|
||||
$out = '<div id="' . $key . 'Message" class="' . $class . '">' . $message . '</div>';
|
||||
} elseif ($flash['element'] == '' || $flash['element'] == null) {
|
||||
} elseif (!$flash['element']) {
|
||||
$out = $message;
|
||||
} else {
|
||||
$options = array();
|
||||
|
|
|
@ -766,7 +766,7 @@ class View extends Object {
|
|||
} else {
|
||||
$data = array($one => $two);
|
||||
}
|
||||
if ($data == null) {
|
||||
if (!$data) {
|
||||
return false;
|
||||
}
|
||||
$this->viewVars = $data + $this->viewVars;
|
||||
|
|
|
@ -44,20 +44,15 @@ if (!function_exists('config')) {
|
|||
*/
|
||||
function config() {
|
||||
$args = func_get_args();
|
||||
$count = count($args);
|
||||
$included = 0;
|
||||
foreach ($args as $arg) {
|
||||
if (file_exists(APP . 'Config' . DS . $arg . '.php')) {
|
||||
include_once APP . 'Config' . DS . $arg . '.php';
|
||||
|
||||
if (count($args) == 1) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (count($args) == 1) {
|
||||
return false;
|
||||
}
|
||||
$included++;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return $included === $count;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue