From 3650ecb5b1fd24157b20722ad64fdb18f3b28c17 Mon Sep 17 00:00:00 2001 From: Bryan Crowe Date: Wed, 2 Dec 2015 06:11:38 -0500 Subject: [PATCH] Condense multi isset calls --- src/I18n/Formatter/IcuFormatter.php | 2 +- src/Mailer/Transport/SmtpTransport.php | 2 +- src/Network/Request.php | 4 ++-- src/ORM/Association/SelectableAssociationTrait.php | 2 +- src/ORM/Query.php | 2 +- src/Routing/Route/PluginShortRoute.php | 2 +- src/Template/Element/exception_stack_trace.ctp | 2 +- src/Validation/Validation.php | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/I18n/Formatter/IcuFormatter.php b/src/I18n/Formatter/IcuFormatter.php index a3862f24332..d0084dd8976 100644 --- a/src/I18n/Formatter/IcuFormatter.php +++ b/src/I18n/Formatter/IcuFormatter.php @@ -51,7 +51,7 @@ public function format($locale, $message, array $vars) return $this->_formatMessage($locale, $message, $vars); } - if (isset($vars['_context']) && isset($message['_context'])) { + if (isset($vars['_context'], $message['_context'])) { $message = $message['_context'][$vars['_context']]; unset($vars['_context']); } diff --git a/src/Mailer/Transport/SmtpTransport.php b/src/Mailer/Transport/SmtpTransport.php index 102be82897c..17f20ea23d5 100644 --- a/src/Mailer/Transport/SmtpTransport.php +++ b/src/Mailer/Transport/SmtpTransport.php @@ -246,7 +246,7 @@ protected function _connect() */ protected function _auth() { - if (isset($this->_config['username']) && isset($this->_config['password'])) { + if (isset($this->_config['username'], $this->_config['password'])) { $replyCode = (string)$this->_smtpSend('AUTH LOGIN', '334|500|502|504'); if ($replyCode === '334') { try { diff --git a/src/Network/Request.php b/src/Network/Request.php index 03f2aa8ed58..81c2af228f9 100644 --- a/src/Network/Request.php +++ b/src/Network/Request.php @@ -332,7 +332,7 @@ protected static function _url($config) } else { $uri = substr($_SERVER['REQUEST_URI'], strlen(Configure::read('App.fullBaseUrl'))); } - } elseif (isset($_SERVER['PHP_SELF']) && isset($_SERVER['SCRIPT_NAME'])) { + } elseif (isset($_SERVER['PHP_SELF'], $_SERVER['SCRIPT_NAME'])) { $uri = str_replace($_SERVER['SCRIPT_NAME'], '', $_SERVER['PHP_SELF']); } elseif (isset($_SERVER['HTTP_X_REWRITE_URL'])) { $uri = $_SERVER['HTTP_X_REWRITE_URL']; @@ -828,7 +828,7 @@ public static function addDetector($name, $callable) static::$_detectors[$name] = $callable; return; } - if (isset(static::$_detectors[$name]) && isset($callable['options'])) { + if (isset(static::$_detectors[$name], $callable['options'])) { $callable = Hash::merge(static::$_detectors[$name], $callable); } static::$_detectors[$name] = $callable; diff --git a/src/ORM/Association/SelectableAssociationTrait.php b/src/ORM/Association/SelectableAssociationTrait.php index 4e78a9438d3..b02291e2d5e 100644 --- a/src/ORM/Association/SelectableAssociationTrait.php +++ b/src/ORM/Association/SelectableAssociationTrait.php @@ -314,7 +314,7 @@ protected function _resultInjector($fetchQuery, $resultMap, $options) $sourceKey = $sourceKeys[0]; return function ($row) use ($resultMap, $sourceKey, $nestKey) { - if (isset($row[$sourceKey]) && isset($resultMap[$row[$sourceKey]])) { + if (isset($row[$sourceKey], $resultMap[$row[$sourceKey]])) { $row[$nestKey] = $resultMap[$row[$sourceKey]]; } return $row; diff --git a/src/ORM/Query.php b/src/ORM/Query.php index 10e894c8423..cceba5db49c 100644 --- a/src/ORM/Query.php +++ b/src/ORM/Query.php @@ -632,7 +632,7 @@ public function applyOptions(array $options) ksort($options); foreach ($options as $option => $values) { - if (isset($valid[$option]) && isset($values)) { + if (isset($valid[$option], $values)) { $this->{$valid[$option]}($values); } else { $this->_options[$option] = $values; diff --git a/src/Routing/Route/PluginShortRoute.php b/src/Routing/Route/PluginShortRoute.php index 70bd04d57e3..7e54f3af905 100644 --- a/src/Routing/Route/PluginShortRoute.php +++ b/src/Routing/Route/PluginShortRoute.php @@ -51,7 +51,7 @@ public function parse($url) */ public function match(array $url, array $context = []) { - if (isset($url['controller']) && isset($url['plugin']) && $url['plugin'] !== $url['controller']) { + if (isset($url['controller'], $url['plugin']) && $url['plugin'] !== $url['controller']) { return false; } $this->defaults['controller'] = $url['controller']; diff --git a/src/Template/Element/exception_stack_trace.ctp b/src/Template/Element/exception_stack_trace.ctp index d8dc4801cd1..9e17ba03286 100644 --- a/src/Template/Element/exception_stack_trace.ctp +++ b/src/Template/Element/exception_stack_trace.ctp @@ -21,7 +21,7 @@ use Cake\Error\Debugger; foreach ($error->getTrace() as $i => $stack): $excerpt = $params = []; - if (isset($stack['file']) && isset($stack['line'])): + if (isset($stack['file'], $stack['line'])): $excerpt = Debugger::excerpt($stack['file'], $stack['line'], 4); endif; diff --git a/src/Validation/Validation.php b/src/Validation/Validation.php index 1ab05f52d31..cb5caaf7bdc 100644 --- a/src/Validation/Validation.php +++ b/src/Validation/Validation.php @@ -746,7 +746,7 @@ public static function range($check, $lower = null, $upper = null) if ((float)$check != $check) { return false; } - if (isset($lower) && isset($upper)) { + if (isset($lower, $upper)) { return ($check >= $lower && $check <= $upper); } return is_finite($check);