Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added union type declarations to method signatures
- Solarium\Core\Query\Helper::formatDate() throws a `TypeError` instead of returning `false` if called with an incompatibly typed parameter
- Managed resources queries no longer work around SOLR-6853 by default. Set the 'useDoubleEncoding' option to `true` if this bug affects you.
- Solarium codebase is now analysed at PHPStan level 2

### Removed
- Solarium\Component\Result\Stats\FacetValue::getFacets(), always returned `null`
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"nyholm/psr7": "^1.8",
"php-http/guzzle7-adapter": "^1.0",
"phpstan/extension-installer": "^1.4",
"phpstan/phpstan": "^2.1",
"phpstan/phpstan": "^2.1.41",
"phpstan/phpstan-deprecation-rules": "^2.0",
"phpstan/phpstan-phpunit": "^2.0",
"phpunit/phpunit": "^10.5",
Expand Down
6 changes: 5 additions & 1 deletion phpstan.dist.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
parameters:
level: 1
level: 2
reportIgnoresWithoutComments: true
paths:
- src
- tests
universalObjectCratesClasses:
- Solarium\Core\Query\DocumentInterface
- Solarium\Core\Query\Result\QueryType
4 changes: 4 additions & 0 deletions src/Builder/Analytics/AnalyticsExpressionVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ public function dispatch(ExpressionInterface $expr)

