diff --git a/src/Aggregation/TopHitsAggregation.php b/src/Aggregation/TopHitsAggregation.php index d41e3d82bab0599a5bf40253c4a63283e63a0edf..3ee30986c346887590ea1ad56f24d4a69e7e9e25 100644 --- a/src/Aggregation/TopHitsAggregation.php +++ b/src/Aggregation/TopHitsAggregation.php @@ -39,9 +39,9 @@ class TopHitsAggregation extends AbstractAggregation /** * Constructor for top hits. * - * @param string $name Aggregation name. - * @param null|int $size Number of top matching hits to return per bucket. - * @param null|int $from The offset from the first result you want to fetch. + * @param string $name Aggregation name. + * @param null|int $size Number of top matching hits to return per bucket. + * @param null|int $from The offset from the first result you want to fetch. * @param null|BuilderInterface $sort How the top matching hits should be sorted. */ public function __construct($name, $size = null, $from = null, $sort = null) diff --git a/src/BuilderBag.php b/src/BuilderBag.php index 4894764905646915fa51f545818bd1a9c4ba47d7..439febc6aabdc4e549ab48254de4c7b1e81667a0 100644 --- a/src/BuilderBag.php +++ b/src/BuilderBag.php @@ -66,7 +66,7 @@ class BuilderBag /** * Removes a builder by name. * - * @param string $name builder name. + * @param string $name Builder name. */ public function remove($name) { @@ -84,7 +84,7 @@ class BuilderBag /** * Returns a builder by name. * - * @param string $name builder name. + * @param string $name Builder name. * * @return BuilderInterface */ @@ -96,7 +96,7 @@ class BuilderBag /** * Returns all builders contained. * - * @param string|null $type builder type. + * @param string|null $type Builder type. * * @return BuilderInterface[] */ @@ -120,6 +120,7 @@ class BuilderBag foreach ($this->all() as $builder) { $output = array_merge($output, $builder->toArray()); } + return $output; } } diff --git a/src/Highlight/Highlight.php b/src/Highlight/Highlight.php index 7723ea042b2ee680984e62cc3cafc095f3835ac7..171e6a1623da8ef182b8b1ed0da31a8b492b9882 100644 --- a/src/Highlight/Highlight.php +++ b/src/Highlight/Highlight.php @@ -32,8 +32,8 @@ class Highlight implements BuilderInterface private $tags; /** - * @param $name - * @param array $params + * @param string $name Field name to highlight. + * @param array $params * * @return $this */ diff --git a/src/NameAwareTrait.php b/src/NameAwareTrait.php index ddf7d90b8e73d801d560a0fc6ba38baabd79308b..c76c9375eb24c4e9be795758603877b4135d7f01 100644 --- a/src/NameAwareTrait.php +++ b/src/NameAwareTrait.php @@ -13,6 +13,9 @@ namespace ONGR\ElasticsearchDSL; trait NameAwareTrait { + /** + * @var string + */ private $name; /** diff --git a/src/Query/BoolQuery.php b/src/Query/BoolQuery.php index 0c4ed3bad83c6851f1ec6dcb8dc0dfcb97cc2ed0..3faed61a019b6a31277de9f28190c81b61dc5ba4 100644 --- a/src/Query/BoolQuery.php +++ b/src/Query/BoolQuery.php @@ -32,6 +32,9 @@ class BoolQuery implements BuilderInterface */ private $container = []; + /** + * Constructor to prepare container. + */ public function __construct() { $this->container = [ @@ -53,6 +56,10 @@ class BoolQuery implements BuilderInterface && count($this->container[self::MUST]) == 1; } + /** + * @param null $boolType + * @return array + */ public function getQueries($boolType = null) { if ($boolType === null) { @@ -69,9 +76,9 @@ class BoolQuery implements BuilderInterface /** * Add BuilderInterface object to bool operator. * - * @param BuilderInterface $query Query add to the bool. - * @param string $type Bool type. Example: must, must_not, should. - * @param string $key Key that indicates a builder id. + * @param BuilderInterface $query Query add to the bool. + * @param string $type Bool type. Example: must, must_not, should. + * @param string $key Key that indicates a builder id. * * @return string Key of added builder. * @@ -103,6 +110,7 @@ class BoolQuery implements BuilderInterface /** @var BuilderInterface $query */ $mustContainer = $this->container[self::MUST]; $query = array_shift($mustContainer); + return [$query->getType() => $query->toArray()]; } diff --git a/src/SearchEndpoint/AbstractSearchEndpoint.php b/src/SearchEndpoint/AbstractSearchEndpoint.php index d6bdc9662604c6eb16309df078de5db533ecbc87..0ec3582fb1fbd0948847872c87bfd0b1592c2c15 100644 --- a/src/SearchEndpoint/AbstractSearchEndpoint.php +++ b/src/SearchEndpoint/AbstractSearchEndpoint.php @@ -68,7 +68,8 @@ abstract class AbstractSearchEndpoint extends AbstractNormalizable implements Se /** * Checks if builder with specific key exists. * - * @param $key + * @param string $key Key to check if it exists in container. + * * @return bool */ public function has($key) diff --git a/src/SearchEndpoint/AggregationsEndpoint.php b/src/SearchEndpoint/AggregationsEndpoint.php index 444066df949ed2ef3274a7611535cb175870fdf7..56c2c508bba2450c6bbdff54e75ecaf495318fec 100644 --- a/src/SearchEndpoint/AggregationsEndpoint.php +++ b/src/SearchEndpoint/AggregationsEndpoint.php @@ -22,7 +22,7 @@ class AggregationsEndpoint extends AbstractSearchEndpoint /** * Endpoint name */ - CONST NAME = 'aggregations'; + const NAME = 'aggregations'; /** * {@inheritdoc} diff --git a/src/SearchEndpoint/FilterEndpoint.php b/src/SearchEndpoint/FilterEndpoint.php index ef53e00d82ee63dc9d75218c8e87adae1c78e0f9..888ca1cbf364ba9011c87f90bb63231f6f997703 100644 --- a/src/SearchEndpoint/FilterEndpoint.php +++ b/src/SearchEndpoint/FilterEndpoint.php @@ -23,7 +23,7 @@ class FilterEndpoint extends QueryEndpoint /** * Endpoint name */ - CONST NAME = 'filter'; + const NAME = 'filter'; /** * {@inheritdoc} diff --git a/src/SearchEndpoint/HighlightEndpoint.php b/src/SearchEndpoint/HighlightEndpoint.php index ba4ff9c3552bd079cda25553604e7a4b8ca95428..45d9c9fe44ac4077833f08c90fba6c7d0599a704 100644 --- a/src/SearchEndpoint/HighlightEndpoint.php +++ b/src/SearchEndpoint/HighlightEndpoint.php @@ -22,7 +22,7 @@ class HighlightEndpoint extends AbstractSearchEndpoint /** * Endpoint name */ - CONST NAME = 'highlight'; + const NAME = 'highlight'; /** * @var BuilderInterface diff --git a/src/SearchEndpoint/PostFilterEndpoint.php b/src/SearchEndpoint/PostFilterEndpoint.php index 88bfc57f5c179d4365461a65ede2bdb52e88fd83..27d67bdd797fc43ca28a534d7723862de1a09151 100644 --- a/src/SearchEndpoint/PostFilterEndpoint.php +++ b/src/SearchEndpoint/PostFilterEndpoint.php @@ -22,7 +22,7 @@ class PostFilterEndpoint extends FilterEndpoint /** * Endpoint name */ - CONST NAME = 'post_filter'; + const NAME = 'post_filter'; /** * {@inheritdoc} diff --git a/src/SearchEndpoint/QueryEndpoint.php b/src/SearchEndpoint/QueryEndpoint.php index 89f5ec940199f3f958e5b041c17f27576ba032ce..52f50597fbe57f0dd6eb4ed35c39c06f3d90ab78 100644 --- a/src/SearchEndpoint/QueryEndpoint.php +++ b/src/SearchEndpoint/QueryEndpoint.php @@ -28,7 +28,7 @@ class QueryEndpoint extends AbstractSearchEndpoint implements OrderedNormalizerI /** * Endpoint name */ - CONST NAME = 'query'; + const NAME = 'query'; /** * @var BoolQuery diff --git a/src/SearchEndpoint/SearchEndpointInterface.php b/src/SearchEndpoint/SearchEndpointInterface.php index 13991125fab1c4fda8c5b24a18809336b34fd9f4..7ee71789666e6a88eeee7cb15379119a8e10fccc 100644 --- a/src/SearchEndpoint/SearchEndpointInterface.php +++ b/src/SearchEndpoint/SearchEndpointInterface.php @@ -23,8 +23,8 @@ interface SearchEndpointInterface extends NormalizableInterface /** * Adds builder to search endpoint. * - * @param BuilderInterface $builder Builder to add. - * @param array $key Additional parameters relevant to builder. + * @param BuilderInterface $builder Builder to add. + * @param array $key Additional parameters relevant to builder. * * @return string Key of added builder. */ @@ -33,10 +33,10 @@ interface SearchEndpointInterface extends NormalizableInterface /** * Adds builder to search endpoint's specific bool type container. * - * @param BuilderInterface $builder Builder to add. - * @param array $boolType Bool type for query or filter. If bool type is left null - * it will be treated as MUST. - * @param array $key Additional parameters relevant to builder. + * @param BuilderInterface $builder Builder to add. + * @param array $boolType Bool type for query or filter. If bool type is left null + * it will be treated as MUST. + * @param array $key Additional parameters relevant to builder. * * @return string Key of added builder. */ diff --git a/src/SearchEndpoint/SortEndpoint.php b/src/SearchEndpoint/SortEndpoint.php index 13eaf6a828bbaa52dd6576bd3f950c6456b34546..d19249d7698023a4e5487d1c6971c53f2c328e9b 100644 --- a/src/SearchEndpoint/SortEndpoint.php +++ b/src/SearchEndpoint/SortEndpoint.php @@ -24,7 +24,7 @@ class SortEndpoint extends AbstractSearchEndpoint /** * Endpoint name */ - CONST NAME = 'sort'; + const NAME = 'sort'; /** * {@inheritdoc} @@ -33,7 +33,7 @@ class SortEndpoint extends AbstractSearchEndpoint { $output = []; - foreach($this->getAll() as $sort) { + foreach ($this->getAll() as $sort) { $output[] = $sort->toArray(); } diff --git a/src/Sort/FieldSort.php b/src/Sort/FieldSort.php index 394affc768d57ecc0f2e5b80b959e7ddfd15680f..c9ae2d621e1301e31382dd67ae79d4c2e9ce3ad3 100644 --- a/src/Sort/FieldSort.php +++ b/src/Sort/FieldSort.php @@ -18,8 +18,8 @@ use ONGR\ElasticsearchDSL\BuilderInterface; */ class FieldSort implements BuilderInterface { - CONST ASC = 'asc'; - CONST DESC = 'desc'; + const ASC = 'asc'; + const DESC = 'desc'; /** * @var string. @@ -37,8 +37,8 @@ class FieldSort implements BuilderInterface private $nestedFilter; /** - * @param string $field Field name. - * @param array $params Params that can be set to field sort. + * @param string $field Field name. + * @param array $params Params that can be set to field sort. */ public function __construct($field, $params = []) { @@ -80,9 +80,10 @@ class FieldSort implements BuilderInterface if ($this->nestedFilter) { $fieldValues = array_merge( $this->params, - ['nested_filter' => [ - $this->nestedFilter->getType() => $this->nestedFilter->toArray(), - ] + [ + 'nested_filter' => [ + $this->nestedFilter->getType() => $this->nestedFilter->toArray(), + ], ] ); } else { diff --git a/tests/BuilderBagTest.php b/tests/BuilderBagTest.php index b2f7a9569c134b55e377f131c447e598a1508611..ec16fc0294180d1c750887ff6e78bb70012ce668 100644 --- a/tests/BuilderBagTest.php +++ b/tests/BuilderBagTest.php @@ -32,7 +32,6 @@ class BuilderBagTest extends \PHPUnit_Framework_TestCase */ public function testRemove() { - $bag = new BuilderBag(); $fooBuilder = $this->getBuilder('foo'); $acmeBuilder = $this->getBuilder('acme'); diff --git a/tests/SearchEndpoint/AggregationsEndpointTest.php b/tests/SearchEndpoint/AggregationsEndpointTest.php index 510421b7b5ece916e1ca8bce1ba4a721a6b8c1cb..8a618dd4284fcb9d584d740e36989c0dfe5c7377 100644 --- a/tests/SearchEndpoint/AggregationsEndpointTest.php +++ b/tests/SearchEndpoint/AggregationsEndpointTest.php @@ -30,6 +30,9 @@ class AggregationsEndpointTest extends \PHPUnit_Framework_TestCase ); } + /** + * Tests if endpoint returns builders. + */ public function testEndpointGetter() { $aggName = 'acme_agg'; diff --git a/tests/SearchEndpoint/FilterEndpointTest.php b/tests/SearchEndpoint/FilterEndpointTest.php index 69d2921b52995fffdf725a659cfb01a32eb33b72..814fbd17853f45965dd3bbbfeca28bd19ba4d9aa 100644 --- a/tests/SearchEndpoint/FilterEndpointTest.php +++ b/tests/SearchEndpoint/FilterEndpointTest.php @@ -67,6 +67,9 @@ class FilterEndpointTest extends \PHPUnit_Framework_TestCase $this->assertSame($matchAllFilter, $reference->getFilter()); } + /** + * Tests if endpoint returns builders. + */ public function testEndpointGetter() { $filterName = 'acme_filter'; diff --git a/tests/SearchEndpoint/HighlightEndpointTest.php b/tests/SearchEndpoint/HighlightEndpointTest.php index 85200ae0141b5f7aaec125f275a061ac0537fcf2..ff5e44f868beed2710cb14ea7d5ee2c1c50cedd1 100644 --- a/tests/SearchEndpoint/HighlightEndpointTest.php +++ b/tests/SearchEndpoint/HighlightEndpointTest.php @@ -52,6 +52,9 @@ class HighlightEndpointTest extends \PHPUnit_Framework_TestCase ); } + /** + * Tests if endpoint returns builders. + */ public function testEndpointGetter() { $highlightName = 'acme_highlight'; diff --git a/tests/SearchEndpoint/PostFilterEndpointTest.php b/tests/SearchEndpoint/PostFilterEndpointTest.php index 3490ba7b6b7d7b1c0fe938afc8d9d3f8723a8e1f..75236a108edb30d8d6063be693400ede10bd613d 100644 --- a/tests/SearchEndpoint/PostFilterEndpointTest.php +++ b/tests/SearchEndpoint/PostFilterEndpointTest.php @@ -59,6 +59,9 @@ class PostFilterEndpointTest extends \PHPUnit_Framework_TestCase ); } + /** + * Tests if endpoint returns builders. + */ public function testEndpointGetter() { $filterName = 'acme_post_filter'; diff --git a/tests/SearchEndpoint/QueryEndpointTest.php b/tests/SearchEndpoint/QueryEndpointTest.php index 0a17c703c7e51c891c19ee29d8ec909f9574ab57..71dfd090cc94e1d1915b8aca15294597d4c54535 100644 --- a/tests/SearchEndpoint/QueryEndpointTest.php +++ b/tests/SearchEndpoint/QueryEndpointTest.php @@ -60,6 +60,9 @@ class QueryEndpointTest extends \PHPUnit_Framework_TestCase ); } + /** + * Tests if endpoint returns builders. + */ public function testEndpointGetter() { $queryName = 'acme_query'; diff --git a/tests/SearchEndpoint/SortEndpointTest.php b/tests/SearchEndpoint/SortEndpointTest.php index c34758347fc84fc81da32c54264971496e8f3956..5f21c9db28d6fc759635421f3249416e4f3594cb 100644 --- a/tests/SearchEndpoint/SortEndpointTest.php +++ b/tests/SearchEndpoint/SortEndpointTest.php @@ -50,6 +50,9 @@ class SortEndpointTest extends \PHPUnit_Framework_TestCase ); } + /** + * Tests if endpoint returns builders. + */ public function testEndpointGetter() { $sortName = 'acme_sort';