diff --git a/.php_cs b/.php_cs index 3e33866b96..1e006d07a1 100644 --- a/.php_cs +++ b/.php_cs @@ -1,32 +1,26 @@ in(['lib', 'test']); +$finder = PhpCsFixer\Finder::create() + ->exclude(['vendor', 'var']) + ->in([__DIR__]) +; -$config = Symfony\CS\Config\Config::create() - ->setUsingCache(true) - ->level(Symfony\CS\FixerInterface::SYMFONY_LEVEL) - ->fixers([ - // [contrib] Multi-line whitespace before closing semicolon are prohibited. - 'multiline_spaces_before_semicolon', - // [contrib] There should be no blank lines before a namespace declaration. - 'no_blank_lines_before_namespace', - // [contrib] Ordering use statements. - 'ordered_use', - // [contrib] Annotations should be ordered so that param annotations come first, then throws annotations, then return annotations. - 'phpdoc_order', - // [contrib] Arrays should use the short syntax. - 'short_array_syntax', - // [contrib] Ensure there is no code on the same line as the PHP open tag. - 'newline_after_open_tag', - // [contrib] Use null coalescing operator ?? where possible - 'ternary_to_null_coalescing', - // [contrib] There should not be useless else cases. - 'no_useless_else', - // [contrib] Use dedicated PHPUnit assertions for better error messages. +$config = PhpCsFixer\Config::create() + ->setFinder($finder) + ->setRules([ + '@PSR2' => true, + '@Symfony' => true, + 'psr0' => false, + 'single_blank_line_before_namespace' => false, + 'ordered_imports' => true, + 'array_syntax' => ['syntax' => 'short'], + 'phpdoc_order' => true, + 'blank_line_after_namespace' => true, + 'ternary_to_null_coalescing' => true, + 'no_useless_else' => true, '@PHPUnit60Migration:risky' => true, - //'php_unit_dedicate_assert' => ['target' => 'newest'], + 'php_unit_dedicate_assert' => ['target' => 'newest'], ]) - ->finder($finder); +; return $config; diff --git a/.travis.yml b/.travis.yml index b08b5ed05b..2c0a5a3d12 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,6 +20,7 @@ env: - TARGET="71" - TARGET="72" - TARGET="73" + - TARGET="Lint" before_install: # check running "docker engine" and "docker-compose" version on travis @@ -41,7 +42,8 @@ before_script: - sudo sysctl -w vm.max_map_count=262144 script: - - make tests TARGET=$TARGET + - if [ "$TARGET" != "Lint" ] ; then make tests TARGET=$TARGET ; fi + - if [ "$TARGET" == "Lint" ] ; then make check-style ; fi after_script: - cat /var/log/elasticsearch/*.log diff --git a/CHANGELOG.md b/CHANGELOG.md index 85c53afe0b..c10815f692 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ All notable changes to this project will be documented in this file based on the * Added `BucketSelector` aggregation [#1554](https://github.com/ruflin/Elastica/pull/1554) * Added `DerivativeAggregation` [#1553](https://github.com/ruflin/Elastica/pull/1553) * The preferred type name is [_doc](https://www.elastic.co/guide/en/elasticsearch/reference/6.5/removal-of-types.html), so that index APIs have the same path as they will have in 7.0 +* Introduced new version of PHP-CS-Fixer and new Lint travis step. [#1555](https://github.com/ruflin/Elastica/pull/1555) ### Improvements diff --git a/Makefile b/Makefile index 132df1b257..2a70f37564 100644 --- a/Makefile +++ b/Makefile @@ -61,7 +61,7 @@ tests: make start mkdir -p build - docker run -e "ES_HOST=elasticsearch" --network=elastica_esnet elastica_elastica make phpunit + docker run -e "ES_HOST=elasticsearch" --network=elastica_esnet elastica_elastica make phpunit docker cp elastica:/elastica/build/coverage/ $(shell pwd)/build/coverage # Makes it easy to run a single test file. Example to run IndexTest.php: make test TEST="IndexTest.php" @@ -79,7 +79,16 @@ doc: # Uses the preconfigured standards in .php_cs .PHONY: lint lint: - ${RUN_ENV} php-cs-fixer fix + ${RUN_ENV} php-cs-fixer fix --allow-risky=yes + +.PHONY: check-style +check-style: + docker build -t ruflin/elastica-dev-base -f env/elastica/${TARGET} env/elastica/ + docker build -t ruflin/elastica . + make start + mkdir -p build + + ${RUN_ENV} php-cs-fixer fix --allow-risky=yes --dry-run .PHONY: loc loc: diff --git a/env/elastica/Lint b/env/elastica/Lint new file mode 100644 index 0000000000..174c980e17 --- /dev/null +++ b/env/elastica/Lint @@ -0,0 +1,39 @@ +# This image is the base image for the Elastica development and includes all parts which rarely change +# PHP 7 Docker file with Composer installed +FROM php:7.2 +MAINTAINER Nicolas Ruflin + +RUN apt-get update && apt-get install -y \ + cloc \ + git \ + graphviz \ + libxslt-dev \ + nano \ + zip unzip \ + wget + # XSL and Graphviz for PhpDocumentor + +RUN docker-php-ext-install sockets xsl + +RUN rm -r /var/lib/apt/lists/* + +# Xdebug for coverage report +RUN pecl install xdebug-2.6.1 + +RUN echo "memory_limit=1024M" >> /usr/local/etc/php/conf.d/memory-limit.ini +RUN echo "date.timezone=UTC" >> /usr/local/etc/php/conf.d/timezone.ini + +# Install and setup composer +RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer +ENV COMPOSER_HOME /root/composer + +# Add composer bin to the environment +ENV PATH=/root/composer/vendor/bin:$PATH + +COPY composer.json /root/composer/ + +RUN composer global remove --no-update phpdocumentor/phpdocumentor -vvv +RUN composer global require --no-update friendsofphp/php-cs-fixer:^2.0 + +# Install development tools, prefer source removed as automatic fallback now +RUN composer global install -vvv diff --git a/env/elastica/composer.json b/env/elastica/composer.json index c81eedf960..705b90c6ed 100644 --- a/env/elastica/composer.json +++ b/env/elastica/composer.json @@ -14,7 +14,6 @@ "require": { "php": "^7.0", "phpdocumentor/phpdocumentor": "^2.9", - "fabpot/php-cs-fixer": "1.11.*", "mayflower/php-codebrowser": "~1.1", "pdepend/pdepend": "^2.5", "phploc/phploc": "^4.0", @@ -23,4 +22,4 @@ "sebastian/phpcpd": "~3.0", "squizlabs/php_codesniffer": "~3.3" } -} \ No newline at end of file +} diff --git a/lib/Elastica/AbstractUpdateAction.php b/lib/Elastica/AbstractUpdateAction.php index bef05d3e01..d81abd3065 100644 --- a/lib/Elastica/AbstractUpdateAction.php +++ b/lib/Elastica/AbstractUpdateAction.php @@ -1,4 +1,5 @@ setBucketsPath($bucketsPath); } } diff --git a/lib/Elastica/Aggregation/BucketScript.php b/lib/Elastica/Aggregation/BucketScript.php index f36bd2e707..945222f182 100644 --- a/lib/Elastica/Aggregation/BucketScript.php +++ b/lib/Elastica/Aggregation/BucketScript.php @@ -1,4 +1,5 @@ setBucketsPath($bucketsPath); } - if ($script !== null) { + if (null !== $script) { $this->setScript($script); } } diff --git a/lib/Elastica/Aggregation/BucketSelector.php b/lib/Elastica/Aggregation/BucketSelector.php index ff19e8ef95..29f42e05ac 100644 --- a/lib/Elastica/Aggregation/BucketSelector.php +++ b/lib/Elastica/Aggregation/BucketSelector.php @@ -1,9 +1,11 @@ setBucketsPath($bucketsPath); } - if ($script !== null) { + if (null !== $script) { $this->setScript($script); } } @@ -49,4 +51,3 @@ public function setGapPolicy(string $gapPolicy = 'skip') return $this->setParam('gap_policy', $gapPolicy); } } - diff --git a/lib/Elastica/Aggregation/Cardinality.php b/lib/Elastica/Aggregation/Cardinality.php index 2332f8395b..a7a467a651 100644 --- a/lib/Elastica/Aggregation/Cardinality.php +++ b/lib/Elastica/Aggregation/Cardinality.php @@ -1,10 +1,11 @@ setBucketsPath($bucketsPath); } } diff --git a/lib/Elastica/Aggregation/ExtendedStats.php b/lib/Elastica/Aggregation/ExtendedStats.php index c5a1b6e38c..9158bf2982 100644 --- a/lib/Elastica/Aggregation/ExtendedStats.php +++ b/lib/Elastica/Aggregation/ExtendedStats.php @@ -1,10 +1,11 @@ setFilter($filter); } } diff --git a/lib/Elastica/Aggregation/Filters.php b/lib/Elastica/Aggregation/Filters.php index 5d21a8d76f..ab3fc0b1dd 100644 --- a/lib/Elastica/Aggregation/Filters.php +++ b/lib/Elastica/Aggregation/Filters.php @@ -1,4 +1,5 @@ setPath($path); } } diff --git a/lib/Elastica/Aggregation/ScriptedMetric.php b/lib/Elastica/Aggregation/ScriptedMetric.php index ec2aa86575..4a41b0b04c 100644 --- a/lib/Elastica/Aggregation/ScriptedMetric.php +++ b/lib/Elastica/Aggregation/ScriptedMetric.php @@ -1,10 +1,11 @@ setBucketsPath($bucketsPath); } } diff --git a/lib/Elastica/Aggregation/SignificantTerms.php b/lib/Elastica/Aggregation/SignificantTerms.php index ff8e5565cc..6db3c4250b 100644 --- a/lib/Elastica/Aggregation/SignificantTerms.php +++ b/lib/Elastica/Aggregation/SignificantTerms.php @@ -1,4 +1,5 @@ setBucketsPath($bucketsPath); } } diff --git a/lib/Elastica/Aggregation/Sum.php b/lib/Elastica/Aggregation/Sum.php index 490093606b..3fcda1cf2c 100644 --- a/lib/Elastica/Aggregation/Sum.php +++ b/lib/Elastica/Aggregation/Sum.php @@ -1,10 +1,11 @@ setBucketsPath($bucketsPath); } } diff --git a/lib/Elastica/Aggregation/Terms.php b/lib/Elastica/Aggregation/Terms.php index b3a4afcafb..25bf3141b5 100644 --- a/lib/Elastica/Aggregation/Terms.php +++ b/lib/Elastica/Aggregation/Terms.php @@ -1,10 +1,11 @@ |"_count"|"_term" => ] definitions. + * @param array $orders a list of [|"_count"|"_term" => ] definitions * * @return $this */ diff --git a/lib/Elastica/Aggregation/TopHits.php b/lib/Elastica/Aggregation/TopHits.php index 8dd6a52d31..69e790e15c 100644 --- a/lib/Elastica/Aggregation/TopHits.php +++ b/lib/Elastica/Aggregation/TopHits.php @@ -1,4 +1,5 @@ _bulkResponses[$this->key()]; } - /** - */ public function next() { ++$this->_position; @@ -125,8 +124,6 @@ public function valid() return isset($this->_bulkResponses[$this->key()]); } - /** - */ public function rewind() { $this->_position = 0; diff --git a/lib/Elastica/Client.php b/lib/Elastica/Client.php index e41265c357..4fe826440a 100644 --- a/lib/Elastica/Client.php +++ b/lib/Elastica/Client.php @@ -1,4 +1,5 @@ _config['connectionStrategy'])) { - if ($this->getConfig('roundRobin') === true) { + if (true === $this->getConfig('roundRobin')) { $this->setConfigValue('connectionStrategy', 'RoundRobin'); } else { $this->setConfigValue('connectionStrategy', 'Simple'); @@ -303,7 +304,7 @@ public function removeHeader($header) * set inside the document, because for bulk settings documents, * documents can belong to any type and index * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html * * @param array|\Elastica\Document[] $docs Array of Elastica\Document * @param array $requestParams @@ -335,7 +336,7 @@ public function updateDocuments(array $docs, array $requestParams = []) * set inside the document, because for bulk settings documents, * documents can belong to any type and index * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html * * @param array|\Elastica\Document[] $docs Array of Elastica\Document * @param array $requestParams @@ -372,7 +373,7 @@ public function addDocuments(array $docs, array $requestParams = []) * * @return \Elastica\Response * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update.html */ public function updateDocument($id, $data, $index, $type, array $options = []) { @@ -594,7 +595,7 @@ public function setConnections(array $connections) /** * Deletes documents with the given ids, index, type from the index. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html * * @param array $ids Document ids * @param string|\Elastica\Index $index Index name @@ -641,7 +642,7 @@ public function deleteIds(array $ids, $index, $type, $routing = false) * array('delete' => array('_index' => 'test', '_type' => 'user', '_id' => '2')) * ); * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html * * @param array $params Parameter array * @@ -763,7 +764,7 @@ protected function _log($context) * @return \Elastica\Response Response object * * @deprecated Replaced by forcemergeAll - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-optimize.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-optimize.html */ public function optimizeAll($args = []) { @@ -779,7 +780,7 @@ public function optimizeAll($args = []) * * @return \Elastica\Response Response object * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-forcemerge.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-forcemerge.html */ public function forcemergeAll($args = []) { @@ -794,7 +795,7 @@ public function forcemergeAll($args = []) * * @return \Elastica\Response Response object * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-refresh.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-refresh.html */ public function refreshAll() { diff --git a/lib/Elastica/Cluster.php b/lib/Elastica/Cluster.php index acf28f7e04..c800f6f69d 100644 --- a/lib/Elastica/Cluster.php +++ b/lib/Elastica/Cluster.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster.html */ class Cluster { @@ -81,7 +82,7 @@ public function getIndexNames() * * @return array State array * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-state.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-state.html */ public function getState() { @@ -134,7 +135,7 @@ public function getClient() /** * Returns the cluster information (not implemented yet). * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-nodes-info.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-nodes-info.html * * @param array $args Additional arguments * @@ -148,7 +149,7 @@ public function getInfo(array $args) /** * Return Cluster health. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-health.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-health.html * * @return \Elastica\Cluster\Health */ diff --git a/lib/Elastica/Cluster/Health.php b/lib/Elastica/Cluster/Health.php index e247021c37..ed4335de59 100644 --- a/lib/Elastica/Cluster/Health.php +++ b/lib/Elastica/Cluster/Health.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-health.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-health.html */ class Health { /** - * @var \Elastica\Client Client object. + * @var \Elastica\Client client object */ protected $_client; /** - * @var array The cluster health data. + * @var array the cluster health data */ protected $_data; /** - * @param \Elastica\Client $client The Elastica client. + * @param \Elastica\Client $client the Elastica client */ public function __construct(Client $client) { @@ -82,7 +83,7 @@ public function getClusterName() /** * Gets the status of the cluster. * - * @return string green, yellow or red. + * @return string green, yellow or red */ public function getStatus() { diff --git a/lib/Elastica/Cluster/Health/Index.php b/lib/Elastica/Cluster/Health/Index.php index e8a77cf6d0..862702afc3 100644 --- a/lib/Elastica/Cluster/Health/Index.php +++ b/lib/Elastica/Cluster/Health/Index.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-health.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-health.html */ class Index { /** - * @var string The name of the index. + * @var string the name of the index */ protected $_name; /** - * @var array The index health data. + * @var array the index health data */ protected $_data; /** - * @param string $name The name of the index. - * @param array $data The index health data. + * @param string $name the name of the index + * @param array $data the index health data */ public function __construct($name, $data) { @@ -43,7 +44,7 @@ public function getName() /** * Gets the status of the index. * - * @return string green, yellow or red. + * @return string green, yellow or red */ public function getStatus() { diff --git a/lib/Elastica/Cluster/Health/Shard.php b/lib/Elastica/Cluster/Health/Shard.php index 08933eea1e..ec53a604f6 100644 --- a/lib/Elastica/Cluster/Health/Shard.php +++ b/lib/Elastica/Cluster/Health/Shard.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-health.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-health.html */ class Shard { /** - * @var int The shard index/number. + * @var int the shard index/number */ protected $_shardNumber; /** - * @var array The shard health data. + * @var array the shard health data */ protected $_data; /** - * @param int $shardNumber The shard index/number. - * @param array $data The shard health data. + * @param int $shardNumber the shard index/number + * @param array $data the shard health data */ public function __construct($shardNumber, $data) { @@ -43,7 +44,7 @@ public function getShardNumber() /** * Gets the status of this shard. * - * @return string green, yellow or red. + * @return string green, yellow or red */ public function getStatus() { @@ -67,7 +68,7 @@ public function isPrimaryActive() */ public function isActive() { - return $this->_data['active_shards'] == 1; + return 1 == $this->_data['active_shards']; } /** @@ -77,7 +78,7 @@ public function isActive() */ public function isRelocating() { - return $this->_data['relocating_shards'] == 1; + return 1 == $this->_data['relocating_shards']; } /** @@ -87,7 +88,7 @@ public function isRelocating() */ public function isInitialized() { - return $this->_data['initializing_shards'] == 1; + return 1 == $this->_data['initializing_shards']; } /** @@ -97,6 +98,6 @@ public function isInitialized() */ public function isUnassigned() { - return $this->_data['unassigned_shards'] == 1; + return 1 == $this->_data['unassigned_shards']; } } diff --git a/lib/Elastica/Cluster/Settings.php b/lib/Elastica/Cluster/Settings.php index 6ea8f9e1f3..aebb71b627 100644 --- a/lib/Elastica/Cluster/Settings.php +++ b/lib/Elastica/Cluster/Settings.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-update-settings.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-update-settings.html */ class Settings { @@ -82,7 +83,7 @@ public function getTransient($setting = '') return $settings[$setting]; } - if (strpos($setting, '.') !== false) { + if (false !== strpos($setting, '.')) { // convert dot notation to nested arrays $keys = explode('.', $setting); foreach ($keys as $key) { diff --git a/lib/Elastica/Connection.php b/lib/Elastica/Connection.php index bbaa378fdb..aabd07f5ac 100644 --- a/lib/Elastica/Connection.php +++ b/lib/Elastica/Connection.php @@ -1,4 +1,5 @@ _exception = $this->_extractException($errors[0]); } else { - if ($this->_extractException($errors[0]) == self::REMOTE_TRANSPORT_EXCEPTION) { + if (self::REMOTE_TRANSPORT_EXCEPTION == $this->_extractException($errors[0])) { $this->_isRemote = true; $this->_exception = $this->_extractException($errors[1]); } else { diff --git a/lib/Elastica/Exception/ExceptionInterface.php b/lib/Elastica/Exception/ExceptionInterface.php index 02f43092a6..0504a1d14a 100644 --- a/lib/Elastica/Exception/ExceptionInterface.php +++ b/lib/Elastica/Exception/ExceptionInterface.php @@ -1,4 +1,5 @@ requestEndpoint(new Exists()); - return $response->getStatus() === 200; + return 200 === $response->getStatus(); } /** @@ -385,7 +386,7 @@ public function count($query = '') * * @return \Elastica\Response Response object * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-open-close.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-open-close.html */ public function open() { @@ -397,7 +398,7 @@ public function open() * * @return \Elastica\Response Response object * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-open-close.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-open-close.html */ public function close() { @@ -432,7 +433,7 @@ public function getClient() * * @return \Elastica\Response Response * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html */ public function addAlias($name, $replace = false) { @@ -460,7 +461,7 @@ public function addAlias($name, $replace = false) * * @return \Elastica\Response Response * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html */ public function removeAlias($name) { @@ -511,7 +512,7 @@ public function hasAlias($name) * * @return \Elastica\Response Response object * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-clearcache.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-clearcache.html */ public function clearCache() { @@ -526,7 +527,7 @@ public function clearCache() * * @return Response Response object * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-flush.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-flush.html */ public function flush(array $options = []) { @@ -543,7 +544,7 @@ public function flush(array $options = []) * * @return \Elastica\Response Response object * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-update-settings.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-update-settings.html */ public function setSettings(array $data) { @@ -595,7 +596,7 @@ public function requestEndpoint(AbstractEndpoint $endpoint) * * @return array Server response * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-analyze.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-analyze.html */ public function analyze(array $body, $args = []) { diff --git a/lib/Elastica/Index/Recovery.php b/lib/Elastica/Index/Recovery.php index 916fd89d69..abe05bfd8b 100644 --- a/lib/Elastica/Index/Recovery.php +++ b/lib/Elastica/Index/Recovery.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-recovery.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-recovery.html */ class Recovery { diff --git a/lib/Elastica/Index/Settings.php b/lib/Elastica/Index/Settings.php index 984247230e..e593dd0bca 100644 --- a/lib/Elastica/Index/Settings.php +++ b/lib/Elastica/Index/Settings.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-update-settings.html - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/index-modules-merge.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-update-settings.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/index-modules-merge.html */ class Settings { @@ -67,7 +68,7 @@ public function __construct(BaseIndex $index) * * @return array|string|null Settings data * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-update-settings.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-update-settings.html */ public function get($setting = '') { @@ -87,23 +88,22 @@ public function get($setting = '') if (isset($settings[$setting])) { return $settings[$setting]; - } else { - if (strpos($setting, '.') !== false) { - // translate old dot-notation settings to nested arrays - $keys = explode('.', $setting); - foreach ($keys as $key) { - if (isset($settings[$key])) { - $settings = $settings[$key]; - } else { - return; - } + } + if (false !== strpos($setting, '.')) { + // translate old dot-notation settings to nested arrays + $keys = explode('.', $setting); + foreach ($keys as $key) { + if (isset($settings[$key])) { + $settings = $settings[$key]; + } else { + return; } - - return $settings; } - return; + return $settings; } + + return; } /** @@ -239,7 +239,7 @@ public function getBlocksMetadata() try { return $this->getBool('blocks.metadata'); } catch (ResponseException $e) { - if ($e->getResponse()->getFullError()['type'] === 'cluster_block_exception') { + if ('cluster_block_exception' === $e->getResponse()->getFullError()['type']) { return true; } @@ -302,7 +302,7 @@ public function getRefreshInterval() * * @return \Elastica\Response * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/index-modules-merge.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/index-modules-merge.html */ public function setMergePolicy($key, $value) { @@ -320,7 +320,7 @@ public function setMergePolicy($key, $value) * * @return string Refresh interval * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/index-modules-merge.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/index-modules-merge.html */ public function getMergePolicy($key) { diff --git a/lib/Elastica/Index/Stats.php b/lib/Elastica/Index/Stats.php index e2d5257b90..ee1c431ee7 100644 --- a/lib/Elastica/Index/Stats.php +++ b/lib/Elastica/Index/Stats.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-stats.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-stats.html */ class Stats { diff --git a/lib/Elastica/IndexTemplate.php b/lib/Elastica/IndexTemplate.php index 1864f97d9e..1b37c8e4e2 100644 --- a/lib/Elastica/IndexTemplate.php +++ b/lib/Elastica/IndexTemplate.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html */ class IndexTemplate { @@ -59,7 +60,7 @@ public function delete() /** * Creates a new index template with the given arguments. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html * * @param array $args OPTIONAL Arguments to use * @@ -79,7 +80,7 @@ public function exists() { $response = $this->request(Request::HEAD); - return $response->getStatus() === 200; + return 200 === $response->getStatus(); } /** diff --git a/lib/Elastica/JSON.php b/lib/Elastica/JSON.php index b9caaad5d3..47754cb91f 100644 --- a/lib/Elastica/JSON.php +++ b/lib/Elastica/JSON.php @@ -1,4 +1,5 @@ _resultSets[$this->key()]; } - /** - */ public function next() { ++$this->_position; @@ -109,8 +108,6 @@ public function valid() return isset($this->_resultSets[$this->key()]); } - /** - */ public function rewind() { $this->_position = 0; @@ -127,7 +124,7 @@ public function count() /** * @param string|int $offset * - * @return bool true on success or false on failure. + * @return bool true on success or false on failure */ public function offsetExists($offset) { @@ -137,7 +134,7 @@ public function offsetExists($offset) /** * @param mixed $offset * - * @return mixed Can return all value types. + * @return mixed can return all value types */ public function offsetGet($offset) { diff --git a/lib/Elastica/Multi/Search.php b/lib/Elastica/Multi/Search.php index 424ba9a97d..4cf132e32f 100644 --- a/lib/Elastica/Multi/Search.php +++ b/lib/Elastica/Multi/Search.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-status.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-status.html */ class Info { @@ -119,7 +120,7 @@ public function getIp() * * @return array plugin data * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-nodes-info.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-nodes-info.html */ public function getPlugins() { diff --git a/lib/Elastica/Node/Stats.php b/lib/Elastica/Node/Stats.php index 85134de00d..0c7e673348 100644 --- a/lib/Elastica/Node/Stats.php +++ b/lib/Elastica/Node/Stats.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-status.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-status.html */ class Stats { diff --git a/lib/Elastica/Param.php b/lib/Elastica/Param.php index b8ea4f358b..0c765eb0b3 100644 --- a/lib/Elastica/Param.php +++ b/lib/Elastica/Param.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ingest-processors.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ingest-processors.html */ class Pipeline extends Param { @@ -54,7 +55,7 @@ public function __construct(Client $client) * * @return Response * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/put-pipeline-api.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/put-pipeline-api.html */ public function create() { @@ -84,7 +85,7 @@ public function create() * * @return Response * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/get-pipeline-api.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/get-pipeline-api.html */ public function getPipeline(string $id) { @@ -101,7 +102,7 @@ public function getPipeline(string $id) * * @return Response * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-pipeline-api.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-pipeline-api.html */ public function deletePipeline(string $id) { diff --git a/lib/Elastica/Processor/AbstractProcessor.php b/lib/Elastica/Processor/AbstractProcessor.php index f301708d30..7bcd89ee1a 100644 --- a/lib/Elastica/Processor/AbstractProcessor.php +++ b/lib/Elastica/Processor/AbstractProcessor.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ingest-processors.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ingest-processors.html */ abstract class AbstractProcessor extends Param { diff --git a/lib/Elastica/Processor/Append.php b/lib/Elastica/Processor/Append.php index 43a48de6fa..a869ba80c4 100644 --- a/lib/Elastica/Processor/Append.php +++ b/lib/Elastica/Processor/Append.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/append-processor.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/append-processor.html */ class Append extends AbstractProcessor { diff --git a/lib/Elastica/Processor/Attachment.php b/lib/Elastica/Processor/Attachment.php index 40f90b0184..5f5d8b1a6e 100644 --- a/lib/Elastica/Processor/Attachment.php +++ b/lib/Elastica/Processor/Attachment.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/append-processor.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/append-processor.html */ class Convert extends AbstractProcessor { diff --git a/lib/Elastica/Processor/Date.php b/lib/Elastica/Processor/Date.php index a2eea3c2c1..6847f24fa8 100644 --- a/lib/Elastica/Processor/Date.php +++ b/lib/Elastica/Processor/Date.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/date-processor.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/date-processor.html */ class Date extends AbstractProcessor { diff --git a/lib/Elastica/Processor/DateIndexName.php b/lib/Elastica/Processor/DateIndexName.php index 0ac111641d..749db94be1 100644 --- a/lib/Elastica/Processor/DateIndexName.php +++ b/lib/Elastica/Processor/DateIndexName.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/date-index-name-processor.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/date-index-name-processor.html */ class DateIndexName extends AbstractProcessor { diff --git a/lib/Elastica/Processor/DotExpander.php b/lib/Elastica/Processor/DotExpander.php index d8b7f8ff9a..458b68a336 100644 --- a/lib/Elastica/Processor/DotExpander.php +++ b/lib/Elastica/Processor/DotExpander.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/dot-expand-processor.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/dot-expand-processor.html */ class DotExpander extends AbstractProcessor { diff --git a/lib/Elastica/Processor/Fail.php b/lib/Elastica/Processor/Fail.php index 0b5eecdc67..acb92158a6 100644 --- a/lib/Elastica/Processor/Fail.php +++ b/lib/Elastica/Processor/Fail.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/fail-processor.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/fail-processor.html */ class Fail extends AbstractProcessor { diff --git a/lib/Elastica/Processor/Join.php b/lib/Elastica/Processor/Join.php index aa8b24ed64..1f1115be28 100644 --- a/lib/Elastica/Processor/Join.php +++ b/lib/Elastica/Processor/Join.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/join-processor.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/join-processor.html */ class Join extends AbstractProcessor { diff --git a/lib/Elastica/Processor/Json.php b/lib/Elastica/Processor/Json.php index f2601b3246..efcc8c5338 100644 --- a/lib/Elastica/Processor/Json.php +++ b/lib/Elastica/Processor/Json.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/json-processor.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/json-processor.html */ class Json extends AbstractProcessor { diff --git a/lib/Elastica/Processor/Kv.php b/lib/Elastica/Processor/Kv.php index 0c54b35713..07935f1117 100644 --- a/lib/Elastica/Processor/Kv.php +++ b/lib/Elastica/Processor/Kv.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/kv-processor.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/kv-processor.html */ class Kv extends AbstractProcessor { diff --git a/lib/Elastica/Processor/Lowercase.php b/lib/Elastica/Processor/Lowercase.php index e34e0c139c..8e2cb9e0f8 100644 --- a/lib/Elastica/Processor/Lowercase.php +++ b/lib/Elastica/Processor/Lowercase.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/lowercase-processor.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/lowercase-processor.html */ class Lowercase extends AbstractProcessor { diff --git a/lib/Elastica/Processor/Remove.php b/lib/Elastica/Processor/Remove.php index 07a4fe6493..dc6d853efd 100644 --- a/lib/Elastica/Processor/Remove.php +++ b/lib/Elastica/Processor/Remove.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/remove-processor.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/remove-processor.html */ class Remove extends AbstractProcessor { diff --git a/lib/Elastica/Processor/Rename.php b/lib/Elastica/Processor/Rename.php index 72426216ef..8d697fe60d 100644 --- a/lib/Elastica/Processor/Rename.php +++ b/lib/Elastica/Processor/Rename.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/rename-processor.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/rename-processor.html */ class Rename extends AbstractProcessor { diff --git a/lib/Elastica/Processor/Set.php b/lib/Elastica/Processor/Set.php index 15d95a62ea..b9f3a62213 100644 --- a/lib/Elastica/Processor/Set.php +++ b/lib/Elastica/Processor/Set.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/ingest-processors.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/ingest-processors.html */ class Set extends AbstractProcessor { diff --git a/lib/Elastica/Processor/Sort.php b/lib/Elastica/Processor/Sort.php index 808132b75d..8cdbc5452c 100644 --- a/lib/Elastica/Processor/Sort.php +++ b/lib/Elastica/Processor/Sort.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/sort-processor.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/sort-processor.html */ class Sort extends AbstractProcessor { diff --git a/lib/Elastica/Processor/Split.php b/lib/Elastica/Processor/Split.php index cd4f84a9c9..c65f4361bf 100644 --- a/lib/Elastica/Processor/Split.php +++ b/lib/Elastica/Processor/Split.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/split-processor.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/split-processor.html */ class Split extends AbstractProcessor { diff --git a/lib/Elastica/Processor/Trim.php b/lib/Elastica/Processor/Trim.php index 7389a89146..1de0131a75 100644 --- a/lib/Elastica/Processor/Trim.php +++ b/lib/Elastica/Processor/Trim.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/trim-processor.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/trim-processor.html */ class Trim extends AbstractProcessor { diff --git a/lib/Elastica/Processor/Uppercase.php b/lib/Elastica/Processor/Uppercase.php index 4b54cb187f..53f626fd98 100644 --- a/lib/Elastica/Processor/Uppercase.php +++ b/lib/Elastica/Processor/Uppercase.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/uppercase-processor.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/uppercase-processor.html */ class Uppercase extends AbstractProcessor { diff --git a/lib/Elastica/Query.php b/lib/Elastica/Query.php index 8b4dcdd2fa..6af3ce3c87 100644 --- a/lib/Elastica/Query.php +++ b/lib/Elastica/Query.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-body.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-body.html */ class Query extends Param { @@ -73,7 +74,6 @@ public static function create($query) case $query instanceof Suggest: return new self($query); - } throw new InvalidException('Unexpected argument to create a query for.'); @@ -135,7 +135,7 @@ public function setFrom($from) * * @return $this * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-sort.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-sort.html */ public function setSort(array $sortArgs) { @@ -149,7 +149,7 @@ public function setSort(array $sortArgs) * * @return $this * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-sort.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-sort.html */ public function addSort($sort) { @@ -163,7 +163,7 @@ public function addSort($sort) * * @return $this * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-sort.html#_track_scores + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-sort.html#_track_scores */ public function setTrackScores($trackScores = true) { @@ -177,7 +177,7 @@ public function setTrackScores($trackScores = true) * * @return $this * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-highlighting.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-highlighting.html */ public function setHighlight(array $highlightArgs) { @@ -191,7 +191,7 @@ public function setHighlight(array $highlightArgs) * * @return $this * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-highlighting.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-highlighting.html */ public function addHighlight($highlight) { @@ -217,7 +217,7 @@ public function setSize($size = 10) * * @return $this * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-explain.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-explain.html */ public function setExplain($explain = true) { @@ -231,7 +231,7 @@ public function setExplain($explain = true) * * @return $this * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-version.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-version.html */ public function setVersion($version = true) { @@ -247,7 +247,7 @@ public function setVersion($version = true) * * @return $this * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-fields.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-fields.html */ public function setStoredFields(array $fields) { @@ -261,7 +261,7 @@ public function setStoredFields(array $fields) * * @return $this * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-fielddata-fields.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-fielddata-fields.html */ public function setFieldDataFields(array $fieldDataFields) { @@ -275,7 +275,7 @@ public function setFieldDataFields(array $fieldDataFields) * * @return $this * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-script-fields.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-script-fields.html */ public function setScriptFields($scriptFields) { @@ -326,7 +326,7 @@ public function addAggregation(AbstractAggregation $agg) */ public function toArray() { - if (!isset($this->_params['query']) && ($this->_suggest == 0)) { + if (!isset($this->_params['query']) && (0 == $this->_suggest)) { $this->setQuery(new MatchAll()); } @@ -390,7 +390,7 @@ public function setRescore($rescore) $buffer = []; foreach ($rescore as $rescoreQuery) { - $buffer [] = $rescoreQuery; + $buffer[] = $rescoreQuery; } } else { $buffer = $rescore; @@ -406,7 +406,7 @@ public function setRescore($rescore) * * @return $this * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-source-filtering.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-source-filtering.html */ public function setSource($params) { @@ -420,7 +420,7 @@ public function setSource($params) * * @return $this * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-post-filter.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-post-filter.html */ public function setPostFilter(AbstractQuery $filter) { diff --git a/lib/Elastica/Query/AbstractGeoDistance.php b/lib/Elastica/Query/AbstractGeoDistance.php index ad9ad4c6d1..97b6c3db01 100644 --- a/lib/Elastica/Query/AbstractGeoDistance.php +++ b/lib/Elastica/Query/AbstractGeoDistance.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-distance-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-distance-query.html */ abstract class AbstractGeoDistance extends AbstractQuery { @@ -158,7 +159,7 @@ public function setGeohash($geohash) */ protected function _getLocationData() { - if ($this->_locationType === self::LOCATION_TYPE_LATLON) { // Latitude/longitude + if (self::LOCATION_TYPE_LATLON === $this->_locationType) { // Latitude/longitude $location = []; if (isset($this->_latitude)) { // Latitude @@ -172,7 +173,7 @@ protected function _getLocationData() } else { throw new InvalidException('Longitude has to be set'); } - } elseif ($this->_locationType === self::LOCATION_TYPE_GEOHASH) { // Geohash + } elseif (self::LOCATION_TYPE_GEOHASH === $this->_locationType) { // Geohash $location = $this->_geohash; } else { // Invalid location type throw new InvalidException('Invalid location type'); diff --git a/lib/Elastica/Query/AbstractGeoShape.php b/lib/Elastica/Query/AbstractGeoShape.php index b50c17bab5..f2b9bb7a7f 100644 --- a/lib/Elastica/Query/AbstractGeoShape.php +++ b/lib/Elastica/Query/AbstractGeoShape.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-shape-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-shape-query.html */ abstract class AbstractGeoShape extends AbstractQuery { diff --git a/lib/Elastica/Query/AbstractQuery.php b/lib/Elastica/Query/AbstractQuery.php index fd1c29b0c3..33ead511d7 100644 --- a/lib/Elastica/Query/AbstractQuery.php +++ b/lib/Elastica/Query/AbstractQuery.php @@ -1,4 +1,5 @@ * @author Alessandro Chitolina * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/span-queries.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/span-queries.html */ abstract class AbstractSpanQuery extends AbstractQuery { diff --git a/lib/Elastica/Query/BoolQuery.php b/lib/Elastica/Query/BoolQuery.php index a504243a0a..9876a6ee96 100644 --- a/lib/Elastica/Query/BoolQuery.php +++ b/lib/Elastica/Query/BoolQuery.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html */ class BoolQuery extends AbstractQuery { diff --git a/lib/Elastica/Query/Boosting.php b/lib/Elastica/Query/Boosting.php index 6f02eccf04..cd26446d8c 100644 --- a/lib/Elastica/Query/Boosting.php +++ b/lib/Elastica/Query/Boosting.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-boosting-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-boosting-query.html */ class Boosting extends AbstractQuery { diff --git a/lib/Elastica/Query/Common.php b/lib/Elastica/Query/Common.php index 37fcdecbbc..d6556bbf1d 100644 --- a/lib/Elastica/Query/Common.php +++ b/lib/Elastica/Query/Common.php @@ -1,10 +1,11 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-constant-score-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-constant-score-query.html */ class ConstantScore extends AbstractQuery { diff --git a/lib/Elastica/Query/DisMax.php b/lib/Elastica/Query/DisMax.php index e7cd41e9dc..b3d3c31432 100644 --- a/lib/Elastica/Query/DisMax.php +++ b/lib/Elastica/Query/DisMax.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-dis-max-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-dis-max-query.html */ class DisMax extends AbstractQuery { diff --git a/lib/Elastica/Query/Exists.php b/lib/Elastica/Query/Exists.php index 895cd05885..e9a6b9cbbb 100644 --- a/lib/Elastica/Query/Exists.php +++ b/lib/Elastica/Query/Exists.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-exists-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-exists-query.html */ class Exists extends AbstractQuery { diff --git a/lib/Elastica/Query/FunctionScore.php b/lib/Elastica/Query/FunctionScore.php index 2f4a01fb5f..ed2712d84d 100644 --- a/lib/Elastica/Query/FunctionScore.php +++ b/lib/Elastica/Query/FunctionScore.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-fuzzy-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-fuzzy-query.html */ class Fuzzy extends AbstractQuery { diff --git a/lib/Elastica/Query/GeoBoundingBox.php b/lib/Elastica/Query/GeoBoundingBox.php index 5e7bfc0916..202d0f0314 100644 --- a/lib/Elastica/Query/GeoBoundingBox.php +++ b/lib/Elastica/Query/GeoBoundingBox.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-bounding-box-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-bounding-box-query.html */ class GeoBoundingBox extends AbstractQuery { diff --git a/lib/Elastica/Query/GeoDistance.php b/lib/Elastica/Query/GeoDistance.php index 127db8a6d9..38adc7a721 100644 --- a/lib/Elastica/Query/GeoDistance.php +++ b/lib/Elastica/Query/GeoDistance.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-distance-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-distance-query.html */ class GeoDistance extends AbstractGeoDistance { diff --git a/lib/Elastica/Query/GeoPolygon.php b/lib/Elastica/Query/GeoPolygon.php index ce16cbcd8c..924439072a 100644 --- a/lib/Elastica/Query/GeoPolygon.php +++ b/lib/Elastica/Query/GeoPolygon.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-polygon-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-polygon-query.html */ class GeoPolygon extends AbstractQuery { diff --git a/lib/Elastica/Query/GeoShapePreIndexed.php b/lib/Elastica/Query/GeoShapePreIndexed.php index 6de3165c25..9fdc79f2fb 100644 --- a/lib/Elastica/Query/GeoShapePreIndexed.php +++ b/lib/Elastica/Query/GeoShapePreIndexed.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-shape-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-shape-query.html */ class GeoShapePreIndexed extends AbstractGeoShape { diff --git a/lib/Elastica/Query/GeoShapeProvided.php b/lib/Elastica/Query/GeoShapeProvided.php index 7d6939652e..b807c2176d 100644 --- a/lib/Elastica/Query/GeoShapeProvided.php +++ b/lib/Elastica/Query/GeoShapeProvided.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-shape-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-shape-query.html */ class GeoShapeProvided extends AbstractGeoShape { diff --git a/lib/Elastica/Query/GeohashCell.php b/lib/Elastica/Query/GeohashCell.php index e82bd3276a..8254849fae 100644 --- a/lib/Elastica/Query/GeohashCell.php +++ b/lib/Elastica/Query/GeohashCell.php @@ -1,4 +1,5 @@ 40.3, 'lon' => 45.2] * @param string|int $precision Integer length of geohash prefix or distance (3, or "50m") - * @param bool $neighbors If true, queries cells next to the given cell. + * @param bool $neighbors if true, queries cells next to the given cell */ public function __construct($key, $location, $precision = -1, $neighbors = false) { @@ -38,7 +39,7 @@ public function setPrecision($precision) /** * Set the neighbors option for this query. * - * @param bool $neighbors If true, queries cells next to the given cell. + * @param bool $neighbors if true, queries cells next to the given cell * * @return $this */ diff --git a/lib/Elastica/Query/HasChild.php b/lib/Elastica/Query/HasChild.php index 08e02f2d01..ef63386594 100644 --- a/lib/Elastica/Query/HasChild.php +++ b/lib/Elastica/Query/HasChild.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-has-child-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-has-child-query.html */ class HasChild extends AbstractQuery { diff --git a/lib/Elastica/Query/HasParent.php b/lib/Elastica/Query/HasParent.php index 66e846d66f..600235f184 100644 --- a/lib/Elastica/Query/HasParent.php +++ b/lib/Elastica/Query/HasParent.php @@ -1,4 +1,5 @@ * @author Tim Rupp * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-ids-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-ids-query.html */ class Ids extends AbstractQuery { diff --git a/lib/Elastica/Query/InnerHits.php b/lib/Elastica/Query/InnerHits.php index 71cd2f1c80..705223618e 100644 --- a/lib/Elastica/Query/InnerHits.php +++ b/lib/Elastica/Query/InnerHits.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-inner-hits.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-inner-hits.html */ class InnerHits extends AbstractQuery { diff --git a/lib/Elastica/Query/Limit.php b/lib/Elastica/Query/Limit.php index 1cb1f04e6e..5ef9d5e213 100644 --- a/lib/Elastica/Query/Limit.php +++ b/lib/Elastica/Query/Limit.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-limit-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-limit-query.html */ class Limit extends AbstractQuery { diff --git a/lib/Elastica/Query/Match.php b/lib/Elastica/Query/Match.php index 679db24639..266646a619 100644 --- a/lib/Elastica/Query/Match.php +++ b/lib/Elastica/Query/Match.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query.html */ class Match extends AbstractQuery { @@ -25,7 +26,7 @@ class Match extends AbstractQuery */ public function __construct($field = null, $values = null) { - if ($field !== null && $values !== null) { + if (null !== $field && null !== $values) { $this->setParam($field, $values); } } @@ -125,7 +126,7 @@ public function setFieldBoost($field, $boost = 1.0) * * @return $this * - * @link Possible values for minimum_should_match https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-minimum-should-match.html + * @see Possible values for minimum_should_match https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-minimum-should-match.html */ public function setFieldMinimumShouldMatch($field, $minimumShouldMatch) { diff --git a/lib/Elastica/Query/MatchAll.php b/lib/Elastica/Query/MatchAll.php index 9dcb4da506..0f15bdf2d3 100644 --- a/lib/Elastica/Query/MatchAll.php +++ b/lib/Elastica/Query/MatchAll.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-all-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-all-query.html */ class MatchAll extends AbstractQuery { diff --git a/lib/Elastica/Query/MatchNone.php b/lib/Elastica/Query/MatchNone.php index 952677a649..38a4ebce2e 100644 --- a/lib/Elastica/Query/MatchNone.php +++ b/lib/Elastica/Query/MatchNone.php @@ -1,4 +1,5 @@ * @author Tobias Schultze * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query-phrase.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query-phrase.html */ class MatchPhrase extends AbstractQuery { @@ -17,7 +18,7 @@ class MatchPhrase extends AbstractQuery */ public function __construct($field = null, $values = null) { - if ($field !== null && $values !== null) { + if (null !== $field && null !== $values) { $this->setParam($field, $values); } } diff --git a/lib/Elastica/Query/MatchPhrasePrefix.php b/lib/Elastica/Query/MatchPhrasePrefix.php index e35ccae3c3..81ed1704f7 100644 --- a/lib/Elastica/Query/MatchPhrasePrefix.php +++ b/lib/Elastica/Query/MatchPhrasePrefix.php @@ -1,4 +1,5 @@ * @author Tobias Schultze * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query-phrase-prefix.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query-phrase-prefix.html */ class MatchPhrasePrefix extends MatchPhrase { diff --git a/lib/Elastica/Query/MoreLikeThis.php b/lib/Elastica/Query/MoreLikeThis.php index fc600041b5..db672bfa9c 100644 --- a/lib/Elastica/Query/MoreLikeThis.php +++ b/lib/Elastica/Query/MoreLikeThis.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-mlt-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-mlt-query.html */ class MoreLikeThis extends AbstractQuery { diff --git a/lib/Elastica/Query/MultiMatch.php b/lib/Elastica/Query/MultiMatch.php index 1e8db7d593..bd849be836 100644 --- a/lib/Elastica/Query/MultiMatch.php +++ b/lib/Elastica/Query/MultiMatch.php @@ -1,4 +1,5 @@ * @author Tristan Maindron * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html */ class MultiMatch extends AbstractQuery { diff --git a/lib/Elastica/Query/Nested.php b/lib/Elastica/Query/Nested.php index 69ae7715cc..c99842ab4f 100644 --- a/lib/Elastica/Query/Nested.php +++ b/lib/Elastica/Query/Nested.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-nested-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-nested-query.html */ class Nested extends AbstractQuery { @@ -37,7 +38,7 @@ public function setQuery(AbstractQuery $query) /** * Set score method. * - * @param string $scoreMode Options: avg, total, max and none. + * @param string $scoreMode options: avg, total, max and none * * @return $this */ diff --git a/lib/Elastica/Query/ParentId.php b/lib/Elastica/Query/ParentId.php index a9860f1850..fd0012aaae 100644 --- a/lib/Elastica/Query/ParentId.php +++ b/lib/Elastica/Query/ParentId.php @@ -1,10 +1,11 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/5.0/query-dsl-percolate-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/5.0/query-dsl-percolate-query.html */ /** * Class Percolate. diff --git a/lib/Elastica/Query/Prefix.php b/lib/Elastica/Query/Prefix.php index 939b3e55e2..bc18db0c9f 100644 --- a/lib/Elastica/Query/Prefix.php +++ b/lib/Elastica/Query/Prefix.php @@ -1,10 +1,11 @@ , Jasper van Wanrooy * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html */ class QueryString extends AbstractQuery { diff --git a/lib/Elastica/Query/Range.php b/lib/Elastica/Query/Range.php index 0e2fa07e73..a156294304 100644 --- a/lib/Elastica/Query/Range.php +++ b/lib/Elastica/Query/Range.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-range-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-range-query.html */ class Range extends AbstractQuery { diff --git a/lib/Elastica/Query/Regexp.php b/lib/Elastica/Query/Regexp.php index ab2ecbb9b5..7222fec525 100644 --- a/lib/Elastica/Query/Regexp.php +++ b/lib/Elastica/Query/Regexp.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-regexp-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-regexp-query.html */ class Regexp extends AbstractQuery { diff --git a/lib/Elastica/Query/Script.php b/lib/Elastica/Query/Script.php index 32e82e539e..db3eab5727 100644 --- a/lib/Elastica/Query/Script.php +++ b/lib/Elastica/Query/Script.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-script-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-script-query.html */ class Script extends AbstractQuery { diff --git a/lib/Elastica/Query/Simple.php b/lib/Elastica/Query/Simple.php index 137e28e70a..ddf2b211db 100644 --- a/lib/Elastica/Query/Simple.php +++ b/lib/Elastica/Query/Simple.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-containing-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-containing-query.html */ class SpanContaining extends AbstractSpanQuery { diff --git a/lib/Elastica/Query/SpanFirst.php b/lib/Elastica/Query/SpanFirst.php index 7ec575ee7e..7467602073 100644 --- a/lib/Elastica/Query/SpanFirst.php +++ b/lib/Elastica/Query/SpanFirst.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-first-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-first-query.html */ class SpanFirst extends AbstractSpanQuery { diff --git a/lib/Elastica/Query/SpanMulti.php b/lib/Elastica/Query/SpanMulti.php index 6ed83b449f..20157813e0 100644 --- a/lib/Elastica/Query/SpanMulti.php +++ b/lib/Elastica/Query/SpanMulti.php @@ -1,4 +1,5 @@ * @author Alessandro Chitolina * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-multi-term-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-multi-term-query.html */ class SpanMulti extends AbstractSpanQuery { diff --git a/lib/Elastica/Query/SpanNear.php b/lib/Elastica/Query/SpanNear.php index c3a9072e69..aebc542f9f 100644 --- a/lib/Elastica/Query/SpanNear.php +++ b/lib/Elastica/Query/SpanNear.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-near-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-near-query.html */ class SpanNear extends AbstractSpanQuery { diff --git a/lib/Elastica/Query/SpanNot.php b/lib/Elastica/Query/SpanNot.php index e9fd753b9e..448f614cc0 100644 --- a/lib/Elastica/Query/SpanNot.php +++ b/lib/Elastica/Query/SpanNot.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-not-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-not-query.html */ class SpanNot extends AbstractSpanQuery { diff --git a/lib/Elastica/Query/SpanOr.php b/lib/Elastica/Query/SpanOr.php index 22d155fb68..67113c478a 100644 --- a/lib/Elastica/Query/SpanOr.php +++ b/lib/Elastica/Query/SpanOr.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-term-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-term-query.html */ class SpanOr extends AbstractSpanQuery { diff --git a/lib/Elastica/Query/SpanTerm.php b/lib/Elastica/Query/SpanTerm.php index 608905cc25..155486f357 100644 --- a/lib/Elastica/Query/SpanTerm.php +++ b/lib/Elastica/Query/SpanTerm.php @@ -1,4 +1,5 @@ * @author Marek Hernik * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-term-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-term-query.html */ class SpanTerm extends AbstractSpanQuery { diff --git a/lib/Elastica/Query/SpanWithin.php b/lib/Elastica/Query/SpanWithin.php index af97eec121..707776f233 100644 --- a/lib/Elastica/Query/SpanWithin.php +++ b/lib/Elastica/Query/SpanWithin.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-within-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-within-query.html */ class SpanWithin extends AbstractSpanQuery { diff --git a/lib/Elastica/Query/Term.php b/lib/Elastica/Query/Term.php index da4c2f7379..ef0f0c8b0e 100644 --- a/lib/Elastica/Query/Term.php +++ b/lib/Elastica/Query/Term.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-term-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-term-query.html */ class Term extends AbstractQuery { diff --git a/lib/Elastica/Query/Terms.php b/lib/Elastica/Query/Terms.php index f56f5ef49f..af9a19ad3c 100644 --- a/lib/Elastica/Query/Terms.php +++ b/lib/Elastica/Query/Terms.php @@ -1,4 +1,5 @@ * @author Roberto Nygaard * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-terms-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-terms-query.html */ class Terms extends AbstractQuery { @@ -42,7 +43,7 @@ public function __construct($key = '', array $terms = []) * Sets key and terms for the query. * * @param string $key Terms key - * @param array $terms Terms for the query. + * @param array $terms terms for the query * * @return $this */ @@ -58,7 +59,7 @@ public function setTerms($key, array $terms) * Sets key and terms lookup for the query. * * @param string $key Terms key - * @param array $termsLookup Terms lookup for the query. + * @param array $termsLookup terms lookup for the query * * @return $this */ diff --git a/lib/Elastica/Query/Type.php b/lib/Elastica/Query/Type.php index 8a93c03986..4fc9bb5243 100644 --- a/lib/Elastica/Query/Type.php +++ b/lib/Elastica/Query/Type.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-type-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-type-query.html */ class Type extends AbstractQuery { diff --git a/lib/Elastica/Query/Wildcard.php b/lib/Elastica/Query/Wildcard.php index 0ad85fbb61..f5476d5f5d 100644 --- a/lib/Elastica/Query/Wildcard.php +++ b/lib/Elastica/Query/Wildcard.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-wildcard-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-wildcard-query.html */ class Wildcard extends AbstractQuery { diff --git a/lib/Elastica/QueryBuilder.php b/lib/Elastica/QueryBuilder.php index 7cdc745fc3..45ebe36586 100644 --- a/lib/Elastica/QueryBuilder.php +++ b/lib/Elastica/QueryBuilder.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations.html */ class Aggregation implements DSL { @@ -57,7 +58,7 @@ public function getType() /** * min aggregation. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-min-aggregation.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-min-aggregation.html * * @param string $name * @@ -71,7 +72,7 @@ public function min($name) /** * max aggregation. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-max-aggregation.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-max-aggregation.html * * @param string $name * @@ -85,7 +86,7 @@ public function max($name) /** * sum aggregation. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-sum-aggregation.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-sum-aggregation.html * * @param string $name * @@ -99,7 +100,7 @@ public function sum($name) /** * sum bucket aggregation. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-sum-bucket-aggregation.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-sum-bucket-aggregation.html * * @param string $name * @param string|null $bucketsPath @@ -114,7 +115,7 @@ public function sum_bucket($name, $bucketsPath = null) /** * avg aggregation. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-avg-aggregation.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-avg-aggregation.html * * @param string $name * @@ -128,7 +129,7 @@ public function avg($name) /** * avg bucket aggregation. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-avg-bucket-aggregation.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-avg-bucket-aggregation.html * * @param string $name * @param string|null $bucketsPath @@ -143,7 +144,7 @@ public function avg_bucket($name, $bucketsPath = null) /** * stats aggregation. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-stats-aggregation.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-stats-aggregation.html * * @param string $name * @@ -157,7 +158,7 @@ public function stats($name) /** * extended stats aggregation. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-extendedstats-aggregation.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-extendedstats-aggregation.html * * @param string $name * @@ -171,7 +172,7 @@ public function extended_stats($name) /** * value count aggregation. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-valuecount-aggregation.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-valuecount-aggregation.html * * @param string $name * @param string $field @@ -186,7 +187,7 @@ public function value_count($name, $field) /** * percentiles aggregation. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-percentile-aggregation.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-percentile-aggregation.html * * @param string $name the name of this aggregation * @param string $field the field on which to perform this aggregation @@ -201,7 +202,7 @@ public function percentiles($name, $field = null) /** * percentile ranks aggregation. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-percentile-rank-aggregation.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-percentile-rank-aggregation.html * * @param string $name */ @@ -213,7 +214,7 @@ public function percentile_ranks($name) /** * cardinality aggregation. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-cardinality-aggregation.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-cardinality-aggregation.html * * @param string $name * @@ -227,7 +228,7 @@ public function cardinality($name) /** * geo bounds aggregation. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-geobounds-aggregation.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-geobounds-aggregation.html * * @param string $name */ @@ -239,7 +240,7 @@ public function geo_bounds($name) /** * top hits aggregation. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-top-hits-aggregation.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-top-hits-aggregation.html * * @param string $name * @@ -253,7 +254,7 @@ public function top_hits($name) /** * scripted metric aggregation. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-scripted-metric-aggregation.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-scripted-metric-aggregation.html * * @param string $name * @param string|null $initScript @@ -271,7 +272,7 @@ public function scripted_metric($name, $initScript = null, $mapScript = null, $c /** * global aggregation. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-global-aggregation.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-global-aggregation.html * * @param string $name * @@ -285,7 +286,7 @@ public function global_agg($name) /** * filter aggregation. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-filter-aggregation.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-filter-aggregation.html * * @param string $name * @param AbstractQuery $filter @@ -300,7 +301,7 @@ public function filter($name, AbstractQuery $filter = null) /** * filters aggregation. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-filters-aggregation.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-filters-aggregation.html * * @param string $name * @@ -314,7 +315,7 @@ public function filters($name) /** * missing aggregation. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-missing-aggregation.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-missing-aggregation.html * * @param string $name * @param string $field @@ -329,7 +330,7 @@ public function missing($name, $field) /** * nested aggregation. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-nested-aggregation.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-nested-aggregation.html * * @param string $name * @param string $path the nested path for this aggregation @@ -344,7 +345,7 @@ public function nested($name, $path) /** * reverse nested aggregation. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-reverse-nested-aggregation.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-reverse-nested-aggregation.html * * @param string $name The name of this aggregation * @param string $path Optional path to the nested object for this aggregation. Defaults to the root of the main document. @@ -359,7 +360,7 @@ public function reverse_nested($name, $path = null) /** * children aggregation. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-children-aggregation.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-children-aggregation.html * * @param string $name */ @@ -371,7 +372,7 @@ public function children($name) /** * terms aggregation. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html * * @param string $name * @@ -385,7 +386,7 @@ public function terms($name) /** * significant terms aggregation. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-significantterms-aggregation.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-significantterms-aggregation.html * * @param string $name * @@ -399,7 +400,7 @@ public function significant_terms($name) /** * range aggregation. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-range-aggregation.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-range-aggregation.html * * @param string $name * @@ -413,7 +414,7 @@ public function range($name) /** * date range aggregation. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-daterange-aggregation.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-daterange-aggregation.html * * @param string $name * @@ -427,7 +428,7 @@ public function date_range($name) /** * ipv4 range aggregation. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-iprange-aggregation.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-iprange-aggregation.html * * @param string $name * @param string $field @@ -442,7 +443,7 @@ public function ipv4_range($name, $field) /** * histogram aggregation. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-histogram-aggregation.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-histogram-aggregation.html * * @param string $name the name of this aggregation * @param string $field the name of the field on which to perform the aggregation @@ -458,7 +459,7 @@ public function histogram($name, $field, $interval) /** * date histogram aggregation. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-datehistogram-aggregation.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-datehistogram-aggregation.html * * @param string $name the name of this aggregation * @param string $field the name of the field on which to perform the aggregation @@ -474,7 +475,7 @@ public function date_histogram($name, $field, $interval) /** * geo distance aggregation. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-geodistance-aggregation.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-geodistance-aggregation.html * * @param string $name the name if this aggregation * @param string $field the field on which to perform this aggregation @@ -490,7 +491,7 @@ public function geo_distance($name, $field, $origin) /** * geohash grid aggregation. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-geohashgrid-aggregation.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-geohashgrid-aggregation.html * * @param string $name the name of this aggregation * @param string $field the field on which to perform this aggregation @@ -505,7 +506,7 @@ public function geohash_grid($name, $field) /** * bucket script aggregation. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-bucket-script-aggregation.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-bucket-script-aggregation.html * * @param string $name * @param array|null $bucketsPath @@ -521,7 +522,7 @@ public function bucket_script($name, $bucketsPath = null, $script = null) /** * serial diff aggregation. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-serialdiff-aggregation.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-serialdiff-aggregation.html * * @param string $name * @param string|null $bucketsPath diff --git a/lib/Elastica/QueryBuilder/DSL/Query.php b/lib/Elastica/QueryBuilder/DSL/Query.php index 3ba9d4ec0b..b775f0dbb6 100644 --- a/lib/Elastica/QueryBuilder/DSL/Query.php +++ b/lib/Elastica/QueryBuilder/DSL/Query.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-queries.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-queries.html */ class Query implements DSL { @@ -64,7 +65,7 @@ public function getType() /** * match query. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query.html * * @param string $field * @param mixed $values @@ -79,7 +80,7 @@ public function match($field = null, $values = null) /** * multi match query. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html * * @return \Elastica\Query\MultiMatch */ @@ -91,7 +92,7 @@ public function multi_match() /** * bool query. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html * * @return \Elastica\Query\BoolQuery */ @@ -103,7 +104,7 @@ public function bool() /** * boosting query. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-boosting-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-boosting-query.html * * @return Boosting */ @@ -115,7 +116,7 @@ public function boosting() /** * common terms query. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-common-terms-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-common-terms-query.html * * @param string $field * @param string $query @@ -131,7 +132,7 @@ public function common_terms($field, $query, $cutoffFrequency) /** * constant score query. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-constant-score-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-constant-score-query.html * * @param null|\Elastica\Query\AbstractQuery|array $filter * @@ -145,7 +146,7 @@ public function constant_score($filter = null) /** * dis max query. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-dis-max-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-dis-max-query.html * * @return DisMax */ @@ -157,7 +158,7 @@ public function dis_max() /** * function score query. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html * * @return FunctionScore */ @@ -169,7 +170,7 @@ public function function_score() /** * fuzzy query. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-fuzzy-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-fuzzy-query.html * * @param string $fieldName Field name * @param string $value String to search for @@ -184,7 +185,7 @@ public function fuzzy($fieldName = null, $value = null) /** * geo shape query. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-shape-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-shape-query.html */ public function geo_shape() { @@ -194,7 +195,7 @@ public function geo_shape() /** * has child query. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-has-child-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-has-child-query.html * * @param string|\Elastica\Query|\Elastica\Query\AbstractQuery $query * @param string $type Parent document type @@ -209,7 +210,7 @@ public function has_child($query, $type = null) /** * has parent query. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-has-parent-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-has-parent-query.html * * @param string|\Elastica\Query|\Elastica\Query\AbstractQuery $query * @param string $type Parent document type @@ -224,7 +225,7 @@ public function has_parent($query, $type) /** * ids query. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-ids-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-ids-query.html * * @param array $ids * @@ -238,7 +239,7 @@ public function ids(array $ids = []) /** * match all query. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-all-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-all-query.html * * @return MatchAll */ @@ -250,7 +251,7 @@ public function match_all() /** * match none query. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-all-query.html#query-dsl-match-none-query + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-all-query.html#query-dsl-match-none-query * * @return MatchNone */ @@ -262,7 +263,7 @@ public function match_none() /** * more like this query. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-mlt-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-mlt-query.html * * @return MoreLikeThis */ @@ -274,7 +275,7 @@ public function more_like_this() /** * nested query. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-nested-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-nested-query.html * * @return Nested */ @@ -298,7 +299,7 @@ public function parent_id($type, $id, $ignoreUnmapped = false) /** * prefix query. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-prefix-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-prefix-query.html * * @param array $prefix Prefix array * @@ -312,7 +313,7 @@ public function prefix(array $prefix = []) /** * query string query. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html * * @param string $queryString OPTIONAL Query string for object * @@ -326,7 +327,7 @@ public function query_string($queryString = '') /** * simple_query_string query. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-simple-query-string-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-simple-query-string-query.html * * @param string $query * @param array $fields @@ -341,7 +342,7 @@ public function simple_query_string($query, array $fields = []) /** * range query. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-range-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-range-query.html * * @param string $fieldName * @param array $args @@ -362,7 +363,7 @@ public function range($fieldName = null, array $args = []) * * @return Regexp * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-regexp-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-regexp-query.html */ public function regexp($key = '', $value = null, $boost = 1.0) { @@ -377,7 +378,7 @@ public function regexp($key = '', $value = null, $boost = 1.0) * * @return SpanFirst * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-first-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-first-query.html */ public function span_first($match = null, $end = null) { @@ -391,7 +392,7 @@ public function span_first($match = null, $end = null) * * @return SpanMulti * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-multi-term-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-multi-term-query.html */ public function span_multi_term($match = null) { @@ -407,7 +408,7 @@ public function span_multi_term($match = null) * * @return SpanNear * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-near-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-near-query.html */ public function span_near($clauses = [], $slop = 1, $inOrder = false) { @@ -422,7 +423,7 @@ public function span_near($clauses = [], $slop = 1, $inOrder = false) * * @return SpanNot * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-not-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-not-query.html */ public function span_not(AbstractSpanQuery $include = null, AbstractSpanQuery $exclude = null) { @@ -436,7 +437,7 @@ public function span_not(AbstractSpanQuery $include = null, AbstractSpanQuery $e * * @return SpanOr * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-or-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-or-query.html */ public function span_or($clauses = []) { @@ -450,7 +451,7 @@ public function span_or($clauses = []) * * @return SpanTerm * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-term-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-term-query.html */ public function span_term(array $term = []) { @@ -465,7 +466,7 @@ public function span_term(array $term = []) * * @return SpanContaining * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-containing-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-containing-query.html */ public function span_containing(AbstractSpanQuery $little = null, AbstractSpanQuery $big = null) { @@ -480,7 +481,7 @@ public function span_containing(AbstractSpanQuery $little = null, AbstractSpanQu * * @return SpanWithin * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-within-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-within-query.html */ public function span_within(AbstractSpanQuery $little = null, AbstractSpanQuery $big = null) { @@ -490,7 +491,7 @@ public function span_within(AbstractSpanQuery $little = null, AbstractSpanQuery /** * term query. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-term-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-term-query.html * * @param array $term * @@ -504,7 +505,7 @@ public function term(array $term = []) /** * terms query. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-terms-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-terms-query.html * * @param string $key * @param array $terms @@ -519,7 +520,7 @@ public function terms($key = '', array $terms = []) /** * wildcard query. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-wildcard-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-wildcard-query.html * * @param string $key OPTIONAL Wildcard key * @param string $value OPTIONAL Wildcard value @@ -535,7 +536,7 @@ public function wildcard($key = '', $value = null, $boost = 1.0) /** * geo distance query. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-distance-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-distance-query.html * * @param string $key * @param array|string $location @@ -551,7 +552,7 @@ public function geo_distance($key, $location, $distance) /** * exists query. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-exists-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-exists-query.html * * @param string $field * @@ -565,7 +566,7 @@ public function exists($field) /** * type query. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-type-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-type-query.html * * @param string $type Type name * @@ -579,7 +580,7 @@ public function type($type = null) /** * type query. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/5.0/query-dsl-percolate-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/5.0/query-dsl-percolate-query.html * * @return Percolate */ diff --git a/lib/Elastica/QueryBuilder/DSL/Suggest.php b/lib/Elastica/QueryBuilder/DSL/Suggest.php index 26b6f49598..f572f86876 100644 --- a/lib/Elastica/QueryBuilder/DSL/Suggest.php +++ b/lib/Elastica/QueryBuilder/DSL/Suggest.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters.html */ class Suggest implements DSL { @@ -29,7 +30,7 @@ public function getType() /** * term suggester. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-term.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-term.html * * @param $name * @param $field @@ -44,7 +45,7 @@ public function term($name, $field) /** * phrase suggester. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-phrase.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-phrase.html * * @param $name * @param $field @@ -59,7 +60,7 @@ public function phrase($name, $field) /** * completion suggester. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-completion.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-completion.html * * @param string $name * @param string $field @@ -74,7 +75,7 @@ public function completion($name, $field) /** * context suggester. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/suggester-context.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/suggester-context.html */ public function context() { diff --git a/lib/Elastica/QueryBuilder/Facade.php b/lib/Elastica/QueryBuilder/Facade.php index 65cc06b8a8..3abe04efa6 100644 --- a/lib/Elastica/QueryBuilder/Facade.php +++ b/lib/Elastica/QueryBuilder/Facade.php @@ -1,4 +1,5 @@ */ diff --git a/lib/Elastica/QueryBuilder/Version/Version240.php b/lib/Elastica/QueryBuilder/Version/Version240.php index 46c28a256b..40ef5d4cbf 100644 --- a/lib/Elastica/QueryBuilder/Version/Version240.php +++ b/lib/Elastica/QueryBuilder/Version/Version240.php @@ -1,4 +1,5 @@ */ diff --git a/lib/Elastica/Reindex.php b/lib/Elastica/Reindex.php index de1f625350..e5e6445a31 100644 --- a/lib/Elastica/Reindex.php +++ b/lib/Elastica/Reindex.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-rescore.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-rescore.html */ abstract class AbstractRescore extends Param { diff --git a/lib/Elastica/Rescore/Query.php b/lib/Elastica/Rescore/Query.php index 3b018e9748..3e3ff37c2e 100644 --- a/lib/Elastica/Rescore/Query.php +++ b/lib/Elastica/Rescore/Query.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-rescore.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-rescore.html */ class Query extends AbstractRescore { diff --git a/lib/Elastica/Response.php b/lib/Elastica/Response.php index a938626a27..a8b5b4d67d 100644 --- a/lib/Elastica/Response.php +++ b/lib/Elastica/Response.php @@ -1,4 +1,5 @@ _response == null) { + if (null == $this->_response) { $response = $this->_responseString; try { @@ -242,7 +243,7 @@ public function getData() /** * Gets the transfer information. * - * @return array Information about the curl request. + * @return array information about the curl request */ public function getTransferInfo() { @@ -253,7 +254,7 @@ public function getTransferInfo() * Sets the transfer info of the curl request. This function is called * from the \Elastica\Client::_callService . * - * @param array $transferInfo The curl transfer information. + * @param array $transferInfo the curl transfer information * * @return $this */ diff --git a/lib/Elastica/Result.php b/lib/Elastica/Result.php index e119b3585e..a20c54017d 100644 --- a/lib/Elastica/Result.php +++ b/lib/Elastica/Result.php @@ -1,4 +1,5 @@ getData(); - return array_key_exists($key, $source) && $source[$key] !== null; + return array_key_exists($key, $source) && null !== $source[$key]; } } diff --git a/lib/Elastica/ResultSet.php b/lib/Elastica/ResultSet.php index d30d5b5136..e99d03ede8 100644 --- a/lib/Elastica/ResultSet.php +++ b/lib/Elastica/ResultSet.php @@ -1,4 +1,5 @@ * @author Martin Janser * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting.html */ abstract class AbstractScript extends AbstractUpdateAction { diff --git a/lib/Elastica/Script/Script.php b/lib/Elastica/Script/Script.php index ad1c96e7ae..2a9c9bdf1f 100644 --- a/lib/Elastica/Script/Script.php +++ b/lib/Elastica/Script/Script.php @@ -1,4 +1,5 @@ * @author Martin Janser * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting.html */ class Script extends AbstractScript { diff --git a/lib/Elastica/Script/ScriptFields.php b/lib/Elastica/Script/ScriptFields.php index bb075dc50a..b572fa53c0 100644 --- a/lib/Elastica/Script/ScriptFields.php +++ b/lib/Elastica/Script/ScriptFields.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-script-fields.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-script-fields.html */ class ScriptFields extends Param { diff --git a/lib/Elastica/Script/ScriptId.php b/lib/Elastica/Script/ScriptId.php index cb97459650..9476934e3f 100644 --- a/lib/Elastica/Script/ScriptId.php +++ b/lib/Elastica/Script/ScriptId.php @@ -1,4 +1,5 @@ * @author Martin Janser * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting.html */ class ScriptId extends AbstractScript { diff --git a/lib/Elastica/Scroll.php b/lib/Elastica/Scroll.php index 28e81c23e1..acdb7de3d2 100644 --- a/lib/Elastica/Scroll.php +++ b/lib/Elastica/Scroll.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html */ class Scroll implements \Iterator { @@ -56,7 +57,7 @@ public function __construct(Search $search, $expiryTime = '1m') /** * Returns current result set. * - * @link http://php.net/manual/en/iterator.current.php + * @see http://php.net/manual/en/iterator.current.php * * @return ResultSet */ @@ -68,7 +69,7 @@ public function current() /** * Next scroll search. * - * @link http://php.net/manual/en/iterator.next.php + * @see http://php.net/manual/en/iterator.next.php */ public function next() { @@ -90,7 +91,7 @@ public function next() /** * Returns scroll id. * - * @link http://php.net/manual/en/iterator.key.php + * @see http://php.net/manual/en/iterator.key.php * * @return string */ @@ -102,19 +103,19 @@ public function key() /** * Returns true if current result set contains at least one hit. * - * @link http://php.net/manual/en/iterator.valid.php + * @see http://php.net/manual/en/iterator.valid.php * * @return bool */ public function valid() { - return $this->_nextScrollId !== null; + return null !== $this->_nextScrollId; } /** * Initial scroll search. * - * @link http://php.net/manual/en/iterator.rewind.php + * @see http://php.net/manual/en/iterator.rewind.php */ public function rewind() { @@ -157,7 +158,7 @@ public function clear() */ protected function _setScrollId(ResultSet $resultSet) { - if ($this->currentPage === 0) { + if (0 === $this->currentPage) { $this->totalPages = $resultSet->count() > 0 ? ceil($resultSet->getTotalHits() / $resultSet->count()) : 0; } diff --git a/lib/Elastica/Search.php b/lib/Elastica/Search.php index cf048c02cb..eb14a16aa7 100644 --- a/lib/Elastica/Search.php +++ b/lib/Elastica/Search.php @@ -1,4 +1,5 @@ request($name); } catch (ResponseException $e) { - if ($e->getResponse()->getStatus() == 404) { + if (404 == $e->getResponse()->getStatus()) { throw new NotFoundException("Repository '".$name."' does not exist."); } throw $e; @@ -110,7 +111,7 @@ public function getSnapshot($repository, $name) try { $response = $this->request($repository.'/'.$name); } catch (ResponseException $e) { - if ($e->getResponse()->getStatus() == 404) { + if (404 == $e->getResponse()->getStatus()) { throw new NotFoundException("Snapshot '".$name."' does not exist in repository '".$repository."'."); } throw $e; diff --git a/lib/Elastica/Status.php b/lib/Elastica/Status.php index 2d6e5a0b9a..c3fb90da57 100644 --- a/lib/Elastica/Status.php +++ b/lib/Elastica/Status.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-status.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-status.html */ class Status { @@ -113,7 +114,7 @@ public function getIndicesWithAlias($alias) $response = $this->_client->requestEndpoint($endpoint); } catch (ResponseException $e) { // 404 means the index alias doesn't exist which means no indexes have it. - if ($e->getResponse()->getStatus() === 404) { + if (404 === $e->getResponse()->getStatus()) { return []; } // If we don't have a 404 then this is still unexpected so rethrow the exception. diff --git a/lib/Elastica/Suggest.php b/lib/Elastica/Suggest.php index e367e3819e..d160abb81b 100644 --- a/lib/Elastica/Suggest.php +++ b/lib/Elastica/Suggest.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-completion.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-completion.html */ class Completion extends AbstractSuggest { /** * Set fuzzy parameter. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-completion.html#fuzzy + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-completion.html#fuzzy * * @param array $fuzzy * diff --git a/lib/Elastica/Suggest/Phrase.php b/lib/Elastica/Suggest/Phrase.php index 65aaedb843..a35784cff5 100644 --- a/lib/Elastica/Suggest/Phrase.php +++ b/lib/Elastica/Suggest/Phrase.php @@ -1,4 +1,5 @@ getData(); - return $data['completed'] === true; + return true === $data['completed']; } public function cancel(): Response diff --git a/lib/Elastica/Transport/AbstractTransport.php b/lib/Elastica/Transport/AbstractTransport.php index 77b615953d..b4957cc4d5 100644 --- a/lib/Elastica/Transport/AbstractTransport.php +++ b/lib/Elastica/Transport/AbstractTransport.php @@ -1,4 +1,5 @@ getData(); if (!empty($data) || '0' === $data) { - if ($req->getMethod() == Request::GET) { + if (Request::GET == $req->getMethod()) { $req = $req->withMethod(Request::POST); } - if ($this->hasParam('postWithRequestBody') && $this->getParam('postWithRequestBody') == true) { + if ($this->hasParam('postWithRequestBody') && true == $this->getParam('postWithRequestBody')) { $request->setMethod(Request::POST); $req = $req->withMethod(Request::POST); } diff --git a/lib/Elastica/Transport/Http.php b/lib/Elastica/Transport/Http.php index 7973b53864..302da0296d 100644 --- a/lib/Elastica/Transport/Http.php +++ b/lib/Elastica/Transport/Http.php @@ -1,4 +1,5 @@ getMethod(); if (!empty($data) || '0' === $data) { - if ($this->hasParam('postWithRequestBody') && $this->getParam('postWithRequestBody') == true) { + if ($this->hasParam('postWithRequestBody') && true == $this->getParam('postWithRequestBody')) { $httpMethod = Request::POST; } @@ -154,7 +155,7 @@ public function exec(Request $request, array $params) curl_setopt($conn, CURLOPT_HTTPHEADER, $headers); - curl_setopt($conn, CURLOPT_NOBODY, $httpMethod == 'HEAD'); + curl_setopt($conn, CURLOPT_NOBODY, 'HEAD' == $httpMethod); curl_setopt($conn, CURLOPT_CUSTOMREQUEST, $httpMethod); diff --git a/lib/Elastica/Transport/HttpAdapter.php b/lib/Elastica/Transport/HttpAdapter.php index e1c44e3a91..180b7f1ad2 100644 --- a/lib/Elastica/Transport/HttpAdapter.php +++ b/lib/Elastica/Transport/HttpAdapter.php @@ -1,4 +1,5 @@ getMethod(); $headers = $connection->hasConfig('headers') ?: []; if (!empty($data) || '0' === $data) { - if ($method == ElasticaRequest::GET) { + if (ElasticaRequest::GET == $method) { $method = ElasticaRequest::POST; } - if ($this->hasParam('postWithRequestBody') && $this->getParam('postWithRequestBody') == true) { + if ($this->hasParam('postWithRequestBody') && true == $this->getParam('postWithRequestBody')) { $elasticaRequest->setMethod(ElasticaRequest::POST); $method = ElasticaRequest::POST; } diff --git a/lib/Elastica/Transport/Https.php b/lib/Elastica/Transport/Https.php index b2b489dda7..996bb2153b 100644 --- a/lib/Elastica/Transport/Https.php +++ b/lib/Elastica/Transport/Https.php @@ -1,4 +1,5 @@ = 0.19.0. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update.html * * @param \Elastica\Document|\Elastica\Script\AbstractScript $data Document with update data * @param array $options array of query params to use for query. For possible options check es api @@ -172,7 +173,7 @@ public function updateDocument($data, array $options = []) * * @return \Elastica\Bulk\ResponseSet * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html */ public function updateDocuments(array $docs, array $options = []) { @@ -191,7 +192,7 @@ public function updateDocuments(array $docs, array $options = []) * * @return \Elastica\Bulk\ResponseSet * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html */ public function addDocuments(array $docs, array $options = []) { @@ -210,7 +211,7 @@ public function addDocuments(array $docs, array $options = []) * * @return Bulk\ResponseSet * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html */ public function addObjects(array $objects, array $options = []) { @@ -234,7 +235,7 @@ public function addObjects(array $objects, array $options = []) * Get the document from search index. * * @param string $id Document id - * @param array $options Options for the get request. + * @param array $options options for the get request * * @throws \Elastica\Exception\NotFoundException * @throws \Elastica\Exception\ResponseException @@ -250,7 +251,7 @@ public function getDocument($id, $options = []) $response = $this->requestEndpoint($endpoint); $result = $response->getData(); - if (!isset($result['found']) || $result['found'] === false) { + if (!isset($result['found']) || false === $result['found']) { throw new NotFoundException('doc id '.$id.' not found'); } @@ -416,7 +417,7 @@ public function deleteDocument(Document $document) * * @return \Elastica\Bulk\ResponseSet * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html */ public function deleteDocuments(array $docs) { @@ -430,7 +431,7 @@ public function deleteDocuments(array $docs) /** * Deletes an entry by its unique identifier. * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete.html * * @param int|string $id Document id * @param array $options @@ -482,7 +483,7 @@ public function deleteIds(array $ids, $routing = false) * * @return \Elastica\Response * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html */ public function deleteByQuery($query, array $options = []) { @@ -552,6 +553,6 @@ public function exists() { $response = $this->requestEndpoint(new Exists()); - return $response->getStatus() === 200; + return 200 === $response->getStatus(); } } diff --git a/lib/Elastica/Type/AbstractType.php b/lib/Elastica/Type/AbstractType.php index de6ff8c984..9c0d7de2cf 100644 --- a/lib/Elastica/Type/AbstractType.php +++ b/lib/Elastica/Type/AbstractType.php @@ -1,4 +1,5 @@ * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping.html */ class Mapping { @@ -89,7 +90,7 @@ public function getProperties() * * @return $this * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-meta.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-meta.html */ public function setMeta(array $meta) { @@ -116,7 +117,7 @@ public function getType() * * @return $this * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-source-field.html + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-source-field.html */ public function setSource(array $source) { diff --git a/lib/Elastica/Util.php b/lib/Elastica/Util.php index b14c9011a5..26f0a98994 100644 --- a/lib/Elastica/Util.php +++ b/lib/Elastica/Util.php @@ -1,4 +1,5 @@ . * - * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#_reserved_characters + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#_reserved_characters * * @param string $term Query term to escape * @@ -127,7 +128,7 @@ public static function escapeTerm($term) * Replace the following reserved words (because part of the query language) * AND OR NOT. * - * @link http://lucene.apache.org/java/2_4_0/queryparsersyntax.html#Boolean%20operators + * @see http://lucene.apache.org/java/2_4_0/queryparsersyntax.html#Boolean%20operators * * @param string $term Query term to replace * @@ -204,7 +205,7 @@ public static function convertDate($date) */ public static function convertDateTimeObject(\DateTime $dateTime, $includeTimezone = true) { - $formatString = 'Y-m-d\TH:i:s'.($includeTimezone === true ? 'P' : '\Z'); + $formatString = 'Y-m-d\TH:i:s'.(true === $includeTimezone ? 'P' : '\Z'); $string = $dateTime->format($formatString); return $string; diff --git a/test/Elastica/Aggregation/AbstractSimpleAggregationTest.php b/test/Elastica/Aggregation/AbstractSimpleAggregationTest.php index ef9ca07eef..329a1dcd93 100644 --- a/test/Elastica/Aggregation/AbstractSimpleAggregationTest.php +++ b/test/Elastica/Aggregation/AbstractSimpleAggregationTest.php @@ -1,4 +1,5 @@ expectException(\Elastica\Exception\InvalidException::class); + $serialDiffAgg = new AvgBucket('avg_bucket'); $serialDiffAgg->toArray(); } diff --git a/test/Elastica/Aggregation/AvgTest.php b/test/Elastica/Aggregation/AvgTest.php index 5ffa2bce20..74b0810b34 100644 --- a/test/Elastica/Aggregation/AvgTest.php +++ b/test/Elastica/Aggregation/AvgTest.php @@ -1,4 +1,5 @@ expectException(InvalidException::class); + $serialDiffAgg = new BucketScript('bucket_scripted'); $serialDiffAgg->toArray(); } /** * @group unit - * @expectedException \Elastica\Exception\InvalidException */ public function testToArrayInvalidScript() { + $this->expectException(InvalidException::class); + $serialDiffAgg = new BucketScript('bucket_scripted', ['path' => 'agg']); $serialDiffAgg->toArray(); } diff --git a/test/Elastica/Aggregation/BucketSelectorTest.php b/test/Elastica/Aggregation/BucketSelectorTest.php index c385e337a3..7758223c31 100644 --- a/test/Elastica/Aggregation/BucketSelectorTest.php +++ b/test/Elastica/Aggregation/BucketSelectorTest.php @@ -1,4 +1,5 @@ search($query)->getAggregation('histogram_agg')['buckets']; - $this->assertEquals(4, count($dateHistogramAggResult)); + $this->assertCount(4, $dateHistogramAggResult); $this->assertEquals(6, $dateHistogramAggResult[0]['max_agg']['value']); $this->assertEquals(9, $dateHistogramAggResult[1]['max_agg']['value']); $this->assertEquals(11, $dateHistogramAggResult[2]['max_agg']['value']); diff --git a/test/Elastica/Aggregation/CardinalityTest.php b/test/Elastica/Aggregation/CardinalityTest.php index eb05107195..17d47a99db 100644 --- a/test/Elastica/Aggregation/CardinalityTest.php +++ b/test/Elastica/Aggregation/CardinalityTest.php @@ -1,4 +1,5 @@ expectException(\InvalidArgumentException::class); + $agg = new Cardinality('threshold'); $agg->setPrecisionThreshold($threshold); } @@ -112,13 +114,14 @@ public function testRehash($rehash) /** * @dataProvider invalidRehashProvider - * @expectedException \InvalidArgumentException * @group unit * * @param mixed $rehash */ public function testInvalidRehash($rehash) { + $this->expectException(\InvalidArgumentException::class); + $agg = new Cardinality('rehash'); $agg->setRehash($rehash); } diff --git a/test/Elastica/Aggregation/ChildrenTest.php b/test/Elastica/Aggregation/ChildrenTest.php index 062288e20a..f3e33a74e1 100644 --- a/test/Elastica/Aggregation/ChildrenTest.php +++ b/test/Elastica/Aggregation/ChildrenTest.php @@ -1,4 +1,5 @@ search($query)->getAggregation('histogram_agg')['buckets']; - $this->assertFalse(array_key_exists('derivative_agg', $dateHistogramAggResult[0])); + $this->assertArrayNotHasKey('derivative_agg', $dateHistogramAggResult[0]); $this->assertEquals(1, $dateHistogramAggResult[1]['derivative_agg']['value']); $this->assertEquals(0, $dateHistogramAggResult[2]['derivative_agg']['value']); $this->assertEquals(2, $dateHistogramAggResult[3]['derivative_agg']['value']); diff --git a/test/Elastica/Aggregation/ExtendedStatsTest.php b/test/Elastica/Aggregation/ExtendedStatsTest.php index 474a0b1cb2..9408b83804 100644 --- a/test/Elastica/Aggregation/ExtendedStatsTest.php +++ b/test/Elastica/Aggregation/ExtendedStatsTest.php @@ -1,4 +1,5 @@ expectException(\Elastica\Exception\InvalidException::class); + $this->expectExceptionMessage('Name must be a string'); + $agg = new Filters('by_color'); $agg->addFilter(new Term(['color' => '0']), 0); } /** * @group unit - * @expectedException \Elastica\Exception\InvalidException - * @expectedExceptionMessage Mix named and anonymous keys are not allowed */ public function testMixNamedAndAnonymousFilters() { + $this->expectException(\Elastica\Exception\InvalidException::class); + $this->expectExceptionMessage('Mix named and anonymous keys are not allowed'); + $agg = new Filters('by_color'); $agg->addFilter(new Term(['color' => '0']), '0'); $agg->addFilter(new Term(['color' => '0'])); @@ -91,11 +94,12 @@ public function testMixNamedAndAnonymousFilters() /** * @group unit - * @expectedException \Elastica\Exception\InvalidException - * @expectedExceptionMessage Mix named and anonymous keys are not allowed */ public function testMixAnonymousAndNamedFilters() { + $this->expectException(\Elastica\Exception\InvalidException::class); + $this->expectExceptionMessage('Mix named and anonymous keys are not allowed'); + $agg = new Filters('by_color'); $agg->addFilter(new Term(['color' => '0'])); diff --git a/test/Elastica/Aggregation/GeoBoundsTest.php b/test/Elastica/Aggregation/GeoBoundsTest.php index 7c9bd4b51d..e4d3f89366 100644 --- a/test/Elastica/Aggregation/GeoBoundsTest.php +++ b/test/Elastica/Aggregation/GeoBoundsTest.php @@ -1,4 +1,5 @@ 100, ], ], - ]; $aggr = new Percentiles('price_percentile'); $aggr->setField('price'); @@ -67,7 +67,6 @@ public function testHdr() 'number_of_significant_value_digits' => 2.0, ], ], - ]; $aggr = new Percentiles('price_percentile'); $aggr->setField('price'); @@ -240,7 +239,6 @@ public function testMissing() ], 'missing' => 10, ], - ]; $aggr = new Percentiles('price_percentile'); $aggr->setField('price'); diff --git a/test/Elastica/Aggregation/RangeTest.php b/test/Elastica/Aggregation/RangeTest.php index 045c1c4e28..97b1644967 100644 --- a/test/Elastica/Aggregation/RangeTest.php +++ b/test/Elastica/Aggregation/RangeTest.php @@ -1,4 +1,5 @@ expectException(\Elastica\Exception\InvalidException::class); + $serialDiffAgg = new SerialDiff('difference'); $serialDiffAgg->toArray(); } diff --git a/test/Elastica/Aggregation/SignificantTermsTest.php b/test/Elastica/Aggregation/SignificantTermsTest.php index 173f4df3c7..0e51e9b433 100644 --- a/test/Elastica/Aggregation/SignificantTermsTest.php +++ b/test/Elastica/Aggregation/SignificantTermsTest.php @@ -1,4 +1,5 @@ getType('_doc')->setMapping($mapping); $docs = []; - for ($i = 0;$i < 250;++$i) { + for ($i = 0; $i < 250; ++$i) { $docs[] = new Document($i, ['color' => $colors[$i % count($colors)], 'temperature' => $temperatures[$i % count($temperatures)]]); } $index->getType('_doc')->addDocuments($docs); diff --git a/test/Elastica/Aggregation/StatsBucketTest.php b/test/Elastica/Aggregation/StatsBucketTest.php index f213089175..1ec273073a 100644 --- a/test/Elastica/Aggregation/StatsBucketTest.php +++ b/test/Elastica/Aggregation/StatsBucketTest.php @@ -1,4 +1,5 @@ expectException(\Elastica\Exception\InvalidException::class); + $serialDiffAgg = new StatsBucket('bucket_part'); $serialDiffAgg->toArray(); } diff --git a/test/Elastica/Aggregation/StatsTest.php b/test/Elastica/Aggregation/StatsTest.php index b2157a226c..c97b92bfa7 100644 --- a/test/Elastica/Aggregation/StatsTest.php +++ b/test/Elastica/Aggregation/StatsTest.php @@ -1,4 +1,5 @@ expectException(\Elastica\Exception\InvalidException::class); + $serialDiffAgg = new SumBucket('sum_bucket'); $serialDiffAgg->toArray(); } diff --git a/test/Elastica/Aggregation/SumTest.php b/test/Elastica/Aggregation/SumTest.php index 8235c6c02c..c11300e0b4 100644 --- a/test/Elastica/Aggregation/SumTest.php +++ b/test/Elastica/Aggregation/SumTest.php @@ -1,4 +1,5 @@ getName(false)); + $groups = TestUtil::getGroups(get_class($this), $this->getName(false)); return in_array('unit', $groups); } protected function _isFunctionalGroup() { - $groups = \PHPUnit\Util\Test::getGroups(get_class($this), $this->getName(false)); + $groups = TestUtil::getGroups(get_class($this), $this->getName(false)); return in_array('functional', $groups); } protected function _isBenchmarkGroup() { - $groups = \PHPUnit\Util\Test::getGroups(get_class($this), $this->getName(false)); + $groups = TestUtil::getGroups(get_class($this), $this->getName(false)); return in_array('benchmark', $groups); } diff --git a/test/Elastica/BasePipeline.php b/test/Elastica/BasePipeline.php index db50a59806..45695bce2d 100644 --- a/test/Elastica/BasePipeline.php +++ b/test/Elastica/BasePipeline.php @@ -1,4 +1,5 @@ expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('The data needs to be a Document or a Script.'); + AbstractDocument::create(new \stdClass()); } /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage Scripts can only be used with the update operation type. * @group unit */ public function testCreateAbstractDocumentWithScript() { + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('Scripts can only be used with the update operation type.'); + AbstractDocument::create(new Script('foobar'), AbstractDocument::OP_TYPE_CREATE); } } diff --git a/test/Elastica/Bulk/Action/UpdateDocumentTest.php b/test/Elastica/Bulk/Action/UpdateDocumentTest.php index 11912c22f4..496b550302 100644 --- a/test/Elastica/Bulk/Action/UpdateDocumentTest.php +++ b/test/Elastica/Bulk/Action/UpdateDocumentTest.php @@ -1,4 +1,5 @@ expectException(\Elastica\Exception\InvalidException::class); + $bulk = new Bulk($this->_getClient()); $bulk->addRawData($rawData); @@ -562,9 +564,11 @@ public function testUpsert() $doc2 = $type->createDocument(2, ['name' => 'Beckenbauer']); $doc3 = $type->createDocument(3, ['name' => 'Baggio']); $doc4 = $type->createDocument(4, ['name' => 'Cruyff']); - $documents = array_map(function ($d) { $d->setDocAsUpsert(true); + $documents = array_map(function ($d) { + $d->setDocAsUpsert(true); -return $d;}, [$doc1, $doc2, $doc3, $doc4]); + return $d; + }, [$doc1, $doc2, $doc3, $doc4]); //index some documents $bulk = new Bulk($client); @@ -635,7 +639,7 @@ public function testRetry() $actions = $bulk->getActions(); $metadata = $actions[0]->getMetadata(); - $this->assertEquals(5, $metadata[ '_retry_on_conflict' ]); + $this->assertEquals(5, $metadata['_retry_on_conflict']); $script = new Script(''); $script->setRetryOnConflict(5); @@ -646,7 +650,7 @@ public function testRetry() $actions = $bulk->getActions(); $metadata = $actions[0]->getMetadata(); - $this->assertEquals(5, $metadata[ '_retry_on_conflict' ]); + $this->assertEquals(5, $metadata['_retry_on_conflict']); } /** diff --git a/test/Elastica/ClientTest.php b/test/Elastica/ClientTest.php index 77f0a09cb7..269d56514a 100644 --- a/test/Elastica/ClientTest.php +++ b/test/Elastica/ClientTest.php @@ -1,4 +1,5 @@ expectException(\Elastica\Exception\Connection\HttpException::class); + $client = $this->_getClient(['host' => 'foo.bar', 'port' => '9201']); $client->getVersion(); } /** * @group functional - * @expectedException Elastica\Exception\Connection\HttpException */ public function testClientBadHost() { + $this->expectException(\Elastica\Exception\Connection\HttpException::class); + $client = $this->_getClient(['host' => 'localhost', 'port' => '9201']); $client->getVersion(); } /** * @group functional - * @expectedException Elastica\Exception\Connection\HttpException */ public function testClientBadHostWithtimeout() { + $this->expectException(\Elastica\Exception\Connection\HttpException::class); + $client = $this->_getClient(['host' => 'foo.bar', 'timeout' => 10]); $client->getVersion(); } @@ -208,10 +212,11 @@ public function testForcemergeAll() /** * @group unit - * @expectedException \Elastica\Exception\InvalidException */ public function testAddDocumentsEmpty() { + $this->expectException(\Elastica\Exception\InvalidException::class); + $client = $this->_getClient(); $client->addDocuments([]); } @@ -612,7 +617,7 @@ public function testOneInvalidConnection() $this->assertCount(2, $connections); // One connection has to be disabled - $this->assertTrue($connections[0]->isEnabled() == false || $connections[1]->isEnabled() == false); + $this->assertTrue(false == $connections[0]->isEnabled() || false == $connections[1]->isEnabled()); } /** @@ -640,7 +645,7 @@ public function testTwoInvalidConnection() $this->assertCount(2, $connections); // One connection has to be disabled - $this->assertTrue($connections[0]->isEnabled() == false || $connections[1]->isEnabled() == false); + $this->assertTrue(false == $connections[0]->isEnabled() || false == $connections[1]->isEnabled()); } /** @@ -1329,11 +1334,12 @@ public function testLogger() } /** - * @expectedException \Elastica\Exception\Connection\HttpException * @group functional */ public function testLoggerOnFailure() { + $this->expectException(\Elastica\Exception\Connection\HttpException::class); + $logger = $this->createMock('Psr\\Log\\LoggerInterface'); $client = $this->_getClient(['connections' => [ ['host' => $this->_getHost(), 'port' => 9201], diff --git a/test/Elastica/Cluster/Health/IndexTest.php b/test/Elastica/Cluster/Health/IndexTest.php index 5b06560869..779d45ebeb 100644 --- a/test/Elastica/Cluster/Health/IndexTest.php +++ b/test/Elastica/Cluster/Health/IndexTest.php @@ -1,4 +1,5 @@ _getClient($config); $response = $client->request('_aliases'); diff --git a/test/Elastica/Connection/Strategy/CallbackStrategyTestHelper.php b/test/Elastica/Connection/Strategy/CallbackStrategyTestHelper.php index b15efe9189..2f79cc71bd 100644 --- a/test/Elastica/Connection/Strategy/CallbackStrategyTestHelper.php +++ b/test/Elastica/Connection/Strategy/CallbackStrategyTestHelper.php @@ -1,4 +1,5 @@ expectException(\Elastica\Exception\ConnectionException::class); + $config = ['connectionStrategy' => 'RoundRobin', 'host' => '255.255.255.0', 'timeout' => $this->_timeout]; $client = $this->_getClient($config); diff --git a/test/Elastica/Connection/Strategy/SimpleTest.php b/test/Elastica/Connection/Strategy/SimpleTest.php index a110690f5e..ccc5047090 100644 --- a/test/Elastica/Connection/Strategy/SimpleTest.php +++ b/test/Elastica/Connection/Strategy/SimpleTest.php @@ -1,4 +1,5 @@ expectException(\Elastica\Exception\ConnectionException::class); + $config = ['host' => '255.255.255.0', 'timeout' => $this->_timeout]; $client = $this->_getClient($config); diff --git a/test/Elastica/Connection/Strategy/StrategyFactoryTest.php b/test/Elastica/Connection/Strategy/StrategyFactoryTest.php index 7408c7a50d..2872ed6961 100644 --- a/test/Elastica/Connection/Strategy/StrategyFactoryTest.php +++ b/test/Elastica/Connection/Strategy/StrategyFactoryTest.php @@ -1,4 +1,5 @@ expectException(\InvalidArgumentException::class); + $strategy = new \stdClass(); StrategyFactory::create($strategy); diff --git a/test/Elastica/ConnectionTest.php b/test/Elastica/ConnectionTest.php index c967b9e855..f2fe62e072 100644 --- a/test/Elastica/ConnectionTest.php +++ b/test/Elastica/ConnectionTest.php @@ -1,4 +1,5 @@ expectException(\Elastica\Exception\ConnectionException::class); + $connection = new Connection(['port' => 9999]); $request = new Request('_stats', Request::GET); @@ -73,11 +75,11 @@ public function testCreate() /** * @group unit - * @expectedException \Elastica\Exception\InvalidException - * @expectedException \Elastica\Exception\InvalidException */ public function testCreateInvalid() { + $this->expectException(\Elastica\Exception\InvalidException::class); + Connection::create('test'); } @@ -103,21 +105,23 @@ public function testGetConfigWithArrayUsedForTransport() /** * @group unit - * @expectedException \Elastica\Exception\InvalidException - * @expectedExceptionMessage Invalid transport */ public function testGetInvalidConfigWithArrayUsedForTransport() { + $this->expectException(\Elastica\Exception\InvalidException::class); + $this->expectExceptionMessage('Invalid transport'); + $connection = new Connection(['transport' => ['type' => 'invalidtransport']]); $connection->getTransportObject(); } /** * @group unit - * @expectedException \Elastica\Exception\InvalidException */ public function testGetConfigInvalidValue() { + $this->expectException(\Elastica\Exception\InvalidException::class); + $connection = new Connection(); $connection->getConfig('url'); } diff --git a/test/Elastica/DeprecatedClassBase.php b/test/Elastica/DeprecatedClassBase.php index dbb7502d7f..45f9ddb432 100644 --- a/test/Elastica/DeprecatedClassBase.php +++ b/test/Elastica/DeprecatedClassBase.php @@ -1,4 +1,5 @@ testCase = $testCase; } diff --git a/test/Elastica/ExampleTest.php b/test/Elastica/ExampleTest.php index 039c4e48d8..d2248a5c82 100644 --- a/test/Elastica/ExampleTest.php +++ b/test/Elastica/ExampleTest.php @@ -1,4 +1,5 @@ expectException(\Elastica\Exception\InvalidException::class); + $client = $this->_getClient(); new IndexTemplate($client, null); } diff --git a/test/Elastica/IndexTest.php b/test/Elastica/IndexTest.php index 985ef9864e..977bcd1a4a 100644 --- a/test/Elastica/IndexTest.php +++ b/test/Elastica/IndexTest.php @@ -1,4 +1,5 @@ expectException(\Elastica\Exception\ResponseException::class); + $client = $this->_getClient(); $indexName1 = 'test1'; @@ -614,12 +616,12 @@ public function testCreate() } /** - * @expectedException \Elastica\Exception\InvalidException - * * @group unit */ public function testCreateWithInvalidOption() { + $this->expectException(\Elastica\Exception\InvalidException::class); + $client = $this->_getClient(); $indexName = 'test'; $index = $client->getIndex($indexName); @@ -785,10 +787,11 @@ public function testAnalyzeExplain() /** * @group unit - * @expectedException \Elastica\Exception\InvalidException */ public function testThrowExceptionIfNotScalar() { + $this->expectException(\Elastica\Exception\InvalidException::class); + $client = $this->_getClient(); $client->getIndex(new \stdClass()); } diff --git a/test/Elastica/JSONTest.php b/test/Elastica/JSONTest.php index 00cb26a850..3ce7ee4691 100644 --- a/test/Elastica/JSONTest.php +++ b/test/Elastica/JSONTest.php @@ -1,37 +1,40 @@ */ -class JSONTest extends \PHPUnit\Framework\TestCase +class JSONTest extends TestCase { public function testStringifyMustNotThrowExceptionOnValid() { JSON::stringify([]); + $this->assertTrue(true); } - /** - * @expectedException \Elastica\Exception\JSONParseException - * @expectedExceptionMessage Inf and NaN cannot be JSON encoded - */ public function testStringifyMustThrowExceptionNanOrInf() { + $this->expectException(\Elastica\Exception\JSONParseException::class); + $this->expectExceptionMessage('Inf and NaN cannot be JSON encoded'); + $arr = [NAN, INF]; JSON::stringify($arr); + $this->assertTrue(true); } - /** - * @expectedException \Elastica\Exception\JSONParseException - * @expectedExceptionMessage Maximum stack depth exceeded - */ public function testStringifyMustThrowExceptionMaximumDepth() { + $this->expectException(\Elastica\Exception\JSONParseException::class); + $this->expectExceptionMessage('Maximum stack depth exceeded'); + $arr = [[[]]]; JSON::stringify($arr, 0, 0); + $this->assertTrue(true); } } diff --git a/test/Elastica/LogTest.php b/test/Elastica/LogTest.php index 3d5bf9db84..46434d3f64 100644 --- a/test/Elastica/LogTest.php +++ b/test/Elastica/LogTest.php @@ -1,4 +1,5 @@ expectException(\Elastica\Exception\InvalidException::class); + $param = new Param(); $param->getParam('notest'); diff --git a/test/Elastica/PipelineTest.php b/test/Elastica/PipelineTest.php index 9b6ff6cb5b..a9bb8a8930 100644 --- a/test/Elastica/PipelineTest.php +++ b/test/Elastica/PipelineTest.php @@ -1,4 +1,5 @@ expectException(\Elastica\Exception\InvalidException::class); + $query = new GeoBoundingBox('foo', []); } diff --git a/test/Elastica/Query/GeoDistanceTest.php b/test/Elastica/Query/GeoDistanceTest.php index 8df8277f88..33f1773ecf 100644 --- a/test/Elastica/Query/GeoDistanceTest.php +++ b/test/Elastica/Query/GeoDistanceTest.php @@ -1,4 +1,5 @@ _getIndexForParentChildrenTest(); $t = $ind->getType('_doc'); $r = $t->search($child); + return $this->_getIndexForParentChildrenTest()->getType('_doc')->search($child); } diff --git a/test/Elastica/Query/LimitTest.php b/test/Elastica/Query/LimitTest.php index bb806edc3a..cc815ceb79 100644 --- a/test/Elastica/Query/LimitTest.php +++ b/test/Elastica/Query/LimitTest.php @@ -1,4 +1,5 @@ expectException(\Elastica\Exception\InvalidException::class); + $query = new QueryString(); $query->setQuery([]); } diff --git a/test/Elastica/Query/RangeTest.php b/test/Elastica/Query/RangeTest.php index a3d4a1a591..23c589807e 100644 --- a/test/Elastica/Query/RangeTest.php +++ b/test/Elastica/Query/RangeTest.php @@ -1,4 +1,5 @@ expectException(\Elastica\Exception\InvalidException::class); + $term1 = new Term(['name' => 'marek']); $term2 = new Term(['name' => 'nicolas']); $spanNearQuery = new SpanNear([$term1, $term2]); @@ -47,7 +49,6 @@ public function testConstructValid() 'name' => 'nicolas', ], ], - ], 'slop' => 5, 'in_order' => true, diff --git a/test/Elastica/Query/SpanNotTest.php b/test/Elastica/Query/SpanNotTest.php index 1b99f6b70b..01410e92fc 100644 --- a/test/Elastica/Query/SpanNotTest.php +++ b/test/Elastica/Query/SpanNotTest.php @@ -1,4 +1,5 @@ expectException(\Elastica\Exception\InvalidException::class); + $term1 = new Term(['name' => 'marek']); $term2 = new Term(['name' => 'nicolas']); $spanOrQuery = new SpanOr([$term1, $term2]); @@ -47,7 +49,6 @@ public function testConstructValid() 'name' => 'nicolas', ], ], - ], ], ]; diff --git a/test/Elastica/Query/SpanTermTest.php b/test/Elastica/Query/SpanTermTest.php index c0f6244bd1..dba4155af0 100644 --- a/test/Elastica/Query/SpanTermTest.php +++ b/test/Elastica/Query/SpanTermTest.php @@ -1,4 +1,5 @@ expectException(\Elastica\Exception\InvalidException::class); + $query = new Terms(); $query->toArray(); diff --git a/test/Elastica/Query/TypeTest.php b/test/Elastica/Query/TypeTest.php index b70794e52c..f1cfe92fac 100644 --- a/test/Elastica/Query/TypeTest.php +++ b/test/Elastica/Query/TypeTest.php @@ -1,4 +1,5 @@ addScript('script', new Script('script')); + $scriptFields->addScript('script', new Script('script')); $query->setScriptFields($scriptFields); - $scriptFields->addScript('another script', new Script('another script')); + $scriptFields->addScript('another script', new Script('another script')); $anotherQuery = new Query(); $anotherQuery->setScriptFields($scriptFields); diff --git a/test/Elastica/ReindexTest.php b/test/Elastica/ReindexTest.php index b89b611c0e..200a2060aa 100644 --- a/test/Elastica/ReindexTest.php +++ b/test/Elastica/ReindexTest.php @@ -1,4 +1,5 @@ expectException(\Elastica\Exception\InvalidException::class); + $request = new Request('', Request::GET); $request->send(); } diff --git a/test/Elastica/ResponseTest.php b/test/Elastica/ResponseTest.php index 4f23288718..171aa27f2b 100644 --- a/test/Elastica/ResponseTest.php +++ b/test/Elastica/ResponseTest.php @@ -1,4 +1,5 @@ expectException(\Elastica\Exception\InvalidException::class); + $index = $this->_createIndex(); $type = $index->getType('_doc'); @@ -111,10 +113,11 @@ public function testInvalidOffsetCreation() /** * @group functional - * @expectedException \Elastica\Exception\InvalidException */ public function testInvalidOffsetGet() { + $this->expectException(\Elastica\Exception\InvalidException::class); + $index = $this->_createIndex(); $type = $index->getType('_doc'); diff --git a/test/Elastica/ResultTest.php b/test/Elastica/ResultTest.php index d7b5d59fd9..16d51156d1 100644 --- a/test/Elastica/ResultTest.php +++ b/test/Elastica/ResultTest.php @@ -1,4 +1,5 @@ assertNotNull($resultSet->getTotalTime(), 'Get Total Time should never be a null value'); $this->assertEquals( 'integer', - getType($resultSet->getTotalTime()), + gettype($resultSet->getTotalTime()), 'Total Time should be an integer' ); } diff --git a/test/Elastica/Script/ScriptFieldsTest.php b/test/Elastica/Script/ScriptFieldsTest.php index 6b6fb4810e..5c2b3bb871 100644 --- a/test/Elastica/Script/ScriptFieldsTest.php +++ b/test/Elastica/Script/ScriptFieldsTest.php @@ -1,4 +1,5 @@ expectException(\Elastica\Exception\InvalidException::class); + $script = new Script('1 + 2'); $scriptFields = new ScriptFields([$script]); } diff --git a/test/Elastica/Script/ScriptIdTest.php b/test/Elastica/Script/ScriptIdTest.php index 7914c9229c..51de268c2b 100644 --- a/test/Elastica/Script/ScriptIdTest.php +++ b/test/Elastica/Script/ScriptIdTest.php @@ -1,4 +1,5 @@ expectException(\Elastica\Exception\InvalidException::class); + ScriptId::create($data); } diff --git a/test/Elastica/Script/ScriptTest.php b/test/Elastica/Script/ScriptTest.php index a8939e77d8..598bdd7c83 100644 --- a/test/Elastica/Script/ScriptTest.php +++ b/test/Elastica/Script/ScriptTest.php @@ -1,4 +1,5 @@ expectException(\Elastica\Exception\InvalidException::class); + Script::create($data); } diff --git a/test/Elastica/ScrollTest.php b/test/Elastica/ScrollTest.php index cdacf6c044..4608378d7c 100644 --- a/test/Elastica/ScrollTest.php +++ b/test/Elastica/ScrollTest.php @@ -1,4 +1,5 @@ getResults(); switch (true) { - case $count === 1: + case 1 === $count: // hits: 1 - 5 $this->assertEquals(5, $resultSet->count()); $this->assertEquals('1', $results[0]->getId()); $this->assertEquals('5', $results[4]->getId()); break; - case $count === 2: + case 2 === $count: // hits: 6 - 10 $this->assertEquals(5, $resultSet->count()); $this->assertEquals('6', $results[0]->getId()); $this->assertEquals('10', $results[4]->getId()); break; - case $count === 3: + case 3 === $count: // hit: 11 $this->assertEquals(1, $resultSet->count()); $this->assertEquals('11', $results[0]->getId()); diff --git a/test/Elastica/SearchTest.php b/test/Elastica/SearchTest.php index f56378d00e..b7333c86e2 100644 --- a/test/Elastica/SearchTest.php +++ b/test/Elastica/SearchTest.php @@ -1,4 +1,5 @@ expectException(\Elastica\Exception\InvalidException::class); + $client = $this->_getClient(); $search = new Search($client); @@ -147,10 +149,11 @@ public function testAddTypeInvalid() /** * @group unit - * @expectedException \Elastica\Exception\InvalidException */ public function testAddIndexInvalid() { + $this->expectException(\Elastica\Exception\InvalidException::class); + $client = $this->_getClient(); $search = new Search($client); @@ -385,7 +388,7 @@ public function testArrayConfigSearch() $this->assertEquals(10, $resultSet->count()); $resultSet = $search->search('test', ['limit' => 0]); - $this->assertTrue(($resultSet->count() === 0) && $resultSet->getTotalHits() === 11); + $this->assertTrue((0 === $resultSet->count()) && 11 === $resultSet->getTotalHits()); //test with filter_path $resultSet = $search->search('test', [Search::OPTION_FILTER_PATH => 'hits.hits._source']); @@ -408,10 +411,11 @@ public function testArrayConfigSearch() /** * @group functional - * @expectedException \Elastica\Exception\InvalidException */ public function testInvalidConfigSearch() { + $this->expectException(\Elastica\Exception\InvalidException::class); + $client = $this->_getClient(); $search = new Search($client); // Throws InvalidException @@ -455,15 +459,15 @@ public function testCountRequest() $type = $index->getType('_doc'); $type->addDocuments([ - new Document(1, ['id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley']), - new Document(2, ['id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley']), - new Document(3, ['id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley']), - new Document(4, ['id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley']), - new Document(5, ['id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley']), - new Document(6, ['id' => 1, 'email' => 'test@test.com', 'username' => 'marley']), - new Document(7, ['id' => 1, 'email' => 'test@test.com', 'username' => 'marley']), - new Document(8, ['id' => 1, 'email' => 'test@test.com', 'username' => 'marley']), - new Document(9, ['id' => 1, 'email' => 'test@test.com', 'username' => 'marley']), + new Document(1, ['id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley']), + new Document(2, ['id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley']), + new Document(3, ['id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley']), + new Document(4, ['id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley']), + new Document(5, ['id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley']), + new Document(6, ['id' => 1, 'email' => 'test@test.com', 'username' => 'marley']), + new Document(7, ['id' => 1, 'email' => 'test@test.com', 'username' => 'marley']), + new Document(8, ['id' => 1, 'email' => 'test@test.com', 'username' => 'marley']), + new Document(9, ['id' => 1, 'email' => 'test@test.com', 'username' => 'marley']), new Document(10, ['id' => 1, 'email' => 'test@test.com', 'username' => 'marley']), new Document(11, ['id' => 1, 'email' => 'test@test.com', 'username' => 'marley']), ]); diff --git a/test/Elastica/SnapshotTest.php b/test/Elastica/SnapshotTest.php index 1b5a92f92b..f643b4a9fe 100644 --- a/test/Elastica/SnapshotTest.php +++ b/test/Elastica/SnapshotTest.php @@ -1,4 +1,5 @@ 3, ], ]), - ]); $index->refresh(); diff --git a/test/Elastica/Suggest/PhraseTest.php b/test/Elastica/Suggest/PhraseTest.php index b49f5fcbf9..b20f7a3149 100644 --- a/test/Elastica/Suggest/PhraseTest.php +++ b/test/Elastica/Suggest/PhraseTest.php @@ -1,4 +1,5 @@ expectException(\Exception::class); + $this->expectExceptionMessage('No task id given'); + $task = new Task($this->_getClient(), ''); $task->cancel(); } diff --git a/test/Elastica/Transport/AbstractTransportTest.php b/test/Elastica/Transport/AbstractTransportTest.php index c479b219eb..39a07c6a6d 100644 --- a/test/Elastica/Transport/AbstractTransportTest.php +++ b/test/Elastica/Transport/AbstractTransportTest.php @@ -1,4 +1,5 @@ expectException(\Elastica\Exception\InvalidException::class); + $this->expectExceptionMessage('Invalid transport'); + AbstractTransport::create($transport, new Connection()); } @@ -128,7 +130,7 @@ public function testBooleanStringValues($transport) $this->fail('Failed to parse value [1] as only [true] or [false] are allowed.'); } - if ($transport['transport'] == 'Http') { + if ('Http' == $transport['transport']) { $info = $results->getResponse()->getTransferInfo(); $url = $info['url']; $this->assertStringEndsWith('version=true', $url); diff --git a/test/Elastica/Transport/AwsAuthV4Test.php b/test/Elastica/Transport/AwsAuthV4Test.php index ab15e98fa0..0241d9f12d 100644 --- a/test/Elastica/Transport/AwsAuthV4Test.php +++ b/test/Elastica/Transport/AwsAuthV4Test.php @@ -1,4 +1,5 @@ expectException(\Elastica\Exception\Connection\GuzzleException::class); + $client = $this->_getClient(['transport' => 'Guzzle', 'port' => 4500, 'persistent' => false]); $response = $client->request('_stats', 'GET'); $client->request('_status', 'GET'); diff --git a/test/Elastica/Transport/HttpTest.php b/test/Elastica/Transport/HttpTest.php index f46016ed73..60a843137a 100644 --- a/test/Elastica/Transport/HttpTest.php +++ b/test/Elastica/Transport/HttpTest.php @@ -1,4 +1,5 @@ getResponse(); $this->assertNotNull($response); - // Validate most of the expected fields in the response data. Consumers of the response - // object have a reasonable expectation of finding "hits", "took", etc - $responseData = $response->getData(); + // Validate most of the expected fields in the response data. Consumers of the response + // object have a reasonable expectation of finding "hits", "took", etc + $responseData = $response->getData(); $this->assertContains('took', $responseData); $this->assertEquals(0, $responseData['took']); $this->assertContains('_shards', $responseData); diff --git a/test/Elastica/Transport/TransportBenchmarkTest.php b/test/Elastica/Transport/TransportBenchmarkTest.php index 7be98d6441..2c15c38874 100644 --- a/test/Elastica/Transport/TransportBenchmarkTest.php +++ b/test/Elastica/Transport/TransportBenchmarkTest.php @@ -1,4 +1,5 @@ $times) { $perc = 0; - if ($minMean != 0) { + if (0 != $minMean) { $perc = (($times['mean'] - $minMean) / $minMean) * 100; } diff --git a/test/Elastica/Type/MappingTest.php b/test/Elastica/Type/MappingTest.php index 2684c33096..9f5007b2a2 100644 --- a/test/Elastica/Type/MappingTest.php +++ b/test/Elastica/Type/MappingTest.php @@ -1,11 +1,11 @@ expectException(\Elastica\Exception\NotFoundException::class); + $index = $this->_createIndex(); $type = new Type($index, '_doc'); $type->addDocument(new Document(1, ['name' => 'ruflin'])); @@ -347,10 +349,11 @@ public function testGetDocumentNotExist() /** * @group functional - * @expectedException \Elastica\Exception\ResponseException */ public function testGetDocumentNotExistingIndex() { + $this->expectException(\Elastica\Exception\ResponseException::class); + $client = $this->_getClient(); $index = new Index($client, 'index'); $type = new Type($index, '_doc'); @@ -725,10 +728,11 @@ public function testUpdateDocumentWithFieldsSource() /** * @group functional - * @expectedException \Elastica\Exception\InvalidException */ public function testUpdateDocumentWithoutId() { + $this->expectException(\Elastica\Exception\InvalidException::class); + $index = $this->_createIndex(); $this->_waitForAllocation($index); $type = $index->getType('_doc'); @@ -868,10 +872,11 @@ public function testAddDocumentPipeline() /** * @group functional - * @expectedException \Elastica\Exception\RuntimeException */ public function testAddDocumentWithoutSerializer() { + $this->expectException(\Elastica\Exception\RuntimeException::class); + $index = $this->_createIndex(); $this->_waitForAllocation($index); diff --git a/test/Elastica/UtilTest.php b/test/Elastica/UtilTest.php index fc52ad0079..df7a00b030 100644 --- a/test/Elastica/UtilTest.php +++ b/test/Elastica/UtilTest.php @@ -1,4 +1,5 @@