Completed
Push — master ( 6a3ea2...b97e84 )
by Maxence
13s
created
lib/Vendor/Elastic/Elasticsearch/Exception/MissingParameterException.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -15,6 +15,5 @@
 block discarded – undo
15 15
 namespace OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Elasticsearch\Exception;
16 16
 
17 17
 use Exception;
18
-class MissingParameterException extends Exception implements ElasticsearchException
19
-{
18
+class MissingParameterException extends Exception implements ElasticsearchException {
20 19
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
  * Elasticsearch B.V licenses this file to you under the MIT License.
12 12
  * See the LICENSE file in the project root for more information.
13 13
  */
14
-declare (strict_types=1);
14
+declare(strict_types=1);
15 15
 namespace OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Elasticsearch\Exception;
16 16
 
17 17
 use Exception;
Please login to merge, or discard this patch.
lib/Vendor/Elastic/Elasticsearch/Exception/HttpClientException.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -15,6 +15,5 @@
 block discarded – undo
15 15
 namespace OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Elasticsearch\Exception;
16 16
 
17 17
 use Exception;
18
-class HttpClientException extends Exception implements ElasticsearchException
19
-{
18
+class HttpClientException extends Exception implements ElasticsearchException {
20 19
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
  * Elasticsearch B.V licenses this file to you under the MIT License.
12 12
  * See the LICENSE file in the project root for more information.
13 13
  */
14
-declare (strict_types=1);
14
+declare(strict_types=1);
15 15
 namespace OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Elasticsearch\Exception;
16 16
 
17 17
 use Exception;
Please login to merge, or discard this patch.
lib/Vendor/Elastic/Elasticsearch/Exception/AuthenticationException.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -15,6 +15,5 @@
 block discarded – undo
15 15
 namespace OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Elasticsearch\Exception;
16 16
 
17 17
 use Exception;
18
-class AuthenticationException extends Exception implements ElasticsearchException
19
-{
18
+class AuthenticationException extends Exception implements ElasticsearchException {
20 19
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
  * Elasticsearch B.V licenses this file to you under the MIT License.
12 12
  * See the LICENSE file in the project root for more information.
13 13
  */
14
-declare (strict_types=1);
14
+declare(strict_types=1);
15 15
 namespace OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Elasticsearch\Exception;
16 16
 
17 17
 use Exception;
Please login to merge, or discard this patch.
lib/Vendor/Elastic/Elasticsearch/Exception/ProductCheckException.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
  * Elasticsearch B.V licenses this file to you under the MIT License.
12 12
  * See the LICENSE file in the project root for more information.
13 13
  */
14
-declare (strict_types=1);
14
+declare(strict_types=1);
15 15
 namespace OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Elasticsearch\Exception;
16 16
 
17 17
 use RuntimeException;
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -15,6 +15,5 @@
 block discarded – undo
15 15
 namespace OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Elasticsearch\Exception;
16 16
 
17 17
 use RuntimeException;
18
-class ProductCheckException extends RuntimeException implements ElasticsearchException
19
-{
18
+class ProductCheckException extends RuntimeException implements ElasticsearchException {
20 19
 }
Please login to merge, or discard this patch.
lib/Vendor/Elastic/Elasticsearch/Exception/ContentTypeException.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -15,6 +15,5 @@
 block discarded – undo
15 15
 namespace OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Elasticsearch\Exception;
16 16
 
17 17
 use Exception;
18
-class ContentTypeException extends Exception implements ElasticsearchException
19
-{
18
+class ContentTypeException extends Exception implements ElasticsearchException {
20 19
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
  * Elasticsearch B.V licenses this file to you under the MIT License.
12 12
  * See the LICENSE file in the project root for more information.
13 13
  */
14
-declare (strict_types=1);
14
+declare(strict_types=1);
15 15
 namespace OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Elasticsearch\Exception;
16 16
 
17 17
 use Exception;
Please login to merge, or discard this patch.
lib/Vendor/Elastic/Elasticsearch/Utility.php 3 patches
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -16,42 +16,42 @@
 block discarded – undo
16 16
 
17 17
 class Utility
18 18
 {
19
-    const ENV_URL_PLUS_AS_SPACE = 'ELASTIC_CLIENT_URL_PLUS_AS_SPACE';
20
-    /**
21
-     * Get the ENV variable with a thread safe fallback criteria
22
-     * @see https://github.com/elastic/elasticsearch-php/issues/1237
23
-     * 
24
-     * @return string | false
25
-     */
26
-    public static function getEnv(string $env)
27
-    {
28
-        return $_SERVER[$env] ?? $_ENV[$env] ?? \getenv($env);
29
-    }
30
-    /**
31
-     * Encode a string in URL using urlencode() or rawurlencode()
32
-     * according to ENV_URL_PLUS_AS_SPACE.
33
-     * If ENV_URL_PLUS_AS_SPACE is not defined or true use urlencode(),
34
-     * otherwise use rawurlencode()
35
-     * 
36
-     * @see https://github.com/elastic/elasticsearch-php/issues/1278
37
-     * @deprecated will be replaced by PHP function rawurlencode()
38
-     */
39
-    public static function urlencode(string $url) : string
40
-    {
41
-        $plusAsSpace = self::getEnv(self::ENV_URL_PLUS_AS_SPACE);
42
-        return $plusAsSpace === \false || $plusAsSpace === 'true' ? \urlencode($url) : \rawurlencode($url);
43
-    }
44
-    /**
45
-     * Remove all the characters not valid for a PHP variable name
46
-     * The valid characters are: a-z, A-Z, 0-9 and _ (underscore)
47
-     * The variable name CANNOT start with a number
48
-     */
49
-    public static function formatVariableName(string $var) : string
50
-    {
51
-        // If the first character is a digit, we append the underscore
52
-        if (\is_int($var[0])) {
53
-            $var = '_' . $var;
54
-        }
55
-        return \preg_replace('/[^a-zA-Z0-9_]/', '', $var);
56
-    }
19
+	const ENV_URL_PLUS_AS_SPACE = 'ELASTIC_CLIENT_URL_PLUS_AS_SPACE';
20
+	/**
21
+	 * Get the ENV variable with a thread safe fallback criteria
22
+	 * @see https://github.com/elastic/elasticsearch-php/issues/1237
23
+	 * 
24
+	 * @return string | false
25
+	 */
26
+	public static function getEnv(string $env)
27
+	{
28
+		return $_SERVER[$env] ?? $_ENV[$env] ?? \getenv($env);
29
+	}
30
+	/**
31
+	 * Encode a string in URL using urlencode() or rawurlencode()
32
+	 * according to ENV_URL_PLUS_AS_SPACE.
33
+	 * If ENV_URL_PLUS_AS_SPACE is not defined or true use urlencode(),
34
+	 * otherwise use rawurlencode()
35
+	 * 
36
+	 * @see https://github.com/elastic/elasticsearch-php/issues/1278
37
+	 * @deprecated will be replaced by PHP function rawurlencode()
38
+	 */
39
+	public static function urlencode(string $url) : string
40
+	{
41
+		$plusAsSpace = self::getEnv(self::ENV_URL_PLUS_AS_SPACE);
42
+		return $plusAsSpace === \false || $plusAsSpace === 'true' ? \urlencode($url) : \rawurlencode($url);
43
+	}
44
+	/**
45
+	 * Remove all the characters not valid for a PHP variable name
46
+	 * The valid characters are: a-z, A-Z, 0-9 and _ (underscore)
47
+	 * The variable name CANNOT start with a number
48
+	 */
49
+	public static function formatVariableName(string $var) : string
50
+	{
51
+		// If the first character is a digit, we append the underscore
52
+		if (\is_int($var[0])) {
53
+			$var = '_' . $var;
54
+		}
55
+		return \preg_replace('/[^a-zA-Z0-9_]/', '', $var);
56
+	}
57 57
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  * Elasticsearch B.V licenses this file to you under the MIT License.
12 12
  * See the LICENSE file in the project root for more information.
13 13
  */
14
-declare (strict_types=1);
14
+declare(strict_types=1);
15 15
 namespace OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Elasticsearch;
16 16
 
17 17
 class Utility
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
     {
51 51
         // If the first character is a digit, we append the underscore
52 52
         if (\is_int($var[0])) {
53
-            $var = '_' . $var;
53
+            $var = '_'.$var;
54 54
         }
55 55
         return \preg_replace('/[^a-zA-Z0-9_]/', '', $var);
56 56
     }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,8 +14,7 @@
 block discarded – undo
14 14
 declare (strict_types=1);
15 15
 namespace OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Elasticsearch;
16 16
 
17
-class Utility
18
-{
17
+class Utility {
19 18
     const ENV_URL_PLUS_AS_SPACE = 'ELASTIC_CLIENT_URL_PLUS_AS_SPACE';
20 19
     /**
21 20
      * Get the ENV variable with a thread safe fallback criteria
Please login to merge, or discard this patch.
lib/Vendor/Elastic/Elasticsearch/Helper/Iterators/SearchHitIterator.php 2 patches
Indentation   +126 added lines, -126 removed lines patch added patch discarded remove patch
@@ -20,130 +20,130 @@
 block discarded – undo
20 20
 use Iterator;
21 21
 class SearchHitIterator implements Iterator, Countable
22 22
 {
23
-    /**
24
-     * @var SearchResponseIterator
25
-     */
26
-    private SearchResponseIterator $searchResponses;
27
-    /**
28
-     * @var int
29
-     */
30
-    protected int $currentKey;
31
-    /**
32
-     * @var int
33
-     */
34
-    protected int $currentHitIndex;
35
-    /**
36
-     * @var array|null
37
-     */
38
-    protected ?array $currentHitData;
39
-    /**
40
-     * @var int
41
-     */
42
-    protected int $count = 0;
43
-    /**
44
-     * Constructor
45
-     *
46
-     * @param SearchResponseIterator $searchResponses
47
-     */
48
-    public function __construct(SearchResponseIterator $searchResponses)
49
-    {
50
-        $this->searchResponses = $searchResponses;
51
-    }
52
-    /**
53
-     * Rewinds the internal SearchResponseIterator and itself
54
-     *
55
-     * @return void
56
-     * @throws ClientResponseException
57
-     * @throws ServerResponseException
58
-     * @see    Iterator::rewind()
59
-     */
60
-    public function rewind() : void
61
-    {
62
-        $this->currentKey = 0;
63
-        $this->searchResponses->rewind();
64
-        // The first page may be empty. In that case, the next page is fetched.
65
-        $currentPage = $this->searchResponses->current();
66
-        if ($this->searchResponses->valid() && empty($currentPage['hits']['hits'])) {
67
-            $this->searchResponses->next();
68
-        }
69
-        $this->count = 0;
70
-        if (isset($currentPage['hits']['total']['value'], $currentPage['hits']['total'])) {
71
-            $this->count = $currentPage['hits']['total']['value'] ?? $currentPage['hits']['total'];
72
-        }
73
-        $this->readPageData();
74
-    }
75
-    /**
76
-     * Advances pointer of the current hit to the next one in the current page. If there
77
-     * isn't a next hit in the current page, then it advances the current page and moves the
78
-     * pointer to the first hit in the page.
79
-     *
80
-     * @return void
81
-     * @throws ClientResponseException
82
-     * @throws ServerResponseException
83
-     * @see    Iterator::next()
84
-     */
85
-    public function next() : void
86
-    {
87
-        $this->currentKey++;
88
-        $this->currentHitIndex++;
89
-        $currentPage = $this->searchResponses->current();
90
-        if (isset($currentPage['hits']['hits'][$this->currentHitIndex])) {
91
-            $this->currentHitData = $currentPage['hits']['hits'][$this->currentHitIndex];
92
-        } else {
93
-            $this->searchResponses->next();
94
-            $this->readPageData();
95
-        }
96
-    }
97
-    /**
98
-     * Returns a boolean indicating whether or not the current pointer has valid data
99
-     *
100
-     * @return bool
101
-     * @see    Iterator::valid()
102
-     */
103
-    public function valid() : bool
104
-    {
105
-        return \is_array($this->currentHitData);
106
-    }
107
-    /**
108
-     * Returns the current hit
109
-     *
110
-     * @return array
111
-     * @see    Iterator::current()
112
-     */
113
-    public function current() : array
114
-    {
115
-        return $this->currentHitData;
116
-    }
117
-    /**
118
-     * Returns the current hit index. The hit index spans all pages.
119
-     *
120
-     * @return int
121
-     * @see    Iterator::key()
122
-     */
123
-    public function key() : int
124
-    {
125
-        return $this->currentKey;
126
-    }
127
-    /**
128
-     * Advances the internal SearchResponseIterator and resets the currentHitIndex to 0
129
-     *
130
-     * @internal
131
-     */
132
-    private function readPageData() : void
133
-    {
134
-        if ($this->searchResponses->valid()) {
135
-            $currentPage = $this->searchResponses->current();
136
-            $this->currentHitIndex = 0;
137
-            $this->currentHitData = $currentPage['hits']['hits'][$this->currentHitIndex];
138
-        } else {
139
-            $this->currentHitData = null;
140
-        }
141
-    }
142
-    /**
143
-     * {@inheritDoc}
144
-     */
145
-    public function count() : int
146
-    {
147
-        return $this->count;
148
-    }
23
+	/**
24
+	 * @var SearchResponseIterator
25
+	 */
26
+	private SearchResponseIterator $searchResponses;
27
+	/**
28
+	 * @var int
29
+	 */
30
+	protected int $currentKey;
31
+	/**
32
+	 * @var int
33
+	 */
34
+	protected int $currentHitIndex;
35
+	/**
36
+	 * @var array|null
37
+	 */
38
+	protected ?array $currentHitData;
39
+	/**
40
+	 * @var int
41
+	 */
42
+	protected int $count = 0;
43
+	/**
44
+	 * Constructor
45
+	 *
46
+	 * @param SearchResponseIterator $searchResponses
47
+	 */
48
+	public function __construct(SearchResponseIterator $searchResponses)
49
+	{
50
+		$this->searchResponses = $searchResponses;
51
+	}
52
+	/**
53
+	 * Rewinds the internal SearchResponseIterator and itself
54
+	 *
55
+	 * @return void
56
+	 * @throws ClientResponseException
57
+	 * @throws ServerResponseException
58
+	 * @see    Iterator::rewind()
59
+	 */
60
+	public function rewind() : void
61
+	{
62
+		$this->currentKey = 0;
63
+		$this->searchResponses->rewind();
64
+		// The first page may be empty. In that case, the next page is fetched.
65
+		$currentPage = $this->searchResponses->current();
66
+		if ($this->searchResponses->valid() && empty($currentPage['hits']['hits'])) {
67
+			$this->searchResponses->next();
68
+		}
69
+		$this->count = 0;
70
+		if (isset($currentPage['hits']['total']['value'], $currentPage['hits']['total'])) {
71
+			$this->count = $currentPage['hits']['total']['value'] ?? $currentPage['hits']['total'];
72
+		}
73
+		$this->readPageData();
74
+	}
75
+	/**
76
+	 * Advances pointer of the current hit to the next one in the current page. If there
77
+	 * isn't a next hit in the current page, then it advances the current page and moves the
78
+	 * pointer to the first hit in the page.
79
+	 *
80
+	 * @return void
81
+	 * @throws ClientResponseException
82
+	 * @throws ServerResponseException
83
+	 * @see    Iterator::next()
84
+	 */
85
+	public function next() : void
86
+	{
87
+		$this->currentKey++;
88
+		$this->currentHitIndex++;
89
+		$currentPage = $this->searchResponses->current();
90
+		if (isset($currentPage['hits']['hits'][$this->currentHitIndex])) {
91
+			$this->currentHitData = $currentPage['hits']['hits'][$this->currentHitIndex];
92
+		} else {
93
+			$this->searchResponses->next();
94
+			$this->readPageData();
95
+		}
96
+	}
97
+	/**
98
+	 * Returns a boolean indicating whether or not the current pointer has valid data
99
+	 *
100
+	 * @return bool
101
+	 * @see    Iterator::valid()
102
+	 */
103
+	public function valid() : bool
104
+	{
105
+		return \is_array($this->currentHitData);
106
+	}
107
+	/**
108
+	 * Returns the current hit
109
+	 *
110
+	 * @return array
111
+	 * @see    Iterator::current()
112
+	 */
113
+	public function current() : array
114
+	{
115
+		return $this->currentHitData;
116
+	}
117
+	/**
118
+	 * Returns the current hit index. The hit index spans all pages.
119
+	 *
120
+	 * @return int
121
+	 * @see    Iterator::key()
122
+	 */
123
+	public function key() : int
124
+	{
125
+		return $this->currentKey;
126
+	}
127
+	/**
128
+	 * Advances the internal SearchResponseIterator and resets the currentHitIndex to 0
129
+	 *
130
+	 * @internal
131
+	 */
132
+	private function readPageData() : void
133
+	{
134
+		if ($this->searchResponses->valid()) {
135
+			$currentPage = $this->searchResponses->current();
136
+			$this->currentHitIndex = 0;
137
+			$this->currentHitData = $currentPage['hits']['hits'][$this->currentHitIndex];
138
+		} else {
139
+			$this->currentHitData = null;
140
+		}
141
+	}
142
+	/**
143
+	 * {@inheritDoc}
144
+	 */
145
+	public function count() : int
146
+	{
147
+		return $this->count;
148
+	}
149 149
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
  * Elasticsearch B.V licenses this file to you under the MIT License.
12 12
  * See the LICENSE file in the project root for more information.
13 13
  */
14
-declare (strict_types=1);
14
+declare(strict_types=1);
15 15
 namespace OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Elasticsearch\Helper\Iterators;
16 16
 
17 17
 use Countable;
Please login to merge, or discard this patch.
Vendor/Elastic/Elasticsearch/Helper/Iterators/SearchResponseIterator.php 3 patches
Indentation   +136 added lines, -136 removed lines patch added patch discarded remove patch
@@ -20,140 +20,140 @@
 block discarded – undo
20 20
 use Iterator;
21 21
 class SearchResponseIterator implements Iterator
22 22
 {
23
-    /**
24
-     * @var ClientInterface
25
-     */
26
-    private ClientInterface $client;
27
-    /**
28
-     * @var array
29
-     */
30
-    private array $params;
31
-    /**
32
-     * @var int
33
-     */
34
-    private int $currentKey = 0;
35
-    /**
36
-     * @var array
37
-     */
38
-    private array $currentScrolledResponse;
39
-    /**
40
-     * @var string|null
41
-     */
42
-    private ?string $scrollId;
43
-    /**
44
-     * @var string duration
45
-     */
46
-    private $scrollTtl;
47
-    /**
48
-     * Constructor
49
-     *
50
-     * @param ClientInterface $client
51
-     * @param array  $searchParams Associative array of parameters
52
-     * @see   ClientInterface::search()
53
-     */
54
-    public function __construct(ClientInterface $client, array $searchParams)
55
-    {
56
-        $this->client = $client;
57
-        $this->params = $searchParams;
58
-        if (isset($searchParams['scroll'])) {
59
-            $this->scrollTtl = $searchParams['scroll'];
60
-        }
61
-    }
62
-    /**
63
-     * Destructor
64
-     *
65
-     * @throws ClientResponseException
66
-     * @throws ServerResponseException
67
-     */
68
-    public function __destruct()
69
-    {
70
-        $this->clearScroll();
71
-    }
72
-    /**
73
-     * Sets the time to live duration of a scroll window
74
-     *
75
-     * @param  string $timeToLive
76
-     * @return $this
77
-     */
78
-    public function setScrollTimeout(string $timeToLive) : SearchResponseIterator
79
-    {
80
-        $this->scrollTtl = $timeToLive;
81
-        return $this;
82
-    }
83
-    /**
84
-     * Clears the current scroll window if there is a scroll_id stored
85
-     *
86
-     * @return void
87
-     * @throws ClientResponseException
88
-     * @throws ServerResponseException
89
-     */
90
-    private function clearScroll() : void
91
-    {
92
-        if (!empty($this->scrollId)) {
93
-            /* @phpstan-ignore-next-line */
94
-            $this->client->clearScroll(['body' => ['scroll_id' => $this->scrollId], 'client' => ['ignore' => 404]]);
95
-            $this->scrollId = null;
96
-        }
97
-    }
98
-    /**
99
-     * Rewinds the iterator by performing the initial search.
100
-     *
101
-     * @return void
102
-     * @throws ClientResponseException
103
-     * @throws ServerResponseException
104
-     * @see    Iterator::rewind()
105
-     */
106
-    public function rewind() : void
107
-    {
108
-        $this->clearScroll();
109
-        $this->currentKey = 0;
110
-        /* @phpstan-ignore-next-line */
111
-        $this->currentScrolledResponse = $this->client->search($this->params)->asArray();
112
-        $this->scrollId = $this->currentScrolledResponse['_scroll_id'];
113
-    }
114
-    /**
115
-     * Fetches every "page" after the first one using the lastest "scroll_id"
116
-     *
117
-     * @return void
118
-     * @throws ClientResponseException
119
-     * @throws ServerResponseException
120
-     * @see    Iterator::next()
121
-     */
122
-    public function next() : void
123
-    {
124
-        /* @phpstan-ignore-next-line */
125
-        $this->currentScrolledResponse = $this->client->scroll(['body' => ['scroll_id' => $this->scrollId, 'scroll' => $this->scrollTtl]])->asArray();
126
-        $this->scrollId = $this->currentScrolledResponse['_scroll_id'];
127
-        $this->currentKey++;
128
-    }
129
-    /**
130
-     * Returns a boolean value indicating if the current page is valid or not
131
-     *
132
-     * @return bool
133
-     * @see    Iterator::valid()
134
-     */
135
-    public function valid() : bool
136
-    {
137
-        return isset($this->currentScrolledResponse['hits']['hits'][0]);
138
-    }
139
-    /**
140
-     * Returns the current "page"
141
-     *
142
-     * @return array
143
-     * @see    Iterator::current()
144
-     */
145
-    public function current() : array
146
-    {
147
-        return $this->currentScrolledResponse;
148
-    }
149
-    /**
150
-     * Returns the current "page number" of the current "page"
151
-     *
152
-     * @return int
153
-     * @see    Iterator::key()
154
-     */
155
-    public function key() : int
156
-    {
157
-        return $this->currentKey;
158
-    }
23
+	/**
24
+	 * @var ClientInterface
25
+	 */
26
+	private ClientInterface $client;
27
+	/**
28
+	 * @var array
29
+	 */
30
+	private array $params;
31
+	/**
32
+	 * @var int
33
+	 */
34
+	private int $currentKey = 0;
35
+	/**
36
+	 * @var array
37
+	 */
38
+	private array $currentScrolledResponse;
39
+	/**
40
+	 * @var string|null
41
+	 */
42
+	private ?string $scrollId;
43
+	/**
44
+	 * @var string duration
45
+	 */
46
+	private $scrollTtl;
47
+	/**
48
+	 * Constructor
49
+	 *
50
+	 * @param ClientInterface $client
51
+	 * @param array  $searchParams Associative array of parameters
52
+	 * @see   ClientInterface::search()
53
+	 */
54
+	public function __construct(ClientInterface $client, array $searchParams)
55
+	{
56
+		$this->client = $client;
57
+		$this->params = $searchParams;
58
+		if (isset($searchParams['scroll'])) {
59
+			$this->scrollTtl = $searchParams['scroll'];
60
+		}
61
+	}
62
+	/**
63
+	 * Destructor
64
+	 *
65
+	 * @throws ClientResponseException
66
+	 * @throws ServerResponseException
67
+	 */
68
+	public function __destruct()
69
+	{
70
+		$this->clearScroll();
71
+	}
72
+	/**
73
+	 * Sets the time to live duration of a scroll window
74
+	 *
75
+	 * @param  string $timeToLive
76
+	 * @return $this
77
+	 */
78
+	public function setScrollTimeout(string $timeToLive) : SearchResponseIterator
79
+	{
80
+		$this->scrollTtl = $timeToLive;
81
+		return $this;
82
+	}
83
+	/**
84
+	 * Clears the current scroll window if there is a scroll_id stored
85
+	 *
86
+	 * @return void
87
+	 * @throws ClientResponseException
88
+	 * @throws ServerResponseException
89
+	 */
90
+	private function clearScroll() : void
91
+	{
92
+		if (!empty($this->scrollId)) {
93
+			/* @phpstan-ignore-next-line */
94
+			$this->client->clearScroll(['body' => ['scroll_id' => $this->scrollId], 'client' => ['ignore' => 404]]);
95
+			$this->scrollId = null;
96
+		}
97
+	}
98
+	/**
99
+	 * Rewinds the iterator by performing the initial search.
100
+	 *
101
+	 * @return void
102
+	 * @throws ClientResponseException
103
+	 * @throws ServerResponseException
104
+	 * @see    Iterator::rewind()
105
+	 */
106
+	public function rewind() : void
107
+	{
108
+		$this->clearScroll();
109
+		$this->currentKey = 0;
110
+		/* @phpstan-ignore-next-line */
111
+		$this->currentScrolledResponse = $this->client->search($this->params)->asArray();
112
+		$this->scrollId = $this->currentScrolledResponse['_scroll_id'];
113
+	}
114
+	/**
115
+	 * Fetches every "page" after the first one using the lastest "scroll_id"
116
+	 *
117
+	 * @return void
118
+	 * @throws ClientResponseException
119
+	 * @throws ServerResponseException
120
+	 * @see    Iterator::next()
121
+	 */
122
+	public function next() : void
123
+	{
124
+		/* @phpstan-ignore-next-line */
125
+		$this->currentScrolledResponse = $this->client->scroll(['body' => ['scroll_id' => $this->scrollId, 'scroll' => $this->scrollTtl]])->asArray();
126
+		$this->scrollId = $this->currentScrolledResponse['_scroll_id'];
127
+		$this->currentKey++;
128
+	}
129
+	/**
130
+	 * Returns a boolean value indicating if the current page is valid or not
131
+	 *
132
+	 * @return bool
133
+	 * @see    Iterator::valid()
134
+	 */
135
+	public function valid() : bool
136
+	{
137
+		return isset($this->currentScrolledResponse['hits']['hits'][0]);
138
+	}
139
+	/**
140
+	 * Returns the current "page"
141
+	 *
142
+	 * @return array
143
+	 * @see    Iterator::current()
144
+	 */
145
+	public function current() : array
146
+	{
147
+		return $this->currentScrolledResponse;
148
+	}
149
+	/**
150
+	 * Returns the current "page number" of the current "page"
151
+	 *
152
+	 * @return int
153
+	 * @see    Iterator::key()
154
+	 */
155
+	public function key() : int
156
+	{
157
+		return $this->currentKey;
158
+	}
159 159
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
  * Elasticsearch B.V licenses this file to you under the MIT License.
12 12
  * See the LICENSE file in the project root for more information.
13 13
  */
14
-declare (strict_types=1);
14
+declare(strict_types=1);
15 15
 namespace OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Elasticsearch\Helper\Iterators;
16 16
 
17 17
 use OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Elasticsearch\ClientInterface;
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,8 +18,7 @@
 block discarded – undo
18 18
 use OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Elasticsearch\Exception\ClientResponseException;
19 19
 use OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Elasticsearch\Exception\ServerResponseException;
20 20
 use Iterator;
21
-class SearchResponseIterator implements Iterator
22
-{
21
+class SearchResponseIterator implements Iterator {
23 22
     /**
24 23
      * @var ClientInterface
25 24
      */
Please login to merge, or discard this patch.
lib/Vendor/Elastic/Elasticsearch/Endpoints/Shutdown.php 3 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  * Elasticsearch B.V licenses this file to you under the MIT License.
12 12
  * See the LICENSE file in the project root for more information.
13 13
  */
14
-declare (strict_types=1);
14
+declare(strict_types=1);
15 15
 namespace OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Elasticsearch\Endpoints;
16 16
 
17 17
 use OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Elasticsearch\Exception\ClientResponseException;
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
     public function deleteNode(array $params = [])
50 50
     {
51 51
         $this->checkRequiredParameters(['node_id'], $params);
52
-        $url = '/_nodes/' . $this->encode($params['node_id']) . '/shutdown';
52
+        $url = '/_nodes/'.$this->encode($params['node_id']).'/shutdown';
53 53
         $method = 'DELETE';
54 54
         $url = $this->addQueryString($url, $params, ['pretty', 'human', 'error_trace', 'source', 'filter_path']);
55 55
         $headers = ['Accept' => 'application/json', 'Content-Type' => 'application/json'];
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
     public function getNode(array $params = [])
79 79
     {
80 80
         if (isset($params['node_id'])) {
81
-            $url = '/_nodes/' . $this->encode($params['node_id']) . '/shutdown';
81
+            $url = '/_nodes/'.$this->encode($params['node_id']).'/shutdown';
82 82
             $method = 'GET';
83 83
         } else {
84 84
             $url = '/_nodes/shutdown';
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
     public function putNode(array $params = [])
114 114
     {
115 115
         $this->checkRequiredParameters(['node_id', 'body'], $params);
116
-        $url = '/_nodes/' . $this->encode($params['node_id']) . '/shutdown';
116
+        $url = '/_nodes/'.$this->encode($params['node_id']).'/shutdown';
117 117
         $method = 'PUT';
118 118
         $url = $this->addQueryString($url, $params, ['pretty', 'human', 'error_trace', 'source', 'filter_path']);
119 119
         $headers = ['Accept' => 'application/json', 'Content-Type' => 'application/json'];
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,8 +23,7 @@
 block discarded – undo
23 23
 /**
24 24
  * @generated This file is generated, please do not edit
25 25
  */
26
-class Shutdown extends AbstractEndpoint
27
-{
26
+class Shutdown extends AbstractEndpoint {
28 27
     /**
29 28
      * Removes a node from the shutdown list. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported.
30 29
      *
Please login to merge, or discard this patch.
Indentation   +101 added lines, -101 removed lines patch added patch discarded remove patch
@@ -25,105 +25,105 @@
 block discarded – undo
25 25
  */
26 26
 class Shutdown extends AbstractEndpoint
27 27
 {
28
-    /**
29
-     * Removes a node from the shutdown list. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported.
30
-     *
31
-     * @see https://www.elastic.co/guide/en/elasticsearch/reference/current
32
-     *
33
-     * @param array{
34
-     *     node_id: string, // (REQUIRED) The node id of node to be removed from the shutdown state
35
-     *     pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
36
-     *     human: boolean, // Return human readable values for statistics. (DEFAULT: true)
37
-     *     error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
38
-     *     source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
39
-     *     filter_path: list, // A comma-separated list of filters used to reduce the response.
40
-     * } $params
41
-     *
42
-     * @throws MissingParameterException if a required parameter is missing
43
-     * @throws NoNodeAvailableException if all the hosts are offline
44
-     * @throws ClientResponseException if the status code of response is 4xx
45
-     * @throws ServerResponseException if the status code of response is 5xx
46
-     *
47
-     * @return Elasticsearch|Promise
48
-     */
49
-    public function deleteNode(array $params = [])
50
-    {
51
-        $this->checkRequiredParameters(['node_id'], $params);
52
-        $url = '/_nodes/' . $this->encode($params['node_id']) . '/shutdown';
53
-        $method = 'DELETE';
54
-        $url = $this->addQueryString($url, $params, ['pretty', 'human', 'error_trace', 'source', 'filter_path']);
55
-        $headers = ['Accept' => 'application/json', 'Content-Type' => 'application/json'];
56
-        $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null);
57
-        $request = $this->addOtelAttributes($params, ['node_id'], $request, 'shutdown.delete_node');
58
-        return $this->client->sendRequest($request);
59
-    }
60
-    /**
61
-     * Retrieve status of a node or nodes that are currently marked as shutting down. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported.
62
-     *
63
-     * @see https://www.elastic.co/guide/en/elasticsearch/reference/current
64
-     *
65
-     * @param array{
66
-     *     node_id: string, //  Which node for which to retrieve the shutdown status
67
-     *     master_timeout: time, // Timeout for processing on master node
68
-     *     pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
69
-     *     human: boolean, // Return human readable values for statistics. (DEFAULT: true)
70
-     *     error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
71
-     *     source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
72
-     *     filter_path: list, // A comma-separated list of filters used to reduce the response.
73
-     * } $params
74
-     *
75
-     * @throws NoNodeAvailableException if all the hosts are offline
76
-     * @throws ClientResponseException if the status code of response is 4xx
77
-     * @throws ServerResponseException if the status code of response is 5xx
78
-     *
79
-     * @return Elasticsearch|Promise
80
-     */
81
-    public function getNode(array $params = [])
82
-    {
83
-        if (isset($params['node_id'])) {
84
-            $url = '/_nodes/' . $this->encode($params['node_id']) . '/shutdown';
85
-            $method = 'GET';
86
-        } else {
87
-            $url = '/_nodes/shutdown';
88
-            $method = 'GET';
89
-        }
90
-        $url = $this->addQueryString($url, $params, ['master_timeout', 'pretty', 'human', 'error_trace', 'source', 'filter_path']);
91
-        $headers = ['Accept' => 'application/json', 'Content-Type' => 'application/json'];
92
-        $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null);
93
-        $request = $this->addOtelAttributes($params, ['node_id'], $request, 'shutdown.get_node');
94
-        return $this->client->sendRequest($request);
95
-    }
96
-    /**
97
-     * Adds a node to be shut down. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported.
98
-     *
99
-     * @see https://www.elastic.co/guide/en/elasticsearch/reference/current
100
-     *
101
-     * @param array{
102
-     *     node_id: string, // (REQUIRED) The node id of node to be shut down
103
-     *     pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
104
-     *     human: boolean, // Return human readable values for statistics. (DEFAULT: true)
105
-     *     error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
106
-     *     source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
107
-     *     filter_path: list, // A comma-separated list of filters used to reduce the response.
108
-     *     body: array, // (REQUIRED) The shutdown type definition to register
109
-     * } $params
110
-     *
111
-     * @throws MissingParameterException if a required parameter is missing
112
-     * @throws NoNodeAvailableException if all the hosts are offline
113
-     * @throws ClientResponseException if the status code of response is 4xx
114
-     * @throws ServerResponseException if the status code of response is 5xx
115
-     *
116
-     * @return Elasticsearch|Promise
117
-     */
118
-    public function putNode(array $params = [])
119
-    {
120
-        $this->checkRequiredParameters(['node_id', 'body'], $params);
121
-        $url = '/_nodes/' . $this->encode($params['node_id']) . '/shutdown';
122
-        $method = 'PUT';
123
-        $url = $this->addQueryString($url, $params, ['pretty', 'human', 'error_trace', 'source', 'filter_path']);
124
-        $headers = ['Accept' => 'application/json', 'Content-Type' => 'application/json'];
125
-        $request = $this->createRequest($method, $url, $headers, $params['body'] ?? null);
126
-        $request = $this->addOtelAttributes($params, ['node_id'], $request, 'shutdown.put_node');
127
-        return $this->client->sendRequest($request);
128
-    }
28
+	/**
29
+	 * Removes a node from the shutdown list. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported.
30
+	 *
31
+	 * @see https://www.elastic.co/guide/en/elasticsearch/reference/current
32
+	 *
33
+	 * @param array{
34
+	 *     node_id: string, // (REQUIRED) The node id of node to be removed from the shutdown state
35
+	 *     pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
36
+	 *     human: boolean, // Return human readable values for statistics. (DEFAULT: true)
37
+	 *     error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
38
+	 *     source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
39
+	 *     filter_path: list, // A comma-separated list of filters used to reduce the response.
40
+	 * } $params
41
+	 *
42
+	 * @throws MissingParameterException if a required parameter is missing
43
+	 * @throws NoNodeAvailableException if all the hosts are offline
44
+	 * @throws ClientResponseException if the status code of response is 4xx
45
+	 * @throws ServerResponseException if the status code of response is 5xx
46
+	 *
47
+	 * @return Elasticsearch|Promise
48
+	 */
49
+	public function deleteNode(array $params = [])
50
+	{
51
+		$this->checkRequiredParameters(['node_id'], $params);
52
+		$url = '/_nodes/' . $this->encode($params['node_id']) . '/shutdown';
53
+		$method = 'DELETE';
54
+		$url = $this->addQueryString($url, $params, ['pretty', 'human', 'error_trace', 'source', 'filter_path']);
55
+		$headers = ['Accept' => 'application/json', 'Content-Type' => 'application/json'];
56
+		$request = $this->createRequest($method, $url, $headers, $params['body'] ?? null);
57
+		$request = $this->addOtelAttributes($params, ['node_id'], $request, 'shutdown.delete_node');
58
+		return $this->client->sendRequest($request);
59
+	}
60
+	/**
61
+	 * Retrieve status of a node or nodes that are currently marked as shutting down. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported.
62
+	 *
63
+	 * @see https://www.elastic.co/guide/en/elasticsearch/reference/current
64
+	 *
65
+	 * @param array{
66
+	 *     node_id: string, //  Which node for which to retrieve the shutdown status
67
+	 *     master_timeout: time, // Timeout for processing on master node
68
+	 *     pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
69
+	 *     human: boolean, // Return human readable values for statistics. (DEFAULT: true)
70
+	 *     error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
71
+	 *     source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
72
+	 *     filter_path: list, // A comma-separated list of filters used to reduce the response.
73
+	 * } $params
74
+	 *
75
+	 * @throws NoNodeAvailableException if all the hosts are offline
76
+	 * @throws ClientResponseException if the status code of response is 4xx
77
+	 * @throws ServerResponseException if the status code of response is 5xx
78
+	 *
79
+	 * @return Elasticsearch|Promise
80
+	 */
81
+	public function getNode(array $params = [])
82
+	{
83
+		if (isset($params['node_id'])) {
84
+			$url = '/_nodes/' . $this->encode($params['node_id']) . '/shutdown';
85
+			$method = 'GET';
86
+		} else {
87
+			$url = '/_nodes/shutdown';
88
+			$method = 'GET';
89
+		}
90
+		$url = $this->addQueryString($url, $params, ['master_timeout', 'pretty', 'human', 'error_trace', 'source', 'filter_path']);
91
+		$headers = ['Accept' => 'application/json', 'Content-Type' => 'application/json'];
92
+		$request = $this->createRequest($method, $url, $headers, $params['body'] ?? null);
93
+		$request = $this->addOtelAttributes($params, ['node_id'], $request, 'shutdown.get_node');
94
+		return $this->client->sendRequest($request);
95
+	}
96
+	/**
97
+	 * Adds a node to be shut down. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported.
98
+	 *
99
+	 * @see https://www.elastic.co/guide/en/elasticsearch/reference/current
100
+	 *
101
+	 * @param array{
102
+	 *     node_id: string, // (REQUIRED) The node id of node to be shut down
103
+	 *     pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
104
+	 *     human: boolean, // Return human readable values for statistics. (DEFAULT: true)
105
+	 *     error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
106
+	 *     source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
107
+	 *     filter_path: list, // A comma-separated list of filters used to reduce the response.
108
+	 *     body: array, // (REQUIRED) The shutdown type definition to register
109
+	 * } $params
110
+	 *
111
+	 * @throws MissingParameterException if a required parameter is missing
112
+	 * @throws NoNodeAvailableException if all the hosts are offline
113
+	 * @throws ClientResponseException if the status code of response is 4xx
114
+	 * @throws ServerResponseException if the status code of response is 5xx
115
+	 *
116
+	 * @return Elasticsearch|Promise
117
+	 */
118
+	public function putNode(array $params = [])
119
+	{
120
+		$this->checkRequiredParameters(['node_id', 'body'], $params);
121
+		$url = '/_nodes/' . $this->encode($params['node_id']) . '/shutdown';
122
+		$method = 'PUT';
123
+		$url = $this->addQueryString($url, $params, ['pretty', 'human', 'error_trace', 'source', 'filter_path']);
124
+		$headers = ['Accept' => 'application/json', 'Content-Type' => 'application/json'];
125
+		$request = $this->createRequest($method, $url, $headers, $params['body'] ?? null);
126
+		$request = $this->addOtelAttributes($params, ['node_id'], $request, 'shutdown.put_node');
127
+		return $this->client->sendRequest($request);
128
+	}
129 129
 }
Please login to merge, or discard this patch.