diff --git a/composer.json b/composer.json index 9384ccd..c9cbd64 100644 --- a/composer.json +++ b/composer.json @@ -53,7 +53,8 @@ "config": { "sort-packages": true, "allow-plugins": { - "symfony/flex": true + "symfony/flex": true, + "php-http/discovery": true } } } diff --git a/src/Bridge/Symfony/DependencyInjection/Configuration.php b/src/Bridge/Symfony/DependencyInjection/Configuration.php index a6cbaef..743e3a5 100644 --- a/src/Bridge/Symfony/DependencyInjection/Configuration.php +++ b/src/Bridge/Symfony/DependencyInjection/Configuration.php @@ -108,7 +108,7 @@ public function getConfigTreeBuilder(): TreeBuilder ->validate() ->ifTrue(fn (array $config): bool => $config['default_connection'] && !\array_key_exists($config['default_connection'], $config['connections'])) ->then(function (array $v) { - throw new InvalidConfigurationException(sprintf('The default connection "%s" does not exists. Available connections are: "%s".', $v['default_connection'], implode('", "', array_keys($v['connections'])))); + throw new InvalidConfigurationException(\sprintf('The default connection "%s" does not exists. Available connections are: "%s".', $v['default_connection'], implode('", "', array_keys($v['connections'])))); }) ->end() ; diff --git a/src/IndexBuilder.php b/src/IndexBuilder.php index 3c5b056..344c33a 100644 --- a/src/IndexBuilder.php +++ b/src/IndexBuilder.php @@ -40,11 +40,11 @@ public function createIndex(string $indexName, array $context = []): Index { $mapping = $this->mappingProvider->provideMapping($indexName, $context); - $realName = sprintf('%s_%s', $indexName, date('Y-m-d-His')); + $realName = \sprintf('%s_%s', $indexName, date('Y-m-d-His')); $index = $this->client->getIndex($realName); if ($index->exists()) { - throw new RuntimeException(sprintf('Index "%s" is already created, something is wrong.', $index->getName())); + throw new RuntimeException(\sprintf('Index "%s" is already created, something is wrong.', $index->getName())); } $index->create($mapping ?? []); @@ -97,7 +97,7 @@ public function migrate(Index $currentIndex, array $params = [], array $context $response = $reindex->run(); if (!$response->isOk()) { - throw new RuntimeException(sprintf('Reindex call failed. %s', $response->getError())); + throw new RuntimeException(\sprintf('Reindex call failed. %s', $response->getError())); } $taskId = $response->getData()['task']; @@ -172,14 +172,14 @@ public function purgeOldIndices(string $indexName, bool $dryRun = false): array $index = new \Elastica\Index($this->client, $realIndexName); $index->delete(); } - $operations[] = sprintf('%s deleted.', $realIndexName); + $operations[] = \sprintf('%s deleted.', $realIndexName); } elseif ($livePassed && 1 === $afterLiveCounter) { // Close if (false === $dryRun) { $index = new \Elastica\Index($this->client, $realIndexName); $index->close(); } - $operations[] = sprintf('%s closed.', $realIndexName); + $operations[] = \sprintf('%s closed.', $realIndexName); } } diff --git a/src/IndexNameMapper.php b/src/IndexNameMapper.php index 7d151da..75f5d9e 100644 --- a/src/IndexNameMapper.php +++ b/src/IndexNameMapper.php @@ -28,7 +28,7 @@ public function __construct(?string $prefix, array $indexClassMapping) public function getPrefixedIndex(string $name): string { if ($this->prefix) { - return sprintf('%s_%s', $this->prefix, $name); + return \sprintf('%s_%s', $this->prefix, $name); } return $name; @@ -42,7 +42,7 @@ public function getIndexNameFromClass(string $className): string $indexName = array_search($className, $this->indexClassMapping, true); if (!$indexName) { - throw new RuntimeException(sprintf('The given type (%s) does not exist in the configuration.', $className)); + throw new RuntimeException(\sprintf('The given type (%s) does not exist in the configuration.', $className)); } return $this->getPrefixedIndex($indexName); @@ -54,7 +54,7 @@ public function getIndexNameFromClass(string $className): string public function getClassFromIndexName(string $indexName): string { if (!isset($this->indexClassMapping[$indexName])) { - throw new RuntimeException(sprintf('Unknown class for index "%s". Please check your configuration.', $indexName)); + throw new RuntimeException(\sprintf('Unknown class for index "%s". Please check your configuration.', $indexName)); } return $this->indexClassMapping[$indexName]; @@ -63,7 +63,7 @@ public function getClassFromIndexName(string $indexName): string public function getPureIndexName(string $fullIndexName): string { if ($this->prefix) { - $pattern = sprintf('/%s_(.+)_\d{4}-\d{2}-\d{2}-\d+/i', preg_quote($this->prefix, '/')); + $pattern = \sprintf('/%s_(.+)_\d{4}-\d{2}-\d{2}-\d+/i', preg_quote($this->prefix, '/')); } else { $pattern = '/(.+)_\d{4}-\d{2}-\d{2}-\d+/i'; } diff --git a/src/Mapping/PhpProvider.php b/src/Mapping/PhpProvider.php index 1ce4bb3..1644df7 100644 --- a/src/Mapping/PhpProvider.php +++ b/src/Mapping/PhpProvider.php @@ -29,7 +29,7 @@ public function provideMapping(string $indexName, array $context = []): ?array $fileName = $context['filename'] ?? ($indexName . '_mapping.php'); $mappingFilePath = $this->configurationDirectory . \DIRECTORY_SEPARATOR . $fileName; if (!is_file($mappingFilePath)) { - throw new InvalidException(sprintf('Mapping file "%s" not found.', $mappingFilePath)); + throw new InvalidException(\sprintf('Mapping file "%s" not found.', $mappingFilePath)); } $mapping = require $mappingFilePath; diff --git a/src/Mapping/YamlProvider.php b/src/Mapping/YamlProvider.php index 2296213..12583e1 100644 --- a/src/Mapping/YamlProvider.php +++ b/src/Mapping/YamlProvider.php @@ -34,7 +34,7 @@ public function provideMapping(string $indexName, array $context = []): ?array $fileName = $context['filename'] ?? ($indexName . '_mapping.yaml'); $mappingFilePath = $this->configurationDirectory . \DIRECTORY_SEPARATOR . $fileName; if (!is_file($mappingFilePath)) { - throw new InvalidException(sprintf('Mapping file "%s" not found. Please check your configuration.', $mappingFilePath)); + throw new InvalidException(\sprintf('Mapping file "%s" not found. Please check your configuration.', $mappingFilePath)); } $mapping = $this->parser->parseFile($mappingFilePath); diff --git a/src/Messenger/IndexationRequest.php b/src/Messenger/IndexationRequest.php index e456df9..6948ecd 100644 --- a/src/Messenger/IndexationRequest.php +++ b/src/Messenger/IndexationRequest.php @@ -20,7 +20,7 @@ final class IndexationRequest implements IndexationRequestInterface public function __construct(string $className, string $id, string $operation = IndexationRequestHandler::OP_INDEX) { if (!\in_array($operation, IndexationRequestHandler::OPERATIONS, true)) { - throw new \InvalidArgumentException(sprintf('Not supported operation "%s" given.', $operation)); + throw new \InvalidArgumentException(\sprintf('Not supported operation "%s" given.', $operation)); } $this->className = $className; diff --git a/tests/Symfony/TestKernel.php b/tests/Symfony/TestKernel.php index 696c625..915fb7c 100644 --- a/tests/Symfony/TestKernel.php +++ b/tests/Symfony/TestKernel.php @@ -57,10 +57,10 @@ protected function configureRoutes($routes): void $routes->add('/with_response', TestController::class . '::withResponse', 'with_response'); } else { $routeConfigurator = $routes->add('with_exception', '/with_exception'); - $routeConfigurator->controller(sprintf('%s::withException', TestController::class)); + $routeConfigurator->controller(\sprintf('%s::withException', TestController::class)); $routeConfigurator = $routes->add('with_response', '/with_response'); - $routeConfigurator->controller(sprintf('%s::withResponse', TestController::class)); + $routeConfigurator->controller(\sprintf('%s::withResponse', TestController::class)); } } }