@@ -21,5 +21,5 @@ |
||
21 | 21 | */ |
22 | 22 | class ServerResponseException extends Exception implements ElasticsearchException |
23 | 23 | { |
24 | - use ResponseTrait; |
|
24 | + use ResponseTrait; |
|
25 | 25 | } |
@@ -19,7 +19,6 @@ |
||
19 | 19 | /** |
20 | 20 | * HTTP server error with 5xx status code |
21 | 21 | */ |
22 | -class ServerResponseException extends Exception implements ElasticsearchException |
|
23 | -{ |
|
22 | +class ServerResponseException extends Exception implements ElasticsearchException { |
|
24 | 23 | use ResponseTrait; |
25 | 24 | } |
@@ -11,7 +11,7 @@ |
||
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 OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Elasticsearch\Traits\ResponseTrait; |
@@ -15,6 +15,5 @@ |
||
15 | 15 | namespace OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Elasticsearch\Exception; |
16 | 16 | |
17 | 17 | use Exception; |
18 | -class ArrayAccessException extends Exception implements ElasticsearchException |
|
19 | -{ |
|
18 | +class ArrayAccessException extends Exception implements ElasticsearchException { |
|
20 | 19 | } |
@@ -11,7 +11,7 @@ |
||
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; |
@@ -15,6 +15,5 @@ |
||
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 | } |
@@ -11,7 +11,7 @@ |
||
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; |
@@ -15,6 +15,5 @@ |
||
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 | } |
@@ -11,7 +11,7 @@ |
||
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; |
@@ -15,6 +15,5 @@ |
||
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 | } |
@@ -11,7 +11,7 @@ |
||
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; |
@@ -11,7 +11,7 @@ |
||
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; |
@@ -15,6 +15,5 @@ |
||
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 | } |
@@ -15,6 +15,5 @@ |
||
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 | } |
@@ -11,7 +11,7 @@ |
||
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; |
@@ -16,42 +16,42 @@ |
||
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 | } |
@@ -11,7 +11,7 @@ discard block |
||
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 |
||
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 | } |
@@ -14,8 +14,7 @@ |
||
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 |
@@ -20,130 +20,130 @@ |
||
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 | } |
@@ -11,7 +11,7 @@ |
||
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; |