Commit 43c97027 authored by Dorian Villet's avatar Dorian Villet

Fix indentations, spaces after namespaces, and a few if() fixes.

parent a2a33ee8
...@@ -64,7 +64,7 @@ class Curl extends Configurable implements AdapterInterface ...@@ -64,7 +64,7 @@ class Curl extends Configurable implements AdapterInterface
{ {
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
if (!function_exists('curl_init')) { if (!function_exists('curl_init')) {
throw new RuntimeException('cURL is not available, install it to use the CurlHttp adapter'); throw new RuntimeException('cURL is not available, install it to use the CurlHttp adapter');
} }
parent::init(); parent::init();
...@@ -148,8 +148,8 @@ class Curl extends Configurable implements AdapterInterface ...@@ -148,8 +148,8 @@ class Curl extends Configurable implements AdapterInterface
curl_setopt($handler, CURLOPT_FOLLOWLOCATION, true); curl_setopt($handler, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($handler, CURLOPT_TIMEOUT, $options['timeout']); curl_setopt($handler, CURLOPT_TIMEOUT, $options['timeout']);
if ( $proxy = $this->getOption('proxy') ) { if ($proxy = $this->getOption('proxy')) {
curl_setopt($handler, CURLOPT_PROXY, $proxy); curl_setopt($handler, CURLOPT_PROXY, $proxy);
} }
if (!isset($options['headers']['Content-Type'])) { if (!isset($options['headers']['Content-Type'])) {
...@@ -158,9 +158,11 @@ class Curl extends Configurable implements AdapterInterface ...@@ -158,9 +158,11 @@ class Curl extends Configurable implements AdapterInterface
// Try endpoint authentication first, fallback to request for backwards compatibility // Try endpoint authentication first, fallback to request for backwards compatibility
$authData = $endpoint->getAuthentication(); $authData = $endpoint->getAuthentication();
if (empty($authData['username'])) $authData = $request->getAuthentication(); if (empty($authData['username'])) {
$authData = $request->getAuthentication();
}
if ( !empty($authData['username']) && !empty($authData['password'])) { if (!empty($authData['username']) && !empty($authData['password'])) {
curl_setopt($handler, CURLOPT_USERPWD, $authData['username']. ':' . $authData['password'] ); curl_setopt($handler, CURLOPT_USERPWD, $authData['username']. ':' . $authData['password'] );
curl_setopt($handler, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_setopt($handler, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
} }
......
...@@ -129,10 +129,14 @@ class Http extends Configurable implements AdapterInterface ...@@ -129,10 +129,14 @@ class Http extends Configurable implements AdapterInterface
// Try endpoint authentication first, fallback to request for backwards compatibility // Try endpoint authentication first, fallback to request for backwards compatibility
$authData = $endpoint->getAuthentication(); $authData = $endpoint->getAuthentication();
if (empty($authData['username'])) $authData = $request->getAuthentication(); if (empty($authData['username'])) {
$authData = $request->getAuthentication();
}
if ( !empty($authData['username']) && !empty($authData['password'])) { if (!empty($authData['username']) && !empty($authData['password'])) {
$request->addHeader('Authorization: Basic ' . base64_encode($authData['username']. ':' . $authData['password'] )); $request->addHeader(
'Authorization: Basic ' . base64_encode($authData['username'] . ':' . $authData['password'])
);
} }
$headers = $request->getHeaders(); $headers = $request->getHeaders();
......
...@@ -65,7 +65,7 @@ class PeclHttp extends Configurable implements AdapterInterface ...@@ -65,7 +65,7 @@ class PeclHttp extends Configurable implements AdapterInterface
{ {
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
if (!class_exists('HttpRequest', false)) { if (!class_exists('HttpRequest', false)) {
throw new RuntimeException('Pecl_http is not available, install it to use the PeclHttp adapter'); throw new RuntimeException('Pecl_http is not available, install it to use the PeclHttp adapter');
} }
parent::init(); parent::init();
...@@ -153,9 +153,11 @@ class PeclHttp extends Configurable implements AdapterInterface ...@@ -153,9 +153,11 @@ class PeclHttp extends Configurable implements AdapterInterface
// Try endpoint authentication first, fallback to request for backwards compatibility // Try endpoint authentication first, fallback to request for backwards compatibility
$authData = $endpoint->getAuthentication(); $authData = $endpoint->getAuthentication();
if (empty($authData['username'])) $authData = $request->getAuthentication(); if (empty($authData['username'])) {
$authData = $request->getAuthentication();
}
if ( !empty($authData['username']) && !empty($authData['password'])) { if (!empty($authData['username']) && !empty($authData['password'])) {
$headers['Authorization'] = 'Basic ' . base64_encode($authData['username']. ':' . $authData['password'] ); $headers['Authorization'] = 'Basic ' . base64_encode($authData['username']. ':' . $authData['password'] );
} }
......
...@@ -591,7 +591,7 @@ class Client extends Configurable ...@@ -591,7 +591,7 @@ class Client extends Configurable
} }
if (!($plugin instanceof PluginInterface)) { if (!($plugin instanceof PluginInterface)) {
throw new InvalidArgumentException('All plugins must implement the PluginInterface'); throw new InvalidArgumentException('All plugins must implement the PluginInterface');
} }
$plugin->initPlugin($this, $options); $plugin->initPlugin($this, $options);
...@@ -911,7 +911,7 @@ class Client extends Configurable ...@@ -911,7 +911,7 @@ class Client extends Configurable
* execute method, thus allowing for an easy to use and clean API. * execute method, thus allowing for an easy to use and clean API.
* *
* @param QueryInterface|\Solarium\QueryType\Analysis\Query\Document|\Solarium\QueryType\Analysis\Query\Field $query * @param QueryInterface|\Solarium\QueryType\Analysis\Query\Document|\Solarium\QueryType\Analysis\Query\Field $query
* @param Endpoint|string|null $endpoint * @param Endpoint|string|null $endpoint
* @return \Solarium\QueryType\Analysis\Result\Document|\Solarium\QueryType\Analysis\Result\Field * @return \Solarium\QueryType\Analysis\Result\Document|\Solarium\QueryType\Analysis\Result\Field
*/ */
public function analyze(QueryInterface $query, $endpoint = null) public function analyze(QueryInterface $query, $endpoint = null)
......
...@@ -138,5 +138,4 @@ class Events ...@@ -138,5 +138,4 @@ class Events
* @var string * @var string
*/ */
const POST_CREATE_QUERY = 'solarium.core.postCreateQuery'; const POST_CREATE_QUERY = 'solarium.core.postCreateQuery';
} }
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
* @namespace * @namespace
*/ */
namespace Solarium\Core\Event; namespace Solarium\Core\Event;
use Symfony\Component\EventDispatcher\Event; use Symfony\Component\EventDispatcher\Event;
use Solarium\Core\Query\QueryInterface; use Solarium\Core\Query\QueryInterface;
......
...@@ -56,12 +56,12 @@ class PostExecuteRequest extends Event ...@@ -56,12 +56,12 @@ class PostExecuteRequest extends Event
/** /**
* @var Endpoint * @var Endpoint
*/ */
protected $endpoint; protected $endpoint;
/** /**
* @var Response * @var Response
*/ */
protected $response; protected $response;
/** /**
* Event constructor * Event constructor
......
...@@ -77,10 +77,10 @@ class Result extends SelectResult ...@@ -77,10 +77,10 @@ class Result extends SelectResult
* *
* @return Query * @return Query
*/ */
public function getQuery() public function getQuery()
{ {
return $this->query; return $this->query;
} }
/** /**
* Get MLT interesting terms * Get MLT interesting terms
......
...@@ -108,9 +108,9 @@ class Query extends BaseQuery ...@@ -108,9 +108,9 @@ class Query extends BaseQuery
*/ */
public function addId($id) public function addId($id)
{ {
$this->ids[$id] = true; $this->ids[$id] = true;
return $this; return $this;
} }
/** /**
...@@ -143,7 +143,7 @@ class Query extends BaseQuery ...@@ -143,7 +143,7 @@ class Query extends BaseQuery
public function removeId($id) public function removeId($id)
{ {
if (isset($this->ids[$id])) { if (isset($this->ids[$id])) {
unset($this->ids[$id]); unset($this->ids[$id]);
} }
return $this; return $this;
......
...@@ -218,7 +218,7 @@ class Highlighting extends Component ...@@ -218,7 +218,7 @@ class Highlighting extends Component
public function removeField($field) public function removeField($field)
{ {
if (isset($this->fields[$field])) { if (isset($this->fields[$field])) {
unset($this->fields[$field]); unset($this->fields[$field]);
} }
return $this; return $this;
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
* @namespace * @namespace
*/ */
namespace Solarium\QueryType\Select\Query\Component; namespace Solarium\QueryType\Select\Query\Component;
use Solarium\QueryType\Select\Query\Query as SelectQuery; use Solarium\QueryType\Select\Query\Query as SelectQuery;
use Solarium\QueryType\Select\RequestBuilder\Component\MoreLikeThis as RequestBuilder; use Solarium\QueryType\Select\RequestBuilder\Component\MoreLikeThis as RequestBuilder;
use Solarium\QueryType\Select\ResponseParser\Component\MoreLikeThis as ResponseParser; use Solarium\QueryType\Select\ResponseParser\Component\MoreLikeThis as ResponseParser;
......
...@@ -381,8 +381,8 @@ class Spellcheck extends Component ...@@ -381,8 +381,8 @@ class Spellcheck extends Component
*/ */
public function setCollateParam($param, $value) public function setCollateParam($param, $value)
{ {
$this->collateParams[$param] = $value; $this->collateParams[$param] = $value;
return $this; return $this;
} }
/** /**
...@@ -391,6 +391,6 @@ class Spellcheck extends Component ...@@ -391,6 +391,6 @@ class Spellcheck extends Component
*/ */
public function getCollateParams() public function getCollateParams()
{ {
return $this->collateParams; return $this->collateParams;
} }
} }
...@@ -99,9 +99,9 @@ class Field extends Configurable ...@@ -99,9 +99,9 @@ class Field extends Configurable
*/ */
public function addFacet($facet) public function addFacet($facet)
{ {
$this->facets[$facet] = true; $this->facets[$facet] = true;
return $this; return $this;
} }
/** /**
...@@ -135,7 +135,7 @@ class Field extends Configurable ...@@ -135,7 +135,7 @@ class Field extends Configurable
public function removeFacet($facet) public function removeFacet($facet)
{ {
if (isset($this->facets[$facet])) { if (isset($this->facets[$facet])) {
unset($this->facets[$facet]); unset($this->facets[$facet]);
} }
return $this; return $this;
......
...@@ -279,9 +279,9 @@ class Stats extends Component ...@@ -279,9 +279,9 @@ class Stats extends Component
*/ */
public function addFacet($facet) public function addFacet($facet)
{ {
$this->facets[$facet] = true; $this->facets[$facet] = true;
return $this; return $this;
} }
/** /**
...@@ -315,7 +315,7 @@ class Stats extends Component ...@@ -315,7 +315,7 @@ class Stats extends Component
public function removeFacet($facet) public function removeFacet($facet)
{ {
if (isset($this->facets[$facet])) { if (isset($this->facets[$facet])) {
unset($this->facets[$facet]); unset($this->facets[$facet]);
} }
return $this; return $this;
......
...@@ -441,9 +441,9 @@ class Query extends BaseQuery ...@@ -441,9 +441,9 @@ class Query extends BaseQuery
*/ */
public function addField($field) public function addField($field)
{ {
$this->fields[$field] = true; $this->fields[$field] = true;
return $this; return $this;
} }
/** /**
...@@ -477,7 +477,7 @@ class Query extends BaseQuery ...@@ -477,7 +477,7 @@ class Query extends BaseQuery
public function removeField($field) public function removeField($field)
{ {
if (isset($this->fields[$field])) { if (isset($this->fields[$field])) {
unset($this->fields[$field]); unset($this->fields[$field]);
} }
return $this; return $this;
......
...@@ -72,7 +72,7 @@ class Spellcheck implements ComponentRequestBuilderInterface ...@@ -72,7 +72,7 @@ class Spellcheck implements ComponentRequestBuilderInterface
$request->addParam('spellcheck.accuracy', $component->getAccuracy()); $request->addParam('spellcheck.accuracy', $component->getAccuracy());
foreach ( $component->getCollateParams() as $param => $value ) { foreach ( $component->getCollateParams() as $param => $value ) {
$request->addParam('spellcheck.collateParam.'.$param, $value); $request->addParam('spellcheck.collateParam.'.$param, $value);
} }
return $request; return $request;
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
* @namespace * @namespace
*/ */
namespace Solarium\QueryType\Select\ResponseParser\Component; namespace Solarium\QueryType\Select\ResponseParser\Component;
use Solarium\QueryType\Select\Query\Query; use Solarium\QueryType\Select\Query\Query;
use Solarium\QueryType\Select\Query\Component\Spellcheck as SpellcheckComponent; use Solarium\QueryType\Select\Query\Component\Spellcheck as SpellcheckComponent;
use Solarium\QueryType\Select\Result\Spellcheck as SpellcheckResult; use Solarium\QueryType\Select\Result\Spellcheck as SpellcheckResult;
...@@ -119,7 +120,7 @@ class Spellcheck extends ResponseParserAbstract implements ComponentParserInterf ...@@ -119,7 +120,7 @@ class Spellcheck extends ResponseParserAbstract implements ComponentParserInterf
} else { } else {
if ($queryObject->getResponseWriter() == $queryObject::WT_JSON) { if ($queryObject->getResponseWriter() == $queryObject::WT_JSON) {
if (is_array(current($values))){ if (is_array(current($values))) {
foreach($values as $key => $value) { foreach($values as $key => $value) {
$values[$key] = $this->convertToKeyValueArray($value); $values[$key] = $this->convertToKeyValueArray($value);
} }
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
* @namespace * @namespace
*/ */
namespace Solarium\QueryType\Update\Query\Command; namespace Solarium\QueryType\Update\Query\Command;
use Solarium\QueryType\Update\Query\Query as UpdateQuery; use Solarium\QueryType\Update\Query\Query as UpdateQuery;
use Solarium\QueryType\Update\Query\Document\DocumentInterface; use Solarium\QueryType\Update\Query\Document\DocumentInterface;
use Solarium\Exception\RuntimeException; use Solarium\Exception\RuntimeException;
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
* @namespace * @namespace
*/ */
namespace Solarium\QueryType\Update\Query\Command; namespace Solarium\QueryType\Update\Query\Command;
use Solarium\QueryType\Update\Query\Query as UpdateQuery; use Solarium\QueryType\Update\Query\Query as UpdateQuery;
/** /**
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
* @namespace * @namespace
*/ */
namespace Solarium\QueryType\Update\Query\Command; namespace Solarium\QueryType\Update\Query\Command;
use Solarium\QueryType\Update\Query\Query as UpdateQuery; use Solarium\QueryType\Update\Query\Query as UpdateQuery;
/** /**
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
* @namespace * @namespace
*/ */
namespace Solarium\QueryType\Update\Query\Command; namespace Solarium\QueryType\Update\Query\Command;
use Solarium\QueryType\Update\Query\Query as UpdateQuery; use Solarium\QueryType\Update\Query\Query as UpdateQuery;
/** /**
......
...@@ -369,7 +369,7 @@ class Document extends AbstractDocument implements DocumentInterface ...@@ -369,7 +369,7 @@ class Document extends AbstractDocument implements DocumentInterface
*/ */
public function setFieldModifier($key, $modifier = null) public function setFieldModifier($key, $modifier = null)
{ {
if (! in_array($modifier, array(self::MODIFIER_ADD, self::MODIFIER_INC, self::MODIFIER_SET)) ) { if (!in_array($modifier, array(self::MODIFIER_ADD, self::MODIFIER_INC, self::MODIFIER_SET))) {
throw new RuntimeException('Attempt to set an atomic update modifier that is not supported'); throw new RuntimeException('Attempt to set an atomic update modifier that is not supported');
} }
$this->modifiers[$key] = $modifier; $this->modifiers[$key] = $modifier;
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
* @namespace * @namespace
*/ */
namespace Solarium\QueryType\Update\Query; namespace Solarium\QueryType\Update\Query;
use Solarium\Core\Client\Client; use Solarium\Core\Client\Client;
use Solarium\Core\Query\Query as BaseQuery; use Solarium\Core\Query\Query as BaseQuery;
use Solarium\QueryType\Update\RequestBuilder; use Solarium\QueryType\Update\RequestBuilder;
...@@ -406,7 +407,7 @@ class Query extends BaseQuery ...@@ -406,7 +407,7 @@ class Query extends BaseQuery
if (null !== $softCommit) { if (null !== $softCommit) {
$commit->setSoftCommit($softCommit); $commit->setSoftCommit($softCommit);
} }
if (null !== $waitSearcher) { if (null !== $waitSearcher) {
$commit->setWaitSearcher($waitSearcher); $commit->setWaitSearcher($waitSearcher);
...@@ -430,25 +431,25 @@ class Query extends BaseQuery ...@@ -430,25 +431,25 @@ class Query extends BaseQuery
* @param int $maxSegments * @param int $maxSegments
* @return self Provides fluent interface * @return self Provides fluent interface
*/ */
public function addOptimize($softCommit = null, $waitSearcher = null, public function addOptimize($softCommit = null, $waitSearcher = null,
$maxSegments = null) $maxSegments = null)
{ {
$optimize = new OptimizeCommand(); $optimize = new OptimizeCommand();
if (null !== $softCommit) { if (null !== $softCommit) {
$optimize->setSoftCommit($softCommit); $optimize->setSoftCommit($softCommit);
} }
if (null !== $waitSearcher) { if (null !== $waitSearcher) {
$optimize->setWaitSearcher($waitSearcher); $optimize->setWaitSearcher($waitSearcher);
} }
if (null !== $maxSegments) { if (null !== $maxSegments) {
$optimize->setMaxSegments($maxSegments); $optimize->setMaxSegments($maxSegments);
} }
return $this->add(null, $optimize); return $this->add(null, $optimize);
} }
/** /**
* Set a custom document class for use in the createDocument method * Set a custom document class for use in the createDocument method
......
...@@ -169,7 +169,7 @@ class RequestBuilder extends BaseRequestBuilder ...@@ -169,7 +169,7 @@ class RequestBuilder extends BaseRequestBuilder
$xml = '<field name="' . $name . '"'; $xml = '<field name="' . $name . '"';
$xml .= $this->attrib('boost', $boost); $xml .= $this->attrib('boost', $boost);
$xml .= $this->attrib('update', $modifier); $xml .= $this->attrib('update', $modifier);
if ($value === null){ if ($value === null) {
$xml .= $this->attrib('null', 'true'); $xml .= $this->attrib('null', 'true');
} }
$xml .= '>' . htmlspecialchars($value, ENT_NOQUOTES, 'UTF-8'); $xml .= '>' . htmlspecialchars($value, ENT_NOQUOTES, 'UTF-8');
...@@ -226,7 +226,7 @@ class RequestBuilder extends BaseRequestBuilder ...@@ -226,7 +226,7 @@ class RequestBuilder extends BaseRequestBuilder
$xml = '<commit'; $xml = '<commit';
$xml .= $this->boolAttrib('softCommit', $command->getSoftCommit()); $xml .= $this->boolAttrib('softCommit', $command->getSoftCommit());
$xml .= $this->boolAttrib('waitSearcher', $command->getWaitSearcher()); $xml .= $this->boolAttrib('waitSearcher', $command->getWaitSearcher());
$xml .= $this->boolAttrib('expungeDeletes',$command->getExpungeDeletes()); $xml .= $this->boolAttrib('expungeDeletes', $command->getExpungeDeletes());
$xml .= '/>'; $xml .= '/>';
return $xml; return $xml;
......
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