Skip to content

Commit

Permalink
Remove support for config objects (#1131)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomascorthals committed Aug 7, 2024
1 parent 19838ed commit daf9df3
Show file tree
Hide file tree
Showing 20 changed files with 156 additions and 223 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- JSON update requests give precedence to `Stringable` over `JsonSerializable` for object set as field value to keep behaviour consistent across request formats

### Removed
- Support for config objects, you have to convert them to an array before passing to a constructor or `setOptions()`


## [6.3.5]
### Added
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ composer require solarium/solarium

When upgrading from an earlier version, you should be aware of a number of pitfalls.

* [Pitfall when upgrading to 6.3.6](https://solarium.readthedocs.io/en/stable/getting-started/#pitfall-when-upgrading-to-636)
* [Pitfall when upgrading to 6.3.2](https://solarium.readthedocs.io/en/stable/getting-started/#pitfall-when-upgrading-to-632)
* [Pitfall when upgrading to 6.3](https://solarium.readthedocs.io/en/stable/getting-started/#pitfall-when-upgrading-to-63)
* [Pitfalls when upgrading from 3.x or 4.x or 5.x](https://solarium.readthedocs.io/en/stable/getting-started/#pitfalls-when-upgrading-from-3x-or-4x-or-5x)
Expand Down
5 changes: 5 additions & 0 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ Upgrading

When upgrading from an earlier version, you should be aware of a number of pitfalls.

### Pitfall when upgrading to 6.3.6

Using a config object is no longer supported. You have to convert it to an array before passing
it to a constructor or the `setOptions()` method.

### Pitfall when upgrading to 6.3.2

Support for PHP 7 was removed in Solarium 6.3.2. Upgrade to PHP 8 first to use the latest Solarium version.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,8 @@ An example using the select query in config mode: (filterqueries and components
require_once(__DIR__.'/init.php');
htmlHeader();


// In this case an array is used for configuration to keep the example simple.
// For an easier to use config file you are probably better of with another format, like Zend_Config_Ini
// See the documentation for more info about this.
// You can also call setters on the query instance for each option.
$select = array(
'query' => '*:*',
'start' => 2,
Expand Down
10 changes: 3 additions & 7 deletions docs/solarium-concepts.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ Solarium allows for three main modes of usage of the library: programmatically,

Currently only the programmatic and extending modes support all features, the configuration mode doesn't support some complex cases. This might be improved over time but there will always be limits to what is possible with configuration only, without creating very complex configurations.

The configuration mode supports an array as input or an object that implements the `toArray()` method (this is also compatible with the Zend Framework `Zend_Config` component).
The configuration mode supports an associative array as input.

The three modes apply to all Solarium classes that extend `Solarium\Core\Configurable`. This includes all Solarium classes that are intended for direct usage, e.g. the query classes, filterqueries, components etcetera. You can check to API for a class to see if it supports config mode.
The three modes apply to all Solarium classes that extend `Solarium\Core\Configurable`. This includes all Solarium classes that are intended for direct usage, e.g. the query classes, filterqueries, components etcetera. You can check the API for a class to see if it supports config mode.

As an example the three modes are demonstrated, all creating an identical Solr client instance:

Expand Down Expand Up @@ -80,10 +80,6 @@ htmlFooter();
require_once(__DIR__.'/init.php');
htmlHeader();


// In this case an array is used for configuration to keep the example simple.
// For an easier to use config file you are probably better of with another format, like Zend_Config_Ini
// See the documentation for more info about this.
$select = array(
'query' => '*:*',
'start' => 2,
Expand Down Expand Up @@ -150,7 +146,7 @@ use Solarium\QueryType\Select\Query\Query as Select;
htmlHeader();

// In most cases using the API or config is advisable, however in some cases it can make sense to extend classes.
// This makes it possible to create 'query inheritance' like in this example
// This makes it possible to create 'query inheritance' like in this example.
class ProductQuery extends Select
{
protected function init()
Expand Down
4 changes: 0 additions & 4 deletions examples/4.2-configuration-usage.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
require_once(__DIR__.'/init.php');
htmlHeader();


// In this case an array is used for configuration to keep the example simple.
// For an easier to use config file you are probably better of with another format, like Zend_Config_Ini
// See the documentation for more info about this.
$select = array(
'query' => '*:*',
'start' => 2,
Expand Down
2 changes: 1 addition & 1 deletion examples/4.3-extending-usage.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
htmlHeader();

// In most cases using the API or config is advisable, however in some cases it can make sense to extend classes.
// This makes it possible to create 'query inheritance' like in this example
// This makes it possible to create 'query inheritance' like in this example.
class ProductQuery extends Select
{
protected function init()
Expand Down
60 changes: 30 additions & 30 deletions src/Component/FacetSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@ public function getExtractFromResponse(): ?bool
*
* @see FacetSetTrait::createFacet for more information on $options
*
* @param array|object|string|null $options
* @param bool $add
* @param string|array|null $options
* @param bool $add
*
* @return \Solarium\Component\Facet\Field|FacetInterface
*/
public function createFacetField($options = null, bool $add = true): FacetInterface
public function createFacetField(string|array|null $options = null, bool $add = true): FacetInterface
{
return $this->createFacet(FacetSetInterface::FACET_FIELD, $options, $add);
}
Expand All @@ -130,12 +130,12 @@ public function createFacetField($options = null, bool $add = true): FacetInterf
*
* @see FacetSetTrait::createFacet for more information on $options
*
* @param array|object|string|null $options
* @param bool $add
* @param string|array|null $options
* @param bool $add
*
* @return \Solarium\Component\Facet\Query
*/
public function createFacetQuery($options = null, bool $add = true): FacetInterface
public function createFacetQuery(string|array|null $options = null, bool $add = true): FacetInterface
{
return $this->createFacet(FacetSetInterface::FACET_QUERY, $options, $add);
}
Expand All @@ -145,12 +145,12 @@ public function createFacetQuery($options = null, bool $add = true): FacetInterf
*
* @see FacetSetTrait::createFacet for more information on $options
*
* @param array|object|string|null $options
* @param bool $add
* @param string|array|null $options
* @param bool $add
*
* @return \Solarium\Component\Facet\MultiQuery
*/
public function createFacetMultiQuery($options = null, bool $add = true): FacetInterface
public function createFacetMultiQuery(string|array|null $options = null, bool $add = true): FacetInterface
{
return $this->createFacet(FacetSetInterface::FACET_MULTIQUERY, $options, $add);
}
Expand All @@ -160,12 +160,12 @@ public function createFacetMultiQuery($options = null, bool $add = true): FacetI
*
* @see FacetSetTrait::createFacet for more information on $options
*
* @param array|object|string|null $options
* @param bool $add
* @param string|array|null $options
* @param bool $add
*
* @return \Solarium\Component\Facet\Range
*/
public function createFacetRange($options = null, bool $add = true): FacetInterface
public function createFacetRange(string|array|null $options = null, bool $add = true): FacetInterface
{
return $this->createFacet(FacetSetInterface::FACET_RANGE, $options, $add);
}
Expand All @@ -175,12 +175,12 @@ public function createFacetRange($options = null, bool $add = true): FacetInterf
*
* @see FacetSetTrait::createFacet for more information on $options
*
* @param array|object|string|null $options
* @param bool $add
* @param string|array|null $options
* @param bool $add
*
* @return \Solarium\Component\Facet\Pivot
*/
public function createFacetPivot($options = null, bool $add = true): FacetInterface
public function createFacetPivot(string|array|null $options = null, bool $add = true): FacetInterface
{
return $this->createFacet(FacetSetInterface::FACET_PIVOT, $options, $add);
}
Expand All @@ -190,12 +190,12 @@ public function createFacetPivot($options = null, bool $add = true): FacetInterf
*
* @see FacetSetTrait::createFacet for more information on $options
*
* @param array|object|string|null $options
* @param bool $add
* @param string|array|null $options
* @param bool $add
*
* @return \Solarium\Component\Facet\Interval
*/
public function createFacetInterval($options = null, bool $add = true): FacetInterface
public function createFacetInterval(string|array|null $options = null, bool $add = true): FacetInterface
{
return $this->createFacet(FacetSetInterface::FACET_INTERVAL, $options, $add);
}
Expand All @@ -205,12 +205,12 @@ public function createFacetInterval($options = null, bool $add = true): FacetInt
*
* @see FacetSetTrait::createFacet for more information on $options
*
* @param array|object|string|null $options
* @param bool $add
* @param string|array|null $options
* @param bool $add
*
* @return \Solarium\Component\Facet\JsonAggregation
*/
public function createJsonFacetAggregation($options = null, bool $add = true): FacetInterface
public function createJsonFacetAggregation(string|array|null $options = null, bool $add = true): FacetInterface
{
return $this->createFacet(FacetSetInterface::JSON_FACET_AGGREGATION, $options, $add);
}
Expand All @@ -220,12 +220,12 @@ public function createJsonFacetAggregation($options = null, bool $add = true): F
*
* @see FacetSetTrait::createFacet for more information on $options
*
* @param array|object|string|null $options
* @param bool $add
* @param string|array|null $options
* @param bool $add
*
* @return \Solarium\Component\Facet\JsonTerms
*/
public function createJsonFacetTerms($options = null, bool $add = true): FacetInterface
public function createJsonFacetTerms(string|array|null $options = null, bool $add = true): FacetInterface
{
return $this->createFacet(FacetSetInterface::JSON_FACET_TERMS, $options, $add);
}
Expand All @@ -235,12 +235,12 @@ public function createJsonFacetTerms($options = null, bool $add = true): FacetIn
*
* @see FacetSetTrait::createFacet for more information on $options
*
* @param array|object|string|null $options
* @param bool $add
* @param string|array|null $options
* @param bool $add
*
* @return \Solarium\Component\Facet\JsonQuery
*/
public function createJsonFacetQuery($options = null, bool $add = true): FacetInterface
public function createJsonFacetQuery(string|array|null $options = null, bool $add = true): FacetInterface
{
return $this->createFacet(FacetSetInterface::JSON_FACET_QUERY, $options, $add);
}
Expand All @@ -250,12 +250,12 @@ public function createJsonFacetQuery($options = null, bool $add = true): FacetIn
*
* @see FacetSetTrait::createFacet for more information on $options
*
* @param array|object|string|null $options
* @param bool $add
* @param string|array|null $options
* @param bool $add
*
* @return \Solarium\Component\Facet\JsonRange
*/
public function createJsonFacetRange($options = null, bool $add = true): FacetInterface
public function createJsonFacetRange(string|array|null $options = null, bool $add = true): FacetInterface
{
return $this->createFacet(FacetSetInterface::JSON_FACET_RANGE, $options, $add);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Component/FacetSetInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,18 +138,18 @@ public function setFacets(array $facets): self;
*
* If you supply a string as the first arguments ($options) it will be used as the key for the facet
* and it will be added to this query.
* If you supply an options array/object that contains a key the facet will also be added to the query.
* If you supply an options array that contains a key the facet will also be added to the query.
*
* When no key is supplied the facet cannot be added, in that case you will need to add it manually
* after setting the key, by using the addFacet method.
*
* @param string $type
* @param array|object|null $options
* @param string|array|null $options
* @param bool $add
*
* @throws OutOfBoundsException
*
* @return FacetInterface
*/
public function createFacet(string $type, $options = null, bool $add = true): FacetInterface;
public function createFacet(string $type, string|array|null $options = null, bool $add = true): FacetInterface;
}
10 changes: 5 additions & 5 deletions src/Component/FacetSetTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,20 +155,20 @@ public function setFacets(array $facets): self
*
* If you supply a string as the first arguments ($options) it will be used as the key for the facet
* and it will be added to this query.
* If you supply an options array/object that contains a key the facet will also be added to the query.
* If you supply an options array that contains a key the facet will also be added to the query.
*
* When no key is supplied the facet cannot be added, in that case you will need to add it manually
* after setting the key, by using the addFacet method.
*
* @param string $type
* @param array|object|string|null $options
* @param bool $add
* @param string $type
* @param string|array|null $options
* @param bool $add
*
* @throws OutOfBoundsException
*
* @return \Solarium\Component\Facet\FacetInterface
*/
public function createFacet(string $type, $options = null, bool $add = true): FacetInterface
public function createFacet(string $type, string|array|null $options = null, bool $add = true): FacetInterface
{
$type = strtolower($type);

Expand Down
6 changes: 3 additions & 3 deletions src/Component/Stats/Stats.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,16 @@ public function getResponseParser(): ?ComponentParserInterface
*
* If you supply a string as the first arguments ($options) it will be used as the key for the field
* and it will be added to this query component.
* If you supply an options array/object that contains a key the field will also be added to the component.
* If you supply an options array that contains a key the field will also be added to the component.
*
* When no key is supplied the field cannot be added, in that case you will need to add it manually
* after setting the key, by using the addField method.
*
* @param mixed $options
* @param string|array $options
*
* @return Field
*/
public function createField($options = null): Field
public function createField(string|array $options = null): Field
{
if (\is_string($options)) {
$fq = new Field();
Expand Down
Loading

0 comments on commit daf9df3

Please sign in to comment.