Skip to content
This repository
Browse code

php-cs-fixer fix --level=all

  • Loading branch information...
commit 1fba1264cf6215c9a95722955a769778051b0496 1 parent 0abadf3
Sébastien Lavoie lavoiesl authored

Showing 147 changed files with 631 additions and 617 deletions. Show diff stats Hide diff stats

  1. +1 1  build.xml
  2. +33 31 lib/Elastica/Client.php
  3. +5 1 lib/Elastica/Cluster.php
  4. +15 11 lib/Elastica/Cluster/Settings.php
  5. +30 17 lib/Elastica/Document.php
  6. +3 3 lib/Elastica/Exception/BulkResponse.php
  7. +3 3 lib/Elastica/Exception/Client.php
  8. +9 7 lib/Elastica/Facet/Abstract.php
  9. +3 2 lib/Elastica/Facet/DateHistogram.php
  10. +1 1  lib/Elastica/Facet/Filter.php
  11. +5 4 lib/Elastica/Facet/GeoDistance.php
  12. +8 8 lib/Elastica/Facet/Histogram.php
  13. +1 1  lib/Elastica/Facet/Query.php
  14. +10 8 lib/Elastica/Facet/Range.php
  15. +4 3 lib/Elastica/Facet/Statistical.php
  16. +8 6 lib/Elastica/Facet/Terms.php
  17. +6 6 lib/Elastica/Filter/Abstract.php
  18. +4 4 lib/Elastica/Filter/Abstract/Multi.php
  19. +14 11 lib/Elastica/Filter/Bool.php
  20. +1 1  lib/Elastica/Filter/Exists.php
  21. +5 5 lib/Elastica/Filter/GeoBoundingBox.php
  22. +10 8 lib/Elastica/Filter/GeoDistance.php
  23. +2 2 lib/Elastica/Filter/GeoPolygon.php
  24. +5 4 lib/Elastica/Filter/HasChild.php
  25. +6 6 lib/Elastica/Filter/Ids.php
  26. +3 3 lib/Elastica/Filter/Limit.php
  27. +0 2  lib/Elastica/Filter/Missing.php
  28. +3 3 lib/Elastica/Filter/Nested.php
  29. +1 1  lib/Elastica/Filter/Not.php
  30. +4 1 lib/Elastica/Filter/Prefix.php
  31. +5 5 lib/Elastica/Filter/Query.php
  32. +6 4 lib/Elastica/Filter/Range.php
  33. +2 2 lib/Elastica/Filter/Script.php
  34. +3 3 lib/Elastica/Filter/Term.php
  35. +8 5 lib/Elastica/Filter/Terms.php
  36. +3 2 lib/Elastica/Filter/Type.php
  37. +24 19 lib/Elastica/Index.php
  38. +22 15 lib/Elastica/Index/Settings.php
  39. +2 0  lib/Elastica/Index/Status.php
  40. +5 4 lib/Elastica/Log.php
  41. +3 2 lib/Elastica/Node.php
  42. +3 3 lib/Elastica/Node/Info.php
  43. +13 10 lib/Elastica/Param.php
  44. +7 5 lib/Elastica/Percolator.php
  45. +2 1  lib/Elastica/Query/Array.php
  46. +11 11 lib/Elastica/Query/Bool.php
  47. +1 1  lib/Elastica/Query/Builder.php
  48. +5 5 lib/Elastica/Query/ConstantScore.php
  49. +8 5 lib/Elastica/Query/CustomFiltersScore.php
  50. +5 4 lib/Elastica/Query/CustomScore.php
  51. +6 3 lib/Elastica/Query/Field.php
  52. +6 4 lib/Elastica/Query/Filtered.php
  53. +2 2 lib/Elastica/Query/Fuzzy.php
  54. +12 7 lib/Elastica/Query/FuzzyLikeThis.php
  55. +4 3 lib/Elastica/Query/HasChild.php
  56. +10 7 lib/Elastica/Query/Ids.php
  57. +15 16 lib/Elastica/Query/MoreLikeThis.php
  58. +3 3 lib/Elastica/Query/Nested.php
  59. +19 19 lib/Elastica/Query/QueryString.php
  60. +2 2 lib/Elastica/Query/Range.php
  61. +4 4 lib/Elastica/Query/Term.php
  62. +8 5 lib/Elastica/Query/Terms.php
  63. +12 11 lib/Elastica/Query/Text.php
  64. +4 3 lib/Elastica/Query/TopChildren.php
  65. +3 3 lib/Elastica/Query/Wildcard.php
  66. +12 9 lib/Elastica/Request.php
  67. +8 2 lib/Elastica/Response.php
  68. +5 4 lib/Elastica/Result.php
  69. +3 1 lib/Elastica/ResultSet.php
  70. +8 8 lib/Elastica/Search.php
  71. +4 4 lib/Elastica/Searchable.php
  72. +12 8 lib/Elastica/Status.php
  73. +2 4 lib/Elastica/Transport/Abstract.php
  74. +5 4 lib/Elastica/Transport/Http.php
  75. +1 1  lib/Elastica/Transport/Https.php
  76. +3 4 lib/Elastica/Transport/Memcache.php
  77. +27 20 lib/Elastica/Type.php
  78. +5 5 lib/Elastica/Type/Abstract.php
  79. +17 14 lib/Elastica/Type/Mapping.php
  80. +8 6 lib/Elastica/Util.php
  81. +1 1  phpdoc.dist.xml
  82. +5 3 test/CodeSniffer/Standards/Xodoa/Sniffs/Commenting/ClassCommentSniff.php
  83. +3 15 test/CodeSniffer/Standards/Xodoa/Sniffs/Commenting/FileCommentSniff.php
  84. +6 8 test/CodeSniffer/Standards/Xodoa/Sniffs/Commenting/FunctionCommentSniff.php
  85. +0 3  test/CodeSniffer/Standards/Xodoa/Sniffs/WhiteSpace/DisallowSpaceIndentSniff.php
  86. +0 4 test/CodeSniffer/Standards/Xodoa/Sniffs/WhiteSpace/ScopeIndentSniff.php
  87. +1 1  test/CodeSniffer/Standards/Xodoa/XodoaCodingStandard.php
  88. +1 1  test/CodeSniffer/Standards/Xodoa/ruleset.xml
  89. +0 1  test/benchmark/BulkMemoryUsageTest.php
  90. +0 1  test/benchmark/ClientTest.php
  91. +1 2  test/lib/Elastica/ClientTest.php
  92. +2 3 test/lib/Elastica/Cluster/SettingsTest.php
  93. +3 4 test/lib/Elastica/ClusterTest.php
  94. +1 2  test/lib/Elastica/DocumentTest.php
  95. +1 1  test/lib/Elastica/Exception/NotImplementedTest.php
  96. +1 5 test/lib/Elastica/Facet/DateHistogramTest.php
  97. +0 1  test/lib/Elastica/Facet/FilterTest.php
  98. +0 1  test/lib/Elastica/Facet/QueryTest.php
  99. +1 3 test/lib/Elastica/Facet/StatisticalTest.php
  100. +1 3 test/lib/Elastica/Facet/TermsTest.php
  101. +0 1  test/lib/Elastica/Filter/AbstractTest.php
  102. +0 4 test/lib/Elastica/Filter/AndTest.php
  103. +0 1  test/lib/Elastica/Filter/ExistsTests.php
  104. +0 3  test/lib/Elastica/Filter/GeoDistanceTest.php
  105. +0 2  test/lib/Elastica/Filter/GeoPolygonTest.php
  106. +0 1  test/lib/Elastica/Filter/IdsTest.php
  107. +1 1  test/lib/Elastica/Filter/MatchAllTest.php
  108. +0 1  test/lib/Elastica/Filter/NestedTest.php
  109. +0 1  test/lib/Elastica/Filter/NotTest.php
  110. +0 1  test/lib/Elastica/Filter/NumericRangeTest.php
  111. +0 2  test/lib/Elastica/Filter/OrTest.php
  112. +1 5 test/lib/Elastica/Filter/PrefixTest.php
  113. +0 1  test/lib/Elastica/Filter/QueryTest.php
  114. +0 1  test/lib/Elastica/Filter/RangeTest.php
  115. +1 1  test/lib/Elastica/Filter/TermTest.php
  116. +0 1  test/lib/Elastica/Filter/TypeTest.php
  117. +1 2  test/lib/Elastica/Index/SettingsTest.php
  118. +1 1  test/lib/Elastica/Index/StatsTest.php
  119. +1 1  test/lib/Elastica/Index/StatusTest.php
  120. +1 2  test/lib/Elastica/LogTest.php
  121. +1 1  test/lib/Elastica/Node/InfoTest.php
  122. +1 1  test/lib/Elastica/NodeTest.php
  123. +3 2 test/lib/Elastica/ParamTest.php
  124. +1 2  test/lib/Elastica/PercolatorTest.php
  125. +1 4 test/lib/Elastica/Query/ConstantScoreTest.php
  126. +1 2  test/lib/Elastica/Query/CustomScoreTest.php
  127. +0 1  test/lib/Elastica/Query/FieldTest.php
  128. +0 2  test/lib/Elastica/Query/FuzzyLikeThisTest.php
  129. +0 1  test/lib/Elastica/Query/FuzzyTest.php
  130. +0 2  test/lib/Elastica/Query/HighlightTest.php
  131. +0 1  test/lib/Elastica/Query/IdsTest.php
  132. +1 1  test/lib/Elastica/Query/MatchAllTest.php
  133. +0 1  test/lib/Elastica/Query/MoreLikeThisTest.php
  134. +2 4 test/lib/Elastica/Query/QueryStringTest.php
  135. +1 1  test/lib/Elastica/Query/TermTest.php
  136. +0 1  test/lib/Elastica/Query/TermsTest.php
  137. +0 1  test/lib/Elastica/Query/TextTest.php
  138. +0 4 test/lib/Elastica/Query/WildcardTest.php
  139. +1 7 test/lib/Elastica/QueryTest.php
  140. +0 3  test/lib/Elastica/ResponseTest.php
  141. +0 3  test/lib/Elastica/ResultTest.php
  142. +1 1  test/lib/Elastica/SearchTest.php
  143. +5 6 test/lib/Elastica/StatusTest.php
  144. +3 2 test/lib/Elastica/Test.php
  145. +0 2  test/lib/Elastica/Transport/MemcacheTest.php
  146. +2 6 test/lib/Elastica/Type/MappingTest.php
  147. +1 3 test/lib/Elastica/TypeTest.php
