diff --git a/.gitattributes b/.gitattributes index feb7aaf2cb..55b80223f7 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3,7 +3,7 @@ /.gitattributes export-ignore /.github export-ignore /.gitignore export-ignore -/.php_cs.dist export-ignore +/.php-cs-fixer.dist.php export-ignore /CHANGELOG.md merge=union /codecov.yml export-ignore /CONTRIBUTING.md export-ignore diff --git a/.github/workflows/continuous-integration.yaml b/.github/workflows/continuous-integration.yaml index 81d1dd5b26..c5424b6026 100644 --- a/.github/workflows/continuous-integration.yaml +++ b/.github/workflows/continuous-integration.yaml @@ -14,11 +14,11 @@ jobs: php-version: '7.2' coverage: 'none' extensions: 'json, mbstring, tokenizer' - tools: 'composer-normalize:2.13.3, php-cs-fixer:2.18.6' + tools: 'composer-normalize:2.13.3, php-cs-fixer:3.0.0' - name: 'Check PHP code' run: | - php-cs-fixer fix --diff --dry-run --allow-risky=yes --using-cache=false + php-cs-fixer fix --diff --dry-run --allow-risky=yes --using-cache=no - name: 'Check composer.json' run: | diff --git a/.gitignore b/.gitignore index a2fb7237ad..eb96a20d0b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,8 @@ .DS_Store .idea *.iml -.php_cs -.php_cs.cache +.php-cs-fixer.php +.php-cs-fixer.cache .phpunit.result.cache cache.properties diff --git a/.php_cs.dist b/.php-cs-fixer.dist.php similarity index 73% rename from .php_cs.dist rename to .php-cs-fixer.dist.php index fbcc8106f0..a55e148f20 100644 --- a/.php_cs.dist +++ b/.php-cs-fixer.dist.php @@ -1,10 +1,11 @@ in(['src/', 'tests/']) +$finder = (new PhpCsFixer\Finder()) + ->in(__DIR__.'/src') + ->in(__DIR__.'/tests') ; -return PhpCsFixer\Config::create() +return (new PhpCsFixer\Config()) ->setFinder($finder) ->setRules([ '@PHP71Migration' => true, @@ -12,12 +13,12 @@ '@PHPUnit75Migration:risky' => true, '@PSR2' => true, '@Symfony' => true, - 'array_syntax' => ['syntax' => 'short'], 'is_null' => true, - 'list_syntax' => ['syntax' => 'short'], 'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'], 'native_constant_invocation' => true, - 'native_function_invocation' => true, + 'native_function_invocation' => [ + 'include' => ['@all'], + ], 'no_alias_functions' => true, 'no_useless_else' => true, 'nullable_type_declaration_for_default_null_value' => true, @@ -28,7 +29,7 @@ 'phpdoc_types_order' => ['null_adjustment' => 'always_last'], 'static_lambda' => true, 'ternary_to_null_coalescing' => true, - 'visibility_required' => ['property', 'method', 'const'], + 'visibility_required' => ['elements' => ['property', 'method', 'const']], 'void_return' => true, ]) ; diff --git a/Makefile b/Makefile index a1bf44baf3..1a64619d0b 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ .PHONY: clean clean: - rm -fr tools vendor build composer.lock .php_cs.cache + rm -fr tools vendor build composer.lock .php-cs-fixer.cache tools/phive.phar: mkdir tools; \ @@ -33,11 +33,11 @@ composer-update: install-tools: install-phpcs .PHONY: run-phpcs -run-phpcs: composer-install install-phpcs - tools/php-cs-fixer.phar fix --dry-run --allow-risky=yes -v +run-phpcs: install-phpcs + tools/php-cs-fixer.phar fix --diff --dry-run --allow-risky=yes -v .PHONY: fix-phpcs -fix-phpcs: composer-install install-phpcs +fix-phpcs: install-phpcs tools/php-cs-fixer.phar fix --allow-risky=yes -v .PHONY: run-phpunit diff --git a/phive.xml b/phive.xml index 7a05d9aa9d..8da86fe416 100644 --- a/phive.xml +++ b/phive.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Aggregation/Range.php b/src/Aggregation/Range.php index aa42b4f1cd..24de49879a 100644 --- a/src/Aggregation/Range.php +++ b/src/Aggregation/Range.php @@ -54,7 +54,7 @@ public function addRange($fromValue = null, $toValue = null, ?string $key = null */ public function setKeyedResponse(bool $keyed = true): self { - trigger_deprecation('ruflin/elastica', '7.1.0', 'The "%s()" method is deprecated, use "setKeyed()" instead. It will be removed in 8.0.', __METHOD__); + \trigger_deprecation('ruflin/elastica', '7.1.0', 'The "%s()" method is deprecated, use "setKeyed()" instead. It will be removed in 8.0.', __METHOD__); return $this->setKeyed($keyed); } diff --git a/src/Exception/ElasticsearchException.php b/src/Exception/ElasticsearchException.php index 4b5ded5f1c..25cc827b7e 100644 --- a/src/Exception/ElasticsearchException.php +++ b/src/Exception/ElasticsearchException.php @@ -2,7 +2,7 @@ namespace Elastica\Exception; -trigger_deprecation('ruflin/elastica', '5.2.0', 'The "%s" class is deprecated, use "Elastica\Exception\ResponseException::getResponse()::getFullError()" instead. It will be removed in 8.0.', ElasticsearchException::class); +\trigger_deprecation('ruflin/elastica', '5.2.0', 'The "%s" class is deprecated, use "Elastica\Exception\ResponseException::getResponse()::getFullError()" instead. It will be removed in 8.0.', ElasticsearchException::class); /** * Elasticsearch exception. diff --git a/src/Exception/ResponseException.php b/src/Exception/ResponseException.php index 9afa23fabf..a62b0724f3 100644 --- a/src/Exception/ResponseException.php +++ b/src/Exception/ResponseException.php @@ -59,7 +59,7 @@ public function getResponse(): Response */ public function getElasticsearchException(): ElasticsearchException { - trigger_deprecation('ruflin/elastica', '7.1.0', 'The "%s()" method is deprecated, use "getResponse()::getFullError()" instead. It will be removed in 8.0.', __METHOD__); + \trigger_deprecation('ruflin/elastica', '7.1.0', 'The "%s()" method is deprecated, use "getResponse()::getFullError()" instead. It will be removed in 8.0.', __METHOD__); $response = $this->getResponse(); diff --git a/src/Index.php b/src/Index.php index f66a8791fe..249232fe08 100644 --- a/src/Index.php +++ b/src/Index.php @@ -392,11 +392,11 @@ public function create(array $args = [], $options = null): Response { if (null === $options) { if (\func_num_args() >= 2) { - trigger_deprecation('ruflin/elastica', '7.1.0', 'Passing null as 2nd argument to "%s()" is deprecated, avoid passing this argument or pass an array instead. It will be removed in 8.0.', __METHOD__); + \trigger_deprecation('ruflin/elastica', '7.1.0', 'Passing null as 2nd argument to "%s()" is deprecated, avoid passing this argument or pass an array instead. It will be removed in 8.0.', __METHOD__); } $options = []; } elseif (\is_bool($options)) { - trigger_deprecation('ruflin/elastica', '7.1.0', 'Passing a bool as 2nd argument to "%s()" is deprecated, pass an array with the key "recreate" instead. It will be removed in 8.0.', __METHOD__); + \trigger_deprecation('ruflin/elastica', '7.1.0', 'Passing a bool as 2nd argument to "%s()" is deprecated, pass an array with the key "recreate" instead. It will be removed in 8.0.', __METHOD__); $options = ['recreate' => $options]; } elseif (!\is_array($options)) { throw new \TypeError(\sprintf('Argument 2 passed to "%s()" must be of type array|bool|null, %s given.', __METHOD__, \is_object($options) ? \get_class($options) : \gettype($options))); diff --git a/src/Processor/Append.php b/src/Processor/Append.php index beb229ad1b..413972c65e 100644 --- a/src/Processor/Append.php +++ b/src/Processor/Append.php @@ -2,7 +2,7 @@ namespace Elastica\Processor; -trigger_deprecation('ruflin/elastica', '7.1.0', 'The "%s" class is deprecated, use "%s" instead. It will be removed in 8.0.', Append::class, AppendProcessor::class); +\trigger_deprecation('ruflin/elastica', '7.1.0', 'The "%s" class is deprecated, use "%s" instead. It will be removed in 8.0.', Append::class, AppendProcessor::class); /** * Elastica Append Processor. diff --git a/src/Processor/Attachment.php b/src/Processor/Attachment.php index 0916f26fbb..e018ede760 100644 --- a/src/Processor/Attachment.php +++ b/src/Processor/Attachment.php @@ -2,7 +2,7 @@ namespace Elastica\Processor; -trigger_deprecation('ruflin/elastica', '7.1.0', 'The "%s" class is deprecated, use "%s" instead. It will be removed in 8.0.', Attachment::class, AttachmentProcessor::class); +\trigger_deprecation('ruflin/elastica', '7.1.0', 'The "%s" class is deprecated, use "%s" instead. It will be removed in 8.0.', Attachment::class, AttachmentProcessor::class); /** * Elastica Attachment Processor. diff --git a/src/Processor/Convert.php b/src/Processor/Convert.php index 54d98e13bc..d2664c7e3c 100644 --- a/src/Processor/Convert.php +++ b/src/Processor/Convert.php @@ -2,7 +2,7 @@ namespace Elastica\Processor; -trigger_deprecation('ruflin/elastica', '7.1.0', 'The "%s" class is deprecated, use "%s" instead. It will be removed in 8.0.', Convert::class, ConvertProcessor::class); +\trigger_deprecation('ruflin/elastica', '7.1.0', 'The "%s" class is deprecated, use "%s" instead. It will be removed in 8.0.', Convert::class, ConvertProcessor::class); /** * Elastica Convert Processor. diff --git a/src/Processor/Date.php b/src/Processor/Date.php index 9b35c17f8a..dd8bd623d1 100644 --- a/src/Processor/Date.php +++ b/src/Processor/Date.php @@ -2,7 +2,7 @@ namespace Elastica\Processor; -trigger_deprecation('ruflin/elastica', '7.1.0', 'The "%s" class is deprecated, use "%s" instead. It will be removed in 8.0.', Date::class, DateProcessor::class); +\trigger_deprecation('ruflin/elastica', '7.1.0', 'The "%s" class is deprecated, use "%s" instead. It will be removed in 8.0.', Date::class, DateProcessor::class); /** * Elastica Date Processor. diff --git a/src/Processor/DateIndexName.php b/src/Processor/DateIndexName.php index 05a2236cc5..781c1442b8 100644 --- a/src/Processor/DateIndexName.php +++ b/src/Processor/DateIndexName.php @@ -2,7 +2,7 @@ namespace Elastica\Processor; -trigger_deprecation('ruflin/elastica', '7.1.0', 'The "%s" class is deprecated, use "%s" instead. It will be removed in 8.0.', DateIndexName::class, DateIndexNameProcessor::class); +\trigger_deprecation('ruflin/elastica', '7.1.0', 'The "%s" class is deprecated, use "%s" instead. It will be removed in 8.0.', DateIndexName::class, DateIndexNameProcessor::class); /** * Elastica DateIndexName Processor. diff --git a/src/Processor/DotExpander.php b/src/Processor/DotExpander.php index 567cd72575..f6e5afda78 100644 --- a/src/Processor/DotExpander.php +++ b/src/Processor/DotExpander.php @@ -2,7 +2,7 @@ namespace Elastica\Processor; -trigger_deprecation('ruflin/elastica', '7.1.0', 'The "%s" class is deprecated, use "%s" instead. It will be removed in 8.0.', DotExpander::class, DotExpanderProcessor::class); +\trigger_deprecation('ruflin/elastica', '7.1.0', 'The "%s" class is deprecated, use "%s" instead. It will be removed in 8.0.', DotExpander::class, DotExpanderProcessor::class); /** * Elastica DotExpander Processor. diff --git a/src/Processor/Fail.php b/src/Processor/Fail.php index 10b9a2b7ac..191fba4c96 100644 --- a/src/Processor/Fail.php +++ b/src/Processor/Fail.php @@ -2,7 +2,7 @@ namespace Elastica\Processor; -trigger_deprecation('ruflin/elastica', '7.1.0', 'The "%s" class is deprecated, use "%s" instead. It will be removed in 8.0.', Fail::class, FailProcessor::class); +\trigger_deprecation('ruflin/elastica', '7.1.0', 'The "%s" class is deprecated, use "%s" instead. It will be removed in 8.0.', Fail::class, FailProcessor::class); /** * Elastica Fail Processor. diff --git a/src/Processor/Join.php b/src/Processor/Join.php index a212757a0a..07a49ad9e4 100644 --- a/src/Processor/Join.php +++ b/src/Processor/Join.php @@ -2,7 +2,7 @@ namespace Elastica\Processor; -trigger_deprecation('ruflin/elastica', '7.1.0', 'The "%s" class is deprecated, use "%s" instead. It will be removed in 8.0.', Join::class, JoinProcessor::class); +\trigger_deprecation('ruflin/elastica', '7.1.0', 'The "%s" class is deprecated, use "%s" instead. It will be removed in 8.0.', Join::class, JoinProcessor::class); /** * Elastica Join Processor. diff --git a/src/Processor/Json.php b/src/Processor/Json.php index 0002982657..6de578cbb6 100644 --- a/src/Processor/Json.php +++ b/src/Processor/Json.php @@ -2,7 +2,7 @@ namespace Elastica\Processor; -trigger_deprecation('ruflin/elastica', '7.1.0', 'The "%s" class is deprecated, use "%s" instead. It will be removed in 8.0.', Json::class, JsonProcessor::class); +\trigger_deprecation('ruflin/elastica', '7.1.0', 'The "%s" class is deprecated, use "%s" instead. It will be removed in 8.0.', Json::class, JsonProcessor::class); /** * Elastica Json Processor. diff --git a/src/Processor/Kv.php b/src/Processor/Kv.php index 19155626d5..c12ac709c8 100644 --- a/src/Processor/Kv.php +++ b/src/Processor/Kv.php @@ -2,7 +2,7 @@ namespace Elastica\Processor; -trigger_deprecation('ruflin/elastica', '7.1.0', 'The "%s" class is deprecated, use "%s" instead. It will be removed in 8.0.', Kv::class, KvProcessor::class); +\trigger_deprecation('ruflin/elastica', '7.1.0', 'The "%s" class is deprecated, use "%s" instead. It will be removed in 8.0.', Kv::class, KvProcessor::class); /** * Elastica KV Processor. diff --git a/src/Processor/Lowercase.php b/src/Processor/Lowercase.php index f75d1c035b..c15cb29c04 100644 --- a/src/Processor/Lowercase.php +++ b/src/Processor/Lowercase.php @@ -2,7 +2,7 @@ namespace Elastica\Processor; -trigger_deprecation('ruflin/elastica', '7.1.0', 'The "%s" class is deprecated, use "%s" instead. It will be removed in 8.0.', Lowercase::class, LowercaseProcessor::class); +\trigger_deprecation('ruflin/elastica', '7.1.0', 'The "%s" class is deprecated, use "%s" instead. It will be removed in 8.0.', Lowercase::class, LowercaseProcessor::class); /** * Elastica Lowercase Processor. diff --git a/src/Processor/Remove.php b/src/Processor/Remove.php index 4ee256df0d..88d5f99fef 100644 --- a/src/Processor/Remove.php +++ b/src/Processor/Remove.php @@ -2,7 +2,7 @@ namespace Elastica\Processor; -trigger_deprecation('ruflin/elastica', '7.1.0', 'The "%s" class is deprecated, use "%s" instead. It will be removed in 8.0.', Remove::class, RemoveProcessor::class); +\trigger_deprecation('ruflin/elastica', '7.1.0', 'The "%s" class is deprecated, use "%s" instead. It will be removed in 8.0.', Remove::class, RemoveProcessor::class); /** * Elastica Remove Processor. diff --git a/src/Processor/Rename.php b/src/Processor/Rename.php index 136c722871..1a1e7cf8a8 100644 --- a/src/Processor/Rename.php +++ b/src/Processor/Rename.php @@ -2,7 +2,7 @@ namespace Elastica\Processor; -trigger_deprecation('ruflin/elastica', '7.1.0', 'The "%s" class is deprecated, use "%s" instead. It will be removed in 8.0.', Rename::class, RenameProcessor::class); +\trigger_deprecation('ruflin/elastica', '7.1.0', 'The "%s" class is deprecated, use "%s" instead. It will be removed in 8.0.', Rename::class, RenameProcessor::class); /** * Elastica Rename Processor. diff --git a/src/Processor/Set.php b/src/Processor/Set.php index babb1a0a9e..abcc216219 100644 --- a/src/Processor/Set.php +++ b/src/Processor/Set.php @@ -2,7 +2,7 @@ namespace Elastica\Processor; -trigger_deprecation('ruflin/elastica', '7.1.0', 'The "%s" class is deprecated, use "%s" instead. It will be removed in 8.0.', Set::class, SetProcessor::class); +\trigger_deprecation('ruflin/elastica', '7.1.0', 'The "%s" class is deprecated, use "%s" instead. It will be removed in 8.0.', Set::class, SetProcessor::class); /** * Elastica Set Processor. diff --git a/src/Processor/Sort.php b/src/Processor/Sort.php index f2dafbc30a..0bf9fa02f3 100644 --- a/src/Processor/Sort.php +++ b/src/Processor/Sort.php @@ -2,7 +2,7 @@ namespace Elastica\Processor; -trigger_deprecation('ruflin/elastica', '7.1.0', 'The "%s" class is deprecated, use "%s" instead. It will be removed in 8.0.', Sort::class, SortProcessor::class); +\trigger_deprecation('ruflin/elastica', '7.1.0', 'The "%s" class is deprecated, use "%s" instead. It will be removed in 8.0.', Sort::class, SortProcessor::class); /** * Elastica Sort Processor. diff --git a/src/Processor/Split.php b/src/Processor/Split.php index 9037f1d897..59941c6376 100644 --- a/src/Processor/Split.php +++ b/src/Processor/Split.php @@ -2,7 +2,7 @@ namespace Elastica\Processor; -trigger_deprecation('ruflin/elastica', '7.1.0', 'The "%s" class is deprecated, use "%s" instead. It will be removed in 8.0.', Split::class, SplitProcessor::class); +\trigger_deprecation('ruflin/elastica', '7.1.0', 'The "%s" class is deprecated, use "%s" instead. It will be removed in 8.0.', Split::class, SplitProcessor::class); /** * Elastica Split Processor. diff --git a/src/Processor/Trim.php b/src/Processor/Trim.php index 2695ebf168..07fc12e5f9 100644 --- a/src/Processor/Trim.php +++ b/src/Processor/Trim.php @@ -2,7 +2,7 @@ namespace Elastica\Processor; -trigger_deprecation('ruflin/elastica', '7.1.0', 'The "%s" class is deprecated, use "%s" instead. It will be removed in 8.0.', Trim::class, TrimProcessor::class); +\trigger_deprecation('ruflin/elastica', '7.1.0', 'The "%s" class is deprecated, use "%s" instead. It will be removed in 8.0.', Trim::class, TrimProcessor::class); /** * Elastica Trim Processor. diff --git a/src/Processor/Uppercase.php b/src/Processor/Uppercase.php index 6376108600..cd9a71fe0e 100644 --- a/src/Processor/Uppercase.php +++ b/src/Processor/Uppercase.php @@ -2,7 +2,7 @@ namespace Elastica\Processor; -trigger_deprecation('ruflin/elastica', '7.1.0', 'The "%s" class is deprecated, use "%s" instead. It will be removed in 8.0.', Uppercase::class, UppercaseProcessor::class); +\trigger_deprecation('ruflin/elastica', '7.1.0', 'The "%s" class is deprecated, use "%s" instead. It will be removed in 8.0.', Uppercase::class, UppercaseProcessor::class); /** * Elastica Uppercase Processor. diff --git a/src/Query/Match.php b/src/Query/Match.php index b60e73d33f..5e76eabc99 100644 --- a/src/Query/Match.php +++ b/src/Query/Match.php @@ -2,7 +2,7 @@ namespace Elastica\Query; -trigger_deprecation('ruflin/elastica', '7.1.0', 'The "%s" class is deprecated, use "%s" instead. "match" is a reserved keyword starting from PHP 8.0. It will be removed in 8.0.', Match::class, MatchQuery::class); +\trigger_deprecation('ruflin/elastica', '7.1.0', 'The "%s" class is deprecated, use "%s" instead. "match" is a reserved keyword starting from PHP 8.0. It will be removed in 8.0.', Match::class, MatchQuery::class); /** * Match query. diff --git a/src/QueryBuilder/DSL/Aggregation.php b/src/QueryBuilder/DSL/Aggregation.php index b461afb1c0..1cbf335e4d 100644 --- a/src/QueryBuilder/DSL/Aggregation.php +++ b/src/QueryBuilder/DSL/Aggregation.php @@ -239,7 +239,7 @@ public function global(string $name): GlobalAggregation */ public function global_agg(string $name): GlobalAggregation { - trigger_deprecation('ruflin/elastica', '7.1.0', 'The "%s()" method is deprecated, use "global()" instead. It will be removed in 8.0.', __METHOD__); + \trigger_deprecation('ruflin/elastica', '7.1.0', 'The "%s()" method is deprecated, use "global()" instead. It will be removed in 8.0.', __METHOD__); return $this->global($name); } diff --git a/src/Transport/HttpAdapter.php b/src/Transport/HttpAdapter.php index 83488519a8..c5d7a69704 100644 --- a/src/Transport/HttpAdapter.php +++ b/src/Transport/HttpAdapter.php @@ -15,7 +15,7 @@ use Ivory\HttpAdapter\Message\Response as HttpAdapterResponse; use Ivory\HttpAdapter\Message\Stream\StringStream; -trigger_deprecation('ruflin/elastica', '7.1.1', 'The "%s" class is deprecated. It will be removed in 8.0.', HttpAdapter::class); +\trigger_deprecation('ruflin/elastica', '7.1.1', 'The "%s" class is deprecated. It will be removed in 8.0.', HttpAdapter::class); /** * @deprecated since version 7.1.1 diff --git a/src/Util.php b/src/Util.php index 8bd91ad389..2b7060cad6 100644 --- a/src/Util.php +++ b/src/Util.php @@ -212,7 +212,7 @@ public static function convertDateTimeObject(\DateTime $dateTime, bool $includeT */ public static function getParamName($class) { - trigger_deprecation('ruflin/elastica', '7.1.0', 'The "%s()" method is deprecated. It will be removed in 8.0.', __METHOD__); + \trigger_deprecation('ruflin/elastica', '7.1.0', 'The "%s()" method is deprecated. It will be removed in 8.0.', __METHOD__); if (\is_object($class)) { $class = \get_class($class);