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