2  build.xml
@@ -187,4 +187,4 @@
187 187 <arg line="--max-user-speed 50" />
188 188 </exec>
189 189 </target>
190   -</project>
  190 +</project>
64 lib/Elastica/Client.php
@@ -80,7 +80,7 @@ public function setConfig(array $config)
80 80 * Returns a specific config key or the whole
81 81 * config array if not set
82 82 *
83   - * @param string $key Config key
  83 + * @param string $key Config key
84 84 * @return array|string Config value
85 85 */
86 86 public function getConfig($key = '')
@@ -99,8 +99,8 @@ public function getConfig($key = '')
99 99 /**
100 100 * Sets / overwrites a specific config value
101 101 *
102   - * @param string $key Key to set
103   - * @param mixed $value Value
  102 + * @param string $key Key to set
  103 + * @param mixed $value Value
104 104 * @return Elastica_Client Client object
105 105 */
106 106 public function setConfigValue($key, $value)
@@ -111,7 +111,7 @@ public function setConfigValue($key, $value)
111 111 /**
112 112 * Returns the index for the given connection
113 113 *
114   - * @param string $name Index name to create connection to
  114 + * @param string $name Index name to create connection to
115 115 * @return Elastica_Index Index for the given name
116 116 */
117 117 public function getIndex($name)
@@ -152,8 +152,8 @@ public function getTransport()
152 152 /**
153 153 * Adds a HTTP Header
154 154 *
155   - * @param string $header The HTTP Header
156   - * @param string $headerValue The HTTP Header Value
  155 + * @param string $header The HTTP Header
  156 + * @param string $headerValue The HTTP Header Value
157 157 * @throws Elastica_Exception_Invalid If $header or $headerValue is not a string
158 158 */
159 159 public function addHeader($header, $headerValue)
@@ -168,7 +168,7 @@ public function addHeader($header, $headerValue)
168 168 /**
169 169 * Remove a HTTP Header
170 170 *
171   - * @param string $header The HTTP Header to remove
  171 + * @param string $header The HTTP Header to remove
172 172 * @throws Elastica_Exception_Invalid IF $header is not a string
173 173 */
174 174 public function removeHeader($header)
@@ -189,8 +189,8 @@ public function removeHeader($header)
189 189 * set inside the document, because for bulk settings documents,
190 190 * documents can belong to any type and index
191 191 *
192   - * @param array $docs Array of Elastica_Document
193   - * @return Elastica_Response Response object
  192 + * @param array $docs Array of Elastica_Document
  193 + * @return Elastica_Response Response object
