@@ -114,7 +114,7 @@ public function testNormalization(string $input, string $output): void
114114 *
115115 * @return array
116116 */
117- protected function getQuestionTests ()
117+ protected function getQuestionTests (): array
118118 {
119119 // Format: [input, expected output, flags array]
120120 return [
@@ -153,7 +153,7 @@ protected function getQuestionTests()
153153 *
154154 * @return void
155155 */
156- protected function runBasicQuestionTest ($ qb , $ handler , $ test )
156+ protected function runBasicQuestionTest (QueryBuilder $ qb , string $ handler , array $ test ): void
157157 {
158158 [$ input , $ output , $ flags ] = $ test ;
159159 if (
@@ -185,7 +185,7 @@ protected function runBasicQuestionTest($qb, $handler, $test)
185185 *
186186 * @return void
187187 */
188- protected function runAdvancedQuestionTest ($ qb , $ handler , $ test )
188+ protected function runAdvancedQuestionTest (QueryBuilder $ qb , string $ handler , array $ test ): void
189189 {
190190 [$ input , $ output , $ flags ] = $ test ;
191191 if (
@@ -213,7 +213,7 @@ protected function runAdvancedQuestionTest($qb, $handler, $test)
213213 *
214214 * @return void
215215 */
216- protected function runQuestionTests ($ builderParams , $ handler )
216+ protected function runQuestionTests (array $ builderParams , string $ handler ): void
217217 {
218218 // Set up an array of expected inputs and outputs:
219219 $ tests = $ this ->getQuestionTests ();
@@ -229,7 +229,7 @@ protected function runQuestionTests($builderParams, $handler)
229229 *
230230 * @return void
231231 */
232- public function testQueryHandler ()
232+ public function testQueryHandler (): void
233233 {
234234 $ this ->runQuestionTests (
235235 [
@@ -244,7 +244,7 @@ public function testQueryHandler()
244244 *
245245 * @return void
246246 */
247- public function testQueryHandlerWithDismax ()
247+ public function testQueryHandlerWithDismax (): void
248248 {
249249 $ this ->runQuestionTests (
250250 [
@@ -259,7 +259,7 @@ public function testQueryHandlerWithDismax()
259259 *
260260 * @return void
261261 */
262- public function testQueryHandlerWithEdismax ()
262+ public function testQueryHandlerWithEdismax (): void
263263 {
264264 $ this ->runQuestionTests (
265265 [
@@ -275,7 +275,7 @@ public function testQueryHandlerWithEdismax()
275275 *
276276 * @return void
277277 */
278- public function testExactQueryHandler ()
278+ public function testExactQueryHandler (): void
279279 {
280280 $ qb = new QueryBuilder (
281281 [
@@ -306,7 +306,7 @@ public function testExactQueryHandler()
306306 *
307307 * @return void
308308 */
309- public function testQueryHandlerWithFilterQueryAndDisMax ()
309+ public function testQueryHandlerWithFilterQueryAndDisMax (): void
310310 {
311311 $ qb = new QueryBuilder (
312312 [
@@ -324,7 +324,7 @@ public function testQueryHandlerWithFilterQueryAndDisMax()
324324 *
325325 * @return void
326326 */
327- public function testQueryHandlerWithFilterQueryAndNoDisMax ()
327+ public function testQueryHandlerWithFilterQueryAndNoDisMax (): void
328328 {
329329 $ qb = new QueryBuilder (
330330 [
@@ -343,7 +343,7 @@ public function testQueryHandlerWithFilterQueryAndNoDisMax()
343343 *
344344 * @return void
345345 */
346- public function testMatchAllQueryWithFilterQueryAndNoDisMax ()
346+ public function testMatchAllQueryWithFilterQueryAndNoDisMax (): void
347347 {
348348 $ qb = new QueryBuilder (
349349 [
@@ -364,7 +364,7 @@ public function testMatchAllQueryWithFilterQueryAndNoDisMax()
364364 *
365365 * @return void
366366 */
367- public function testHlQ ()
367+ public function testHlQ (): void
368368 {
369369 $ qb = new QueryBuilder (
370370 [
@@ -391,7 +391,7 @@ public function testHlQ()
391391 *
392392 * @return void
393393 */
394- public function testSetFieldsToHighlight ()
394+ public function testSetFieldsToHighlight (): void
395395 {
396396 $ qb = new QueryBuilder (
397397 [
@@ -432,7 +432,7 @@ public function testSetFieldsToHighlight()
432432 *
433433 * @return void
434434 */
435- public function testSetCreateSpellingQuery ()
435+ public function testSetCreateSpellingQuery (): void
436436 {
437437 $ qb = new QueryBuilder (
438438 [
@@ -463,7 +463,7 @@ public function testSetCreateSpellingQuery()
463463 *
464464 * @return void
465465 */
466- public function testQueryGroup ()
466+ public function testQueryGroup (): void
467467 {
468468 $ qb = new QueryBuilder (
469469 [
@@ -494,7 +494,7 @@ public function testQueryGroup()
494494 *
495495 * @return void
496496 */
497- public function testQueryGroupWithAdvancedSyntax ()
497+ public function testQueryGroupWithAdvancedSyntax (): void
498498 {
499499 $ qb = new QueryBuilder (
500500 [
@@ -529,7 +529,7 @@ public function testQueryGroupWithAdvancedSyntax()
529529 *
530530 * @return void
531531 */
532- public function testMultipleQuotedPhrases ()
532+ public function testMultipleQuotedPhrases (): void
533533 {
534534 $ qb = new QueryBuilder (
535535 [
@@ -553,7 +553,7 @@ public function testMultipleQuotedPhrases()
553553 *
554554 * @return void
555555 */
556- public function testMixedQuotedPhrases ()
556+ public function testMixedQuotedPhrases (): void
557557 {
558558 $ qb = new QueryBuilder (
559559 [
@@ -577,7 +577,7 @@ public function testMixedQuotedPhrases()
577577 *
578578 * @return void
579579 */
580- public function testMixedQuotedPhrasesWithEscapedQuote ()
580+ public function testMixedQuotedPhrasesWithEscapedQuote (): void
581581 {
582582 $ qb = new QueryBuilder (
583583 [
@@ -599,9 +599,9 @@ public function testMixedQuotedPhrasesWithEscapedQuote()
599599 /**
600600 * Data provider for testIndividualQueryHandlerWithGlobalExtraParams().
601601 *
602- * @return \ Iterator
602+ * @return Iterator
603603 */
604- public static function globalExtraParamsIndividualQueryDataProvider (): \ Iterator
604+ public static function globalExtraParamsIndividualQueryDataProvider (): Iterator
605605 {
606606 yield 'Single value, no extra params ' => [
607607 'globalExtraParams ' => null ,
@@ -773,18 +773,18 @@ public static function globalExtraParamsIndividualQueryDataProvider(): \Iterator
773773 /**
774774 * Test generation with GlobalExtraParams using individual queries.
775775 *
776- * @param array $globalExtraParams Global extra parameters
777- * @param array $expected1 First set of expected fields
778- * @param array $expected2 Second set of expected fields
776+ * @param ? array $globalExtraParams Global extra parameters
777+ * @param array $expected1 First set of expected fields
778+ * @param array $expected2 Second set of expected fields
779779 *
780780 * @return void
781781 */
782782 #[\PHPUnit \Framework \Attributes \DataProvider('globalExtraParamsIndividualQueryDataProvider ' )]
783783 public function testIndividualQueryHandlerWithGlobalExtraParams (
784- $ globalExtraParams ,
785- $ expected1 ,
786- $ expected2
787- ) {
784+ ? array $ globalExtraParams ,
785+ array $ expected1 ,
786+ array $ expected2
787+ ): void {
788788 $ q1 = new Query ('q ' , 'test ' );
789789 $ params1 = new ParamBag (['sort ' => 'score desc ' ]);
790790 $ q2 = new Query ('q ' , 'test2 ' );
@@ -826,9 +826,9 @@ public function testIndividualQueryHandlerWithGlobalExtraParams(
826826 /**
827827 * Data provider for testGroupedQueryHandlerWithGlobalExtraParams().
828828 *
829- * @return \ Iterator
829+ * @return Iterator
830830 */
831- public static function globalExtraParamsGroupedQueryDataProvider (): \ Iterator
831+ public static function globalExtraParamsGroupedQueryDataProvider (): Iterator
832832 {
833833 yield 'Search type in [test] ' => [
834834 'globalExtraParams ' => [
@@ -906,9 +906,9 @@ public static function globalExtraParamsGroupedQueryDataProvider(): \Iterator
906906 */
907907 #[\PHPUnit \Framework \Attributes \DataProvider('globalExtraParamsGroupedQueryDataProvider ' )]
908908 public function testGroupedQueryHandlerWithGlobalExtraParams (
909- $ globalExtraParams ,
910- $ expectedFields
911- ) {
909+ array $ globalExtraParams ,
910+ array $ expectedFields
911+ ): void {
912912 $ q1 = new Query ('q ' , 'test ' );
913913 $ q2 = new Query ('q ' , 'test2 ' );
914914 $ group = new QueryGroup ('AND ' , [$ q1 , $ q2 ]);
@@ -940,7 +940,7 @@ public function testGroupedQueryHandlerWithGlobalExtraParams(
940940 *
941941 * @return void
942942 */
943- public function testNegatedQuery ()
943+ public function testNegatedQuery (): void
944944 {
945945 $ group = new QueryGroup ('NOT ' , [new Query ('q ' )]);
946946 $ qb = new QueryBuilder ([]);
@@ -953,7 +953,7 @@ public function testNegatedQuery()
953953 *
954954 * @return void
955955 */
956- public function testNegatedAndQuery ()
956+ public function testNegatedAndQuery (): void
957957 {
958958 $ subgroup1 = new QueryGroup ('NOT ' , [new Query ('q1 ' ), new Query ('q2 ' )]);
959959 $ subgroup2 = new QueryGroup ('AND ' , [new Query ('q3 ' ), new Query ('q4 ' )]);
@@ -971,7 +971,7 @@ public function testNegatedAndQuery()
971971 *
972972 * @return void
973973 */
974- public function testNegatedOrQuery ()
974+ public function testNegatedOrQuery (): void
975975 {
976976 $ subgroup1 = new QueryGroup ('NOT ' , [new Query ('q1 ' ), new Query ('q2 ' )]);
977977 $ subgroup2 = new QueryGroup ('AND ' , [new Query ('q3 ' ), new Query ('q4 ' )]);
@@ -989,7 +989,7 @@ public function testNegatedOrQuery()
989989 *
990990 * @return void
991991 */
992- public function testDismaxMunge ()
992+ public function testDismaxMunge (): void
993993 {
994994 // Set up an array of expected inputs and outputs:
995995 $ tests = [
@@ -1021,7 +1021,12 @@ public function testDismaxMunge()
10211021 }
10221022 }
10231023
1024- public function testDismaxMungeQueryGroupOnlyOnce ()
1024+ /**
1025+ * Test that dismax munge is only applied once in query group.
1026+ *
1027+ * @return void
1028+ */
1029+ public function testDismaxMungeQueryGroupOnlyOnce (): void
10251030 {
10261031 $ specs = [
10271032 'test ' => [
@@ -1033,11 +1038,12 @@ public function testDismaxMungeQueryGroupOnlyOnce()
10331038 ];
10341039 $ qb = new QueryBuilder ($ specs );
10351040 $ query = new QueryGroup (
1036- 'AND ' , [ new Query ('some-coded-value ' , 'test ' ) ]
1041+ 'AND ' ,
1042+ [ new Query ('some-coded-value ' , 'test ' ) ]
10371043 );
10381044 $ response = $ qb ->build ($ query );
10391045 $ processedQ = $ response ->get ('q ' );
1040- $ this ->assertEquals ( 1 , preg_match ( '/\}22@some-coded-value"/ ' , $ processedQ [0 ]) );
1041- $ this ->assertEquals ( 0 , preg_match ( '/\}22@22@some-coded-value"/ ' , $ processedQ [0 ]) );
1046+ $ this ->assertMatchesRegularExpression ( '/\}22@some-coded-value"/ ' , $ processedQ [0 ]);
1047+ $ this ->assertDoesNotMatchRegularExpression ( '/\}22@22@some-coded-value"/ ' , $ processedQ [0 ]);
10421048 }
10431049}
0 commit comments