Skip to content

Commit

Permalink
fix CS
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-gribanov committed Dec 20, 2023
1 parent 767829c commit 338fd64
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 27 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ phpunit.xml
composer.lock
.php_cs.cache
.phpunit.result.cache
.php-cs-fixer.cache

3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
"require-dev": {
"phpunit/phpunit": "~7.0|~8.0|~9.0",
"phpstan/phpstan": "^0.12",
"phpstan/phpstan-phpunit": "^0.12"
"phpstan/phpstan-phpunit": "^0.12",
"friendsofphp/php-cs-fixer": "^3.41"
},
"suggest": {
"splitbrain/php-archive": "Greatly reduces memory usage for the geoip2:update command"
Expand Down
10 changes: 5 additions & 5 deletions src/Command/UpdateDatabaseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ protected function configure(): void
$databases_help .= sprintf(' * <info>%s</info>'.PHP_EOL, $name);
}

[$first, $second, ] = array_keys($this->databases);
[$first, $second] = array_keys($this->databases);

$help .= <<<EOT
Expand Down Expand Up @@ -105,10 +105,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int
throw new \InvalidArgumentException(sprintf('Undefined "%s" database.', $database));
}

if (!array_key_exists('url', $this->databases[$database]) ||
!array_key_exists('path', $this->databases[$database]) ||
!is_string($this->databases[$database]['url']) ||
!is_string($this->databases[$database]['path'])
if (!array_key_exists('url', $this->databases[$database])
|| !array_key_exists('path', $this->databases[$database])
|| !is_string($this->databases[$database]['url'])
|| !is_string($this->databases[$database]['path'])
) {
throw new \InvalidArgumentException(sprintf('Invalid "%s" database config.', $database));
}
Expand Down
40 changes: 20 additions & 20 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,10 @@ private function normalizeDefaultDatabase(NodeDefinition $root_node): void
->beforeNormalization()
->ifTrue(static function ($v): bool {
return
is_array($v) &&
!array_key_exists('default_database', $v) &&
!empty($v['databases']) &&
is_array($v['databases']);
is_array($v)
&& !array_key_exists('default_database', $v)
&& !empty($v['databases'])
&& is_array($v['databases']);
})
->then(static function (array $v): array {
$keys = array_keys($v['databases']);
Expand Down Expand Up @@ -268,10 +268,10 @@ private function validateAvailableDefaultDatabase(NodeDefinition $root_node): vo
->validate()
->ifTrue(static function ($v): bool {
return
is_array($v) &&
array_key_exists('default_database', $v) &&
!empty($v['databases']) &&
!array_key_exists($v['default_database'], $v['databases']);
is_array($v)
&& array_key_exists('default_database', $v)
&& !empty($v['databases'])
&& !array_key_exists($v['default_database'], $v['databases']);
})
->then(static function (array $v): array {
$databases = implode('", "', array_keys($v['databases']));
Expand All @@ -292,10 +292,10 @@ private function allowGlobalLicense(NodeDefinition $root_node): void
->beforeNormalization()
->ifTrue(static function ($v): bool {
return
is_array($v) &&
array_key_exists('license', $v) &&
array_key_exists('databases', $v) &&
is_array($v['databases']);
is_array($v)
&& array_key_exists('license', $v)
&& array_key_exists('databases', $v)
&& is_array($v['databases']);
})
->then(static function (array $v): array {
foreach ($v['databases'] as $name => $database) {
Expand All @@ -320,10 +320,10 @@ private function allowGlobalLocales(NodeDefinition $root_node): void
->beforeNormalization()
->ifTrue(static function ($v): bool {
return
is_array($v) &&
array_key_exists('locales', $v) &&
array_key_exists('databases', $v) &&
is_array($v['databases']);
is_array($v)
&& array_key_exists('locales', $v)
&& array_key_exists('databases', $v)
&& is_array($v['databases']);
})
->then(static function (array $v): array {
foreach ($v['databases'] as $name => $database) {
Expand Down Expand Up @@ -386,10 +386,10 @@ private function normalizeUrl(NodeDefinition $database_node): void
->beforeNormalization()
->ifTrue(static function ($v): bool {
return
is_array($v) &&
!array_key_exists('url', $v) &&
array_key_exists('license', $v) &&
array_key_exists('edition', $v);
is_array($v)
&& !array_key_exists('url', $v)
&& array_key_exists('license', $v)
&& array_key_exists('edition', $v);
})
->then(static function (array $v): array {
$v['url'] = sprintf(self::URL, urlencode($v['edition']), urlencode($v['license']));
Expand Down
2 changes: 1 addition & 1 deletion src/Reader/ReaderFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function __construct(array $databases, string $reader_class = Reader::cla
*
* @return Reader
*/
public function create(string $database, ?array $locales = null): Reader
public function create(string $database, array $locales = null): Reader
{
if (!array_key_exists($database, $this->databases)) {
$databases = implode('", "', array_keys($this->databases));
Expand Down

0 comments on commit 338fd64

Please sign in to comment.