194 194 * @throws Elastica_Exception_Invalid If docs is empty
195 195 * @link http://www.elasticsearch.com/docs/elasticsearch/rest_api/bulk/
196 196 */
@@ -201,7 +201,7 @@ public function addDocuments(array $docs)
201 201 }
202 202 $params = array();
203 203
204   - foreach($docs as $doc) {
  204 + foreach ($docs as $doc) {
205 205
206 206 $indexInfo = array(
207 207 '_index' => $doc->getIndex(),
@@ -227,17 +227,18 @@ public function addDocuments(array $docs)
227 227 $params[] = array('index' => $indexInfo);
228 228 $params[] = $doc->getData();
229 229 }
  230 +
230 231 return $this->bulk($params);
231 232 }
232 233
233 234 /**
234 235 * Update document, using update script. Requires elasticsearch >= 0.19.0
235 236 *
236   - * @param int $id document id
237   - * @param Elastica_Script $script script to use for update
238   - * @param string $index index to update
239   - * @param string $type type of index to update
240   - * @param array $options array of query params to use for query. For possible options check es api
  237 + * @param int $id document id
  238 + * @param Elastica_Script $script script to use for update
  239 + * @param string $index index to update
  240 + * @param string $type type of index to update
  241 + * @param array $options array of query params to use for query. For possible options check es api
241 242 * @return Elastica_Response
242 243 * @link http://www.elasticsearch.org/guide/reference/api/update.html
243 244 */
@@ -265,7 +266,7 @@ public function updateDocument($id, Elastica_Script $script, $index, $type, arra
265 266 /**
266 267 * Bulk deletes documents (not implemented yet)
267 268 *
268   - * @param array $docs Docs
  269 + * @param array $docs Docs
269 270 * @throws Elastica_Exception
270 271 */
271 272 public function deleteDocuments(array $docs)
@@ -297,11 +298,11 @@ public function getCluster()
297 298 /**
298 299 * Deletes documents with the given ids, index, type from the index
299 300 *
300   - * @param array $ids Document ids
301   - * @param string|Elastica_Index $index Index name
302   - * @param string|Elastica_Type $type Type of documents
303   - * @return Elastica_Response Response object
304   - * @throws Elastica_Exception If ids is empty
  301 + * @param array $ids Document ids
  302 + * @param string|Elastica_Index $index Index name
  303 + * @param string|Elastica_Type $type Type of documents
  304 + * @return Elastica_Response Response object
  305 + * @throws Elastica_Exception If ids is empty
305 306 * @link http://www.elasticsearch.com/docs/elasticsearch/rest_api/bulk/
306 307 */
307 308 public function deleteIds(array $ids, $index, $type)
@@ -319,7 +320,7 @@ public function deleteIds(array $ids, $index, $type)
319 320 }
320 321
321 322 $params = array();
322   - foreach($ids as $id) {
  323 + foreach ($ids as $id) {
323 324 $action = array(
324 325 'delete' => array(
325 326 '_index' => $index,
@@ -346,7 +347,7 @@ public function deleteIds(array $ids, $index, $type)
346 347 * array('delete' => array('_index' => 'test', '_type' => 'user', '_id' => '2'))
347 348 * );
348 349 *
349   - * @param array $params Parameter array
  350 + * @param array $params Parameter array
350 351 * @return Elastica_Response Reponse object
351 352 * @todo Test
352 353 * @link http://www.elasticsearch.com/docs/elasticsearch/rest_api/bulk/
@@ -360,7 +361,7 @@ public function bulk(array $params)
360 361 $path = '_bulk';
361 362
362 363 $queryString = '';
363   - foreach($params as $index => $baseArray) {
  364 + foreach ($params as $index => $baseArray) {
364 365 // Always newline needed
365 366 $queryString .= json_encode($baseArray) . PHP_EOL;
366 367 }
@@ -369,9 +370,9 @@ public function bulk(array $params)
369 370 $data = $response->getData();
370 371
371 372 if (isset($data['items'])) {
372   - foreach($data['items'] as $item) {
  373 + foreach ($data['items'] as $item) {
373 374 $params = reset($item);
374   - if(isset($params['error'])) {
  375 + if (isset($params['error'])) {
375 376 throw new Elastica_Exception_BulkResponse($response);
376 377 }
377 378 }
@@ -385,22 +386,23 @@ public function bulk(array $params)
385 386 *
386 387 * It's possible to make any REST query directly over this method
387 388 *
388   - * @param string $path Path to call
389   - * @param string $method Rest method to use (GET, POST, DELETE, PUT)
390   - * @param array $data OPTIONAL Arguments as array
391   - * @param array $query OPTIONAL Query params
  389 + * @param string $path Path to call
  390 + * @param string $method Rest method to use (GET, POST, DELETE, PUT)
  391 + * @param array $data OPTIONAL Arguments as array
  392 + * @param array $query OPTIONAL Query params
392 393 * @return Elastica_Response Response object
393 394 */
394 395 public function request($path, $method, $data = array(), array $query = array())
395 396 {
396 397 $request = new Elastica_Request($this, $path, $method, $data, $query);
  398 +
397 399 return $request->send();
398 400 }
399 401
400 402 /**
401 403 * Optimizes all search indices
402 404 *
403   - * @param array $args OPTIONAL Optional arguments
  405 + * @param array $args OPTIONAL Optional arguments
404 406 * @return Elastica_Response Response object
405 407 * @link http://www.elasticsearch.com/docs/elasticsearch/rest_api/admin/indices/optimize/
406 408 */
6 lib/Elastica/Cluster.php
@@ -60,6 +60,7 @@ public function getIndexNames()
60 60 foreach ($metaData as $key => $value) {
61 61 $indices[] = $key;
62 62 }
  63 +
63 64 return $indices;
64 65 }
65 66
@@ -82,6 +83,7 @@ public function getState()
82 83 public function getNodeNames()
83 84 {
84 85 $data = $this->getState();
  86 +
85 87 return array_keys($data['routing_nodes']['nodes']);
86 88 }
87 89
@@ -96,6 +98,7 @@ public function getNodes()
96 98 foreach ($this->getNodeNames() as $name) {
97 99 $nodes[] = new Elastica_Node($name, $this->getClient());
98 100 }
  101 +
99 102 return $nodes;
100 103 }
101 104
@@ -144,13 +147,14 @@ public function getSettings()
144 147 /**
145 148 * Shuts down the complete cluster
146 149 *
147   - * @param string $delay OPTIONAL Seconds to shutdown cluster after (default = 1s)
  150 + * @param string $delay OPTIONAL Seconds to shutdown cluster after (default = 1s)
148 151 * @return Elastica_Response
149 152 * @link http://www.elasticsearch.org/guide/reference/api/admin-cluster-nodes-shutdown.html
150 153 */
151 154 public function shutdown($delay = '1s')
152 155 {
153 156 $path = '_shutdown?delay=' . $delay;
  157 +
154 158 return $this->_client->request($path, Elastica_Request::POST);
155 159 }
156 160 }
26 lib/Elastica/Cluster/Settings.php
@@ -41,7 +41,7 @@ public function get()
41 41 *
42 42 * If param is set, only specified setting is return.
43 43 *
44   - * @param string $setting OPTIONAL Setting name to return
  44 + * @param string $setting OPTIONAL Setting name to return
45 45 * @return array|string|null Settings data
46 46 */
47 47 public function getPersistent($setting = '')
@@ -56,6 +56,7 @@ public function getPersistent($setting = '')
56 56 return null;
57 57 }
58 58 }
  59 +
59 60 return $settings;
60 61 }
61 62
@@ -64,7 +65,7 @@ public function getPersistent($setting = '')
64 65 *
65 66 * If param is set, only specified setting is return.
66 67 *
67   - * @param string $setting OPTIONAL Setting name to return
  68 + * @param string $setting OPTIONAL Setting name to return
68 69 * @return array|string|null Settings data
69 70 */
70 71 public function getTransient($setting = '')
@@ -79,14 +80,15 @@ public function getTransient($setting = '')
79 80 return null;
80 81 }
81 82 }
  83 +
