1515
1616use Behat \Behat \Context \Context ;
1717use Elastic \Elasticsearch \Client ;
18+ use Elasticsearch \Client as V7Client ;
1819use Symfony \Component \Finder \Finder ;
1920
2021/**
2425 */
2526final class ElasticsearchContext implements Context
2627{
27- public function __construct (private readonly Client $ client , private readonly string $ elasticsearchMappingsPath , private readonly string $ elasticsearchFixturesPath )
28- {
28+ public function __construct (
29+ private readonly V7Client |Client $ client , // @phpstan-ignore-line
30+ private readonly string $ elasticsearchMappingsPath ,
31+ private readonly string $ elasticsearchFixturesPath ,
32+ ) {
2933 }
3034
3135 /**
@@ -76,7 +80,7 @@ private function createIndexesAndMappings(): void
7680 $ finder ->files ()->in ($ this ->elasticsearchMappingsPath );
7781
7882 foreach ($ finder as $ file ) {
79- $ this ->client ->indices ()->create ([
83+ $ this ->client ->indices ()->create ([ // @phpstan-ignore-line
8084 'index ' => $ file ->getBasename ('.json ' ),
8185 'body ' => json_decode ($ file ->getContents (), true , 512 , \JSON_THROW_ON_ERROR ),
8286 ]);
@@ -95,7 +99,7 @@ private function deleteIndexes(): void
9599 }
96100
97101 if ([] !== $ indexes ) {
98- $ this ->client ->indices ()->delete ([
102+ $ this ->client ->indices ()->delete ([ // @phpstan-ignore-line
99103 'index ' => implode (', ' , $ indexes ),
100104 'ignore_unavailable ' => true ,
101105 ]);
@@ -107,7 +111,7 @@ private function loadFixtures(): void
107111 $ finder = new Finder ();
108112 $ finder ->files ()->in ($ this ->elasticsearchFixturesPath )->name ('*.json ' );
109113
110- $ indexClient = $ this ->client ->indices ();
114+ $ indexClient = $ this ->client ->indices (); // @phpstan-ignore-line
111115
112116 foreach ($ finder as $ file ) {
113117 $ index = $ file ->getBasename ('.json ' );
@@ -123,13 +127,13 @@ private function loadFixtures(): void
123127 $ bulk [] = $ document ;
124128
125129 if (0 === (\count ($ bulk ) % 50 )) {
126- $ this ->client ->bulk (['body ' => $ bulk ]);
130+ $ this ->client ->bulk (['body ' => $ bulk ]); // @phpstan-ignore-line
127131 $ bulk = [];
128132 }
129133 }
130134
131135 if ($ bulk ) {
132- $ this ->client ->bulk (['body ' => $ bulk ]);
136+ $ this ->client ->bulk (['body ' => $ bulk ]); // @phpstan-ignore-line
133137 }
134138
135139 $ indexClient ->refresh (['index ' => $ index ]);
0 commit comments