/**
* {@inheritdoc}
*
* @param ExpressionInterface&FunctionInterface $expression
*
* @return mixed
*/
public function walkExpression(ExpressionInterface $expression)
{
Expand Down
11 changes: 6 additions & 5 deletions src/Builder/Analytics/FunctionBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Solarium\Builder\Analytics;

use Solarium\Builder\ExpressionInterface;
use Solarium\Builder\FunctionInterface;

/**
* FunctionBuilder.
Expand All @@ -20,7 +21,7 @@
*/
class FunctionBuilder
{
private ExpressionInterface $function;
private ExpressionInterface&FunctionInterface $function;

private static ?ExpressionBuilder $expressionBuilder = null;

Expand All @@ -45,21 +46,21 @@ public static function expr(): ExpressionBuilder
}

/**
* @param ExpressionInterface $function
* @param ExpressionInterface&FunctionInterface $function
*
* @return self Provides fluent interface
*/
public function where(ExpressionInterface $function): self
public function where(ExpressionInterface&FunctionInterface $function): self
{
$this->function = $function;

return $this;
}

/**
* @return ExpressionInterface
* @return ExpressionInterface&FunctionInterface
*/
public function getFunction(): ExpressionInterface
public function getFunction(): ExpressionInterface&FunctionInterface
{
return $this->function;
}
Expand Down
14 changes: 7 additions & 7 deletions src/Component/ComponentAwareQueryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ interface ComponentAwareQueryInterface
/**
* Get all registered component types.
*
* @return array
* @return array<self::COMPONENT_*|string> An array of self::COMPONENT_* and/or self-registered keys
*/
public function getComponentTypes(): array;

Expand All @@ -131,9 +131,9 @@ public function getComponents(): array;
* You can optionally supply an autoload class to create a new component
* instance if there is no registered component for the given key yet.
*
* @param string $key Use one of the constants
* @param bool $autoload Autoload if component needs to be created
* @param array|null $config Configuration to use for autoload
* @param self::COMPONENT_*|string $key A self::COMPONENT_* or self-registered key
* @param bool $autoload Autoload if component needs to be created
* @param array|null $config Configuration to use for autoload
*
* @throws OutOfBoundsException
*
Expand All @@ -146,8 +146,8 @@ public function getComponent(string $key, ?bool $autoload = false, ?array $confi
*
* This overwrites any existing component registered with the same key.
*
* @param string $key
* @param AbstractComponent $component
* @param self::COMPONENT_*|string $key A self::COMPONENT_* or self-registered key
* @param AbstractComponent $component
*
* @return self Provides fluent interface
*/
Expand All @@ -158,7 +158,7 @@ public function setComponent(string $key, AbstractComponent $component): self;
*
* You can remove a component by passing its key or the component instance.
*
* @param string|AbstractComponent $component
* @param self::COMPONENT_*|string|AbstractComponent $component
*
* @return self Provides fluent interface
*/
Expand Down
14 changes: 7 additions & 7 deletions src/Component/ComponentAwareQueryTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ trait ComponentAwareQueryTrait
/**
* Get all registered component types.
*
* @return array
* @return array<self::COMPONENT_*|string> An array of self::COMPONENT_* and/or self-registered keys
*/
public function getComponentTypes(): array
{
Expand Down Expand Up @@ -69,9 +69,9 @@ public function getComponents(): array
* You can optionally supply an autoload class to create a new component
* instance if there is no registered component for the given key yet.
*
* @param string $key Use one of the constants
* @param bool $autoload Autoload if component needs to be created
* @param array|null $config Configuration to use for autoload
* @param self::COMPONENT_*|string $key A self::COMPONENT_* or self-registered key
* @param bool $autoload Autoload if component needs to be created
* @param array|null $config Configuration to use for autoload
*
* @throws OutOfBoundsException
*
Expand Down Expand Up @@ -104,8 +104,8 @@ public function getComponent(string $key, ?bool $autoload = false, ?array $confi
*
* This overwrites any existing component registered with the same key.
*
* @param string $key
* @param AbstractComponent $component
* @param self::COMPONENT_*|string $key A self::COMPONENT_* or self-registered key
* @param AbstractComponent $component
*
* @return self Provides fluent interface
*/
Expand All @@ -122,7 +122,7 @@ public function setComponent(string $key, AbstractComponent $component): self
*
* You can remove a component by passing its key or the component instance.
*
* @param string|AbstractComponent $component
* @param self::COMPONENT_*|string|AbstractComponent $component
*
* @return self Provides fluent interface
*/
Expand Down
8 changes: 2 additions & 6 deletions src/Component/Facet/FieldValueParametersInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,7 @@ public function getMatches(): ?string;
/**
* Set the facet sort type.
*
* Use one of the SORT_* constants as the value.
*
* @param string $sort
* @param self::SORT_* $sort
*/
public function setSort(string $sort): static;

Expand Down Expand Up @@ -177,9 +175,7 @@ public function getMissing(): ?bool;
/**
* Set the facet method.
*
* Use one of the METHOD_* constants as value.
*
* @param string $method
* @param self::METHOD_* $method
*/
public function setMethod(string $method): static;

Expand Down
8 changes: 2 additions & 6 deletions src/Component/Facet/FieldValueParametersTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,7 @@ public function getMatches(): ?string
/**
* Set the facet sort type.
*
* Use one of the SORT_* constants as the value.
*
* @param string $sort
* @param self::SORT_* $sort
*/
public function setSort(string $sort): static
{
Expand Down Expand Up @@ -217,9 +215,7 @@ public function getMissing(): ?bool
/**
* Set the facet method.
*
* Use one of the METHOD_* constants as value.
*
* @param string $method
* @param self::METHOD_* $method
*/
public function setMethod(string $method): static
{
Expand Down
2 changes: 1 addition & 1 deletion src/Component/Facet/JsonFacetInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*
* @see https://solr.apache.org/guide/json-facet-api.html
*/
interface JsonFacetInterface
interface JsonFacetInterface extends FacetInterface
{
/**
* Serializes nested facets as option "facet" and returns that array structure.
Expand Down
22 changes: 22 additions & 0 deletions src/Component/Facet/JsonFacetTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,28 @@ public function addFacet(FacetInterface|array $facet): static
throw new InvalidArgumentException('Only JSON facets can be nested.');
}

/**
* Get a facet.
*
* @param string $key
*
* @return JsonFacetInterface|null
*/
public function getFacet(string $key): ?JsonFacetInterface
{
return $this->facets[$key] ?? null;
}

/**
* Get all facets.
*
* @return JsonFacetInterface[]
*/
public function getFacets(): array
{
return $this->facets;
}

/**
* Remove a single facet.
*
Expand Down
6 changes: 2 additions & 4 deletions src/Component/Facet/JsonTerms.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public function getLimit(): ?int
*
* @see https://solr.apache.org/guide/json-facet-api.html#sorting-facets-by-nested-functions
*
* @param string $sort
* @param self::SORT_*|string $sort
*/
public function setSort(string $sort): static
{
Expand Down Expand Up @@ -385,9 +385,7 @@ public function getPrefix(): ?string
/**
* Set the facet algorithm to use.
*
* Use one of the METHOD_* constants as value.
*
* @param string $method
* @param self::METHOD_* $method
*/
public function setMethod(string $method): static
{
Expand Down
4 changes: 1 addition & 3 deletions src/Component/Facet/Pivot.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,7 @@ public function getOffset(): ?int
/**
* Set the facet sort type.
*
* Use one of the SORT_* constants as the value.
*
* @param string $sort
* @param self::SORT_* $sort
*/
public function setSort(string $sort): static
{
Expand Down
23 changes: 11 additions & 12 deletions src/Component/FacetSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

namespace Solarium\Component;

use Solarium\Component\Facet\FacetInterface;
use Solarium\Component\Facet\Field;
use Solarium\Component\Facet\FieldValueParametersInterface;
use Solarium\Component\Facet\FieldValueParametersTrait;
Expand Down Expand Up @@ -116,9 +115,9 @@ public function getExtractFromResponse(): ?bool
* @param string|array|null $options
* @param bool $add
*
* @return Field|FacetInterface
* @return Field
*/
public function createFacetField(string|array|null $options = null, bool $add = true): FacetInterface
public function createFacetField(string|array|null $options = null, bool $add = true): Field
{
return $this->createFacet(FacetSetInterface::FACET_FIELD, $options, $add);
}
Expand All @@ -133,7 +132,7 @@ public function createFacetField(string|array|null $options = null, bool $add =
*
* @return Query
*/
public function createFacetQuery(string|array|null $options = null, bool $add = true): FacetInterface
public function createFacetQuery(string|array|null $options = null, bool $add = true): Query
{
return $this->createFacet(FacetSetInterface::FACET_QUERY, $options, $add);
}
Expand All @@ -148,7 +147,7 @@ public function createFacetQuery(string|array|null $options = null, bool $add =
*
* @return MultiQuery
*/
public function createFacetMultiQuery(string|array|null $options = null, bool $add = true): FacetInterface
public function createFacetMultiQuery(string|array|null $options = null, bool $add = true): MultiQuery
{
return $this->createFacet(FacetSetInterface::FACET_MULTIQUERY, $options, $add);
}
Expand All @@ -163,7 +162,7 @@ public function createFacetMultiQuery(string|array|null $options = null, bool $a
*
* @return Range
*/
public function createFacetRange(string|array|null $options = null, bool $add = true): FacetInterface
public function createFacetRange(string|array|null $options = null, bool $add = true): Range
{
return $this->createFacet(FacetSetInterface::FACET_RANGE, $options, $add);
}
Expand All @@ -178,7 +177,7 @@ public function createFacetRange(string|array|null $options = null, bool $add =
*
* @return Pivot
*/
public function createFacetPivot(string|array|null $options = null, bool $add = true): FacetInterface
public function createFacetPivot(string|array|null $options = null, bool $add = true): Pivot
{
return $this->createFacet(FacetSetInterface::FACET_PIVOT, $options, $add);
}
Expand All @@ -193,7 +192,7 @@ public function createFacetPivot(string|array|null $options = null, bool $add =
*
* @return Interval
*/
public function createFacetInterval(string|array|null $options = null, bool $add = true): FacetInterface
public function createFacetInterval(string|array|null $options = null, bool $add = true): Interval
{
return $this->createFacet(FacetSetInterface::FACET_INTERVAL, $options, $add);
}
Expand All @@ -208,7 +207,7 @@ public function createFacetInterval(string|array|null $options = null, bool $add
*
* @return JsonAggregation
*/
public function createJsonFacetAggregation(string|array|null $options = null, bool $add = true): FacetInterface
public function createJsonFacetAggregation(string|array|null $options = null, bool $add = true): JsonAggregation
{
return $this->createFacet(FacetSetInterface::JSON_FACET_AGGREGATION, $options, $add);
}
Expand All @@ -223,7 +222,7 @@ public function createJsonFacetAggregation(string|array|null $options = null, bo
*
* @return JsonTerms
*/
public function createJsonFacetTerms(string|array|null $options = null, bool $add = true): FacetInterface
public function createJsonFacetTerms(string|array|null $options = null, bool $add = true): JsonTerms
{
return $this->createFacet(FacetSetInterface::JSON_FACET_TERMS, $options, $add);
}
Expand All @@ -238,7 +237,7 @@ public function createJsonFacetTerms(string|array|null $options = null, bool $ad
*
* @return JsonQuery
*/
public function createJsonFacetQuery(string|array|null $options = null, bool $add = true): FacetInterface
public function createJsonFacetQuery(string|array|null $options = null, bool $add = true): JsonQuery
{
return $this->createFacet(FacetSetInterface::JSON_FACET_QUERY, $options, $add);
}
Expand All @@ -253,7 +252,7 @@ public function createJsonFacetQuery(string|array|null $options = null, bool $ad
*
* @return JsonRange
*/
public function createJsonFacetRange(string|array|null $options = null, bool $add = true): FacetInterface
public function createJsonFacetRange(string|array|null $options = null, bool $add = true): JsonRange
{
return $this->createFacet(FacetSetInterface::JSON_FACET_RANGE, $options, $add);
}
Expand Down
Loading
Loading