Skip to content

Commit

Permalink
Remove unneeded else.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Scherer committed Feb 12, 2016
1 parent 107c1ca commit 4a9249f
Show file tree
Hide file tree
Showing 19 changed files with 74 additions and 55 deletions.
3 changes: 2 additions & 1 deletion src/Console/ConsoleOptionParser.php
Expand Up @@ -581,7 +581,8 @@ public function parse($argv)
while (($token = array_shift($this->_tokens)) !== null) {
if (isset($this->_subcommands[$token])) {
continue;
} elseif (substr($token, 0, 2) === '--') {
}
if (substr($token, 0, 2) === '--') {
$params = $this->_parseLongOption($token, $params);
} elseif (substr($token, 0, 1) === '-') {
$params = $this->_parseShortOption($token, $params);
Expand Down
3 changes: 2 additions & 1 deletion src/Database/Expression/CaseExpression.php
Expand Up @@ -130,7 +130,8 @@ protected function _addExpressions($conditions, $values, $types)
$value = $keyValues[$k];
array_push($this->_values, $value);
continue;
} elseif ($value instanceof ExpressionInterface) {
}
if ($value instanceof ExpressionInterface) {
array_push($this->_values, $value);
continue;
}
Expand Down
3 changes: 2 additions & 1 deletion src/Database/Log/QueryLogger.php
Expand Up @@ -63,7 +63,8 @@ protected function _interpolate($query)
$params = array_map(function ($p) {
if ($p === null) {
return 'NULL';
} elseif (is_bool($p)) {
}
if (is_bool($p)) {
return $p ? '1' : '0';
}
return is_string($p) ? "'$p'" : $p;
Expand Down
3 changes: 2 additions & 1 deletion src/Database/Type/FloatType.php
Expand Up @@ -104,7 +104,8 @@ public function marshal($value)
}
if (is_numeric($value)) {
return (float)$value;
} elseif (is_string($value) && $this->_useLocaleParser) {
}
if (is_string($value) && $this->_useLocaleParser) {
return $this->_parseValue($value);
}
if (is_array($value)) {
Expand Down
6 changes: 4 additions & 2 deletions src/Error/Debugger.php
Expand Up @@ -323,9 +323,11 @@ public static function trimPath($path)

if (strpos($path, APP) === 0) {
return str_replace(APP, 'APP/', $path);
} elseif (strpos($path, CAKE_CORE_INCLUDE_PATH) === 0) {
}
if (strpos($path, CAKE_CORE_INCLUDE_PATH) === 0) {
return str_replace(CAKE_CORE_INCLUDE_PATH, 'CORE', $path);
} elseif (strpos($path, ROOT) === 0) {
}
if (strpos($path, ROOT) === 0) {
return str_replace(ROOT, 'ROOT', $path);
}

Expand Down
3 changes: 2 additions & 1 deletion src/Event/EventManager.php
Expand Up @@ -312,7 +312,8 @@ protected function _detachSubscriber(EventListenerInterface $subscriber, $eventK
$events = (array)$subscriber->implementedEvents();
if (!empty($eventKey) && empty($events[$eventKey])) {
return;
} elseif (!empty($eventKey)) {
}
if (!empty($eventKey)) {
$events = [$eventKey => $events[$eventKey]];
}
foreach ($events as $key => $function) {
Expand Down
3 changes: 2 additions & 1 deletion src/Filesystem/File.php
Expand Up @@ -338,7 +338,8 @@ public function name()
}
if (isset($this->info['extension'])) {
return basename($this->name, '.' . $this->info['extension']);
} elseif ($this->name) {
}
if ($this->name) {
return $this->name;
}
return false;
Expand Down
6 changes: 4 additions & 2 deletions src/Network/Request.php
Expand Up @@ -332,7 +332,8 @@ protected static function _url($config)
{
if (!empty($_SERVER['PATH_INFO'])) {
return $_SERVER['PATH_INFO'];
} elseif (isset($_SERVER['REQUEST_URI']) && strpos($_SERVER['REQUEST_URI'], '://') === false) {
}
if (isset($_SERVER['REQUEST_URI']) && strpos($_SERVER['REQUEST_URI'], '://') === false) {
$uri = $_SERVER['REQUEST_URI'];
} elseif (isset($_SERVER['REQUEST_URI'])) {
$qPosition = strpos($_SERVER['REQUEST_URI'], '?');
Expand Down Expand Up @@ -559,7 +560,8 @@ public function referer($local = false)
$ref = '/' . $ref;
}
return $ref;
} elseif (!$local) {
}
if (!$local) {
return $ref;
}
}
Expand Down
13 changes: 6 additions & 7 deletions src/ORM/Association/HasMany.php
Expand Up @@ -442,16 +442,15 @@ protected function _unlink(array $foreignKey, Table $target, array $conditions =
$ok = $ok && $target->delete($assoc, $options);
}
return $ok;
} else {
$target->deleteAll($conditions);
return true;
}
} else {
$updateFields = array_fill_keys($foreignKey, null);
$target->updateAll($updateFields, $conditions);
return true;

$target->deleteAll($conditions);
return true;
}

$updateFields = array_fill_keys($foreignKey, null);
$target->updateAll($updateFields, $conditions);
return true;
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/ORM/Behavior/TreeBehavior.php
Expand Up @@ -911,7 +911,8 @@ protected function _scope($query)

if (is_array($config['scope'])) {
return $query->where($config['scope']);
} elseif (is_callable($config['scope'])) {
}
if (is_callable($config['scope'])) {
return $config['scope']($query);
}

Expand Down
3 changes: 2 additions & 1 deletion src/Routing/Route/Route.php
Expand Up @@ -499,7 +499,8 @@ public function match(array $url, array $context = [])
$numeric = is_numeric($key);
if ($numeric && isset($defaults[$key]) && $defaults[$key] == $value) {
continue;
} elseif ($numeric) {
}
if ($numeric) {
$pass[] = $value;
unset($url[$key]);
continue;
Expand Down
3 changes: 2 additions & 1 deletion src/Routing/Router.php
Expand Up @@ -571,7 +571,8 @@ public static function url($url = null, $full = false)
$output = static::fullBaseUrl() . $output;
}
return $output;
} elseif (is_array($url)) {
}
if (is_array($url)) {
if (isset($url['_full']) && $url['_full'] === true) {
$full = true;
unset($url['_full']);
Expand Down
21 changes: 12 additions & 9 deletions src/Shell/Task/ExtractTask.php
Expand Up @@ -133,10 +133,12 @@ protected function _getPaths()
$this->err('Extract Aborted');
$this->_stop();
return;
} elseif (strtoupper($response) === 'D' && count($this->_paths)) {
}
if (strtoupper($response) === 'D' && count($this->_paths)) {
$this->out();
return;
} elseif (strtoupper($response) === 'D') {
}
if (strtoupper($response) === 'D') {
$this->err('<warning>No directories selected.</warning> Please choose a directory.');
} elseif (is_dir($response)) {
$this->_paths[] = $response;
Expand Down Expand Up @@ -205,16 +207,17 @@ public function main()
$this->err('Extract Aborted');
$this->_stop();
return;
} elseif ($this->_isPathUsable($response)) {
}
if ($this->_isPathUsable($response)) {
$this->_output = $response . DS;
break;
} else {
$this->err('');
$this->err(
'<error>The directory path you supplied was ' .
'not found. Please try again.</error>'
);
}

$this->err('');
$this->err(
'<error>The directory path you supplied was ' .
'not found. Please try again.</error>'
);
$this->out();
}
}
Expand Down
38 changes: 19 additions & 19 deletions src/TestSuite/TestCase.php
Expand Up @@ -398,27 +398,27 @@ public function assertHtml($expected, $string, $fullDebug = false)
$attrs[] = $matches[1];
$explanations[] = sprintf('Regex "%s" matches', $matches[1]);
continue;
}

