Commit 207fa796 authored by Andreas Möller's avatar Andreas Möller Committed by Markus Kalkbrenner

Fix: Remove useless else (#553)

parent bb1659ca
...@@ -306,10 +306,10 @@ class DisMax extends AbstractComponent ...@@ -306,10 +306,10 @@ class DisMax extends AbstractComponent
//double add calls for the same BQ are ignored, but non-unique keys cause an exception //double add calls for the same BQ are ignored, but non-unique keys cause an exception
if (array_key_exists($key, $this->boostQueries) && $this->boostQueries[$key] !== $boostQuery) { if (array_key_exists($key, $this->boostQueries) && $this->boostQueries[$key] !== $boostQuery) {
throw new InvalidArgumentException('A boostquery must have a unique key value within a query'); throw new InvalidArgumentException('A boostquery must have a unique key value within a query');
} else {
$this->boostQueries[$key] = $boostQuery;
} }
$this->boostQueries[$key] = $boostQuery;
return $this; return $this;
} }
......
...@@ -124,8 +124,6 @@ class MultiQuery extends AbstractFacet ...@@ -124,8 +124,6 @@ class MultiQuery extends AbstractFacet
{ {
if (isset($this->facetQueries[$key])) { if (isset($this->facetQueries[$key])) {
return $this->facetQueries[$key]; return $this->facetQueries[$key];
} else {
return;
} }
} }
......
...@@ -335,10 +335,10 @@ class FacetSet extends AbstractComponent ...@@ -335,10 +335,10 @@ class FacetSet extends AbstractComponent
//double add calls for the same facet are ignored, but non-unique keys cause an exception //double add calls for the same facet are ignored, but non-unique keys cause an exception
if (array_key_exists($key, $this->facets) && $this->facets[$key] !== $facet) { if (array_key_exists($key, $this->facets) && $this->facets[$key] !== $facet) {
throw new InvalidArgumentException('A facet must have a unique key value within a query'); throw new InvalidArgumentException('A facet must have a unique key value within a query');
} else {
$this->facets[$key] = $facet;
} }
$this->facets[$key] = $facet;
return $this; return $this;
} }
...@@ -374,8 +374,6 @@ class FacetSet extends AbstractComponent ...@@ -374,8 +374,6 @@ class FacetSet extends AbstractComponent
{ {
if (isset($this->facets[$key])) { if (isset($this->facets[$key])) {
return $this->facets[$key]; return $this->facets[$key];
} else {
return;
} }
} }
......
...@@ -98,8 +98,6 @@ class Highlighting extends AbstractComponent ...@@ -98,8 +98,6 @@ class Highlighting extends AbstractComponent
$this->addField($name); $this->addField($name);
return $this->fields[$name]; return $this->fields[$name];
} else {
return;
} }
} }
......
...@@ -73,9 +73,7 @@ class DocumentSet implements \IteratorAggregate, \Countable ...@@ -73,9 +73,7 @@ class DocumentSet implements \IteratorAggregate, \Countable
{ {
if (isset($this->docs[$key])) { if (isset($this->docs[$key])) {
return $this->docs[$key]; return $this->docs[$key];
} else { }
return;
}
} }
/** /**
......
...@@ -92,8 +92,6 @@ class Timing implements \IteratorAggregate, \Countable ...@@ -92,8 +92,6 @@ class Timing implements \IteratorAggregate, \Countable
{ {
if (isset($this->phases[$key])) { if (isset($this->phases[$key])) {
return $this->phases[$key]; return $this->phases[$key];
} else {
return;
} }
} }
......
...@@ -101,8 +101,6 @@ class TimingPhase implements \IteratorAggregate, \Countable ...@@ -101,8 +101,6 @@ class TimingPhase implements \IteratorAggregate, \Countable
{ {
if (isset($this->timings[$key])) { if (isset($this->timings[$key])) {
return $this->timings[$key]; return $this->timings[$key];
} else {
return;
} }
} }
......
...@@ -73,9 +73,7 @@ class FacetSet implements \IteratorAggregate, \Countable ...@@ -73,9 +73,7 @@ class FacetSet implements \IteratorAggregate, \Countable
{ {
if (isset($this->facets[$key])) { if (isset($this->facets[$key])) {
return $this->facets[$key]; return $this->facets[$key];
} else { }
return;
}
} }
/** /**
......
...@@ -85,8 +85,6 @@ class Result implements \IteratorAggregate, \Countable ...@@ -85,8 +85,6 @@ class Result implements \IteratorAggregate, \Countable
{ {
if (isset($this->groups[$key])) { if (isset($this->groups[$key])) {
return $this->groups[$key]; return $this->groups[$key];
} else {
return;
} }
} }
......
...@@ -73,8 +73,6 @@ class Highlighting implements \IteratorAggregate, \Countable ...@@ -73,8 +73,6 @@ class Highlighting implements \IteratorAggregate, \Countable
{ {
if (isset($this->results[$key])) { if (isset($this->results[$key])) {
return $this->results[$key]; return $this->results[$key];
} else {
return;
} }
} }
......
...@@ -83,9 +83,9 @@ class Result implements \IteratorAggregate, \Countable ...@@ -83,9 +83,9 @@ class Result implements \IteratorAggregate, \Countable
{ {
if (isset($this->fields[$key])) { if (isset($this->fields[$key])) {
return $this->fields[$key]; return $this->fields[$key];
} else {
return array();
} }
return array();
} }
/** /**
......
...@@ -73,8 +73,6 @@ class MoreLikeThis implements \IteratorAggregate, \Countable ...@@ -73,8 +73,6 @@ class MoreLikeThis implements \IteratorAggregate, \Countable
{ {
if (isset($this->results[$key])) { if (isset($this->results[$key])) {
return $this->results[$key]; return $this->results[$key];
} else {
return;
} }
} }
......
...@@ -92,13 +92,13 @@ class Result implements \IteratorAggregate, \Countable ...@@ -92,13 +92,13 @@ class Result implements \IteratorAggregate, \Countable
$nrOfCollations = count($this->collations); $nrOfCollations = count($this->collations);
if ($nrOfCollations == 0) { if ($nrOfCollations == 0) {
return; return;
} else { }
if ($key === null) {
return reset($this->collations);
}
return $this->collations[$key]; if ($key === null) {
return reset($this->collations);
} }
return $this->collations[$key];
} }
/** /**
...@@ -134,8 +134,6 @@ class Result implements \IteratorAggregate, \Countable ...@@ -134,8 +134,6 @@ class Result implements \IteratorAggregate, \Countable
{ {
if (isset($this->suggestions[$key])) { if (isset($this->suggestions[$key])) {
return $this->suggestions[$key]; return $this->suggestions[$key];
} else {
return;
} }
} }
......
...@@ -115,9 +115,9 @@ class Suggestion ...@@ -115,9 +115,9 @@ class Suggestion
$word = reset($this->words); $word = reset($this->words);
if (isset($word['word'])) { if (isset($word['word'])) {
return $word['word']; return $word['word'];
} else {
return $word;
} }
return $word;
} }
/** /**
...@@ -142,8 +142,6 @@ class Suggestion ...@@ -142,8 +142,6 @@ class Suggestion
$word = reset($this->words); $word = reset($this->words);
if (isset($word['freq'])) { if (isset($word['freq'])) {
return $word['freq']; return $word['freq'];
} else {
return;
} }
} }
} }
...@@ -73,8 +73,6 @@ class Stats implements \IteratorAggregate, \Countable ...@@ -73,8 +73,6 @@ class Stats implements \IteratorAggregate, \Countable
{ {
if (isset($this->results[$key])) { if (isset($this->results[$key])) {
return $this->results[$key]; return $this->results[$key];
} else {
return;
} }
} }
......
...@@ -66,9 +66,9 @@ class Result implements \IteratorAggregate, \Countable ...@@ -66,9 +66,9 @@ class Result implements \IteratorAggregate, \Countable
{ {
if (isset($this->results[$dictionary])) { if (isset($this->results[$dictionary])) {
return $this->results[$dictionary]; return $this->results[$dictionary];
} else {
return null;
} }
return null;
} }
/** /**
......
...@@ -45,9 +45,9 @@ class Field implements \IteratorAggregate, \Countable ...@@ -45,9 +45,9 @@ class Field implements \IteratorAggregate, \Countable
{ {
if (isset($this->terms[$field])) { if (isset($this->terms[$field])) {
return $this->terms[$field]; return $this->terms[$field];
} else {
return null;
} }
return null;
} }
/** /**
......
...@@ -65,9 +65,9 @@ class Result implements \IteratorAggregate, \Countable ...@@ -65,9 +65,9 @@ class Result implements \IteratorAggregate, \Countable
{ {
if (isset($this->results[$field])) { if (isset($this->results[$field])) {
return $this->results[$field]; return $this->results[$field];
} else {
return null;
} }
return null;
} }
/** /**
......
...@@ -116,10 +116,10 @@ class Stats extends AbstractComponent ...@@ -116,10 +116,10 @@ class Stats extends AbstractComponent
//double add calls for the same field are ignored, but non-unique keys cause an exception //double add calls for the same field are ignored, but non-unique keys cause an exception
if (array_key_exists($key, $this->fields) && $this->fields[$key] !== $field) { if (array_key_exists($key, $this->fields) && $this->fields[$key] !== $field) {
throw new InvalidArgumentException('A field must have a unique key value'); throw new InvalidArgumentException('A field must have a unique key value');
} else {
$this->fields[$key] = $field;
} }
$this->fields[$key] = $field;
return $this; return $this;
} }
...@@ -155,8 +155,6 @@ class Stats extends AbstractComponent ...@@ -155,8 +155,6 @@ class Stats extends AbstractComponent
{ {
if (isset($this->fields[$key])) { if (isset($this->fields[$key])) {
return $this->fields[$key]; return $this->fields[$key];
} else {
return;
} }
} }
......
...@@ -301,13 +301,13 @@ class Client extends Configurable implements ClientInterface ...@@ -301,13 +301,13 @@ class Client extends Configurable implements ClientInterface
//double add calls for the same endpoint are ignored, but non-unique keys cause an exception //double add calls for the same endpoint are ignored, but non-unique keys cause an exception
if (array_key_exists($key, $this->endpoints) && $this->endpoints[$key] !== $endpoint) { if (array_key_exists($key, $this->endpoints) && $this->endpoints[$key] !== $endpoint) {
throw new InvalidArgumentException('An endpoint must have a unique key'); throw new InvalidArgumentException('An endpoint must have a unique key');
} else { }
$this->endpoints[$key] = $endpoint;
// if no default endpoint is set do so now $this->endpoints[$key] = $endpoint;
if (null === $this->defaultEndpoint) {
$this->defaultEndpoint = $key; // if no default endpoint is set do so now
} if (null === $this->defaultEndpoint) {
$this->defaultEndpoint = $key;
} }
return $this; return $this;
...@@ -474,9 +474,9 @@ class Client extends Configurable implements ClientInterface ...@@ -474,9 +474,9 @@ class Client extends Configurable implements ClientInterface
$this->adapter = $adapter; $this->adapter = $adapter;
return $this; return $this;
} else {
throw new InvalidArgumentException('Invalid adapter input for setAdapter');
} }
throw new InvalidArgumentException('Invalid adapter input for setAdapter');
} }
/** /**
...@@ -659,11 +659,9 @@ class Client extends Configurable implements ClientInterface ...@@ -659,11 +659,9 @@ class Client extends Configurable implements ClientInterface
$this->registerPlugin($key, $this->pluginTypes[$key]); $this->registerPlugin($key, $this->pluginTypes[$key]);
return $this->pluginInstances[$key]; return $this->pluginInstances[$key];
} else { }
throw new OutOfBoundsException('Cannot autoload plugin of unknown type: '.$key);
} throw new OutOfBoundsException('Cannot autoload plugin of unknown type: '.$key);
} else {
return;
} }
} }
......
...@@ -155,8 +155,6 @@ class Request extends Configurable ...@@ -155,8 +155,6 @@ class Request extends Configurable
{ {
if (isset($this->params[$key])) { if (isset($this->params[$key])) {
return $this->params[$key]; return $this->params[$key];
} else {
return;
} }
} }
......
...@@ -132,9 +132,7 @@ class Configurable implements ConfigurableInterface ...@@ -132,9 +132,7 @@ class Configurable implements ConfigurableInterface
{ {
if (isset($this->options[$name])) { if (isset($this->options[$name])) {
return $this->options[$name]; return $this->options[$name];
} else { }
return;
}
} }
/** /**
......
...@@ -121,9 +121,9 @@ abstract class AbstractRequestBuilder implements RequestBuilderInterface ...@@ -121,9 +121,9 @@ abstract class AbstractRequestBuilder implements RequestBuilderInterface
$value = (true === (bool)$value) ? 'true' : 'false'; $value = (true === (bool)$value) ? 'true' : 'false';
return $this->attrib($name, $value); return $this->attrib($name, $value);
} else {
return '';
} }
return '';
} }
/** /**
...@@ -140,8 +140,8 @@ abstract class AbstractRequestBuilder implements RequestBuilderInterface ...@@ -140,8 +140,8 @@ abstract class AbstractRequestBuilder implements RequestBuilderInterface
{ {
if (null !== $value) { if (null !== $value) {
return ' '.$name.'="'.$value.'"'; return ' '.$name.'="'.$value.'"';
} else {
return '';
} }
return '';
} }
} }
...@@ -186,10 +186,10 @@ class Helper ...@@ -186,10 +186,10 @@ class Helper
$iso8601 .= 'Z'; $iso8601 .= 'Z';
return $iso8601; return $iso8601;
} else {
// unsupported input
return false;
} }
// unsupported input
return false;
} }
/** /**
...@@ -223,9 +223,9 @@ class Helper ...@@ -223,9 +223,9 @@ class Helper
if ($inclusive) { if ($inclusive) {
return $field.':['.$from.' TO '.$to.']'; return $field.':['.$from.' TO '.$to.']';
} else {
return $field.':{'.$from.' TO '.$to.'}';
} }
return $field.':{'.$from.' TO '.$to.'}';
} }
/** /**
...@@ -369,9 +369,9 @@ class Helper ...@@ -369,9 +369,9 @@ class Helper
} }
return $name.'()'; return $name.'()';
} else {
return $name.'('.implode($params, ',').')';
} }
return $name.'('.implode($params, ',').')';
} }
/** /**
......
...@@ -161,9 +161,7 @@ class CustomizeRequest extends AbstractPlugin ...@@ -161,9 +161,7 @@ class CustomizeRequest extends AbstractPlugin
{ {
if (isset($this->customizations[$key])) { if (isset($this->customizations[$key])) {
return $this->customizations[$key]; return $this->customizations[$key];
} else { }
return;
}
} }
/** /**
......
...@@ -205,10 +205,10 @@ class Loadbalancer extends AbstractPlugin ...@@ -205,10 +205,10 @@ class Loadbalancer extends AbstractPlugin
if (array_key_exists($endpoint, $this->endpoints)) { if (array_key_exists($endpoint, $this->endpoints)) {
throw new InvalidArgumentException('An endpoint for the loadbalancer plugin must have a unique key'); throw new InvalidArgumentException('An endpoint for the loadbalancer plugin must have a unique key');
} else {
$this->endpoints[$endpoint] = $weight;
} }
$this->endpoints[$endpoint] = $weight;
// reset the randomizer as soon as a new endpoint is added // reset the randomizer as soon as a new endpoint is added
$this->randomizer = null; $this->randomizer = null;
...@@ -487,12 +487,12 @@ class Loadbalancer extends AbstractPlugin ...@@ -487,12 +487,12 @@ class Loadbalancer extends AbstractPlugin
// if we get here no more retries available, throw exception // if we get here no more retries available, throw exception
throw new RuntimeException('Maximum number of loadbalancer retries reached'); throw new RuntimeException('Maximum number of loadbalancer retries reached');
} else {
// no failover retries, just execute and let an exception bubble upwards
$endpoint = $this->getRandomEndpoint();
return $adapter->execute($request, $endpoint);
} }
// no failover retries, just execute and let an exception bubble upwards
$endpoint = $this->getRandomEndpoint();
return $adapter->execute($request, $endpoint);
} }
/** /**
......
...@@ -145,8 +145,8 @@ class WeightedRandomChoice ...@@ -145,8 +145,8 @@ class WeightedRandomChoice
if ($this->lookup[$low] >= $random) { if ($this->lookup[$low] >= $random) {
return $low; return $low;
} else {
return $low+1;
} }
return $low+1;
} }
} }
...@@ -149,8 +149,6 @@ class Document extends BaseResult implements \IteratorAggregate, \Countable ...@@ -149,8 +149,6 @@ class Document extends BaseResult implements \IteratorAggregate, \Countable
if (isset($this->items[$key])) { if (isset($this->items[$key])) {
return $this->items[$key]; return $this->items[$key];
} else { }
return;
}
} }
} }
...@@ -185,9 +185,9 @@ class Item ...@@ -185,9 +185,9 @@ class Item
{ {
if (is_array($this->positionHistory)) { if (is_array($this->positionHistory)) {
return $this->positionHistory; return $this->positionHistory;
} else {
return array();
} }
return array();
} }
/** /**
......
...@@ -607,10 +607,10 @@ class Query extends AbstractQuery implements ComponentAwareQueryInterface ...@@ -607,10 +607,10 @@ class Query extends AbstractQuery implements ComponentAwareQueryInterface
//double add calls for the same FQ are ignored, but non-unique keys cause an exception //double add calls for the same FQ are ignored, but non-unique keys cause an exception
if (array_key_exists($key, $this->filterQueries) && $this->filterQueries[$key] !== $filterQuery) { if (array_key_exists($key, $this->filterQueries) && $this->filterQueries[$key] !== $filterQuery) {
throw new InvalidArgumentException('A filterquery must have a unique key value within a query'); throw new InvalidArgumentException('A filterquery must have a unique key value within a query');
} else {
$this->filterQueries[$key] = $filterQuery;
} }
$this->filterQueries[$key] = $filterQuery;
return $this; return $this;
} }
...@@ -646,8 +646,6 @@ class Query extends AbstractQuery implements ComponentAwareQueryInterface ...@@ -646,8 +646,6 @@ class Query extends AbstractQuery implements ComponentAwareQueryInterface
{ {
if (isset($this->filterQueries[$key])) { if (isset($this->filterQueries[$key])) {
return $this->filterQueries[$key]; return $this->filterQueries[$key];
} else {
return;
} }
} }
......
...@@ -262,9 +262,9 @@ class Result extends BaseResult implements \IteratorAggregate, \Countable ...@@ -262,9 +262,9 @@ class Result extends BaseResult implements \IteratorAggregate, \Countable
if (isset($this->components[$key])) { if (isset($this->components[$key])) {
return $this->components[$key]; return $this->components[$key];
} else {
return null;
} }
return null;
} }
/** /**
......
...@@ -153,9 +153,9 @@ class Result extends BaseResult implements \IteratorAggregate, \Countable ...@@ -153,9 +153,9 @@ class Result extends BaseResult implements \IteratorAggregate, \Countable
if (isset($this->results[$term])) { if (isset($this->results[$term])) {
return $this->results[$term]; return $this->results[$term];
} else {
return array();
} }
return array();
} }
/** /**
......
...@@ -83,9 +83,9 @@ class Dictionary implements \IteratorAggregate, \Countable ...@@ -83,9 +83,9 @@ class Dictionary implements \IteratorAggregate, \Countable
{ {
if (isset($this->terms[$term])) { if (isset($this->terms[$term])) {
return $this->terms[$term]; return $this->terms[$term];
} else {
return null;
} }
return null;
} }
/** /**
......
...@@ -144,9 +144,9 @@ class Result extends BaseResult implements \IteratorAggregate, \Countable ...@@ -144,9 +144,9 @@ class Result extends BaseResult implements \IteratorAggregate, \Countable
if (isset($this->results[$dictionary])) { if (isset($this->results[$dictionary])) {
return $this->results[$dictionary]; return $this->results[$dictionary];
} else {
return null;
} }
return null;
} }
/** /**
......
...@@ -125,9 +125,9 @@ class Result extends BaseResult implements \IteratorAggregate, \Countable ...@@ -125,9 +125,9 @@ class Result extends BaseResult implements \IteratorAggregate, \Countable
if (isset($this->results[$field])) { if (isset($this->results[$field])) {
return $this->results[$field]; return $this->results[$field];
} else {
return array();
} }
return array();
} }
/** /**
......
...@@ -273,9 +273,7 @@ class Document extends AbstractDocument implements DocumentInterface ...@@ -273,9 +273,7 @@ class Document extends AbstractDocument implements DocumentInterface
{ {
if (isset($this->fieldBoosts[$key])) { if (isset($this->fieldBoosts[$key])) {
return $this->fieldBoosts[$key]; return $this->fieldBoosts[$key];
} else { }
return;
}
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment