diff --git a/src/HAB/Solr/Command/QueryBuilder.php b/src/HAB/Solr/Command/QueryBuilder.php index f76d87f58feec24da0383fff7c5115f931aff243..2c9e155f39bf9abd14d7b09904255dcb94015357 100644 --- a/src/HAB/Solr/Command/QueryBuilder.php +++ b/src/HAB/Solr/Command/QueryBuilder.php @@ -37,7 +37,7 @@ class QueryBuilder implements QueryBuilderInterface /** * Return Solr query parameters. * - * @param array|\ArrayAccess $query + * @param iterable $query * @return ParamBag */ public function buildQuery ($query) @@ -48,4 +48,4 @@ class QueryBuilder implements QueryBuilderInterface } return $params; } -} \ No newline at end of file +} diff --git a/src/HAB/Solr/Command/Search.php b/src/HAB/Solr/Command/Search.php index 5bd9c1c9d8ff90dc6dc7450c1029a2499b6c3f77..37303ee9915a1022571620aa2ad2263c1ea27347 100644 --- a/src/HAB/Solr/Command/Search.php +++ b/src/HAB/Solr/Command/Search.php @@ -119,7 +119,7 @@ class Search implements CommandInterface public function getQuery () { - if (is_null($this->query)) { + if ($this->query === null) { $this->setQuery(new ArrayObject()); } return $this->query; diff --git a/src/HAB/Solr/Facet/AbstractFacetAdapter.php b/src/HAB/Solr/Facet/AbstractFacetAdapter.php index 4a4ccb6bb94b6c8d3b67130c9c503b1339a82cf3..e0606e89b2cc6e8d43aed23453d7f25a7df4996c 100644 --- a/src/HAB/Solr/Facet/AbstractFacetAdapter.php +++ b/src/HAB/Solr/Facet/AbstractFacetAdapter.php @@ -140,10 +140,10 @@ abstract class AbstractFacetAdapter implements FacetAdapterInterface */ public function getFacetValueContainer () { - if (!$this->container) { + if ($this->container === null) { $this->setFacetValueContainer(new Value\Container\FacetValueList()); } - if ($this->sort) { + if ($this->sort !== null) { call_user_func($this->sort, $this->container); } return $this->container; @@ -165,7 +165,7 @@ abstract class AbstractFacetAdapter implements FacetAdapterInterface */ public function getRequestValueMapper () { - if (!$this->mapper) { + if ($this->mapper === null) { $this->setRequestValueMapper(new ValueMapper\RequestValueIdentityMapper()); } return $this->mapper; @@ -189,7 +189,7 @@ abstract class AbstractFacetAdapter implements FacetAdapterInterface public function setComponentState (array $state) { if (array_key_exists('f', $state)) { - $params = $state->get('f'); + $params = $state['f']; if ($params && is_array($params) && isset($params[$this->getName()])) { $this->setFilterValues($params[$this->getName()]); } @@ -200,7 +200,7 @@ abstract class AbstractFacetAdapter implements FacetAdapterInterface public function getGlobalComponentState () { if ($this->state) { - return $this->state->all(); + return $this->state; } return array(); } diff --git a/src/HAB/Solr/Facet/DefaultFacetAdapter.php b/src/HAB/Solr/Facet/DefaultFacetAdapter.php index 01c3ac32b3f54b9ad52dac35d7b5038222a43bd3..3d85d0ecd365c6f509e0f149af3991468686c620 100644 --- a/src/HAB/Solr/Facet/DefaultFacetAdapter.php +++ b/src/HAB/Solr/Facet/DefaultFacetAdapter.php @@ -85,20 +85,11 @@ class DefaultFacetAdapter extends AbstractFacetAdapter return $this->getRequestValueMapper()->mapToRequest($this->facet->getSelected()); } - /** - * {@inheritDoc} - */ - public function getSearchParameters () - { - return $this->facet->getSearchParameters(); - } - /** * {@inheritDoc} */ public function setRecordCollection (RecordCollection $response) { - $this->facet->setRecordCollection($response); $container = $this->getFacetValueContainer(); $factory = $this->getFacetValueLabelFactory(); $selected = $this->facet->getSelected(); @@ -133,7 +124,7 @@ class DefaultFacetAdapter extends AbstractFacetAdapter */ public function getFacetValueLabelFactory () { - if (!$this->labelFactory) { + if ($this->labelFactory === null) { $this->setFacetValueLabelFactory(new LabelFactory\DefaultLabelFactory()); } return $this->labelFactory; @@ -149,4 +140,4 @@ class DefaultFacetAdapter extends AbstractFacetAdapter { $this->labelFactory = $factory; } -} \ No newline at end of file +} diff --git a/src/HAB/Solr/Facet/FacetCollection.php b/src/HAB/Solr/Facet/FacetCollection.php index 3f55fd5bec9cebd526f93e47c9208b49ceb40de8..53bf6bd216240531bf364baa3757697b7e930625 100644 --- a/src/HAB/Solr/Facet/FacetCollection.php +++ b/src/HAB/Solr/Facet/FacetCollection.php @@ -116,7 +116,7 @@ class FacetCollection implements Countable, IteratorAggregate, ParameterProvider */ public function getComponentStateFilter () { - if (!$this->filter) { + if ($this->filter === null) { $this->setComponentStateFilter(new StateFilter\DefaultStateFilter()); } return $this->filter; diff --git a/src/HAB/Solr/Facet/Impl/FieldFacet.php b/src/HAB/Solr/Facet/Impl/FieldFacet.php index 4d81202dad2eb9846382b54c3b3eee2f1e2c44c5..7292ccd42779c901cf525e48cc71707ac3dabdab 100644 --- a/src/HAB/Solr/Facet/Impl/FieldFacet.php +++ b/src/HAB/Solr/Facet/Impl/FieldFacet.php @@ -64,7 +64,7 @@ class FieldFacet implements FacetImplInterface /** * Filter query tag, if any. * - * @var string + * @var string|null */ private $fqTag; @@ -356,7 +356,7 @@ class FieldFacet implements FacetImplInterface */ public function __clone () { - if ($this->localParams) { + if ($this->localParams !== null) { $this->localParams = clone($this->localParams); } $this->fqTag = null; diff --git a/src/HAB/Solr/Facet/LabelFactory/RegExpLabelFactory.php b/src/HAB/Solr/Facet/LabelFactory/RegExpLabelFactory.php index 7cd9faf0bc6fab6095f3eb10c93ddb7e294a5e2d..50adfbd6d4331cce4ca2f9ee0152bc63c66c9aed 100644 --- a/src/HAB/Solr/Facet/LabelFactory/RegExpLabelFactory.php +++ b/src/HAB/Solr/Facet/LabelFactory/RegExpLabelFactory.php @@ -65,8 +65,8 @@ class RegExpLabelFactory implements LabelFactoryInterface public function createLabel ($value) { if (preg_match($this->pattern, $value)) { - return preg_replace($this->pattern, $this->template, $value); + return (string)preg_replace($this->pattern, $this->template, $value); } return $value; } -} \ No newline at end of file +} diff --git a/src/HAB/Solr/Facet/StateFilter/DefaultStateFilter.php b/src/HAB/Solr/Facet/StateFilter/DefaultStateFilter.php index 9419b1caf899b577dbf64beb2b5bd1319c6f5f65..ec121f650e290ca60f04df4da0538b24a3662c3a 100644 --- a/src/HAB/Solr/Facet/StateFilter/DefaultStateFilter.php +++ b/src/HAB/Solr/Facet/StateFilter/DefaultStateFilter.php @@ -41,6 +41,6 @@ class DefaultStateFilter implements StateFilterInterface */ public function filter (array $state) { - return clone($state); + return $state; } } diff --git a/src/HAB/Solr/Facet/Value/Container/FacetValueList.php b/src/HAB/Solr/Facet/Value/Container/FacetValueList.php index f5aefba212d39b3da5c2f41b8be7686e01d5da34..26718209b8ddba94b3d13bf680fd824cd3c71fb1 100644 --- a/src/HAB/Solr/Facet/Value/Container/FacetValueList.php +++ b/src/HAB/Solr/Facet/Value/Container/FacetValueList.php @@ -103,7 +103,7 @@ class FacetValueList implements ContainerInterface */ public function sortByLabel ($reverse = false) { - usort($this->values, array('HAB Solr\Search\Facet\Value\FacetValue', 'compareByLabel')); + usort($this->values, array(FacetValue::class, 'compareByLabel')); if ($reverse) { $this->values = array_reverse($this->values); } @@ -114,7 +114,7 @@ class FacetValueList implements ContainerInterface */ public function sortByCount ($reverse = false) { - usort($this->values, array('HAB Solr\Search\Facet\Value\FacetValue', 'compareByCount')); + usort($this->values, array(FacetValue::class, 'compareByCount')); if ($reverse) { $this->values = array_reverse($this->values); } @@ -127,4 +127,4 @@ class FacetValueList implements ContainerInterface { return count($this->values); } -} \ No newline at end of file +} diff --git a/src/HAB/Solr/Facet/Value/Container/FacetValueTree.php b/src/HAB/Solr/Facet/Value/Container/FacetValueTree.php index cd627d6b6981e67ad8aebf789af379792bf4012f..fbfb89240bfbb2b98c43be2148de214c14be6f59 100644 --- a/src/HAB/Solr/Facet/Value/Container/FacetValueTree.php +++ b/src/HAB/Solr/Facet/Value/Container/FacetValueTree.php @@ -69,13 +69,13 @@ class FacetValueTree implements ContainerInterface /** * Constructor. * - * @param FacetValueTreePathFactory $pathFactory + * @param PathFactory\PathFactoryInterface $pathFactory * @return void */ public function __construct (PathFactory\PathFactoryInterface $pathFactory) { $this->pathFactory = $pathFactory; - $this->rootNode = new FacetValueTreeNode(uniqid(true)); + $this->rootNode = new FacetValueTreeNode(uniqid('node', true)); $this->values = array(); } @@ -152,7 +152,7 @@ class FacetValueTree implements ContainerInterface public function sortByLabel ($reverse = false) { $this->rootNode->sortByLabel($reverse); - $sortfunc = array('HAB Solr\Search\Facet\Value\FacetValue', 'compareByLabel'); + $sortfunc = array(FacetValue::class, 'compareByLabel'); usort($this->values, $sortfunc); if ($reverse) { $this->values = array_reverse($this->values); @@ -164,7 +164,7 @@ class FacetValueTree implements ContainerInterface */ public function sortByCount ($reverse = false) { - $sortfunc = array('HAB Solr\Search\Facet\Value\FacetValue', 'compareByCount'); + $sortfunc = array(FacetValue::class, 'compareByCount'); $this->sortByFunction($sortfunc, $reverse); } diff --git a/src/HAB/Solr/Facet/Value/Container/FacetValueTreeNode.php b/src/HAB/Solr/Facet/Value/Container/FacetValueTreeNode.php index 1acca45554dbe2a0baab6c0faa7a25218afea399..ea147d8a6a8a22d85110e8257e32050792269068 100644 --- a/src/HAB/Solr/Facet/Value/Container/FacetValueTreeNode.php +++ b/src/HAB/Solr/Facet/Value/Container/FacetValueTreeNode.php @@ -82,7 +82,7 @@ class FacetValueTreeNode implements RecursiveIterator public static function getCollator () { if (self::$collator === null) { - self::$collator = new Collator(null); + self::$collator = new Collator(''); } return self::$collator; } @@ -199,7 +199,7 @@ class FacetValueTreeNode implements RecursiveIterator /** * Return node value. * - * @return FacetValue|null + * @return FacetValue */ public function getValue () { @@ -213,7 +213,7 @@ class FacetValueTreeNode implements RecursiveIterator */ public function hasValue () { - return !!$this->value; + return $this->value !== null; } /** @@ -292,7 +292,7 @@ class FacetValueTreeNode implements RecursiveIterator foreach ($this->childNodes as $node) { $node->sortByLabel($reverse); } - usort($this->childNodes, 'self::compareByLabel'); + usort($this->childNodes, array(FacetValueTreeNode::class, 'compareByLabel')); if ($reverse) { $this->childNodes = array_reverse($this->childNodes); } @@ -390,4 +390,4 @@ class FacetValueTreeNode implements RecursiveIterator return $this->current(); } -} \ No newline at end of file +} diff --git a/src/HAB/Solr/Facet/Value/FacetValue.php b/src/HAB/Solr/Facet/Value/FacetValue.php index 3f6bd1ff191de484fbe5a27593ba0248db51e859..226ffc4dd92af0556b964518114b8e64c0bbfe4f 100644 --- a/src/HAB/Solr/Facet/Value/FacetValue.php +++ b/src/HAB/Solr/Facet/Value/FacetValue.php @@ -92,7 +92,7 @@ class FacetValue public static function getCollator () { if (self::$collator === null) { - self::$collator = new Collator(null); + self::$collator = new Collator(''); } return self::$collator; } diff --git a/src/HAB/Solr/Facet/ValueMapper/RequestValueArrayMapMapper.php b/src/HAB/Solr/Facet/ValueMapper/RequestValueArrayMapMapper.php index bae9b749777c2d2fd3555eec1492242672047303..25d982eb9f85f72f107917555a4f6cfb71e5aca3 100644 --- a/src/HAB/Solr/Facet/ValueMapper/RequestValueArrayMapMapper.php +++ b/src/HAB/Solr/Facet/ValueMapper/RequestValueArrayMapMapper.php @@ -122,9 +122,9 @@ class RequestValueArrayMapMapper implements RequestValueMapperInterface private function lookupRequestValue ($facetValue) { $key = array_search($facetValue, $this->map); - if ($key !== false) { + if (is_string($key)) { return $key; } return null; } -} \ No newline at end of file +} diff --git a/src/HAB/Solr/Facet/ValueMapper/RequestValueMapperInterface.php b/src/HAB/Solr/Facet/ValueMapper/RequestValueMapperInterface.php index 527eb1dc7ec2edac9bdae6fcad418ccb96745397..4157ba0d4ea94c85f654b1b6c1f68747d9dc3a8d 100644 --- a/src/HAB/Solr/Facet/ValueMapper/RequestValueMapperInterface.php +++ b/src/HAB/Solr/Facet/ValueMapper/RequestValueMapperInterface.php @@ -53,7 +53,7 @@ interface RequestValueMapperInterface * Map a single value from request to internal representation. * * @param string $value - * @return string + * @return string|null */ public function mapFromRequestSingleValue ($value); @@ -61,7 +61,7 @@ interface RequestValueMapperInterface * Map a single value from internal representation to request. * * @param string $value - * @return string + * @return string|null */ public function mapToRequestSingleValue ($value); -} \ No newline at end of file +} diff --git a/src/HAB/Solr/Facet/ValueMapper/RequestValuePrefixMapper.php b/src/HAB/Solr/Facet/ValueMapper/RequestValuePrefixMapper.php index 071cf6b1101dd90a3419e942d4051083ebf91b99..19f35dde72ca95260a90212e90ed1dc8099ab3cc 100644 --- a/src/HAB/Solr/Facet/ValueMapper/RequestValuePrefixMapper.php +++ b/src/HAB/Solr/Facet/ValueMapper/RequestValuePrefixMapper.php @@ -66,7 +66,7 @@ class RequestValuePrefixMapper implements RequestValueMapperInterface if (is_array($values)) { return array_map(array($this, 'addPrefix'), $values); } - return $this->addPrefix($values); + return (array)$this->addPrefix($values); } /** @@ -117,4 +117,4 @@ class RequestValuePrefixMapper implements RequestValueMapperInterface { return $this->prefix . $value; } -} \ No newline at end of file +} diff --git a/src/HAB/Solr/ParamBag.php b/src/HAB/Solr/ParamBag.php index db4e1e94396584e2532354dca1bb45720e5e7727..2cd6a24901e91428bd224637cf8b97ee8acb2d2c 100644 --- a/src/HAB/Solr/ParamBag.php +++ b/src/HAB/Solr/ParamBag.php @@ -95,7 +95,7 @@ class ParamBag * Set a parameter. * * @param string $name Parameter name - * @param string $value Parameter value + * @param mixed $value Parameter value * * @return void */ @@ -229,4 +229,4 @@ class ParamBag } return $request; } -} \ No newline at end of file +} diff --git a/src/HAB/Solr/Response/Json/Facets.php b/src/HAB/Solr/Response/Json/Facets.php index 0a46a50de5bd72b212a484489beb2531db906e3d..38007d98c702b46aad7e24e6e6931c20575fad03 100644 --- a/src/HAB/Solr/Response/Json/Facets.php +++ b/src/HAB/Solr/Response/Json/Facets.php @@ -84,7 +84,7 @@ class Facets */ public function getFieldFacets() { - if (!$this->fields) { + if ($this->fields === null) { $this->fields = new ArrayObject(); if (isset($this->facets['facet_fields'])) { foreach ($this->facets['facet_fields'] as $name => $info) { @@ -102,7 +102,7 @@ class Facets */ public function getQueryFacets() { - if (!$this->queries) { + if ($this->queries === null) { $this->queries = new ArrayObject(); if (isset($this->facets['facet_queries'])) { $this->queries->exchangeArray($this->facets['facet_queries']); @@ -111,4 +111,4 @@ class Facets return $this->queries; } -} \ No newline at end of file +} diff --git a/src/HAB/Solr/Response/Json/QuerySuggestion.php b/src/HAB/Solr/Response/Json/QuerySuggestion.php index 78d4c4c399abcd3f38503978e5442141006fd1bb..64e545a26da9acb9c92f2f5131b2eb33b4c1a55d 100644 --- a/src/HAB/Solr/Response/Json/QuerySuggestion.php +++ b/src/HAB/Solr/Response/Json/QuerySuggestion.php @@ -50,7 +50,7 @@ class QuerySuggestion /** * Number of records matching the query. * - * @var integer|false + * @var integer|null */ private $hits; @@ -58,11 +58,11 @@ class QuerySuggestion * Constructor. * * @param string $query - * @param integer $hitcount + * @param integer $hits * * @return void */ - public function __construct ($query, $hits = false) + public function __construct ($query, $hits = null) { $this->query = $query; $this->hits = $hits; @@ -81,10 +81,10 @@ class QuerySuggestion /** * Return number of matching records. * - * @return integer + * @return integer|null */ public function getHits () { return $this->hits; } -} \ No newline at end of file +}