$quotes = '["\']';
if (is_numeric($attr)) {
$attr = $val;
$val = '.+?';
$explanations[] = sprintf('Attribute "%s" present', $attr);
} elseif (!empty($val) && preg_match('/^preg\:\/(.+)\/$/i', $val, $matches)) {
$val = str_replace(
['.*', '.+'],
['.*?', '.+?'],
$matches[1]
);
$quotes = $val !== $matches[1] ? '["\']' : '["\']?';

$explanations[] = sprintf('Attribute "%s" matches "%s"', $attr, $val);
} else {
$quotes = '["\']';
if (is_numeric($attr)) {
$attr = $val;
$val = '.+?';
$explanations[] = sprintf('Attribute "%s" present', $attr);
} elseif (!empty($val) && preg_match('/^preg\:\/(.+)\/$/i', $val, $matches)) {
$val = str_replace(
['.*', '.+'],
['.*?', '.+?'],
$matches[1]
);
$quotes = $val !== $matches[1] ? '["\']' : '["\']?';

$explanations[] = sprintf('Attribute "%s" matches "%s"', $attr, $val);
} else {
$explanations[] = sprintf('Attribute "%s" == "%s"', $attr, $val);
$val = preg_quote($val, '/');
}
$attrs[] = '[\s]+' . preg_quote($attr, '/') . '=' . $quotes . $val . $quotes;
$explanations[] = sprintf('Attribute "%s" == "%s"', $attr, $val);
$val = preg_quote($val, '/');
}
$attrs[] = '[\s]+' . preg_quote($attr, '/') . '=' . $quotes . $val . $quotes;
$i++;
}
if ($attrs) {
Expand Down
6 changes: 3 additions & 3 deletions src/Utility/Text.php
Expand Up @@ -604,10 +604,10 @@ public static function truncate($text, $length = 100, array $options = [])

$truncate .= mb_substr($tag[3], 0, $left + $entitiesLength);
break;
} else {
$truncate .= $tag[3];
$totalLength += $contentLength;
}