82 84 return $settings;
83 85 }
84 86
85 87 /**
86 88 * Sets persistent setting
87 89 *
88   - * @param string $key
89   - * @param string $value
  90 + * @param string $key
  91 + * @param string $value
90 92 * @return Elastica_Response
91 93 */
92 94 public function setPersistent($key, $value)
@@ -103,8 +105,8 @@ public function setPersistent($key, $value)
103 105 /**
104 106 * Sets transient settings
105 107 *
106   - * @param string $key
107   - * @param string $value
  108 + * @param string $key
  109 + * @param string $value
108 110 * @return Elastica_Response
109 111 */
110 112 public function setTransient($key, $value)
@@ -123,8 +125,8 @@ public function setTransient($key, $value)
123 125 *
124 126 * Second param can be used to set it persistent
125 127 *
126   - * @param bool $readOnly
127   - * @param bool $persistent
  128 + * @param bool $readOnly
  129 + * @param bool $persistent
128 130 * @return Elastica_Response $response
129 131 */
130 132 public function setReadOnly($readOnly = true, $persistent = false)
@@ -136,13 +138,14 @@ public function setReadOnly($readOnly = true, $persistent = false)
136 138 } else {
137 139 $response = $this->setTransient($key, $readOnly);
138 140 }
  141 +
139 142 return $response;
140 143 }
141 144
142 145 /**
143 146 * Set settings for cluster
144 147 *
145   - * @param array $settings Raw settings (including persistent or transient)
  148 + * @param array $settings Raw settings (including persistent or transient)
146 149 * @return Elastica_Response
147 150 */
148 151 public function set(array $settings)
@@ -163,13 +166,14 @@ public function getClient()
163 166 /**
164 167 * Sends settings request
165 168 *
166   - * @param array $data OPTIONAL Data array
167   - * @param string $method OPTIONAL Transfer method (default = Elastica_Request::GET)
  169 + * @param array $data OPTIONAL Data array
  170 + * @param string $method OPTIONAL Transfer method (default = Elastica_Request::GET)
168 171 * @return Elastica_Response Response object
169 172 */
170 173 public function request(array $data = array(), $method = Elastica_Request::GET)
171 174 {
172 175 $path = '_cluster/settings';
  176 +
173 177 return $this->getClient()->request($path, $method, $data);
174 178 }
175 179 }
47 lib/Elastica/Document.php
@@ -93,13 +93,14 @@ public function getId()
93 93 /**
94 94 * Adds the given key/value pair to the document
95 95 *
96   - * @param string $key Document entry key
97   - * @param mixed $value Document entry value
  96 + * @param string $key Document entry key
  97 + * @param mixed $value Document entry value
98 98 * @return Elastica_Document
99 99 */
100 100 public function add($key, $value)
101 101 {
102 102 $this->_data[$key] = $value;
  103 +
103 104 return $this;
104 105 }
105 106
@@ -114,9 +115,9 @@ public function add($key, $value)
114 115 * This installs the tika file analysis plugin. More infos about supported formats
115 116 * can be found here: {@link http://tika.apache.org/0.7/formats.html}
116 117 *
117   - * @param string $key Key to add the file to
118   - * @param string $filepath Path to add the file
119   - * @param string $mimeType OPTIONAL Header mime type
  118 + * @param string $key Key to add the file to
  119 + * @param string $filepath Path to add the file
  120 + * @param string $mimeType OPTIONAL Header mime type
120 121 * @return Elastica_Document
121 122 */
122 123 public function addFile($key, $filepath, $mimeType = '')
@@ -128,14 +129,15 @@ public function addFile($key, $filepath, $mimeType = '')
128 129 }
129 130
130 131 $this->add($key, $value);
  132 +
131 133 return $this;
132 134 }
133 135
134 136 /**
135 137 * Add file content
136 138 *
137   - * @param string $key Document key
138   - * @param string $content Raw file content
  139 + * @param string $key Document key
  140 + * @param string $content Raw file content
139 141 * @return Elastica_Document
140 142 */
141 143 public function addFileContent($key, $content)
@@ -159,25 +161,27 @@ public function addGeoPoint($key, $latitude, $longitude)
159 161 $value = array('lat' => $latitude, 'lon' => $longitude,);
160 162
161 163 $this->add($key, $value);
  164 +
162 165 return $this;
163 166 }
164 167
165 168 /**
166 169 * Overwrites the curent document data with the given data
167 170 *
168   - * @param array $data Data array
  171 + * @param array $data Data array
169 172 * @return Elastica_Document
170 173 */
171 174 public function setData(array $data)
172 175 {
173 176 $this->_data = $data;
  177 +
174 178 return $this;
175 179 }
176 180
177 181 /**
178 182 * Sets lifetime of document
179 183 *
180   - * @param string $ttl
  184 + * @param string $ttl
181 185 * @return Elastica_Document
182 186 */
183 187 public function setTtl($ttl)
@@ -198,19 +202,20 @@ public function getData()
198 202 /**
199 203 * Sets the document type name
200 204 *
201   - * @param string $type Type name
  205 + * @param string $type Type name
202 206 * @return Elastica_Document Current object
203 207 */
204 208 public function setType($type)
205 209 {
206 210 $this->_type = $type;
  211 +
207 212 return $this;
208 213 }
209 214
210 215 /**
211 216 * Return document type name
212 217 *
213   - * @return string Document type name
  218 + * @return string Document type name
214 219 * @throws Elastica_Exception_Invalid
215 220 */
216 221 public function getType()
@@ -220,25 +225,27 @@ public function getType()
220 225 if (is_null($type)) {
221 226 throw new Elastica_Exception_Invalid('Type not set');
222 227 }
  228 +
223 229 return $type;
224 230 }
225 231
226 232 /**
227 233 * Sets the document index name
228 234 *
229   - * @param string $index Index name
  235 + * @param string $index Index name
230 236 * @return Elastica_Document Current object
231 237 */
232 238 public function setIndex($index)
233 239 {
234 240 $this->_index = $index;
  241 +
235 242 return $this;
236 243 }
237 244
238 245 /**
239 246 * Get the document index name
240 247 *
241   - * @return string Index name
  248 + * @return string Index name
242 249 * @throws Elastica_Exception_Invalid
243 250 */
244 251 public function getIndex()
@@ -248,13 +255,14 @@ public function getIndex()
248 255 if (is_null($index)) {
249 256 throw new Elastica_Exception_Invalid('Index not set');
250 257 }
  258 +
251 259 return $index;
252 260 }
253 261
254 262 /**
255 263 * Sets the version of a document for use with optimistic concurrency control
256 264 *
257   - * @param int $version Document version
  265 + * @param int $version Document version
258 266 * @return Elastica_Document Current object
259 267 * @link http://www.elasticsearch.org/blog/2011/02/08/versioning.html
260 268 */
@@ -263,6 +271,7 @@ public function setVersion($version)
263 271 if ($version !== '') {
264 272 $this->_version = (int) $version;
265 273 }
  274 +
266 275 return $this;
267 276 }
268 277
@@ -279,13 +288,14 @@ public function getVersion()
279 288 /**
280 289 * Sets parent document id
281 290 *
282   - * @param string|int $parent Parent document id
  291 + * @param string|int $parent Parent document id
283 292 * @return Elastica_Document Current object
284 293 * @link http://www.elasticsearch.org/guide/reference/mapping/parent-field.html
285 294 */
286 295 public function setParent($parent)
287 296 {
288 297 $this->_parent = $parent;
  298 +
289 299 return $this;
290 300 }
291 301
@@ -302,12 +312,13 @@ public function getParent()
302 312 /**
303 313 * Set operation type
304 314 *
305   - * @param string $optype Only accept create
  315 + * @param string $optype Only accept create
306 316 * @return Elastica_Document Current object
307 317 */
308 318 public function setOpType($optype)
309 319 {
310 320 $this->_optype = $optype;
  321 +
311 322 return $this;
312 323 }
313 324
@@ -322,12 +333,13 @@ public function getOpType()
322 333 /**
323 334 * Set percolate query param
324 335 *
325   - * @param string $value percolator filter
  336 + * @param string $value percolator filter
326 337 * @return Elastica_Document
327 338 */
328 339 public function setPercolate($value = '*')
329 340 {
330 341 $this->_percolate = $value;
  342 +
331 343 return $this;
332 344 }
333 345
@@ -372,6 +384,7 @@ public function toArray()
372 384 }
373 385
374 386 $doc['_source'] = $this->getData();
  387 +
