Commit c37e459b authored by Bas de Nooijer's avatar Bas de Nooijer

Various code standard fixes

parent 404be18c
...@@ -192,7 +192,7 @@ class Client extends Configurable ...@@ -192,7 +192,7 @@ class Client extends Configurable
*/ */
protected function init() protected function init()
{ {
foreach ($this->options AS $name => $value) { foreach ($this->options as $name => $value) {
switch ($name) { switch ($name) {
case 'endpoint': case 'endpoint':
$this->addEndpoints($value); $this->addEndpoints($value);
...@@ -281,7 +281,7 @@ class Client extends Configurable ...@@ -281,7 +281,7 @@ class Client extends Configurable
*/ */
public function addEndpoints(array $endpoints) public function addEndpoints(array $endpoints)
{ {
foreach ($endpoints AS $key => $endpoint) { foreach ($endpoints as $key => $endpoint) {
// in case of a config array: add key to config // in case of a config array: add key to config
if (is_array($endpoint) && !isset($endpoint['key'])) { if (is_array($endpoint) && !isset($endpoint['key'])) {
...@@ -415,13 +415,13 @@ class Client extends Configurable ...@@ -415,13 +415,13 @@ class Client extends Configurable
if (is_string($adapter)) { if (is_string($adapter)) {
$this->adapter = null; $this->adapter = null;
return $this->setOption('adapter', $adapter); return $this->setOption('adapter', $adapter);
} else if($adapter instanceof AdapterInterface){ } else if($adapter instanceof AdapterInterface) {
// forward options // forward options
$adapter->setOptions($this->options); $adapter->setOptions($this->options);
// overwrite existing adapter // overwrite existing adapter
$this->adapter = $adapter; $this->adapter = $adapter;
return $this; return $this;
}else{ } else {
throw new Exception('Invalid adapter input for setAdapter'); throw new Exception('Invalid adapter input for setAdapter');
} }
} }
...@@ -445,7 +445,7 @@ class Client extends Configurable ...@@ -445,7 +445,7 @@ class Client extends Configurable
$adapter = new $adapterClass; $adapter = new $adapterClass;
// check interface // check interface
if(!($adapter instanceof AdapterInterface)) { if (!($adapter instanceof AdapterInterface)) {
throw new Exception('An adapter must implement the AdapterInterface'); throw new Exception('An adapter must implement the AdapterInterface');
} }
...@@ -666,7 +666,7 @@ class Client extends Configurable ...@@ -666,7 +666,7 @@ class Client extends Configurable
*/ */
protected function callPlugins($event, $params, $resultOverride = false) protected function callPlugins($event, $params, $resultOverride = false)
{ {
foreach ($this->pluginInstances AS $plugin) { foreach ($this->pluginInstances as $plugin) {
if (method_exists($plugin, $event)) { if (method_exists($plugin, $event)) {
$result = call_user_func_array(array($plugin, $event), $params); $result = call_user_func_array(array($plugin, $event), $params);
...@@ -686,7 +686,7 @@ class Client extends Configurable ...@@ -686,7 +686,7 @@ class Client extends Configurable
public function createRequest(QueryInterface $query) public function createRequest(QueryInterface $query)
{ {
$pluginResult = $this->callPlugins('preCreateRequest', array($query), true); $pluginResult = $this->callPlugins('preCreateRequest', array($query), true);
if($pluginResult !== null) { if ($pluginResult !== null) {
return $pluginResult; return $pluginResult;
} }
...@@ -934,7 +934,7 @@ class Client extends Configurable ...@@ -934,7 +934,7 @@ class Client extends Configurable
$type = strtolower($type); $type = strtolower($type);
$pluginResult = $this->callPlugins('preCreateQuery', array($type, $options), true); $pluginResult = $this->callPlugins('preCreateQuery', array($type, $options), true);
if($pluginResult !== null) { if ($pluginResult !== null) {
return $pluginResult; return $pluginResult;
} }
......
...@@ -69,7 +69,7 @@ class Endpoint extends Configurable ...@@ -69,7 +69,7 @@ class Endpoint extends Configurable
*/ */
protected function init() protected function init()
{ {
foreach ($this->options AS $name => $value) { foreach ($this->options as $name => $value) {
switch ($name) { switch ($name) {
case 'path': case 'path':
$this->setPath($value); $this->setPath($value);
......
...@@ -96,7 +96,7 @@ class Request extends Configurable ...@@ -96,7 +96,7 @@ class Request extends Configurable
*/ */
protected function init() protected function init()
{ {
foreach ($this->options AS $name => $value) { foreach ($this->options as $name => $value) {
switch ($name) { switch ($name) {
case 'rawdata': case 'rawdata':
$this->setRawData($value); $this->setRawData($value);
......
...@@ -138,7 +138,7 @@ class Response ...@@ -138,7 +138,7 @@ class Response
// get the status header // get the status header
$statusHeader = null; $statusHeader = null;
foreach ($headers AS $header) { foreach ($headers as $header) {
if (substr($header, 0, 4) == 'HTTP') { if (substr($header, 0, 4) == 'HTTP') {
$statusHeader = $header; $statusHeader = $header;
break; break;
......
...@@ -76,7 +76,7 @@ abstract class RequestBuilder implements RequestBuilderInterface ...@@ -76,7 +76,7 @@ abstract class RequestBuilder implements RequestBuilderInterface
public function renderLocalParams($value, $localParams = array()) public function renderLocalParams($value, $localParams = array())
{ {
$params = ''; $params = '';
foreach ($localParams AS $paramName => $paramValue) { foreach ($localParams as $paramName => $paramValue) {
if (empty($paramValue)) { if (empty($paramValue)) {
continue; continue;
} }
......
...@@ -83,7 +83,7 @@ class QueryType extends Result ...@@ -83,7 +83,7 @@ class QueryType extends Result
*/ */
protected function mapData($mapData) protected function mapData($mapData)
{ {
foreach ($mapData AS $key => $data) { foreach ($mapData as $key => $data) {
$this->$key = $data; $this->$key = $data;
} }
} }
......
...@@ -65,7 +65,7 @@ class CustomizeRequest extends Plugin ...@@ -65,7 +65,7 @@ class CustomizeRequest extends Plugin
*/ */
protected function init() protected function init()
{ {
foreach ($this->options AS $name => $value) { foreach ($this->options as $name => $value) {
switch ($name) { switch ($name) {
case 'customization': case 'customization':
$this->addCustomizations($value); $this->addCustomizations($value);
...@@ -146,7 +146,7 @@ class CustomizeRequest extends Plugin ...@@ -146,7 +146,7 @@ class CustomizeRequest extends Plugin
*/ */
public function addCustomizations(array $customizations) public function addCustomizations(array $customizations)
{ {
foreach ($customizations AS $key => $customization) { foreach ($customizations as $key => $customization) {
// in case of a config array: add key to config // in case of a config array: add key to config
if (is_array($customization) && !isset($customization['key'])) { if (is_array($customization) && !isset($customization['key'])) {
......
...@@ -145,7 +145,7 @@ class Loadbalancer extends Plugin ...@@ -145,7 +145,7 @@ class Loadbalancer extends Plugin
*/ */
protected function init() protected function init()
{ {
foreach ($this->options AS $name => $value) { foreach ($this->options as $name => $value) {
switch ($name) { switch ($name) {
case 'endpoint': case 'endpoint':
$this->setEndpoints($value); $this->setEndpoints($value);
...@@ -208,7 +208,7 @@ class Loadbalancer extends Plugin ...@@ -208,7 +208,7 @@ class Loadbalancer extends Plugin
*/ */
public function addEndpoint($endpoint, $weight = 1) public function addEndpoint($endpoint, $weight = 1)
{ {
if(!is_string($endpoint)) { if (!is_string($endpoint)) {
$endpoint = $endpoint->getKey(); $endpoint = $endpoint->getKey();
} }
...@@ -232,7 +232,7 @@ class Loadbalancer extends Plugin ...@@ -232,7 +232,7 @@ class Loadbalancer extends Plugin
*/ */
public function addEndpoints(array $endpoints) public function addEndpoints(array $endpoints)
{ {
foreach ($endpoints AS $endpoint => $weight) { foreach ($endpoints as $endpoint => $weight) {
$this->addEndpoint($endpoint, $weight); $this->addEndpoint($endpoint, $weight);
} }
...@@ -267,7 +267,7 @@ class Loadbalancer extends Plugin ...@@ -267,7 +267,7 @@ class Loadbalancer extends Plugin
*/ */
public function removeEndpoint($endpoint) public function removeEndpoint($endpoint)
{ {
if(!is_string($endpoint)) { if (!is_string($endpoint)) {
$endpoint = $endpoint->getKey(); $endpoint = $endpoint->getKey();
} }
...@@ -305,7 +305,7 @@ class Loadbalancer extends Plugin ...@@ -305,7 +305,7 @@ class Loadbalancer extends Plugin
*/ */
public function setForcedEndpointForNextQuery($endpoint) public function setForcedEndpointForNextQuery($endpoint)
{ {
if(!is_string($endpoint)) { if (!is_string($endpoint)) {
$endpoint = $endpoint->getKey(); $endpoint = $endpoint->getKey();
} }
...@@ -377,7 +377,7 @@ class Loadbalancer extends Plugin ...@@ -377,7 +377,7 @@ class Loadbalancer extends Plugin
*/ */
public function addBlockedQueryTypes($types) public function addBlockedQueryTypes($types)
{ {
foreach ($types AS $type) { foreach ($types as $type) {
$this->addBlockedQueryType($type); $this->addBlockedQueryType($type);
} }
} }
...@@ -472,7 +472,7 @@ class Loadbalancer extends Plugin ...@@ -472,7 +472,7 @@ class Loadbalancer extends Plugin
$endpoint = $this->getRandomEndpoint(); $endpoint = $this->getRandomEndpoint();
try { try {
return $adapter->execute($request, $endpoint); return $adapter->execute($request, $endpoint);
} catch(HttpException $e) { } catch (HttpException $e) {
// ignore HTTP errors and try again // ignore HTTP errors and try again
// but do issue an event for things like logging // but do issue an event for things like logging
$this->client->triggerEvent('LoadbalancerEndpointFail', array($endpoint->getOptions(), $e)); $this->client->triggerEvent('LoadbalancerEndpointFail', array($endpoint->getOptions(), $e));
......
...@@ -76,7 +76,7 @@ class WeightedRandomChoice ...@@ -76,7 +76,7 @@ class WeightedRandomChoice
public function __construct($choices) public function __construct($choices)
{ {
$i = 0; $i = 0;
foreach ($choices AS $key => $weight) { foreach ($choices as $key => $weight) {
if ($weight <=0) { if ($weight <=0) {
throw new Exception('Weight must be greater than zero'); throw new Exception('Weight must be greater than zero');
} }
......
...@@ -50,9 +50,9 @@ use Solarium\Core\Query\Query; ...@@ -50,9 +50,9 @@ use Solarium\Core\Query\Query;
* *
* While query execution is parallel, the results only become available as soon as all requests have finished. So the * While query execution is parallel, the results only become available as soon as all requests have finished. So the
* time of the slowest query will be the effective execution time for all queries. * time of the slowest query will be the effective execution time for all queries.
*
* @codeCoverageIgnoreStart
*/ */
// @codeCoverageIgnoreStart
class ParallelExecution extends Plugin class ParallelExecution extends Plugin
{ {
...@@ -173,7 +173,7 @@ class ParallelExecution extends Plugin ...@@ -173,7 +173,7 @@ class ParallelExecution extends Plugin
curl_multi_remove_handle($multiHandle, $handle); curl_multi_remove_handle($multiHandle, $handle);
$response = $adapter->getResponse($handle, curl_multi_getcontent($handle)); $response = $adapter->getResponse($handle, curl_multi_getcontent($handle));
$results[$key] = $this->client->createResult($this->queries[$key]['query'], $response); $results[$key] = $this->client->createResult($this->queries[$key]['query'], $response);
} catch(HttpException $e) { } catch (HttpException $e) {
$results[$key] = $e; $results[$key] = $e;
} }
...@@ -184,5 +184,7 @@ class ParallelExecution extends Plugin ...@@ -184,5 +184,7 @@ class ParallelExecution extends Plugin
return $results; return $results;
} }
// @codeCoverageIgnoreEnd /**
* @codeCoverageIgnoreEnd
*/
} }
...@@ -180,7 +180,7 @@ class PrefetchIterator extends Plugin implements \Iterator, \Countable ...@@ -180,7 +180,7 @@ class PrefetchIterator extends Plugin implements \Iterator, \Countable
* *
* @return int * @return int
*/ */
function key() public function key()
{ {
return $this->position; return $this->position;
} }
......
...@@ -72,12 +72,12 @@ class Document extends BaseRequestBuilder ...@@ -72,12 +72,12 @@ class Document extends BaseRequestBuilder
{ {
$xml = '<docs>'; $xml = '<docs>';
foreach ($query->getDocuments() AS $doc) { foreach ($query->getDocuments() as $doc) {
$xml .= '<doc>'; $xml .= '<doc>';
foreach ($doc->getFields() AS $name => $value) { foreach ($doc->getFields() as $name => $value) {
if (is_array($value)) { if (is_array($value)) {
foreach ($value AS $multival) { foreach ($value as $multival) {
$xml .= $this->buildFieldXml($name, $multival); $xml .= $this->buildFieldXml($name, $multival);
} }
} else { } else {
......
...@@ -51,7 +51,7 @@ class Types extends ResultList ...@@ -51,7 +51,7 @@ class Types extends ResultList
*/ */
public function getIndexAnalysis() public function getIndexAnalysis()
{ {
foreach ($this->items AS $item) { foreach ($this->items as $item) {
if ($item->getName() == 'index') { if ($item->getName() == 'index') {
return $item; return $item;
} }
...@@ -67,7 +67,7 @@ class Types extends ResultList ...@@ -67,7 +67,7 @@ class Types extends ResultList
*/ */
public function getQueryAnalysis() public function getQueryAnalysis()
{ {
foreach ($this->items AS $item) { foreach ($this->items as $item) {
if ($item->getName() == 'query') { if ($item->getName() == 'query') {
return $item; return $item;
} }
......
...@@ -54,7 +54,7 @@ use Solarium\Query\Select\Result\Result as SelectResult; ...@@ -54,7 +54,7 @@ use Solarium\Query\Select\Result\Result as SelectResult;
* count($result); * count($result);
* *
* // iterate over fetched mlt docs * // iterate over fetched mlt docs
* foreach ($result AS $doc) { * foreach ($result as $doc) {
* .... * ....
* } * }
* </code> * </code>
......
...@@ -95,7 +95,7 @@ class DistributedSearch extends Component ...@@ -95,7 +95,7 @@ class DistributedSearch extends Component
*/ */
protected function init() protected function init()
{ {
foreach ($this->options AS $name => $value) { foreach ($this->options as $name => $value) {
switch ($name) { switch ($name) {
case 'shards': case 'shards':
$this->setShards($value); $this->setShards($value);
......
...@@ -69,7 +69,7 @@ abstract class Facet extends Configurable ...@@ -69,7 +69,7 @@ abstract class Facet extends Configurable
*/ */
protected function init() protected function init()
{ {
foreach ($this->options AS $name => $value) { foreach ($this->options as $name => $value) {
switch ($name) { switch ($name) {
case 'key': case 'key':
$this->setKey($value); $this->setKey($value);
...@@ -126,7 +126,7 @@ abstract class Facet extends Configurable ...@@ -126,7 +126,7 @@ abstract class Facet extends Configurable
*/ */
public function addExcludes(array $excludes) public function addExcludes(array $excludes)
{ {
foreach ($excludes AS $exclude) { foreach ($excludes as $exclude) {
$this->addExclude($exclude); $this->addExclude($exclude);
} }
......
...@@ -68,7 +68,7 @@ class MultiQuery extends Facet ...@@ -68,7 +68,7 @@ class MultiQuery extends Facet
{ {
parent::init(); parent::init();
foreach ($this->options AS $name => $value) { foreach ($this->options as $name => $value) {
switch ($name) { switch ($name) {
case 'query': case 'query':
if (!is_array($value)) { if (!is_array($value)) {
...@@ -154,7 +154,7 @@ class MultiQuery extends Facet ...@@ -154,7 +154,7 @@ class MultiQuery extends Facet
*/ */
public function addQueries(array $facetQueries) public function addQueries(array $facetQueries)
{ {
foreach ($facetQueries AS $key => $facetQuery) { foreach ($facetQueries as $key => $facetQuery) {
// in case of a config array: add key to config // in case of a config array: add key to config
if (is_array($facetQuery) && !isset($facetQuery['key'])) { if (is_array($facetQuery) && !isset($facetQuery['key'])) {
...@@ -252,7 +252,7 @@ class MultiQuery extends Facet ...@@ -252,7 +252,7 @@ class MultiQuery extends Facet
*/ */
public function addExclude($tag) public function addExclude($tag)
{ {
foreach ($this->facetQueries AS $facetQuery) { foreach ($this->facetQueries as $facetQuery) {
$facetQuery->addExclude($tag); $facetQuery->addExclude($tag);
} }
...@@ -273,7 +273,7 @@ class MultiQuery extends Facet ...@@ -273,7 +273,7 @@ class MultiQuery extends Facet
*/ */
public function removeExclude($exclude) public function removeExclude($exclude)
{ {
foreach ($this->facetQueries AS $facetQuery) { foreach ($this->facetQueries as $facetQuery) {
$facetQuery->removeExclude($exclude); $facetQuery->removeExclude($exclude);
} }
...@@ -293,7 +293,7 @@ class MultiQuery extends Facet ...@@ -293,7 +293,7 @@ class MultiQuery extends Facet
*/ */
public function clearExcludes() public function clearExcludes()
{ {
foreach ($this->facetQueries AS $facetQuery) { foreach ($this->facetQueries as $facetQuery) {
$facetQuery->clearExcludes(); $facetQuery->clearExcludes();
} }
......
...@@ -109,7 +109,7 @@ class Range extends Facet ...@@ -109,7 +109,7 @@ class Range extends Facet
{ {
parent::init(); parent::init();
foreach ($this->options AS $name => $value) { foreach ($this->options as $name => $value) {
switch ($name) { switch ($name) {
case 'include': case 'include':
$this->setInclude($value); $this->setInclude($value);
......
...@@ -137,7 +137,7 @@ class FacetSet extends Component ...@@ -137,7 +137,7 @@ class FacetSet extends Component
protected function init() protected function init()
{ {
if (isset($this->options['facet'])) { if (isset($this->options['facet'])) {
foreach ($this->options['facet'] AS $key => $config) { foreach ($this->options['facet'] as $key => $config) {
if (!isset($config['key'])) { if (!isset($config['key'])) {
$config['key'] = $key; $config['key'] = $key;
} }
...@@ -311,7 +311,7 @@ class FacetSet extends Component ...@@ -311,7 +311,7 @@ class FacetSet extends Component
*/ */
public function addFacets(array $facets) public function addFacets(array $facets)
{ {
foreach ($facets AS $key => $facet) { foreach ($facets as $key => $facet) {
// in case of a config array: add key to config // in case of a config array: add key to config
if (is_array($facet) && !isset($facet['key'])) { if (is_array($facet) && !isset($facet['key'])) {
......
...@@ -47,8 +47,7 @@ use Solarium\Query\Select\ResponseParser\Component\Grouping as ResponseParser; ...@@ -47,8 +47,7 @@ use Solarium\Query\Select\ResponseParser\Component\Grouping as ResponseParser;
* Also known as Result Grouping or Field Collapsing. * Also known as Result Grouping or Field Collapsing.
* See the Solr wiki for more info about this functionality * See the Solr wiki for more info about this functionality
* *
* @link http://wiki.apache.org/solr/FieldCollapsing * @link http://wiki.apache.org/solr/FieldCollapsing
*
* @since 2.1.0 * @since 2.1.0
*/ */
class Grouping extends Component class Grouping extends Component
...@@ -125,7 +124,7 @@ class Grouping extends Component ...@@ -125,7 +124,7 @@ class Grouping extends Component
*/ */
protected function init() protected function init()
{ {
foreach ($this->options AS $name => $value) { foreach ($this->options as $name => $value) {
switch ($name) { switch ($name) {
case 'queries': case 'queries':
$this->setQueries($value); $this->setQueries($value);
......
...@@ -106,7 +106,7 @@ class Highlighting extends Component ...@@ -106,7 +106,7 @@ class Highlighting extends Component
*/ */
protected function init() protected function init()
{ {
foreach ($this->options AS $name => $value) { foreach ($this->options as $name => $value) {
switch ($name) { switch ($name) {
case 'field': case 'field':
$this->addFields($value); $this->addFields($value);
...@@ -173,7 +173,7 @@ class Highlighting extends Component ...@@ -173,7 +173,7 @@ class Highlighting extends Component
$fields = array_map('trim', $fields); $fields = array_map('trim', $fields);
} }
foreach ($fields AS $key => $field) { foreach ($fields as $key => $field) {
// in case of a config array without key: add key to config // in case of a config array without key: add key to config
if (is_array($field) && !isset($field['name'])) { if (is_array($field) && !isset($field['name'])) {
......
...@@ -62,7 +62,7 @@ class Field extends Configurable ...@@ -62,7 +62,7 @@ class Field extends Configurable
*/ */
protected function init() protected function init()
{ {
foreach ($this->options AS $name => $value) { foreach ($this->options as $name => $value) {
switch ($name) { switch ($name) {
case 'facet': case 'facet':
$this->setFacets($value); $this->setFacets($value);
...@@ -119,7 +119,7 @@ class Field extends Configurable ...@@ -119,7 +119,7 @@ class Field extends Configurable
$facets = array_map('trim', $facets); $facets = array_map('trim', $facets);
} }
foreach ($facets AS $facet) { foreach ($facets as $facet) {
$this->addFacet($facet); $this->addFacet($facet);
} }
......
...@@ -105,7 +105,7 @@ class Stats extends Component ...@@ -105,7 +105,7 @@ class Stats extends Component
*/ */
protected function init() protected function init()
{ {
foreach ($this->options AS $name => $value) { foreach ($this->options as $name => $value) {
switch ($name) { switch ($name) {
case 'field': case 'field':
$this->setFields($value); $this->setFields($value);
...@@ -186,7 +186,7 @@ class Stats extends Component ...@@ -186,7 +186,7 @@ class Stats extends Component
*/ */
public function addFields(array $fields) public function addFields(array $fields)
{ {
foreach ($fields AS $key => $field) { foreach ($fields as $key => $field) {
// in case of a config array: add key to config // in case of a config array: add key to config
if (is_array($field) && !isset($field['key'])) { if (is_array($field) && !isset($field['key'])) {
...@@ -296,7 +296,7 @@ class Stats extends Component ...@@ -296,7 +296,7 @@ class Stats extends Component
$facets = array_map('trim', $facets); $facets = array_map('trim', $facets);
} }
foreach ($facets AS $facet) { foreach ($facets as $facet) {
$this->addFacet($facet); $this->addFacet($facet);
} }
......
...@@ -69,7 +69,7 @@ class FilterQuery extends Configurable ...@@ -69,7 +69,7 @@ class FilterQuery extends Configurable
*/ */
protected function init() protected function init()
{ {
foreach ($this->options AS $name => $value) { foreach ($this->options as $name => $value) {
switch ($name) { switch ($name) {
case 'tag': case 'tag':
if (!is_array($value)) { if (!is_array($value)) {
...@@ -158,7 +158,7 @@ class FilterQuery extends Configurable ...@@ -158,7 +158,7 @@ class FilterQuery extends Configurable
*/ */
public function addTags($tags) public function addTags($tags)
{ {
foreach ($tags AS $tag) { foreach ($tags as $tag) {
$this->addTag($tag); $this->addTag($tag);
} }
return $this; return $this;
......
...@@ -218,7 +218,7 @@ class Query extends BaseQuery ...@@ -218,7 +218,7 @@ class Query extends BaseQuery
*/ */
protected function init() protected function init()
{ {
foreach ($this->options AS $name => $value) { foreach ($this->options as $name => $value) {
switch ($name) { switch ($name) {
case 'query': case 'query':
$this->setQuery($value); $this->setQuery($value);
...@@ -433,7 +433,7 @@ class Query extends BaseQuery ...@@ -433,7 +433,7 @@ class Query extends BaseQuery
$fields = array_map('trim', $fields); $fields = array_map('trim', $fields);
} }
foreach ($fields AS $field) { foreach ($fields as $field) {
$this->addField($field); $this->addField($field);
} }
...@@ -516,7 +516,7 @@ class Query extends BaseQuery ...@@ -516,7 +516,7 @@ class Query extends BaseQuery
*/ */
public function addSorts(array $sorts) public function addSorts(array $sorts)
{ {
foreach ($sorts AS $sort => $order) { foreach ($sorts as $sort => $order) {
$this->addSort($sort, $order); $this->addSort($sort, $order);
} }
...@@ -644,7 +644,7 @@ class Query extends BaseQuery ...@@ -644,7 +644,7 @@ class Query extends BaseQuery
*/ */
public function addFilterQueries(array $filterQueries) public function addFilterQueries(array $filterQueries)
{ {
foreach ($filterQueries AS $key => $filterQuery) { foreach ($filterQueries as $key => $filterQuery) {
// in case of a config array: add key to config // in case of a config array: add key to config
if (is_array($filterQuery) && !isset($filterQuery['key'])) { if (is_array($filterQuery) && !isset($filterQuery['key'])) {
...@@ -841,7 +841,7 @@ class Query extends BaseQuery ...@@ -841,7 +841,7 @@ class Query extends BaseQuery
*/ */
protected function createComponents($configs) protected function createComponents($configs)
{ {
foreach ($configs AS $type => $config) { foreach ($configs as $type => $config) {
$this->getComponent($type, true, $config); $this->getComponent($type, true, $config);
} }
} }
......
...@@ -75,7 +75,7 @@ class FacetSet extends RequestBuilder ...@@ -75,7 +75,7 @@ class FacetSet extends RequestBuilder
$request->addParam('facet.mincount', $component->getMinCount()); $request->addParam('facet.mincount', $component->getMinCount());
$request->addParam('facet.limit', $component->getLimit()); $request->addParam('facet.limit', $component->getLimit());
foreach ($facets AS $facet) { foreach ($facets as $facet) {
switch ($facet->getType()) switch ($facet->getType())
{ {
case FacetsetComponent::FACET_FIELD: case FacetsetComponent::FACET_FIELD:
...@@ -154,7 +154,7 @@ class FacetSet extends RequestBuilder ...@@ -154,7 +154,7 @@ class FacetSet extends RequestBuilder
*/ */
public function addFacetMultiQuery($request, $facet) public function addFacetMultiQuery($request, $facet)
{ {
foreach ($facet->getQueries() AS $facetQuery) { foreach ($facet->getQueries() as $facetQuery) {
$this->addFacetQuery($request, $facetQuery); $this->addFacetQuery($request, $facetQuery);
} }
} }
...@@ -185,14 +185,14 @@ class FacetSet extends RequestBuilder ...@@ -185,14 +185,14 @@ class FacetSet extends RequestBuilder
if ($facet->getInclude() !== null) { if ($facet->getInclude() !== null) {
$other = explode(',', $facet->getOther()); $other = explode(',', $facet->getOther());
foreach ($other AS $otherValue) { foreach ($other as $otherValue) {
$request->addParam("f.$field.facet.range.other", trim($otherValue)); $request->addParam("f.$field.facet.range.other", trim($otherValue));
} }
} }
if ($facet->getInclude() !== null) { if ($facet->getInclude() !== null) {
$include = explode(',', $facet->getInclude()); $include = explode(',', $facet->getInclude());
foreach ($include AS $includeValue) { foreach ($include as $includeValue) {
$request->addParam("f.$field.facet.range.include", trim($includeValue)); $request->addParam("f.$field.facet.range.include", trim($includeValue));
} }
} }
......
...@@ -68,7 +68,7 @@ class RequestBuilder extends BaseRequestBuilder ...@@ -68,7 +68,7 @@ class RequestBuilder extends BaseRequestBuilder
// add sort fields to request // add sort fields to request
$sort = array(); $sort = array();
foreach ($query->getSorts() AS $field => $order) { foreach ($query->getSorts() as $field => $order) {
$sort[] = $field . ' ' . $order; $sort[] = $field . ' ' . $order;
} }
if (count($sort) !== 0) { if (count($sort) !== 0) {
...@@ -78,7 +78,7 @@ class RequestBuilder extends BaseRequestBuilder ...@@ -78,7 +78,7 @@ class RequestBuilder extends BaseRequestBuilder
// add filterqueries to request // add filterqueries to request
$filterQueries = $query->getFilterQueries(); $filterQueries = $query->getFilterQueries();
if (count($filterQueries) !== 0) { if (count($filterQueries) !== 0) {
foreach ($filterQueries AS $filterQuery) { foreach ($filterQueries as $filterQuery) {
$fq = $this->renderLocalParams( $fq = $this->renderLocalParams(
$filterQuery->getQuery(), $filterQuery->getQuery(),
array('tag' => $filterQuery->getTags()) array('tag' => $filterQuery->getTags())
......
...@@ -61,7 +61,7 @@ class FacetSet ...@@ -61,7 +61,7 @@ class FacetSet
public function parse($query, $facetSet, $data) public function parse($query, $facetSet, $data)
{ {
$facets = array(); $facets = array();
foreach ($facetSet->getFacets() AS $key => $facet) { foreach ($facetSet->getFacets() as $key => $facet) {
switch ($facet->getType()) { switch ($facet->getType()) {
case QueryFacetSet::FACET_FIELD: case QueryFacetSet::FACET_FIELD:
$result = $this->facetField($facet, $data); $result = $this->facetField($facet, $data);
...@@ -116,7 +116,7 @@ class FacetSet ...@@ -116,7 +116,7 @@ class FacetSet
); );
$facetValues = array(); $facetValues = array();
foreach ($values AS $value) { foreach ($values as $value) {
$facetValues[$value[0]] = $value[1]; $facetValues[$value[0]] = $value[1];
} }
...@@ -151,7 +151,7 @@ class FacetSet ...@@ -151,7 +151,7 @@ class FacetSet
protected function facetMultiQuery($facet, $data) protected function facetMultiQuery($facet, $data)
{ {
$values = array(); $values = array();
foreach ($facet->getQueries() AS $query) { foreach ($facet->getQueries() as $query) {
$key = $query->getKey(); $key = $query->getKey();
if (isset($data['facet_counts']['facet_queries'][$key])) { if (isset($data['facet_counts']['facet_queries'][$key])) {
$count = $data['facet_counts']['facet_queries'][$key]; $count = $data['facet_counts']['facet_queries'][$key];
......
...@@ -61,7 +61,7 @@ class Highlighting ...@@ -61,7 +61,7 @@ class Highlighting
if (isset($data['highlighting'])) { if (isset($data['highlighting'])) {
$highlightResults = $data['highlighting']; $highlightResults = $data['highlighting'];
foreach ($highlightResults AS $key => $result) { foreach ($highlightResults as $key => $result) {
$results[$key] = new HighlightingResult\Result( $results[$key] = new HighlightingResult\Result(
$result $result
); );
......
...@@ -63,11 +63,11 @@ class MoreLikeThis ...@@ -63,11 +63,11 @@ class MoreLikeThis
$documentClass = $query->getOption('documentclass'); $documentClass = $query->getOption('documentclass');
$searchResults = $data['moreLikeThis']; $searchResults = $data['moreLikeThis'];
foreach ($searchResults AS $key => $result) { foreach ($searchResults as $key => $result) {
// create document instances // create document instances
$docs = array(); $docs = array();
foreach ($result['docs'] AS $fields) { foreach ($result['docs'] as $fields) {
$docs[] = new $documentClass($fields); $docs[] = new $documentClass($fields);
} }
......
...@@ -63,7 +63,7 @@ class Stats ...@@ -63,7 +63,7 @@ class Stats
if (isset($data['stats']['stats_fields'])) { if (isset($data['stats']['stats_fields'])) {
$statResults = $data['stats']['stats_fields']; $statResults = $data['stats']['stats_fields'];
foreach ($statResults AS $field => $stats) { foreach ($statResults as $field => $stats) {
if (isset($stats['facets'])) { if (isset($stats['facets'])) {
foreach ($stats['facets'] as $facetField => $values) { foreach ($stats['facets'] as $facetField => $values) {
foreach ($values as $value => $valueStats) { foreach ($values as $value => $valueStats) {
......
...@@ -61,7 +61,7 @@ class ResponseParser implements ResponseParserInterface ...@@ -61,7 +61,7 @@ class ResponseParser implements ResponseParserInterface
$documentClass = $query->getOption('documentclass'); $documentClass = $query->getOption('documentclass');
$documents = array(); $documents = array();
if (isset($data['response']['docs'])) { if (isset($data['response']['docs'])) {
foreach ($data['response']['docs'] AS $doc) { foreach ($data['response']['docs'] as $doc) {
$fields = (array) $doc; $fields = (array) $doc;
$documents[] = new $documentClass($fields); $documents[] = new $documentClass($fields);
} }
......
...@@ -41,7 +41,8 @@ namespace Solarium\Query\Select\Result\Debug; ...@@ -41,7 +41,8 @@ namespace Solarium\Query\Select\Result\Debug;
/** /**
* Select component debug document result * Select component debug document result
*/ */
class Document extends Detail implements \IteratorAggregate, \Countable{ class Document extends Detail implements \IteratorAggregate, \Countable
{
/** /**
* Key * Key
......
...@@ -55,7 +55,7 @@ use Solarium\Core\Query\Result\QueryType as BaseResult; ...@@ -55,7 +55,7 @@ use Solarium\Core\Query\Result\QueryType as BaseResult;
* $result->getFacet('category'); * $result->getFacet('category');
* *
* // iterate over fetched docs * // iterate over fetched docs
* foreach ($result AS $doc) { * foreach ($result as $doc) {
* .... * ....
* } * }
* </code> * </code>
......
...@@ -42,7 +42,6 @@ use Solarium\Query\Update\Query\Query as UpdateQuery; ...@@ -42,7 +42,6 @@ use Solarium\Query\Update\Query\Query as UpdateQuery;
/** /**
* Update query add command * Update query add command
* *
* For details about the Solr options see:
* @link http://wiki.apache.org/solr/UpdateXmlMessages#add.2BAC8-update * @link http://wiki.apache.org/solr/UpdateXmlMessages#add.2BAC8-update
*/ */
class Add extends Command class Add extends Command
......
...@@ -42,7 +42,6 @@ use Solarium\Query\Update\Query\Query as UpdateQuery; ...@@ -42,7 +42,6 @@ use Solarium\Query\Update\Query\Query as UpdateQuery;
/** /**
* Update query commit command * Update query commit command
* *
* For details about the Solr options see:
* @link http://wiki.apache.org/solr/UpdateXmlMessages#A.22commit.22_and_.22optimize.22 * @link http://wiki.apache.org/solr/UpdateXmlMessages#A.22commit.22_and_.22optimize.22
*/ */
class Commit extends Command class Commit extends Command
......
...@@ -42,7 +42,6 @@ use Solarium\Query\Update\Query\Query as UpdateQuery; ...@@ -42,7 +42,6 @@ use Solarium\Query\Update\Query\Query as UpdateQuery;
/** /**
* Update query delete command * Update query delete command
* *
* For details about the Solr options see:
* @link http://wiki.apache.org/solr/UpdateXmlMessages#A.22delete.22_by_ID_and_by_Query * @link http://wiki.apache.org/solr/UpdateXmlMessages#A.22delete.22_by_ID_and_by_Query
*/ */
class Delete extends Command class Delete extends Command
......
...@@ -42,7 +42,6 @@ use Solarium\Query\Update\Query\Query as UpdateQuery; ...@@ -42,7 +42,6 @@ use Solarium\Query\Update\Query\Query as UpdateQuery;
/** /**
* Update query optimize command * Update query optimize command
* *
* For details about the Solr options see:
* @link http://wiki.apache.org/solr/UpdateXmlMessages#A.22commit.22_and_.22optimize.22 * @link http://wiki.apache.org/solr/UpdateXmlMessages#A.22commit.22_and_.22optimize.22
*/ */
class Optimize extends Command class Optimize extends Command
......
...@@ -42,7 +42,6 @@ use Solarium\Query\Update\Query\Query as UpdateQuery; ...@@ -42,7 +42,6 @@ use Solarium\Query\Update\Query\Query as UpdateQuery;
/** /**
* Update query rollback command * Update query rollback command
* *
* For details see:
* @link http://wiki.apache.org/solr/UpdateXmlMessages#A.22rollback.22 * @link http://wiki.apache.org/solr/UpdateXmlMessages#A.22rollback.22
*/ */
class Rollback extends Command class Rollback extends Command
......
...@@ -77,7 +77,7 @@ class RequestBuilder extends BaseRequestBuilder ...@@ -77,7 +77,7 @@ class RequestBuilder extends BaseRequestBuilder
public function getRawData($query) public function getRawData($query)
{ {
$xml = '<update>'; $xml = '<update>';
foreach ($query->getCommands() AS $command) { foreach ($query->getCommands() as $command) {
switch ($command->getType()) { switch ($command->getType()) {
case UpdateQuery::COMMAND_ADD: case UpdateQuery::COMMAND_ADD:
$xml .= $this->buildAddXml($command); $xml .= $this->buildAddXml($command);
...@@ -117,15 +117,15 @@ class RequestBuilder extends BaseRequestBuilder ...@@ -117,15 +117,15 @@ class RequestBuilder extends BaseRequestBuilder
$xml .= $this->attrib('commitWithin', $command->getCommitWithin()); $xml .= $this->attrib('commitWithin', $command->getCommitWithin());
$xml .= '>'; $xml .= '>';
foreach ($command->getDocuments() AS $doc) { foreach ($command->getDocuments() as $doc) {
$xml .= '<doc'; $xml .= '<doc';
$xml .= $this->attrib('boost', $doc->getBoost()); $xml .= $this->attrib('boost', $doc->getBoost());
$xml .= '>'; $xml .= '>';
foreach ($doc->getFields() AS $name => $value) { foreach ($doc->getFields() as $name => $value) {
$boost = $doc->getFieldBoost($name); $boost = $doc->getFieldBoost($name);
if (is_array($value)) { if (is_array($value)) {
foreach ($value AS $multival) { foreach ($value as $multival) {
$xml .= $this->buildFieldXml($name, $boost, $multival); $xml .= $this->buildFieldXml($name, $boost, $multival);
} }
} else { } else {
...@@ -170,11 +170,11 @@ class RequestBuilder extends BaseRequestBuilder ...@@ -170,11 +170,11 @@ class RequestBuilder extends BaseRequestBuilder
public function buildDeleteXml($command) public function buildDeleteXml($command)
{ {
$xml = '<delete>'; $xml = '<delete>';
foreach ($command->getIds() AS $id) { foreach ($command->getIds() as $id) {
$xml .= '<id>' . htmlspecialchars($id, ENT_NOQUOTES, 'UTF-8') $xml .= '<id>' . htmlspecialchars($id, ENT_NOQUOTES, 'UTF-8')
. '</id>'; . '</id>';
} }
foreach ($command->getQueries() AS $query) { foreach ($command->getQueries() as $query) {
$xml .= '<query>' . htmlspecialchars($query, ENT_NOQUOTES, 'UTF-8') $xml .= '<query>' . htmlspecialchars($query, ENT_NOQUOTES, 'UTF-8')
. '</query>'; . '</query>';
} }
......
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