Skip to content

Commit 690a98a

Browse files
committed
Merge pull request #788 from im-denisenko/feature/fix-fluent
Fix fluent interface inconsistency
2 parents 7f62b40 + 52763f9 commit 690a98a

File tree

155 files changed

+1478
-1234
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

155 files changed

+1478
-1234
lines changed

lib/Elastica/AbstractUpdateAction.php

+40-38
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ class AbstractUpdateAction extends Param
2020
/**
2121
* Sets the id of the document.
2222
*
23-
* @param string $id
24-
* @return \Elastica\Document
23+
* @param string $id
24+
* @return $this
2525
*/
2626
public function setId($id)
2727
{
@@ -49,8 +49,8 @@ public function hasId()
4949
/**
5050
* Sets lifetime of document
5151
*
52-
* @param string $ttl
53-
* @return \Elastica\Document
52+
* @param string $ttl
53+
* @return $this
5454
*/
5555
public function setTtl($ttl)
5656
{
@@ -76,8 +76,8 @@ public function hasTtl()
7676
/**
7777
* Sets the document type name
7878
*
79-
* @param string $type Type name
80-
* @return \Elastica\Document Current object
79+
* @param string $type Type name
80+
* @return $this
8181
*/
8282
public function setType($type)
8383
{
@@ -92,8 +92,9 @@ public function setType($type)
9292
/**
9393
* Return document type name
9494
*
95-
* @return string Document type name
9695
* @throws \Elastica\Exception\InvalidException
96+
*
97+
* @return string Document type name
9798
*/
9899
public function getType()
99100
{
@@ -103,8 +104,8 @@ public function getType()
103104
/**
104105
* Sets the document index name
105106
*
106-
* @param string $index Index name
107-
* @return \Elastica\Document Current object
107+
* @param string $index Index name
108+
* @return $this
108109
*/
109110
public function setIndex($index)
110111
{
@@ -118,8 +119,9 @@ public function setIndex($index)
118119
/**
119120
* Get the document index name
120121
*
121-
* @return string Index name
122122
* @throws \Elastica\Exception\InvalidException
123+
*
124+
* @return string Index name
123125
*/
124126
public function getIndex()
125127
{
@@ -129,8 +131,8 @@ public function getIndex()
129131
/**
130132
* Sets the version of a document for use with optimistic concurrency control
131133
*
132-
* @param int $version Document version
133-
* @return \Elastica\Document Current object
134+
* @param int $version Document version
135+
* @return $this
134136
* @link http://www.elasticsearch.org/blog/2011/02/08/versioning.html
135137
*/
136138
public function setVersion($version)
@@ -160,8 +162,8 @@ public function hasVersion()
160162
* Sets the version_type of a document
161163
* Default in ES is internal, but you can set to external to use custom versioning
162164
*
163-
* @param int $versionType Document version type
164-
* @return \Elastica\Document Current object
165+
* @param int $versionType Document version type
166+
* @return $this
165167
* @link http://www.elasticsearch.org/guide/reference/api/index_.html
166168
*/
167169
public function setVersionType($versionType)
@@ -190,8 +192,8 @@ public function hasVersionType()
190192
/**
191193
* Sets parent document id
192194
*
193-
* @param string|int $parent Parent document id
194-
* @return \Elastica\Document Current object
195+
* @param string|int $parent Parent document id
196+
* @return $this
195197
* @link http://www.elasticsearch.org/guide/reference/mapping/parent-field.html
196198
*/
197199
public function setParent($parent)
@@ -220,8 +222,8 @@ public function hasParent()
220222
/**
221223
* Set operation type
222224
*
223-
* @param string $opType Only accept create
224-
* @return \Elastica\Document Current object
225+
* @param string $opType Only accept create
226+
* @return $this
225227
*/
226228
public function setOpType($opType)
227229
{
@@ -248,8 +250,8 @@ public function hasOpType()
248250
/**
249251
* Set percolate query param
250252
*
251-
* @param string $value percolator filter
252-
* @return \Elastica\Document
253+
* @param string $value percolator filter
254+
* @return $this
253255
*/
254256
public function setPercolate($value = '*')
255257
{
@@ -277,8 +279,8 @@ public function hasPercolate()
277279
/**
278280
* Set routing query param
279281
*
280-
* @param string $value routing
281-
* @return \Elastica\Document
282+
* @param string $value routing
283+
* @return $this
282284
*/
283285
public function setRouting($value)
284286
{
@@ -304,8 +306,8 @@ public function hasRouting()
304306
}
305307

306308
/**
307-
* @param array|string $fields
308-
* @return \Elastica\Document
309+
* @param array|string $fields
310+
* @return $this
309311
*/
310312
public function setFields($fields)
311313
{
@@ -317,7 +319,7 @@ public function setFields($fields)
317319
}
318320

319321
/**
320-
* @return \Elastica\Document
322+
* @return $this
321323
*/
322324
public function setFieldsSource()
323325
{
@@ -341,8 +343,8 @@ public function hasFields()
341343
}
342344

343345
/**
344-
* @param int $num
345-
* @return \Elastica\Document
346+
* @param int $num
347+
* @return $this
346348
*/
347349
public function setRetryOnConflict($num)
348350
{
@@ -366,8 +368,8 @@ public function hasRetryOnConflict()
366368
}
367369

368370
/**
369-
* @param string $timestamp
370-
* @return \Elastica\Document
371+
* @param string $timestamp
372+
* @return $this
371373
*/
372374
public function setTimestamp($timestamp)
373375
{
@@ -391,8 +393,8 @@ public function hasTimestamp()
391393
}
392394

393395
/**
394-
* @param bool $refresh
395-
* @return \Elastica\Document
396+
* @param bool $refresh
397+
* @return $this
396398
*/
397399
public function setRefresh($refresh = true)
398400
{
@@ -416,8 +418,8 @@ public function hasRefresh()
416418
}
417419

418420
/**
419-
* @param string $timeout
420-
* @return \Elastica\Document
421+
* @param string $timeout
422+
* @return $this
421423
*/
422424
public function setTimeout($timeout)
423425
{
@@ -441,8 +443,8 @@ public function hasTimeout()
441443
}
442444

443445
/**
444-
* @param string $timeout
445-
* @return \Elastica\Document
446+
* @param string $timeout
447+
* @return $this
446448
*/
447449
public function setConsistency($timeout)
448450
{
@@ -466,8 +468,8 @@ public function hasConsistency()
466468
}
467469

468470
/**
469-
* @param string $timeout
470-
* @return \Elastica\Document
471+
* @param string $timeout
472+
* @return $this
471473
*/
472474
public function setReplication($timeout)
473475
{
@@ -492,7 +494,7 @@ public function hasReplication()
492494

493495
/**
494496
* @param \Elastica\Document|array $data
495-
* @return \Elastica\Document
497+
* @return $this
496498
*/
497499
public function setUpsert($data)
498500
{

lib/Elastica/Aggregation/AbstractAggregation.php

+6-5
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,12 @@
88
abstract class AbstractAggregation extends Param
99
{
1010
/**
11-
* The name of this aggregation
12-
* @var string
11+
* @var string The name of this aggregation
1312
*/
1413
protected $_name;
1514

1615
/**
17-
* Subaggregations belonging to this aggregation
18-
* @var array
16+
* @var array Subaggregations belonging to this aggregation
1917
*/
2018
protected $_aggs = array();
2119

@@ -34,6 +32,8 @@ public function __construct($name)
3432
public function setName($name)
3533
{
3634
$this->_name = $name;
35+
36+
return $this;
3737
}
3838

3939
/**
@@ -56,8 +56,9 @@ public function getAggs()
5656

5757
/**
5858
* Add a sub-aggregation
59-
* @param AbstractAggregation $aggregation
6059
* @throws \Elastica\Exception\InvalidException
60+
*
61+
* @param AbstractAggregation $aggregation
6162
* @return $this
6263
*/
6364
public function addAggregation(AbstractAggregation $aggregation)

lib/Elastica/Aggregation/AbstractSimpleAggregation.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ abstract class AbstractSimpleAggregation extends AbstractAggregation
88
{
99
/**
1010
* Set the field for this aggregation
11-
* @param string $field the name of the document field on which to perform this aggregation
11+
* @param string $field the name of the document field on which to perform this aggregation
1212
* @return $this
1313
*/
1414
public function setField($field)
@@ -18,7 +18,7 @@ public function setField($field)
1818

1919
/**
2020
* Set a script for this aggregation
21-
* @param string|Script $script
21+
* @param string|Script $script
2222
* @return $this
2323
*/
2424
public function setScript($script)

lib/Elastica/Aggregation/DateHistogram.php

+14-14
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ class DateHistogram extends Histogram
1111
{
1212
/**
1313
* Set pre-rounding based on interval
14-
* @param string $preZone
15-
* @return DateHistogram
14+
* @param string $preZone
15+
* @return $this
1616
*/
1717
public function setPreZone($preZone)
1818
{
@@ -21,8 +21,8 @@ public function setPreZone($preZone)
2121

2222
/**
2323
* Set post-rounding based on interval
24-
* @param string $postZone
25-
* @return DateHistogram
24+
* @param string $postZone
25+
* @return $this
2626
*/
2727
public function setPostZone($postZone)
2828
{
@@ -31,8 +31,8 @@ public function setPostZone($postZone)
3131

3232
/**
3333
* Set pre-zone adjustment for larger time intervals (day and above)
34-
* @param string $adjust
35-
* @return DateHistogram
34+
* @param string $adjust
35+
* @return $this
3636
*/
3737
public function setPreZoneAdjustLargeInterval($adjust)
3838
{
@@ -41,8 +41,8 @@ public function setPreZoneAdjustLargeInterval($adjust)
4141

4242
/**
4343
* Adjust for granularity of date data
44-
* @param int $factor set to 1000 if date is stored in seconds rather than milliseconds
45-
* @return DateHistogram
44+
* @param int $factor set to 1000 if date is stored in seconds rather than milliseconds
45+
* @return $this
4646
*/
4747
public function setFactor($factor)
4848
{
@@ -51,8 +51,8 @@ public function setFactor($factor)
5151

5252
/**
5353
* Set the offset for pre-rounding
54-
* @param string $offset "1d", for example
55-
* @return DateHistogram
54+
* @param string $offset "1d", for example
55+
* @return $this
5656
*/
5757
public function setPreOffset($offset)
5858
{
@@ -61,8 +61,8 @@ public function setPreOffset($offset)
6161

6262
/**
6363
* Set the offset for post-rounding
64-
* @param string $offset "1d", for example
65-
* @return DateHistogram
64+
* @param string $offset "1d", for example
65+
* @return $this
6666
*/
6767
public function setPostOffset($offset)
6868
{
@@ -72,8 +72,8 @@ public function setPostOffset($offset)
7272
/**
7373
* Set the format for returned bucket key_as_string values
7474
* @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-aggregations-bucket-daterange-aggregation.html#date-format-pattern
75-
* @param string $format see link for formatting options
76-
* @return DateHistogram
75+
* @param string $format see link for formatting options
76+
* @return $this
7777
*/
7878
public function setFormat($format)
7979
{

lib/Elastica/Aggregation/DateRange.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class DateRange extends Range
1212
/**
1313
* Set the formatting for the returned date values
1414
* @param string $format see documentation for formatting options
15-
* @return Range
15+
* @return $this
1616
*/
1717
public function setFormat($format)
1818
{

lib/Elastica/Aggregation/Filter.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Filter extends AbstractAggregation
1414
/**
1515
* Set the filter for this aggregation
1616
* @param AbstractFilter $filter
17-
* @return Filter
17+
* @return $this
1818
*/
1919
public function setFilter(AbstractFilter $filter)
2020
{

lib/Elastica/Aggregation/Filters.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Filters extends AbstractAggregation
1818
*
1919
* @param AbstractFilter $filter
2020
* @param string $name
21-
* @return Filters
21+
* @return $this
2222
*/
2323
public function addFilter(AbstractFilter $filter, $name = '')
2424
{

0 commit comments

Comments
 (0)