375 388 return $doc;
376 389 }
377 390 }
6 lib/Elastica/Exception/BulkResponse.php
@@ -45,14 +45,14 @@ public function getFailures()
45 45 $data = $this->_response->getData();
46 46 $errors = array();
47 47
48   - foreach($data['items'] as $item) {
  48 + foreach ($data['items'] as $item) {
49 49 $meta = reset($item);
50 50 $action = key($item);
51   - if(isset($meta['error'])) {
  51 + if (isset($meta['error'])) {
52 52 $error = array(
53 53 'action' => $action,
54 54 );
55   - foreach($meta as $key => $value) {
  55 + foreach ($meta as $key => $value) {
56 56 $key = ltrim($key, '_');
57 57 $error[$key] = $value;
58 58 }
6 lib/Elastica/Exception/Client.php
@@ -32,8 +32,8 @@ class Elastica_Exception_Client extends Elastica_Exception_Abstract
32 32 /**
33 33 * Construct Exception
34 34 *
35   - * @param string $error Error
36   - * @param Elastica_Request $request
  35 + * @param string $error Error
  36 + * @param Elastica_Request $request
37 37 * @param Elastica_Response $response
38 38 */
39 39 public function __construct($error, Elastica_Request $request = null, Elastica_Response $response = null)
@@ -50,7 +50,7 @@ public function __construct($error, Elastica_Request $request = null, Elastica_R
50 50 * Returns the error message corresponding to the error code
51 51 * cUrl error code reference can be found here {@link http://curl.haxx.se/libcurl/c/libcurl-errors.html}
52 52 *
53   - * @param string $error Error code
  53 + * @param string $error Error code
54 54 * @return string Error message
55 55 */
56 56 public function getErrorMessage($error)
16 lib/Elastica/Facet/Abstract.php
@@ -35,7 +35,7 @@ public function __construct($name)
35 35 * Sets the name of the facet. It is automatically set by
36 36 * the constructor.
37 37 *
38   - * @param string $name The name of the facet.
  38 + * @param string $name The name of the facet.
39 39 * @throws Elastica_Exception_Invalid
40 40 * @return Elastica_Facet_Abstract
41 41 */
@@ -45,6 +45,7 @@ public function setName($name)
45 45 throw new Elastica_Exception_Invalid('Facet name has to be set');
46 46 }
47 47 $this->_name = $name;
  48 +
48 49 return $this;
49 50 }
50 51
@@ -61,7 +62,7 @@ public function getName()
61 62 /**
62 63 * Sets a filter for this facet.
63 64 *
64   - * @param Elastica_Filter_Abstract $filter A filter to apply on the facet.
  65 + * @param Elastica_Filter_Abstract $filter A filter to apply on the facet.
65 66 * @return Elastica_Facet_Abstract
66 67 */
67 68 public function setFilter(Elastica_Filter_Abstract $filter)
@@ -74,7 +75,7 @@ public function setFilter(Elastica_Filter_Abstract $filter)
74 75 * current search query. When not set, it defaults to the
75 76 * ElasticSearch default value.
76 77 *
77   - * @param bool $global Flag to either run the facet globally.
  78 + * @param bool $global Flag to either run the facet globally.
78 79 * @return Elastica_Facet_Abstract
79 80 */
80 81 public function setGlobal($global = true)
@@ -85,7 +86,7 @@ public function setGlobal($global = true)
85 86 /**
86 87 * Sets the path to the nested document
87 88 *
88   - * @param string $nestedPath Nested path
  89 + * @param string $nestedPath Nested path
89 90 * @return Elastica_Facet_Abstract
90 91 */
91 92 public function setNested($nestedPath)
@@ -96,7 +97,7 @@ public function setNested($nestedPath)
96 97 /**
97 98 * Sets the scope
98 99 *
99   - * @param string $scope Scope
  100 + * @param string $scope Scope
100 101 * @return Elastica_Facet_Abstract
101 102 */
102 103 public function setScope($scope)
@@ -120,13 +121,14 @@ public function toArray()
120 121 * Sets a param for the facet. Each facet implementation needs to take
121 122 * care of handling their own params.
122 123 *
123   - * @param string $key The key of the param to set.
124   - * @param mixed $value The value of the param.
  124 + * @param string $key The key of the param to set.
  125 + * @param mixed $value The value of the param.
125 126 * @return Elastica_Facet_Abstract
126 127 */
127 128 protected function _setFacetParam($key, $value)
128 129 {
129 130 $this->_facet[$key] = $value;
  131 +
130 132 return $this;
131 133 }
132 134 }
5 lib/Elastica/Facet/DateHistogram.php
@@ -13,7 +13,7 @@ class Elastica_Facet_DateHistogram extends Elastica_Facet_Histogram
13 13 /**
14 14 * Set the time_zone parameter
15 15 *
16   - * @param string $tzOffset
  16 + * @param string $tzOffset
17 17 * @return void
18 18 */
19 19 public function setTimezone($tzOffset)
@@ -35,6 +35,7 @@ public function toArray()
35 35 * Set the range in the abstract as param.
36 36 */
37 37 $this->_setFacetParam('date_histogram', $this->_params);
  38 +
38 39 return $this->_facet;
39 40 }
40   -}
  41 +}
2  lib/Elastica/Facet/Filter.php
@@ -12,7 +12,7 @@ class Elastica_Facet_Filter extends Elastica_Facet_Abstract
12 12 /**
13 13 * Set the filter for the facet.
14 14 *
15   - * @param Elastica_Filter_Abstract $filter
  15 + * @param Elastica_Filter_Abstract $filter
16 16 * @return Elastica_Facet_Filter
17 17 */
18 18 public function setFilter(Elastica_Filter_Abstract $filter)
9 lib/Elastica/Facet/GeoDistance.php
@@ -19,7 +19,7 @@ class Elastica_Facet_GeoDistance extends Elastica_Facet_Abstract
19 19 * array('from' => 150)
20 20 * )
21 21 *
22   - * @param array $ranges Numerical array with range definitions.
  22 + * @param array $ranges Numerical array with range definitions.
23 23 * @return Elastica_Facet_GeoDistance
24 24 */
25 25 public function setRanges(array $ranges)
@@ -30,9 +30,9 @@ public function setRanges(array $ranges)
30 30 /**
31 31 * Set the relative GeoPoint for the facet.
32 32 *
33   - * @param string $typeField index type and field e.g foo.bar
34   - * @param float $latitude
35   - * @param float $longitude
  33 + * @param string $typeField index type and field e.g foo.bar
  34 + * @param float $latitude
  35 + * @param float $longitude
36 36 * @return Elastica_Facet_GeoDistance
37 37 */
38 38 public function setGeoPoint($typeField, $latitude, $longitude)
@@ -57,6 +57,7 @@ public function toArray()
57 57 * Set the geo_distance in the abstract as param.
58 58 */
59 59 $this->_setFacetParam ( 'geo_distance', $this->_params );
  60 +
