@@ -1734,10 +1734,6 @@ static function (&$data): void {
17341734 usort (
17351735 $ data ->searchHits ,
17361736 static function (SearchHit $ a , SearchHit $ b ): int {
1737- if (!is_array ($ a ->valueObject ) || !is_array ($ b ->valueObject )) {
1738- throw new \RuntimeException ('Expected simplified search hit value objects to be arrays. ' );
1739- }
1740-
17411737 return $ a ->valueObject ['id ' ] <=> $ b ->valueObject ['id ' ];
17421738 }
17431739 );
@@ -1933,10 +1929,6 @@ static function (&$data) {
19331929 usort (
19341930 $ data ->searchHits ,
19351931 static function ($ a , $ b ) use ($ map ) {
1936- if (!is_array ($ a ->valueObject ) || !is_array ($ b ->valueObject )) {
1937- throw new \RuntimeException ('Expected simplified search hit value objects to be arrays. ' );
1938- }
1939-
19401932 return ($ map [$ a ->valueObject ['id ' ]] < $ map [$ b ->valueObject ['id ' ]]) ? -1 : 1 ;
19411933 }
19421934 );
@@ -4772,28 +4764,23 @@ protected function assertQueryFixture(
47724764
47734765 $ fixture = require $ fixtureFilePath ;
47744766
4775- if (!$ fixture instanceof SearchResult) {
4776- self ::fail (sprintf (
4777- 'Fixture "%s" must return an instance of %s, %s given. ' ,
4778- $ fixtureFilePath ,
4779- SearchResult::class,
4780- is_object ($ fixture ) ? get_class ($ fixture ) : gettype ($ fixture )
4781- ));
4782- }
4783-
47844767 if ($ closure !== null ) {
47854768 $ closure ($ fixture );
47864769 $ closure ($ result );
47874770 }
47884771
47894772 if ($ ignoreScore ) {
47904773 foreach ([$ fixture , $ result ] as $ set ) {
4791- $ property = new \ReflectionProperty (get_class ($ set ), 'maxScore ' );
4774+ $ setClass = get_class ($ set );
4775+ self ::assertIsString ($ setClass );
4776+ $ property = new \ReflectionProperty ($ setClass , 'maxScore ' );
47924777 $ property ->setAccessible (true );
47934778 $ property ->setValue ($ set , 0.0 );
47944779
47954780 foreach ($ set ->searchHits as $ hit ) {
4796- $ property = new \ReflectionProperty (get_class ($ hit ), 'score ' );
4781+ $ hitClass = get_class ($ hit );
4782+ self ::assertIsString ($ hitClass );
4783+ $ property = new \ReflectionProperty ($ hitClass , 'score ' );
47974784 $ property ->setAccessible (true );
47984785 $ property ->setValue ($ hit , 0.0 );
47994786 }
@@ -4802,19 +4789,17 @@ protected function assertQueryFixture(
48024789
48034790 foreach ([$ fixture , $ result ] as $ set ) {
48044791 foreach ($ set ->searchHits as $ hit ) {
4805- $ property = new \ReflectionProperty (get_class ($ hit ), 'index ' );
4792+ $ hitClass = get_class ($ hit );
4793+ self ::assertIsString ($ hitClass );
4794+ $ property = new \ReflectionProperty ($ hitClass , 'index ' );
48064795 $ property ->setAccessible (true );
48074796 $ property ->setValue ($ hit , null );
48084797
4809- $ property = new \ReflectionProperty (get_class ( $ hit ) , 'matchedTranslation ' );
4798+ $ property = new \ReflectionProperty ($ hitClass , 'matchedTranslation ' );
48104799 $ property ->setAccessible (true );
48114800 $ property ->setValue ($ hit , null );
48124801
48134802 if (!$ id ) {
4814- if (!is_array ($ hit ->valueObject )) {
4815- throw new \RuntimeException ('Expected simplified search hit value objects to be arrays. ' );
4816- }
4817-
48184803 $ hit ->valueObject ['id ' ] = null ;
48194804 }
48204805 }
@@ -4839,10 +4824,6 @@ protected function printResult(SearchResult $result)
48394824 {
48404825 $ printed = '' ;
48414826 foreach ($ result ->searchHits as $ hit ) {
4842- if (!is_array ($ hit ->valueObject )) {
4843- throw new \RuntimeException ('Expected simplified search hit value objects to be arrays. ' );
4844- }
4845-
48464827 $ printed .= sprintf (" - %s (%s) \n" , $ hit ->valueObject ['title ' ], $ hit ->valueObject ['id ' ]);
48474828 }
48484829
0 commit comments