Skip to content

Commit

Permalink
enable native_function_invocation
Browse files Browse the repository at this point in the history
- enable php-cs-fixer's native_function_invocation rule
  • Loading branch information
wickedOne committed Dec 20, 2024
1 parent fb26d5e commit 19c50b9
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 14 deletions.
1 change: 0 additions & 1 deletion .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
'strict_comparison' => true,
'strict_param' => true,
'fopen_flags' => array('b_mode' => true),
'native_function_invocation' => false,
))
->setFinder(
(new PhpCsFixer\Finder())
Expand Down
4 changes: 2 additions & 2 deletions src/Command/AbstractPhraseKeyCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private function list(OutputInterface $output, ?string $key, array $tags): int
try {
$result = $this->tagService->list($key, $tags);
} catch (ProviderException $e) {
$output->writeln(sprintf('<error>%s</error>', $e->getMessage()));
$output->writeln(\sprintf('<error>%s</error>', $e->getMessage()));

return Command::FAILURE;
}
Expand All @@ -85,7 +85,7 @@ private function list(OutputInterface $output, ?string $key, array $tags): int
$output->writeln('<info>your query would match the following keys (sample):</info>');

foreach ($result as $item) {
$output->writeln(sprintf('<comment>></comment> <info>%s</info>', $item));
$output->writeln(\sprintf('<comment>></comment> <info>%s</info>', $item));
}

return Command::SUCCESS;
Expand Down
4 changes: 2 additions & 2 deletions src/Command/PhraseKeyTagCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ protected function executeCommand(InputInterface $input, OutputInterface $output
try {
$keys = $this->tagService->tag($queryKey, $queryTag, $tag);
} catch (ProviderException $e) {
$output->writeln(sprintf('<error>%s</error>', $e->getMessage()));
$output->writeln(\sprintf('<error>%s</error>', $e->getMessage()));

return Command::FAILURE;
}

$output->writeln(sprintf('<info>successfully tagged %d keys with "%s"</info>', $keys, implode(', ', $tag)));
$output->writeln(\sprintf('<info>successfully tagged %d keys with "%s"</info>', $keys, implode(', ', $tag)));

return Command::SUCCESS;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Command/PhraseKeyUntagCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ protected function executeCommand(InputInterface $input, OutputInterface $output
try {
$keys = $this->tagService->untag($queryKey, $queryTag, $tag);
} catch (ProviderException $e) {
$output->writeln(sprintf('<error>%s</error>', $e->getMessage()));
$output->writeln(\sprintf('<error>%s</error>', $e->getMessage()));

return Command::FAILURE;
}

$output->writeln(sprintf('<info>successfully untagged %d keys with "%s"</info>', $keys, implode(', ', $tag)));
$output->writeln(\sprintf('<info>successfully untagged %d keys with "%s"</info>', $keys, implode(', ', $tag)));

return Command::SUCCESS;
}
Expand Down
10 changes: 5 additions & 5 deletions src/Service/PhraseTagService.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function list(?string $key, array $tags): array
]);

if (200 !== $statusCode = $response->getStatusCode()) {
throw new ProviderException(sprintf('phrase replied with an error (%d): "%s"', $statusCode, $response->getContent(false)), $response);
throw new ProviderException(\sprintf('phrase replied with an error (%d): "%s"', $statusCode, $response->getContent(false)), $response);
}

/** @var array{name: string} $arr */
Expand Down Expand Up @@ -76,14 +76,14 @@ public function tag(?string $key, array $tags, array $addTags): int
]);

if (200 !== $statusCode = $response->getStatusCode()) {
throw new ProviderException(sprintf('phrase replied with an error (%d): "%s"', $statusCode, $response->getContent(false)), $response);
throw new ProviderException(\sprintf('phrase replied with an error (%d): "%s"', $statusCode, $response->getContent(false)), $response);
}

/** @var array{records_affected: string} $arr */
$arr = $response->toArray();
$records = $arr['records_affected'];

$this->logger->info(sprintf('tagged %d keys matching "%s" with tag(s) "%s"', $records, $query, implode(', ', $addTags)));
$this->logger->info(\sprintf('tagged %d keys matching "%s" with tag(s) "%s"', $records, $query, implode(', ', $addTags)));

return (int) $records;
}
Expand All @@ -110,14 +110,14 @@ public function untag(?string $key, array $tags, array $removeTags): int
]);

if (200 !== $statusCode = $response->getStatusCode()) {
throw new ProviderException(sprintf('phrase replied with an error (%d): "%s"', $statusCode, $response->getContent(false)), $response);
throw new ProviderException(\sprintf('phrase replied with an error (%d): "%s"', $statusCode, $response->getContent(false)), $response);
}

/** @var array{records_affected: string} $arr */
$arr = $response->toArray();
$records = $arr['records_affected'];

$this->logger->info(sprintf('untagged %d keys matching "%s" with tag(s) "%s"', $records, $query, implode(', ', $removeTags)));
$this->logger->info(\sprintf('untagged %d keys matching "%s" with tag(s) "%s"', $records, $query, implode(', ', $removeTags)));

return (int) $records;
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Service/PhraseTagServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public function testTag(?string $key, array $tags, array $newTags): void
$this->getLogger()
->expects(self::once())
->method('info')
->with(sprintf('tagged 10 keys matching "%s" with tag(s) "%s"', $this->query($key, $tags), implode(', ', $newTags)));
->with(\sprintf('tagged 10 keys matching "%s" with tag(s) "%s"', $this->query($key, $tags), implode(', ', $newTags)));

$responses = [
'tag keys' => function (string $method, string $url, array $options = []) use ($key, $tags, $newTags): ResponseInterface {
Expand Down Expand Up @@ -158,7 +158,7 @@ public function testUnTag(?string $key, array $tags, array $newTags): void
$this->getLogger()
->expects(self::once())
->method('info')
->with(sprintf('untagged 10 keys matching "%s" with tag(s) "%s"', $this->query($key, $tags), implode(', ', $newTags)));
->with(\sprintf('untagged 10 keys matching "%s" with tag(s) "%s"', $this->query($key, $tags), implode(', ', $newTags)));

$responses = [
'untag keys' => function (string $method, string $url, array $options = []) use ($key, $tags, $newTags): ResponseInterface {
Expand Down

0 comments on commit 19c50b9

Please sign in to comment.