60 61 return parent::toArray ();
61 62 }
62 63 }
16 lib/Elastica/Facet/Histogram.php
@@ -12,7 +12,7 @@ class Elastica_Facet_Histogram extends Elastica_Facet_Abstract
12 12 /**
13 13 * Sets the field for histogram
14 14 *
15   - * @param string $field The name of the field for the historgram
  15 + * @param string $field The name of the field for the historgram
16 16 * @return Elastica_Facet_Histogram
17 17 */
18 18 public function setField($field)
@@ -23,7 +23,7 @@ public function setField($field)
23 23 /**
24 24 * Set the value for interval
25 25 *
26   - * @param string $interval
  26 + * @param string $interval
27 27 * @return Elastica_Facet_Range
28 28 */
29 29 public function setInterval($interval)
@@ -31,12 +31,11 @@ public function setInterval($interval)
31 31 return $this->setParam('interval', $interval);
32 32 }
33 33
34   -
35 34 /**
36 35 * Set the fields for key_field and value_field
37 36 *
38   - * @param string $keyField Key field
39   - * @param string $valueField Value field
  37 + * @param string $keyField Key field
  38 + * @param string $valueField Value field
40 39 * @return Elastica_Facet_Range
41 40 */
42 41 public function setKeyValueFields($keyField, $valueField)
@@ -47,7 +46,7 @@ public function setKeyValueFields($keyField, $valueField)
47 46 /**
48 47 * Sets the key and value for this facet by script.
49 48 *
50   - * @param string $keyScript Script to check whether it falls into the range.
  49 + * @param string $keyScript Script to check whether it falls into the range.
51 50 * @param string $valueScript Script to use for statistical calculations.
52 51 */
53 52 public function setKeyValueScripts($keyScript, $valueScript)
@@ -59,7 +58,7 @@ public function setKeyValueScripts($keyScript, $valueScript)
59 58 /**
60 59 * Set the "params" essential to the a script
61 60 *
62   - * @param array $params Associative array (key/value pair)
  61 + * @param array $params Associative array (key/value pair)
63 62 * @return Elastica_Facet_Histogram Facet object
64 63 */
65 64 public function setScriptParams(array $params)
@@ -81,6 +80,7 @@ public function toArray()
81 80 * Set the range in the abstract as param.
82 81 */
83 82 $this->_setFacetParam('histogram', $this->_params);
  83 +
84 84 return parent::toArray();
85 85 }
86   -}
  86 +}
2  lib/Elastica/Facet/Query.php
@@ -12,7 +12,7 @@ class Elastica_Facet_Query extends Elastica_Facet_Abstract
12 12 /**
13 13 * Set the query for the facet.
14 14 *
15   - * @param Elastica_Query_Abstract $query
  15 + * @param Elastica_Query_Abstract $query
16 16 * @return Elastica_Facet_Query
17 17 */
18 18 public function setQuery(Elastica_Query_Abstract $query)
18 lib/Elastica/Facet/Range.php
@@ -12,7 +12,7 @@ class Elastica_Facet_Range extends Elastica_Facet_Abstract
12 12 /**
13 13 * Sets the field for the range.
14 14 *
15   - * @param string $field The name of the field for range.
  15 + * @param string $field The name of the field for range.
16 16 * @return Elastica_Facet_Range
17 17 */
18 18 public function setField($field)
@@ -23,8 +23,8 @@ public function setField($field)
23 23 /**
24 24 * Sets the fields by their separate key and value fields.
25 25 *
26   - * @param string $keyField The key_field param for the range.
27   - * @param string $valueField The key_value param for the range.
  26 + * @param string $keyField The key_field param for the range.
  27 + * @param string $valueField The key_value param for the range.
28 28 * @return Elastica_Facet_Range
29 29 */
30 30 public function setKeyValueFields($keyField, $valueField)
@@ -36,7 +36,7 @@ public function setKeyValueFields($keyField, $valueField)
36 36 /**
37 37 * Sets the key and value for this facet by script.
38 38 *
39   - * @param string $keyScript Script to check whether it falls into the range.
  39 + * @param string $keyScript Script to check whether it falls into the range.
40 40 * @param string $valueScript Script to use for statistical calculations.
41 41 */
42 42 public function setKeyValueScripts($keyScript, $valueScript)
@@ -54,7 +54,7 @@ public function setKeyValueScripts($keyScript, $valueScript)
54 54 * array('from' => 150)
55 55 * )
56 56 *
57   - * @param array $ranges Numerical array with range definitions.
  57 + * @param array $ranges Numerical array with range definitions.
58 58 * @return Elastica_Facet_Range
59 59 */
60 60 public function setRanges(array $ranges)
@@ -65,8 +65,8 @@ public function setRanges(array $ranges)
65 65 /**
66 66 * Adds a range to the range facet.
67 67 *
68   - * @param mixed $from The from for the range.
69   - * @param mixed $to The to for the range.
  68 + * @param mixed $from The from for the range.
  69 + * @param mixed $to The to for the range.
70 70 * @return Elastica_Facet_Range
71 71 */
72 72 public function addRange($from = null, $to = null)
@@ -76,6 +76,7 @@ public function addRange($from = null, $to = null)
76 76 }
77 77
78 78 $this->_params['ranges'][] = array('from' => $from, 'to' => $to);
  79 +
79 80 return $this;
80 81 }
81 82
@@ -117,6 +118,7 @@ public function toArray()
117 118 * Set the range in the abstract as param.
118 119 */
119 120 $this->_setFacetParam('range', $this->_params);
  121 +
120 122 return parent::toArray();
121 123 }
122   -}
  124 +}
