Skip to content

Commit

Permalink
Various code standard fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
basdenooijer committed Mar 24, 2012
1 parent 404be18 commit c37e459
Show file tree
Hide file tree
Showing 40 changed files with 86 additions and 89 deletions.
16 changes: 8 additions & 8 deletions library/Solarium/Core/Client/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -281,7 +281,7 @@ public function addEndpoint($endpoint)
*/
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'])) {
Expand Down Expand Up @@ -415,13 +415,13 @@ public function setAdapter($adapter)
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');
}
}
Expand All @@ -445,7 +445,7 @@ protected function createAdapter()
$adapter = new $adapterClass;

// check interface
if(!($adapter instanceof AdapterInterface)) {
if (!($adapter instanceof AdapterInterface)) {
throw new Exception('An adapter must implement the AdapterInterface');
}

Expand Down Expand Up @@ -666,7 +666,7 @@ public function triggerEvent($event, $params = array(), $resultOverride = false)
*/
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);

Expand All @@ -686,7 +686,7 @@ protected function callPlugins($event, $params, $resultOverride = false)
public function createRequest(QueryInterface $query)
{
$pluginResult = $this->callPlugins('preCreateRequest', array($query), true);
if($pluginResult !== null) {
if ($pluginResult !== null) {
return $pluginResult;
}

Expand Down Expand Up @@ -934,7 +934,7 @@ public function createQuery($type, $options = null)
$type = strtolower($type);

$pluginResult = $this->callPlugins('preCreateQuery', array($type, $options), true);
if($pluginResult !== null) {
if ($pluginResult !== null) {
return $pluginResult;
}

Expand Down
2 changes: 1 addition & 1 deletion library/Solarium/Core/Client/Endpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion library/Solarium/Core/Client/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion library/Solarium/Core/Client/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public function setHeaders($headers)

// get the status header
$statusHeader = null;
foreach ($headers AS $header) {
foreach ($headers as $header) {
if (substr($header, 0, 4) == 'HTTP') {
$statusHeader = $header;
break;
Expand Down
2 changes: 1 addition & 1 deletion library/Solarium/Core/Query/RequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function build(QueryInterface $query)
public function renderLocalParams($value, $localParams = array())
{
$params = '';
foreach ($localParams AS $paramName => $paramValue) {
foreach ($localParams as $paramName => $paramValue) {
if (empty($paramValue)) {
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion library/Solarium/Core/Query/Result/QueryType.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ protected function parseResponse()
*/
protected function mapData($mapData)
{
foreach ($mapData AS $key => $data) {
foreach ($mapData as $key => $data) {
$this->$key = $data;
}
}
Expand Down
4 changes: 2 additions & 2 deletions library/Solarium/Plugin/CustomizeRequest/CustomizeRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -146,7 +146,7 @@ public function addCustomization($customization)
*/
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'])) {
Expand Down
14 changes: 7 additions & 7 deletions library/Solarium/Plugin/Loadbalancer/Loadbalancer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -208,7 +208,7 @@ public function getFailoverMaxRetries()
*/
public function addEndpoint($endpoint, $weight = 1)
{
if(!is_string($endpoint)) {
if (!is_string($endpoint)) {
$endpoint = $endpoint->getKey();
}

Expand All @@ -232,7 +232,7 @@ public function addEndpoint($endpoint, $weight = 1)
*/
public function addEndpoints(array $endpoints)
{
foreach ($endpoints AS $endpoint => $weight) {
foreach ($endpoints as $endpoint => $weight) {
$this->addEndpoint($endpoint, $weight);
}

Expand Down Expand Up @@ -267,7 +267,7 @@ public function clearEndpoints()
*/
public function removeEndpoint($endpoint)
{
if(!is_string($endpoint)) {
if (!is_string($endpoint)) {
$endpoint = $endpoint->getKey();
}

Expand Down Expand Up @@ -305,7 +305,7 @@ public function setEndpoints($endpoints)
*/
public function setForcedEndpointForNextQuery($endpoint)
{
if(!is_string($endpoint)) {
if (!is_string($endpoint)) {
$endpoint = $endpoint->getKey();
}

Expand Down Expand Up @@ -377,7 +377,7 @@ public function addBlockedQueryType($type)
*/
public function addBlockedQueryTypes($types)
{
foreach ($types AS $type) {
foreach ($types as $type) {
$this->addBlockedQueryType($type);
}
}
Expand Down Expand Up @@ -472,7 +472,7 @@ protected function getLoadbalancedResponse($request)
$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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down
10 changes: 6 additions & 4 deletions library/Solarium/Plugin/ParallelExecution.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@
*
* 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
{

Expand Down Expand Up @@ -173,7 +173,7 @@ public function execute()
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;
}
Expand All @@ -184,5 +184,7 @@ public function execute()
return $results;
}

// @codeCoverageIgnoreEnd
/**
* @codeCoverageIgnoreEnd
*/
}
2 changes: 1 addition & 1 deletion library/Solarium/Plugin/PrefetchIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public function current()
*
* @return int
*/
function key()
public function key()
{
return $this->position;
}
Expand Down
6 changes: 3 additions & 3 deletions library/Solarium/Query/Analysis/RequestBuilder/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ public function getRawData($query)
{
$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 {
Expand Down
4 changes: 2 additions & 2 deletions library/Solarium/Query/Analysis/Result/Types.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -67,7 +67,7 @@ public function getIndexAnalysis()
*/
public function getQueryAnalysis()
{
foreach ($this->items AS $item) {
foreach ($this->items as $item) {
if ($item->getName() == 'query') {
return $item;
}
Expand Down
2 changes: 1 addition & 1 deletion library/Solarium/Query/MoreLikeThis/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
* count($result);
*
* // iterate over fetched mlt docs
* foreach ($result AS $doc) {
* foreach ($result as $doc) {
* ....
* }
* </code>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function getResponseParser()
*/
protected function init()
{
foreach ($this->options AS $name => $value) {
foreach ($this->options as $name => $value) {
switch ($name) {
case 'shards':
$this->setShards($value);
Expand Down
4 changes: 2 additions & 2 deletions library/Solarium/Query/Select/Query/Component/Facet/Facet.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ abstract public function getType();
*/
protected function init()
{
foreach ($this->options AS $name => $value) {
foreach ($this->options as $name => $value) {
switch ($name) {
case 'key':
$this->setKey($value);
Expand Down Expand Up @@ -126,7 +126,7 @@ public function addExclude($tag)
*/
public function addExcludes(array $excludes)
{
foreach ($excludes AS $exclude) {
foreach ($excludes as $exclude) {
$this->addExclude($exclude);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ protected function init()
{
parent::init();

foreach ($this->options AS $name => $value) {
foreach ($this->options as $name => $value) {
switch ($name) {
case 'query':
if (!is_array($value)) {
Expand Down Expand Up @@ -154,7 +154,7 @@ public function addQuery($facetQuery)
*/
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'])) {
Expand Down Expand Up @@ -252,7 +252,7 @@ public function setQueries($facetQueries)
*/
public function addExclude($tag)
{
foreach ($this->facetQueries AS $facetQuery) {
foreach ($this->facetQueries as $facetQuery) {
$facetQuery->addExclude($tag);
}

Expand All @@ -273,7 +273,7 @@ public function addExclude($tag)
*/
public function removeExclude($exclude)
{
foreach ($this->facetQueries AS $facetQuery) {
foreach ($this->facetQueries as $facetQuery) {
$facetQuery->removeExclude($exclude);
}

Expand All @@ -293,7 +293,7 @@ public function removeExclude($exclude)
*/
public function clearExcludes()
{
foreach ($this->facetQueries AS $facetQuery) {
foreach ($this->facetQueries as $facetQuery) {
$facetQuery->clearExcludes();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ protected function init()
{
parent::init();

foreach ($this->options AS $name => $value) {
foreach ($this->options as $name => $value) {
switch ($name) {
case 'include':
$this->setInclude($value);
Expand Down
4 changes: 2 additions & 2 deletions library/Solarium/Query/Select/Query/Component/FacetSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public function getResponseParser()
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;
}
Expand Down Expand Up @@ -311,7 +311,7 @@ public function addFacet($facet)
*/
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'])) {
Expand Down
Loading

0 comments on commit c37e459

Please sign in to comment.