$truncate .= $tag[3];
$totalLength += $contentLength;
if ($totalLength >= $length) {
break;
}
Expand Down
3 changes: 2 additions & 1 deletion src/View/Form/EntityContext.php
Expand Up @@ -221,7 +221,8 @@ public function val($field)

if ($entity instanceof EntityInterface) {
return $entity->get(array_pop($parts));
} elseif (is_array($entity)) {
}
if (is_array($entity)) {
$key = array_pop($parts);
return isset($entity[$key]) ? $entity[$key] : null;
}
Expand Down
3 changes: 2 additions & 1 deletion src/View/Helper/FormHelper.php
Expand Up @@ -635,7 +635,8 @@ protected function _secure($lock, $field, $value = null)
if (!in_array($field, $this->fields)) {
if ($value !== null) {
return $this->fields[$field] = $value;
} elseif (isset($this->fields[$field]) && $value === null) {
}
if (isset($this->fields[$field]) && $value === null) {
unset($this->fields[$field]);
}
$this->fields[] = $field;
Expand Down
3 changes: 2 additions & 1 deletion src/View/Helper/RssHelper.php
Expand Up @@ -218,7 +218,8 @@ public function item($att = [], $elements = [])
}
$elements[$key] = implode('', $categories);
continue 2;
} elseif (is_array($val) && isset($val['domain'])) {
}
if (is_array($val) && isset($val['domain'])) {
$attrib['domain'] = $val['domain'];
}
break;
Expand Down
3 changes: 2 additions & 1 deletion src/View/SerializedView.php
Expand Up @@ -86,7 +86,8 @@ public function render($view = null, $layout = null)

if ($serialize !== false) {
return $this->_serialize($serialize);
} elseif ($view !== false && $this->_getViewFileName($view)) {
}
if ($view !== false && $this->_getViewFileName($view)) {
return parent::render($view, false);
}
}
Expand Down

0 comments on commit 4a9249f

Please sign in to comment.