7 lib/Elastica/Facet/Statistical.php
@@ -12,7 +12,7 @@ class Elastica_Facet_Statistical extends Elastica_Facet_Abstract
12 12 /**
13 13 * Sets the field for the statistical query.
14 14 *
15   - * @param string $field The field name for the statistical query.
  15 + * @param string $field The field name for the statistical query.
16 16 * @return Elastica_Facet_Statistical
17 17 */
18 18 public function setField($field)
@@ -23,7 +23,7 @@ public function setField($field)
23 23 /**
24 24 * Sets multiple fields for the statistical query.
25 25 *
26   - * @param array $fields Numerical array with the fields for the statistical query.
  26 + * @param array $fields Numerical array with the fields for the statistical query.
27 27 * @return Elastica_Facet_Statistical
28 28 */
29 29 public function setFields(array $fields)
@@ -34,7 +34,7 @@ public function setFields(array $fields)
34 34 /**
35 35 * Sets a script to calculate statistical information
36 36 *
37   - * @param string $script The script to do calculations on the statistical values
  37 + * @param string $script The script to do calculations on the statistical values
38 38 * @return Elastica_Facet_Statistical
39 39 */
40 40 public function setScript($script)
@@ -52,6 +52,7 @@ public function setScript($script)
52 52 public function toArray()
53 53 {
54 54 $this->_setFacetParam('statistical', $this->_params);
  55 +
55 56 return parent::toArray();
56 57 }
57 58 }
14 lib/Elastica/Facet/Terms.php
@@ -21,7 +21,7 @@ class Elastica_Facet_Terms extends Elastica_Facet_Abstract
21 21 /**
22 22 * Sets the field for the terms.
23 23 *
24   - * @param string $field The field name for the terms.
  24 + * @param string $field The field name for the terms.
25 25 * @return Elastica_Facet_Terms
26 26 */
27 27 public function setField($field)
@@ -32,7 +32,7 @@ public function setField($field)
32 32 /**
33 33 * Sets multiple fields for the terms.
34 34 *
35   - * @param array $fields Numerical array with the fields for the terms.
  35 + * @param array $fields Numerical array with the fields for the terms.
36 36 * @return Elastica_Facet_Terms
37 37 */
38 38 public function setFields(array $fields)
@@ -44,7 +44,7 @@ public function setFields(array $fields)
44 44 * Sets the flag to return all available terms. When they
45 45 * don't have a hit, they have a count of zero.
46 46 *
47   - * @param bool $allTerms Flag to fetch all terms.
  47 + * @param bool $allTerms Flag to fetch all terms.
48 48 * @return Elastica_Facet_Terms
49 49 */
50 50 public function setAllTerms($allTerms)
@@ -56,7 +56,7 @@ public function setAllTerms($allTerms)
56 56 * Sets the ordering type for this facet. ElasticSearch
57 57 * internal default is count.
58 58 *
59   - * @param string $type The order type to set use for sorting of the terms.
  59 + * @param string $type The order type to set use for sorting of the terms.
60 60 * @throws Elastica_Exception_Invalid When an invalid order type was set.
61 61 * @return Elastica_Facet_Terms
62 62 */
@@ -65,13 +65,14 @@ public function setOrder($type)
65 65 if (!in_array($type, $this->_orderTypes)) {
66 66 throw new Elastica_Exception_Invalid('Invalid order type: ' . $type);
67 67 }
  68 +
68 69 return $this->setParam('order', $type);
69 70 }
70 71
71 72 /**
72 73 * Set an array with terms which are omitted in the search.
73 74 *
74   - * @param array $exclude Numerical array which includes all terms which needs to be ignored.
  75 + * @param array $exclude Numerical array which includes all terms which needs to be ignored.
75 76 * @return Elastica_Facet_Terms
76 77 */
77 78 public function setExclude(array $exclude)
@@ -82,7 +83,7 @@ public function setExclude(array $exclude)
82 83 /**
83 84 * Sets the amount of terms to be returned.
84 85 *
85   - * @param int $size The amount of terms to be returned.
  86 + * @param int $size The amount of terms to be returned.
86 87 * @return Elastica_Facet_Terms
87 88 */
88 89 public function setSize($size)
@@ -100,6 +101,7 @@ public function setSize($size)
100 101 public function toArray()
101 102 {
102 103 $this->_setFacetParam('terms', $this->_params);
  104 +
103 105 return parent::toArray();
104 106 }
105 107 }
12 lib/Elastica/Filter/Abstract.php
@@ -12,28 +12,28 @@
12 12 /**
13 13 * Sets the filter cache
14 14 *
15   - * @param boolean $cached Cached
  15 + * @param boolean $cached Cached
16 16 * @return Elastica_Filter_Abstract
17 17 */
18 18 public function setCached($cached = true)
19 19 {
20   - return $this->setParam('_cache', (bool)$cached);
  20 + return $this->setParam('_cache', (bool) $cached);
21 21 }
22 22
23 23 /**
24 24 * Sets the filter cache key
25 25 *
26   - * @param string $cacheKey Cache key
  26 + * @param string $cacheKey Cache key
27 27 * @return Elastica_Filter_Abstract
28 28 */
29 29 public function setCacheKey($cacheKey)
30 30 {
31   - $cacheKey = (string)$cacheKey;
  31 + $cacheKey = (string) $cacheKey;
32 32
33   - if(empty($cacheKey)) {
  33 + if (empty($cacheKey)) {
34 34 throw new Elastica_Exception_Invalid('Invalid parameter. Has to be a non empty string');
35 35 }
36 36
37   - return $this->setParam('_cache_key', (string)$cacheKey);
  37 + return $this->setParam('_cache_key', (string) $cacheKey);
38 38 }
39 39 }
8 lib/Elastica/Filter/Abstract/Multi.php
@@ -18,7 +18,7 @@
18 18 /**
19 19 * Add filter
20 20 *
21   - * @param Elastica_Filter_Abstract $filter
  21 + * @param Elastica_Filter_Abstract $filter
22 22 * @return Elastica_Filter_Abstract_Multi
23 23 */
24 24 public function addFilter(Elastica_Filter_Abstract $filter)
@@ -31,14 +31,14 @@ public function addFilter(Elastica_Filter_Abstract $filter)
31 31 /**
32 32 * Set filters
33 33 *
34   - * @param array $filters
  34 + * @param array $filters
35 35 * @return Elastica_Filter_Abstract_Multi
36 36 */
37 37 public function setFilters(array $filters)
38 38 {
39 39 $this->_filters = array();
40 40
41   - foreach($filters as $filter) {
  41 + foreach ($filters as $filter) {
42 42 $this->addFilter($filter);
43 43 }
44 44
@@ -54,7 +54,7 @@ public function toArray()
54 54 $name = $this->_getName();
55 55 $filterData = $data[$name];
56 56
57   - if(empty($filterData)) {
  57 + if (empty($filterData)) {
58 58 $filterData = $this->_filters;
59 59 } else {
60 60 $filterData['filters'] = $this->_filters;
25 lib/Elastica/Filter/Bool.php
@@ -41,8 +41,8 @@ class Elastica_Filter_Bool extends Elastica_Filter_Abstract
41 41 /**
42 42 * Adds should filter
43 43 *
44   - * @param array|Elastica_Filter_Abstract $args Filter data
45   - * @return Elastica_Filter_Bool Current object
  44 + * @param array|Elastica_Filter_Abstract $args Filter data
  45 + * @return Elastica_Filter_Bool Current object