Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix fluent interface inconsistency #788

Merged
merged 5 commits into from
Feb 21, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 40 additions & 38 deletions lib/Elastica/AbstractUpdateAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ class AbstractUpdateAction extends Param
/**
* Sets the id of the document.
*
* @param string $id
* @return \Elastica\Document
* @param string $id
* @return $this
*/
public function setId($id)
{
Expand Down Expand Up @@ -49,8 +49,8 @@ public function hasId()
/**
* Sets lifetime of document
*
* @param string $ttl
* @return \Elastica\Document
* @param string $ttl
* @return $this
*/
public function setTtl($ttl)
{
Expand All @@ -76,8 +76,8 @@ public function hasTtl()
/**
* Sets the document type name
*
* @param string $type Type name
* @return \Elastica\Document Current object
* @param string $type Type name
* @return $this
*/
public function setType($type)
{
Expand All @@ -92,8 +92,9 @@ public function setType($type)
/**
* Return document type name
*
* @return string Document type name
* @throws \Elastica\Exception\InvalidException
*
* @return string Document type name
*/
public function getType()
{
Expand All @@ -103,8 +104,8 @@ public function getType()
/**
* Sets the document index name
*
* @param string $index Index name
* @return \Elastica\Document Current object
* @param string $index Index name
* @return $this
*/
public function setIndex($index)
{
Expand All @@ -118,8 +119,9 @@ public function setIndex($index)
/**
* Get the document index name
*
* @return string Index name
* @throws \Elastica\Exception\InvalidException
*
* @return string Index name
*/
public function getIndex()
{
Expand All @@ -129,8 +131,8 @@ public function getIndex()
/**
* Sets the version of a document for use with optimistic concurrency control
*
* @param int $version Document version
* @return \Elastica\Document Current object
* @param int $version Document version
* @return $this
* @link http://www.elasticsearch.org/blog/2011/02/08/versioning.html
*/
public function setVersion($version)
Expand Down Expand Up @@ -160,8 +162,8 @@ public function hasVersion()
* Sets the version_type of a document
* Default in ES is internal, but you can set to external to use custom versioning
*
* @param int $versionType Document version type
* @return \Elastica\Document Current object
* @param int $versionType Document version type
* @return $this
* @link http://www.elasticsearch.org/guide/reference/api/index_.html
*/
public function setVersionType($versionType)
Expand Down Expand Up @@ -190,8 +192,8 @@ public function hasVersionType()
/**
* Sets parent document id
*
* @param string|int $parent Parent document id
* @return \Elastica\Document Current object
* @param string|int $parent Parent document id
* @return $this
* @link http://www.elasticsearch.org/guide/reference/mapping/parent-field.html
*/
public function setParent($parent)
Expand Down Expand Up @@ -220,8 +222,8 @@ public function hasParent()
/**
* Set operation type
*
* @param string $opType Only accept create
* @return \Elastica\Document Current object
* @param string $opType Only accept create
* @return $this
*/
public function setOpType($opType)
{
Expand All @@ -248,8 +250,8 @@ public function hasOpType()
/**
* Set percolate query param
*
* @param string $value percolator filter
* @return \Elastica\Document
* @param string $value percolator filter
* @return $this
*/
public function setPercolate($value = '*')
{
Expand Down Expand Up @@ -277,8 +279,8 @@ public function hasPercolate()
/**
* Set routing query param
*
* @param string $value routing
* @return \Elastica\Document
* @param string $value routing
* @return $this
*/
public function setRouting($value)
{
Expand All @@ -304,8 +306,8 @@ public function hasRouting()
}

/**
* @param array|string $fields
* @return \Elastica\Document
* @param array|string $fields
* @return $this
*/
public function setFields($fields)
{
Expand All @@ -317,7 +319,7 @@ public function setFields($fields)
}

/**
* @return \Elastica\Document
* @return $this
*/
public function setFieldsSource()
{
Expand All @@ -341,8 +343,8 @@ public function hasFields()
}

/**
* @param int $num
* @return \Elastica\Document
* @param int $num
* @return $this
*/
public function setRetryOnConflict($num)
{
Expand All @@ -366,8 +368,8 @@ public function hasRetryOnConflict()
}

/**
* @param string $timestamp
* @return \Elastica\Document
* @param string $timestamp
* @return $this
*/
public function setTimestamp($timestamp)
{
Expand All @@ -391,8 +393,8 @@ public function hasTimestamp()
}

/**
* @param bool $refresh
* @return \Elastica\Document
* @param bool $refresh
* @return $this
*/
public function setRefresh($refresh = true)
{
Expand All @@ -416,8 +418,8 @@ public function hasRefresh()
}

/**
* @param string $timeout
* @return \Elastica\Document
* @param string $timeout
* @return $this
*/
public function setTimeout($timeout)
{
Expand All @@ -441,8 +443,8 @@ public function hasTimeout()
}

/**
* @param string $timeout
* @return \Elastica\Document
* @param string $timeout
* @return $this
*/
public function setConsistency($timeout)
{
Expand All @@ -466,8 +468,8 @@ public function hasConsistency()
}

/**
* @param string $timeout
* @return \Elastica\Document
* @param string $timeout
* @return $this
*/
public function setReplication($timeout)
{
Expand All @@ -492,7 +494,7 @@ public function hasReplication()

/**
* @param \Elastica\Document|array $data
* @return \Elastica\Document
* @return $this
*/
public function setUpsert($data)
{
Expand Down
11 changes: 6 additions & 5 deletions lib/Elastica/Aggregation/AbstractAggregation.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@
abstract class AbstractAggregation extends Param
{
/**
* The name of this aggregation
* @var string
* @var string The name of this aggregation
*/
protected $_name;

/**
* Subaggregations belonging to this aggregation
* @var array
* @var array Subaggregations belonging to this aggregation
*/
protected $_aggs = array();

Expand All @@ -34,6 +32,8 @@ public function __construct($name)
public function setName($name)
{
$this->_name = $name;

return $this;
}

/**
Expand All @@ -56,8 +56,9 @@ public function getAggs()

/**
* Add a sub-aggregation
* @param AbstractAggregation $aggregation
* @throws \Elastica\Exception\InvalidException
*
* @param AbstractAggregation $aggregation
* @return $this
*/
public function addAggregation(AbstractAggregation $aggregation)
Expand Down
4 changes: 2 additions & 2 deletions lib/Elastica/Aggregation/AbstractSimpleAggregation.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ abstract class AbstractSimpleAggregation extends AbstractAggregation
{
/**
* Set the field for this aggregation
* @param string $field the name of the document field on which to perform this aggregation
* @param string $field the name of the document field on which to perform this aggregation
* @return $this
*/
public function setField($field)
Expand All @@ -18,7 +18,7 @@ public function setField($field)

/**
* Set a script for this aggregation
* @param string|Script $script
* @param string|Script $script
* @return $this
*/
public function setScript($script)
Expand Down
28 changes: 14 additions & 14 deletions lib/Elastica/Aggregation/DateHistogram.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ class DateHistogram extends Histogram
{
/**
* Set pre-rounding based on interval
* @param string $preZone
* @return DateHistogram
* @param string $preZone
* @return $this
*/
public function setPreZone($preZone)
{
Expand All @@ -21,8 +21,8 @@ public function setPreZone($preZone)

/**
* Set post-rounding based on interval
* @param string $postZone
* @return DateHistogram
* @param string $postZone
* @return $this
*/
public function setPostZone($postZone)
{
Expand All @@ -31,8 +31,8 @@ public function setPostZone($postZone)

/**
* Set pre-zone adjustment for larger time intervals (day and above)
* @param string $adjust
* @return DateHistogram
* @param string $adjust
* @return $this
*/
public function setPreZoneAdjustLargeInterval($adjust)
{
Expand All @@ -41,8 +41,8 @@ public function setPreZoneAdjustLargeInterval($adjust)

/**
* Adjust for granularity of date data
* @param int $factor set to 1000 if date is stored in seconds rather than milliseconds
* @return DateHistogram
* @param int $factor set to 1000 if date is stored in seconds rather than milliseconds
* @return $this
*/
public function setFactor($factor)
{
Expand All @@ -51,8 +51,8 @@ public function setFactor($factor)

/**
* Set the offset for pre-rounding
* @param string $offset "1d", for example
* @return DateHistogram
* @param string $offset "1d", for example
* @return $this
*/
public function setPreOffset($offset)
{
Expand All @@ -61,8 +61,8 @@ public function setPreOffset($offset)

/**
* Set the offset for post-rounding
* @param string $offset "1d", for example
* @return DateHistogram
* @param string $offset "1d", for example
* @return $this
*/
public function setPostOffset($offset)
{
Expand All @@ -72,8 +72,8 @@ public function setPostOffset($offset)
/**
* Set the format for returned bucket key_as_string values
* @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-aggregations-bucket-daterange-aggregation.html#date-format-pattern
* @param string $format see link for formatting options
* @return DateHistogram
* @param string $format see link for formatting options
* @return $this
*/
public function setFormat($format)
{
Expand Down
2 changes: 1 addition & 1 deletion lib/Elastica/Aggregation/DateRange.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class DateRange extends Range
/**
* Set the formatting for the returned date values
* @param string $format see documentation for formatting options
* @return Range
* @return $this
*/
public function setFormat($format)
{
Expand Down
2 changes: 1 addition & 1 deletion lib/Elastica/Aggregation/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Filter extends AbstractAggregation
/**
* Set the filter for this aggregation
* @param AbstractFilter $filter
* @return Filter
* @return $this
*/
public function setFilter(AbstractFilter $filter)
{
Expand Down
2 changes: 1 addition & 1 deletion lib/Elastica/Aggregation/Filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Filters extends AbstractAggregation
*
* @param AbstractFilter $filter
* @param string $name
* @return Filters
* @return $this
*/
public function addFilter(AbstractFilter $filter, $name = '')
{
Expand Down
Loading