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