Skip to content

Commit

Permalink
Merge 524230b into 4336265
Browse files Browse the repository at this point in the history
  • Loading branch information
deguif committed Oct 26, 2020
2 parents 4336265 + 524230b commit c924197
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Used `GuzzleHttp\RequestOptions` constants for configuring request options [#1820](https://github.com/ruflin/Elastica/pull/1820)
### Deprecated
* Deprecated `Elastica\QueryBuilder\DSL\Aggregation::global_agg()`, use `global()` instead [#1826](https://github.com/ruflin/Elastica/pull/1826)
* Deprecated `Elastica\Util::getParamName()` [#1832](https://github.com/ruflin/Elastica/pull/1832)
* Deprecated Match query class and introduced MatchQuery instead for PHP 8.0 compatibility reason [#1799](https://github.com/ruflin/Elastica/pull/1799)
* Deprecated `version`/`version_type` options [(deprecated in `6.7.0`)](https://www.elastic.co/guide/en/elasticsearch/reference/6.8/docs-update.html) and added `if_seq_no` / `if_primary_term` that replaced it
* Deprecated passing `bool` or `null` as 2nd argument to `Elastica\Index::create()` [#1828](https://github.com/ruflin/Elastica/pull/1828)
Expand Down
2 changes: 1 addition & 1 deletion src/Param.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ protected function _convertArrayable(array $array)
*/
protected function _getBaseName()
{
return Util::getParamName($this);
return Util::toSnakeCase((new \ReflectionClass($this))->getShortName());
}

/**
Expand Down
8 changes: 8 additions & 0 deletions src/Query/AbstractQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Elastica\Query;

use Elastica\Param;
use Elastica\Util;

/**
* Abstract query object. Should be extended by all query types.
Expand All @@ -11,4 +12,11 @@
*/
abstract class AbstractQuery extends Param
{
protected function _getBaseName()
{
$shortName = (new \ReflectionClass($this))->getShortName();
$shortName = \preg_replace('/Query$/', '', $shortName);

return Util::toSnakeCase($shortName);
}
}
2 changes: 2 additions & 0 deletions src/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ public static function convertDateTimeObject(\DateTime $dateTime, bool $includeT
*/
public static function getParamName($class)
{
trigger_deprecation('ruflin/elastica', '7.1.0', 'The "%s()" method is deprecated. It will be removed in 8.0.', __METHOD__);

if (\is_object($class)) {
$class = \get_class($class);
}
Expand Down
10 changes: 2 additions & 8 deletions tests/ParamTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Elastica\Param;
use Elastica\Test\Base as BaseTest;
use Elastica\Util;

/**
* @internal
Expand All @@ -18,7 +17,7 @@ public function testToArrayEmpty(): void
{
$param = new Param();
$this->assertInstanceOf(Param::class, $param);
$this->assertEquals([$this->_getFilterName($param) => []], $param->toArray());
$this->assertEquals(['param' => []], $param->toArray());
}

/**
Expand All @@ -31,7 +30,7 @@ public function testSetParams(): void
$param->setParams($params);

$this->assertInstanceOf(Param::class, $param);
$this->assertEquals([$this->_getFilterName($param) => $params], $param->toArray());
$this->assertEquals(['param' => $params], $param->toArray());
}

/**
Expand Down Expand Up @@ -112,9 +111,4 @@ public function testHasParam(): void
$param->setParam($key, $value);
$this->assertTrue($param->hasParam($key));
}

protected function _getFilterName($filter)
{
return Util::getParamName($filter);
}
}

0 comments on commit c924197

Please sign in to comment.