Commit 6542c720 authored by Bas de Nooijer's avatar Bas de Nooijer

Code style fixes

parent d9182d68
......@@ -136,7 +136,7 @@ class Solarium_Client extends Solarium_Configurable
/**
* Registered plugin instances
*
*
* @var array
*/
protected $_plugins = array();
......@@ -193,7 +193,7 @@ class Solarium_Client extends Solarium_Configurable
* the adapter (lazy-loading)
*
* If an adapter instance is passed it will replace the current adapter
* immediately, bypassing the lazy loading.
* immediately, bypassing the lazy loading.
*
* @param string|Solarium_Client_Adapter $adapter
* @return Solarium_Client Provides fluent interface
......@@ -297,7 +297,7 @@ class Solarium_Client extends Solarium_Configurable
/**
* Get all registered querytypes
*
*
* @return array
*/
public function getQueryTypes()
......@@ -322,11 +322,11 @@ class Solarium_Client extends Solarium_Configurable
if (is_string($plugin)) {
$plugin = new $plugin;
}
if (!($plugin instanceof Solarium_Plugin_Abstract)) {
throw new Solarium_Exception('All plugins must extend Solarium_Plugin_Abstract');
}
$plugin->init($this, $options);
$this->_plugins[$key] = $plugin;
......@@ -336,7 +336,7 @@ class Solarium_Client extends Solarium_Configurable
/**
* Register multiple plugins
*
*
* @param array $plugins
* @return Solarium_Client Provides fluent interface
*/
......@@ -392,8 +392,7 @@ class Solarium_Client extends Solarium_Configurable
public function removePlugin($plugin)
{
if (is_object($plugin)) {
foreach ($this->_plugins as $key => $instance)
{
foreach ($this->_plugins as $key => $instance) {
if ($instance === $plugin) {
unset($this->_plugins[$key]);
break;
......@@ -492,7 +491,7 @@ class Solarium_Client extends Solarium_Configurable
return $result;
}
/**
* Execute a request and return the response
*
......@@ -582,7 +581,7 @@ class Solarium_Client extends Solarium_Configurable
{
return $this->execute($query);
}
/**
* Execute a MoreLikeThis query
*
......@@ -657,7 +656,7 @@ class Solarium_Client extends Solarium_Configurable
{
return $this->createQuery(self::QUERYTYPE_SELECT, $options);
}
/**
* Create a MoreLikeThis query instance
*
......
......@@ -93,8 +93,9 @@ class Solarium_Client_Adapter_PeclHttp extends Solarium_Client_Adapter
if (!isset($options['headers']['Content-Type'])) {
$options['headers']['Content-Type'] = 'text/xml; charset=utf-8';
}
$httpResponse = http_post_data($uri, $request->getRawData(),
$options);
$httpResponse = http_post_data(
$uri, $request->getRawData(), $options
);
} else if ($method == Solarium_Client_Request::METHOD_GET) {
$httpResponse = http_get($uri, $options);
} else if ($method == Solarium_Client_Request::METHOD_HEAD) {
......@@ -108,8 +109,9 @@ class Solarium_Client_Adapter_PeclHttp extends Solarium_Client_Adapter
if ($message = http_parse_message($httpResponse)) {
$data = $message->body;
if ($firstPositionOfCRLF = strpos($httpResponse, "\r\n\r\n")) {
$headersAsString = substr($httpResponse, 0,
$firstPositionOfCRLF);
$headersAsString = substr(
$httpResponse, 0, $firstPositionOfCRLF
);
$headers = explode("\n", $headersAsString);
}
}
......
......@@ -80,7 +80,7 @@ class Solarium_Client_RequestBuilder_Select_Component_Highlighting
$request->addParam('hl.regex.maxAnalyzedChars', $component->getRegexMaxAnalyzedChars());
// set per-field highlighting params
foreach($component->getFields() as $field) {
foreach ($component->getFields() as $field) {
$this->_addFieldParams($field, $request);
}
......
......@@ -44,7 +44,7 @@
*/
class Solarium_Client_RequestBuilder_Select_Component_Spellcheck
{
/**
* Add request settings for Spellcheck
*
......@@ -57,21 +57,19 @@ class Solarium_Client_RequestBuilder_Select_Component_Spellcheck
// enable spellcheck
$request->addParam('spellcheck', 'true');
$request->addParam('spellcheck.q', $component->getQuery());
$request->addParam('spellcheck.build', $component->getBuild());
$request->addParam('spellcheck.reload', $component->getReload());
$request->addParam('spellcheck.dictionary', $component->getDictionary());
$request->addParam('spellcheck.count', $component->getCount());
$request->addParam('spellcheck.onlyMorePopular', $component->getOnlyMorePopular());
$request->addParam('spellcheck.extendedResults', $component->getExtendedResults());
$request->addParam('spellcheck.q', $component->getQuery());
$request->addParam('spellcheck.build', $component->getBuild());
$request->addParam('spellcheck.reload', $component->getReload());
$request->addParam('spellcheck.dictionary', $component->getDictionary());
$request->addParam('spellcheck.count', $component->getCount());
$request->addParam('spellcheck.onlyMorePopular', $component->getOnlyMorePopular());
$request->addParam('spellcheck.extendedResults', $component->getExtendedResults());
$request->addParam('spellcheck.collate', $component->getCollate());
$request->addParam('spellcheck.maxCollations', $component->getMaxCollations());
$request->addParam('spellcheck.maxCollationTries', $component->getMaxCollationTries());
$request->addParam('spellcheck.maxCollationEvaluations', $component->getMaxCollationEvaluations());
$request->addParam('spellcheck.collateExtendedResults', $component->getCollateExtendedResults());
$request->addParam('spellcheck.accuracy', $component->getAccuracy());
$request->addParam('spellcheck.maxCollations', $component->getMaxCollations());
$request->addParam('spellcheck.maxCollationTries', $component->getMaxCollationTries());
$request->addParam('spellcheck.maxCollationEvaluations', $component->getMaxCollationEvaluations());
$request->addParam('spellcheck.collateExtendedResults', $component->getCollateExtendedResults());
$request->addParam('spellcheck.accuracy', $component->getAccuracy());
return $request;
}
......
......@@ -54,7 +54,7 @@ class Solarium_Client_ResponseParser_Analysis_Document extends Solarium_Client_R
protected function _parseAnalysis($data)
{
$documents = array();
foreach($data as $documentKey => $documentData) {
foreach ($data as $documentKey => $documentData) {
$fields = $this->_parseTypes($documentData);
$documents[] = new Solarium_Result_Analysis_List($documentKey, $fields);
}
......
......@@ -77,7 +77,7 @@ class Solarium_Client_ResponseParser_Analysis_Field extends Solarium_Client_Resp
protected function _parseAnalysis($data)
{
$types = array();
foreach($data as $documentKey => $documentData) {
foreach ($data as $documentKey => $documentData) {
$fields = $this->_parseTypes($documentData);
$types[] = new Solarium_Result_Analysis_List($documentKey, $fields);
}
......@@ -100,18 +100,18 @@ class Solarium_Client_ResponseParser_Analysis_Field extends Solarium_Client_Resp
foreach ($fieldData as $typeKey => $typeData) {
// fix for extra level for key fields
if(count($typeData) == 1){
if (count($typeData) == 1){
$typeData = current($typeData);
}
$counter = 0;
$classes = array();
while(isset($typeData[$counter]) && isset($typeData[$counter+1])) {
while (isset($typeData[$counter]) && isset($typeData[$counter+1])) {
$class = $typeData[$counter];
$analysis = $typeData[$counter+1];
$items = array();
foreach($analysis AS $itemData) {
foreach ($analysis AS $itemData) {
$items[] = new Solarium_Result_Analysis_Item($itemData);
}
......
......@@ -56,7 +56,11 @@ class Solarium_Client_ResponseParser_Select_Component_Spellcheck
public function parse($query, $spellcheck, $data)
{
$results = array();
if (isset($data['spellcheck']['suggestions']) && is_array($data['spellcheck']['suggestions']) && count($data['spellcheck']['suggestions']) > 0) {
if (
isset($data['spellcheck']['suggestions']) &&
is_array($data['spellcheck']['suggestions']) &&
count($data['spellcheck']['suggestions']) > 0
) {
$spellcheckResults = $data['spellcheck']['suggestions'];
......@@ -144,7 +148,7 @@ class Solarium_Client_ResponseParser_Select_Component_Spellcheck
$endOffset = (isset($value['endOffset'])) ? $value['endOffset'] : null;
$originalFrequency = (isset($value['origFreq'])) ? $value['origFreq'] : null;
if(is_string($value['suggestion'][0])) {
if (is_string($value['suggestion'][0])) {
$word = $value['suggestion'][0];
$frequency = null;
} else {
......
......@@ -82,7 +82,7 @@ class Solarium_Query_Select extends Solarium_Query
/**
* Query component spellcheck
*/
const COMPONENT_SPELLCHECK = 'spellcheck';
const COMPONENT_SPELLCHECK = 'spellcheck';
/**
* Query component grouping
......@@ -564,7 +564,7 @@ class Solarium_Query_Select extends Solarium_Query
}
if (array_key_exists($key, $this->_filterQueries)) {
if($this->_filterQueries[$key] === $filterQuery) {
if ($this->_filterQueries[$key] === $filterQuery) {
//double add calls for the same FQ are ignored
//@todo add trigger_error with a notice?
} else {
......@@ -765,8 +765,7 @@ class Solarium_Query_Select extends Solarium_Query
public function removeComponent($component)
{
if (is_object($component)) {
foreach ($this->_components as $key => $instance)
{
foreach ($this->_components as $key => $instance) {
if ($instance === $component) {
unset($this->_components[$key]);
break;
......
......@@ -40,7 +40,7 @@
* MoreLikeThis component
*
* @link http://wiki.apache.org/solr/MoreLikeThis
*
*
* @package Solarium
* @subpackage Query
*/
......@@ -81,14 +81,14 @@ class Solarium_Query_Select_Component_FacetSet extends Solarium_Query_Select_Com
/**
* Component type
*
*
* @var string
*/
protected $_type = Solarium_Query_Select::COMPONENT_FACETSET;
/**
* Default options
*
*
* @var array
*/
protected $_options = array();
......@@ -267,7 +267,7 @@ class Solarium_Query_Select_Component_FacetSet extends Solarium_Query_Select_Com
}
if (array_key_exists($key, $this->_facets)) {
if($this->_facets[$key] === $facet) {
if ($this->_facets[$key] === $facet) {
//double add calls for the same facet are ignored
//@todo add trigger_error with a notice?
} else {
......
......@@ -99,7 +99,7 @@ class Solarium_Query_Select_Component_Highlighting extends Solarium_Query_Select
{
if (isset($this->_fields[$name])) {
return $this->_fields[$name];
} else if($autocreate) {
} else if ($autocreate) {
$this->addField($name);
return $this->_fields[$name];
} else {
......
......@@ -86,10 +86,10 @@ class Solarium_Query_Update extends Solarium_Query
self::COMMAND_OPTIMIZE => 'Solarium_Query_Update_Command_Optimize',
self::COMMAND_ROLLBACK => 'Solarium_Query_Update_Command_Rollback',
);
/**
* Default options
*
*
* @var array
*/
protected $_options = array(
......@@ -167,7 +167,7 @@ class Solarium_Query_Update extends Solarium_Query
/**
* Get all commands for this update query
*
*
* @return array
*/
public function getCommands()
......@@ -207,8 +207,7 @@ class Solarium_Query_Update extends Solarium_Query
public function remove($command)
{
if (is_object($command)) {
foreach ($this->_commands as $key => $instance)
{
foreach ($this->_commands as $key => $instance) {
if ($instance === $command) {
unset($this->_commands[$key]);
break;
......
......@@ -144,8 +144,8 @@ class Solarium_Result_Analysis_Document extends Solarium_Result_QueryType
public function getDocument($key)
{
$this->_parseResponse();
if(isset($this->_items[$key])) {
if (isset($this->_items[$key])) {
return $this->_items[$key];
} else {
return null;
......
......@@ -52,8 +52,7 @@ class Solarium_Result_Analysis_Types extends Solarium_Result_Analysis_List
*/
public function getIndexAnalysis()
{
foreach($this->_items AS $item)
{
foreach ($this->_items AS $item) {
if ($item->getName() == 'index') {
return $item;
}
......@@ -69,8 +68,7 @@ class Solarium_Result_Analysis_Types extends Solarium_Result_Analysis_List
*/
public function getQueryAnalysis()
{
foreach($this->_items AS $item)
{
foreach ($this->_items AS $item) {
if ($item->getName() == 'query') {
return $item;
}
......
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