Skip to content

Commit

Permalink
Merge pull request #1693 from deguif/bump-query-builder-version
Browse files Browse the repository at this point in the history
Bump query builder version to 7.0
  • Loading branch information
ruflin authored Nov 18, 2019
2 parents 61a8ba5 + d21ff4d commit d3dc5a7
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 17 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ All notable changes to this project will be documented in this file based on the

### Backward Compatibility Breaks
* The class `\Elastica\Type\Mapping` has been moved to `\Elastica\Mapping` [#1666](https://github.com/ruflin/Elastica/pull/1666)
* The class `\Elastica\QueryBuilder\Version\Version240` has been moved to `\Elastica\QueryBuilder\Version\Version700` and type query was removed [#1693](https://github.com/ruflin/Elastica/pull/1693)
* The `\Elastica\Query::$_suggest` property has been renamed to `$hasSuggest` and is now private, it should not be used from extending classes [#1679](https://github.com/ruflin/Elastica/pull/1679)
* `\Elastica\Document` expects a string as ID, not an int [#1672](https://github.com/ruflin/Elastica/pull/1672).
* Removed `\Elastica\Query\GeohashCell` query, use `\Elastica\Query\GeoBoundingBox` instead [#1672](https://github.com/ruflin/Elastica/pull/1672).
Expand Down
10 changes: 2 additions & 8 deletions lib/Elastica/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,10 @@ class QueryBuilder

/**
* Constructor.
*
* @param Version $version
*/
public function __construct(Version $version = null)
{
$this->_version = $version ?: new Version\Latest();
$this->_version = $version ?? new Version\Latest();

$this->addDSL(new DSL\Query());
$this->addDSL(new DSL\Aggregation());
Expand All @@ -41,13 +39,9 @@ public function __construct(Version $version = null)
/**
* Returns Facade for custom DSL object.
*
* @param $dsl
*
* @throws QueryBuilderException
*
* @return Facade
*/
public function __call($dsl, array $arguments)
public function __call(string $dsl, array $arguments): Facade
{
if (false === isset($this->_facades[$dsl])) {
throw new QueryBuilderException('DSL "'.$dsl.'" not supported');
Expand Down
8 changes: 4 additions & 4 deletions lib/Elastica/QueryBuilder/DSL.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
*/
interface DSL
{
const TYPE_QUERY = 'query';
const TYPE_AGGREGATION = 'aggregation';
const TYPE_SUGGEST = 'suggest';
const TYPE_COLLAPSE = 'collapse';
public const TYPE_QUERY = 'query';
public const TYPE_AGGREGATION = 'aggregation';
public const TYPE_SUGGEST = 'suggest';
public const TYPE_COLLAPSE = 'collapse';

/**
* must return type for QueryBuilder usage.
Expand Down
2 changes: 1 addition & 1 deletion lib/Elastica/QueryBuilder/Version/Latest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*
* @author Manuel Andreo Garcia <andreo.garcia@gmail.com>
*/
class Latest extends Version240
class Latest extends Version700
{
// this class always points to the latest valid DSL version
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
use Elastica\QueryBuilder\Version;

/**
* elasticsearch 2.4 DSL.
* elasticsearch 7.0 DSL.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/2.4/index.html
* @see https://www.elastic.co/guide/en/elasticsearch/reference/7.0/index.html
*
* @author Cariou Pierre-Yves <cariou.p@gmail.com>
*/
class Version240 extends Version
class Version700 extends Version
{
protected $queries = [
'match',
Expand Down
2 changes: 1 addition & 1 deletion test/Elastica/QueryBuilder/VersionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function testVersions()
];

$versions = [
new Version\Version240(),
new Version\Version700(),
new Version\Latest(),
];

Expand Down

0 comments on commit d3dc5a7

Please sign in to comment.