Skip to content

Commit 255e151

Browse files
Remove support for config objects
1 parent 19838ed commit 255e151

20 files changed

+156
-223
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414
### Changed
1515
- JSON update requests give precedence to `Stringable` over `JsonSerializable` for object set as field value to keep behaviour consistent across request formats
1616

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

1821
## [6.3.5]
1922
### Added

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ composer require solarium/solarium
3232

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

35+
* [Pitfall when upgrading to 6.3.6](https://solarium.readthedocs.io/en/stable/getting-started/#pitfall-when-upgrading-to-636)
3536
* [Pitfall when upgrading to 6.3.2](https://solarium.readthedocs.io/en/stable/getting-started/#pitfall-when-upgrading-to-632)
3637
* [Pitfall when upgrading to 6.3](https://solarium.readthedocs.io/en/stable/getting-started/#pitfall-when-upgrading-to-63)
3738
* [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)

docs/getting-started.md

+5
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@ Upgrading
9090

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

93+
### Pitfall when upgrading to 6.3.6
94+
95+
Using a config object is no longer supported. You have to convert it to an array before passing
96+
it to a constructor or the `setOptions()` method.
97+
9398
### Pitfall when upgrading to 6.3.2
9499

95100
Support for PHP 7 was removed in Solarium 6.3.2. Upgrade to PHP 8 first to use the latest Solarium version.

docs/queries/select-query/building-a-select-query/building-a-select-query.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,8 @@ An example using the select query in config mode: (filterqueries and components
9292
require_once(__DIR__.'/init.php');
9393
htmlHeader();
9494

95-
9695
// In this case an array is used for configuration to keep the example simple.
97-
// For an easier to use config file you are probably better of with another format, like Zend_Config_Ini
98-
// See the documentation for more info about this.
96+
// You can also call setters on the query instance for each option.
9997
$select = array(
10098
'query' => '*:*',
10199
'start' => 2,

docs/solarium-concepts.md

+3-7
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ Solarium allows for three main modes of usage of the library: programmatically,
1111

1212
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.
1313

14-
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).
14+
The configuration mode supports an associative array as input.
1515

16-
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.
16+
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.
1717

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

@@ -80,10 +80,6 @@ htmlFooter();
8080
require_once(__DIR__.'/init.php');
8181
htmlHeader();
8282

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

152148
// In most cases using the API or config is advisable, however in some cases it can make sense to extend classes.
153-
// This makes it possible to create 'query inheritance' like in this example
149+
// This makes it possible to create 'query inheritance' like in this example.
154150
class ProductQuery extends Select
155151
{
156152
protected function init()

examples/4.2-configuration-usage.php

-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33
require_once(__DIR__.'/init.php');
44
htmlHeader();
55

6-
7-
// In this case an array is used for configuration to keep the example simple.
8-
// For an easier to use config file you are probably better of with another format, like Zend_Config_Ini
9-
// See the documentation for more info about this.
106
$select = array(
117
'query' => '*:*',
128
'start' => 2,

examples/4.3-extending-usage.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
htmlHeader();
88

99
// In most cases using the API or config is advisable, however in some cases it can make sense to extend classes.
10-
// This makes it possible to create 'query inheritance' like in this example
10+
// This makes it possible to create 'query inheritance' like in this example.
1111
class ProductQuery extends Select
1212
{
1313
protected function init()

src/Component/FacetSet.php

+30-30
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,12 @@ public function getExtractFromResponse(): ?bool
115115
*
116116
* @see FacetSetTrait::createFacet for more information on $options
117117
*
118-
* @param array|object|string|null $options
119-
* @param bool $add
118+
* @param string|array|null $options
119+
* @param bool $add
120120
*
121121
* @return \Solarium\Component\Facet\Field|FacetInterface
122122
*/
123-
public function createFacetField($options = null, bool $add = true): FacetInterface
123+
public function createFacetField(string|array|null $options = null, bool $add = true): FacetInterface
124124
{
125125
return $this->createFacet(FacetSetInterface::FACET_FIELD, $options, $add);
126126
}
@@ -130,12 +130,12 @@ public function createFacetField($options = null, bool $add = true): FacetInterf
130130
*
131131
* @see FacetSetTrait::createFacet for more information on $options
132132
*
133-
* @param array|object|string|null $options
134-
* @param bool $add
133+
* @param string|array|null $options
134+
* @param bool $add
135135
*
136136
* @return \Solarium\Component\Facet\Query
137137
*/
138-
public function createFacetQuery($options = null, bool $add = true): FacetInterface
138+
public function createFacetQuery(string|array|null $options = null, bool $add = true): FacetInterface
139139
{
140140
return $this->createFacet(FacetSetInterface::FACET_QUERY, $options, $add);
141141
}
@@ -145,12 +145,12 @@ public function createFacetQuery($options = null, bool $add = true): FacetInterf
145145
*
146146
* @see FacetSetTrait::createFacet for more information on $options
147147
*
148-
* @param array|object|string|null $options
149-
* @param bool $add
148+
* @param string|array|null $options
149+
* @param bool $add
150150
*
151151
* @return \Solarium\Component\Facet\MultiQuery
152152
*/
153-
public function createFacetMultiQuery($options = null, bool $add = true): FacetInterface
153+
public function createFacetMultiQuery(string|array|null $options = null, bool $add = true): FacetInterface
154154
{
155155
return $this->createFacet(FacetSetInterface::FACET_MULTIQUERY, $options, $add);
156156
}
@@ -160,12 +160,12 @@ public function createFacetMultiQuery($options = null, bool $add = true): FacetI
160160
*
161161
* @see FacetSetTrait::createFacet for more information on $options
162162
*
163-
* @param array|object|string|null $options
164-
* @param bool $add
163+
* @param string|array|null $options
164+
* @param bool $add
165165
*
166166
* @return \Solarium\Component\Facet\Range
167167
*/
168-
public function createFacetRange($options = null, bool $add = true): FacetInterface
168+
public function createFacetRange(string|array|null $options = null, bool $add = true): FacetInterface
169169
{
170170
return $this->createFacet(FacetSetInterface::FACET_RANGE, $options, $add);
171171
}
@@ -175,12 +175,12 @@ public function createFacetRange($options = null, bool $add = true): FacetInterf
175175
*
176176
* @see FacetSetTrait::createFacet for more information on $options
177177
*
178-
* @param array|object|string|null $options
179-
* @param bool $add
178+
* @param string|array|null $options
179+
* @param bool $add
180180
*
181181
* @return \Solarium\Component\Facet\Pivot
182182
*/
183-
public function createFacetPivot($options = null, bool $add = true): FacetInterface
183+
public function createFacetPivot(string|array|null $options = null, bool $add = true): FacetInterface
184184
{
185185
return $this->createFacet(FacetSetInterface::FACET_PIVOT, $options, $add);
186186
}
@@ -190,12 +190,12 @@ public function createFacetPivot($options = null, bool $add = true): FacetInterf
190190
*
191191
* @see FacetSetTrait::createFacet for more information on $options
192192
*
193-
* @param array|object|string|null $options
194-
* @param bool $add
193+
* @param string|array|null $options
194+
* @param bool $add
195195
*
196196
* @return \Solarium\Component\Facet\Interval
197197
*/
198-
public function createFacetInterval($options = null, bool $add = true): FacetInterface
198+
public function createFacetInterval(string|array|null $options = null, bool $add = true): FacetInterface
199199
{
200200
return $this->createFacet(FacetSetInterface::FACET_INTERVAL, $options, $add);
201201
}
@@ -205,12 +205,12 @@ public function createFacetInterval($options = null, bool $add = true): FacetInt
205205
*
206206
* @see FacetSetTrait::createFacet for more information on $options
207207
*
208-
* @param array|object|string|null $options
209-
* @param bool $add
208+
* @param string|array|null $options
209+
* @param bool $add
210210
*
211211
* @return \Solarium\Component\Facet\JsonAggregation
212212
*/
213-
public function createJsonFacetAggregation($options = null, bool $add = true): FacetInterface
213+
public function createJsonFacetAggregation(string|array|null $options = null, bool $add = true): FacetInterface
214214
{
215215
return $this->createFacet(FacetSetInterface::JSON_FACET_AGGREGATION, $options, $add);
216216
}
@@ -220,12 +220,12 @@ public function createJsonFacetAggregation($options = null, bool $add = true): F
220220
*
221221
* @see FacetSetTrait::createFacet for more information on $options
222222
*
223-
* @param array|object|string|null $options
224-
* @param bool $add
223+
* @param string|array|null $options
224+
* @param bool $add
225225
*
226226
* @return \Solarium\Component\Facet\JsonTerms
227227
*/
228-
public function createJsonFacetTerms($options = null, bool $add = true): FacetInterface
228+
public function createJsonFacetTerms(string|array|null $options = null, bool $add = true): FacetInterface
229229
{
230230
return $this->createFacet(FacetSetInterface::JSON_FACET_TERMS, $options, $add);
231231
}
@@ -235,12 +235,12 @@ public function createJsonFacetTerms($options = null, bool $add = true): FacetIn
235235
*
236236
* @see FacetSetTrait::createFacet for more information on $options
237237
*
238-
* @param array|object|string|null $options
239-
* @param bool $add
238+
* @param string|array|null $options
239+
* @param bool $add
240240
*
241241
* @return \Solarium\Component\Facet\JsonQuery
242242
*/
243-
public function createJsonFacetQuery($options = null, bool $add = true): FacetInterface
243+
public function createJsonFacetQuery(string|array|null $options = null, bool $add = true): FacetInterface
244244
{
245245
return $this->createFacet(FacetSetInterface::JSON_FACET_QUERY, $options, $add);
246246
}
@@ -250,12 +250,12 @@ public function createJsonFacetQuery($options = null, bool $add = true): FacetIn
250250
*
251251
* @see FacetSetTrait::createFacet for more information on $options
252252
*
253-
* @param array|object|string|null $options
254-
* @param bool $add
253+
* @param string|array|null $options
254+
* @param bool $add
255255
*
256256
* @return \Solarium\Component\Facet\JsonRange
257257
*/
258-
public function createJsonFacetRange($options = null, bool $add = true): FacetInterface
258+
public function createJsonFacetRange(string|array|null $options = null, bool $add = true): FacetInterface
259259
{
260260
return $this->createFacet(FacetSetInterface::JSON_FACET_RANGE, $options, $add);
261261
}

src/Component/FacetSetInterface.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -138,18 +138,18 @@ public function setFacets(array $facets): self;
138138
*
139139
* If you supply a string as the first arguments ($options) it will be used as the key for the facet
140140
* and it will be added to this query.
141-
* If you supply an options array/object that contains a key the facet will also be added to the query.
141+
* If you supply an options array that contains a key the facet will also be added to the query.
142142
*
143143
* When no key is supplied the facet cannot be added, in that case you will need to add it manually
144144
* after setting the key, by using the addFacet method.
145145
*
146146
* @param string $type
147-
* @param array|object|null $options
147+
* @param string|array|null $options
148148
* @param bool $add
149149
*
150150
* @throws OutOfBoundsException
151151
*
152152
* @return FacetInterface
153153
*/
154-
public function createFacet(string $type, $options = null, bool $add = true): FacetInterface;
154+
public function createFacet(string $type, string|array|null $options = null, bool $add = true): FacetInterface;
155155
}

src/Component/FacetSetTrait.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -155,20 +155,20 @@ public function setFacets(array $facets): self
155155
*
156156
* If you supply a string as the first arguments ($options) it will be used as the key for the facet
157157
* and it will be added to this query.
158-
* If you supply an options array/object that contains a key the facet will also be added to the query.
158+
* If you supply an options array that contains a key the facet will also be added to the query.
159159
*
160160
* When no key is supplied the facet cannot be added, in that case you will need to add it manually
161161
* after setting the key, by using the addFacet method.
162162
*
163-
* @param string $type
164-
* @param array|object|string|null $options
165-
* @param bool $add
163+
* @param string $type
164+
* @param string|array|null $options
165+
* @param bool $add
166166
*
167167
* @throws OutOfBoundsException
168168
*
169169
* @return \Solarium\Component\Facet\FacetInterface
170170
*/
171-
public function createFacet(string $type, $options = null, bool $add = true): FacetInterface
171+
public function createFacet(string $type, string|array|null $options = null, bool $add = true): FacetInterface
172172
{
173173
$type = strtolower($type);
174174

src/Component/Stats/Stats.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,16 @@ public function getResponseParser(): ?ComponentParserInterface
6868
*
6969
* If you supply a string as the first arguments ($options) it will be used as the key for the field
7070
* and it will be added to this query component.
71-
* If you supply an options array/object that contains a key the field will also be added to the component.
71+
* If you supply an options array that contains a key the field will also be added to the component.
7272
*
7373
* When no key is supplied the field cannot be added, in that case you will need to add it manually
7474
* after setting the key, by using the addField method.
7575
*
76-
* @param mixed $options
76+
* @param string|array $options
7777
*
7878
* @return Field
7979
*/
80-
public function createField($options = null): Field
80+
public function createField(string|array $options = null): Field
8181
{
8282
if (\is_string($options)) {
8383
$fq = new Field();

0 commit comments

Comments
 (0)