From a59c7ad521dd329a260e792beea6bb10dfa68db3 Mon Sep 17 00:00:00 2001 From: Oliwier Ptak Date: Fri, 4 Aug 2023 12:36:41 +0200 Subject: [PATCH] code style --- .../ErrorLogLoggerPluginConfigurator.php | 51 ++++++++--------- .../Plugin/NulleeLoggerPluginConfigurator.php | 43 +++++++-------- .../Plugin/StreamLoggerPluginConfigurator.php | 55 ++++++++----------- .../Plugin/SyslogLoggerPluginConfigurator.php | 55 ++++++++----------- 4 files changed, 88 insertions(+), 116 deletions(-) diff --git a/src/Shared/LoggerBasic/Configurator/Plugin/ErrorLogLoggerPluginConfigurator.php b/src/Shared/LoggerBasic/Configurator/Plugin/ErrorLogLoggerPluginConfigurator.php index 4a71c89..229456a 100644 --- a/src/Shared/LoggerBasic/Configurator/Plugin/ErrorLogLoggerPluginConfigurator.php +++ b/src/Shared/LoggerBasic/Configurator/Plugin/ErrorLogLoggerPluginConfigurator.php @@ -6,7 +6,7 @@ * Everon logger configuration file. Auto-generated. */ -declare(strict_types = 1); +declare(strict_types=1); namespace Everon\Shared\LoggerBasic\Configurator\Plugin; @@ -14,11 +14,14 @@ use DateTimeZone; use Throwable; use UnexpectedValueException; + use function array_filter; use function array_key_exists; use function array_keys; +use function array_replace_recursive; use function in_array; use function sort; + use const ARRAY_FILTER_USE_KEY; use const SORT_STRING; @@ -161,7 +164,7 @@ public function requireAll(): self if (empty($errors) === false) { throw new UnexpectedValueException( - implode("\n", $errors), + implode("\n", $errors) ); } @@ -179,6 +182,7 @@ public function fromArray(array $data): self ]; + foreach ($metadata as $name => $mappedName) { $meta = self::METADATA[$name]; $value = $data[$mappedName] ?? $this->$name ?? null; @@ -300,6 +304,7 @@ public function toArray(): array } + return $data; } @@ -316,9 +321,7 @@ protected function map(array $data, array $mappings): array if (self::METADATA[$name]['type'] === 'popo') { $popo = self::METADATA[$name]['default']; - $value = $this->$name !== null ? $this->$name->toMappedArray(...$mappings) : (new $popo)->toMappedArray( - ...$mappings, - ); + $value = $this->$name !== null ? $this->$name->toMappedArray(...$mappings) : (new $popo)->toMappedArray(...$mappings); } $key = $this->mapKeyName($mappings, $propertyMetadata['mappingPolicyValue']); @@ -352,22 +355,22 @@ static function (string $key): string { $mappingPolicy['snake-to-camel'] = static function (string $key): string { $stringTokens = explode('_', mb_strtolower($key)); - $camelizedString = array_shift($stringTokens); - foreach ($stringTokens as $token) { - $camelizedString .= ucfirst($token); - } + $camelizedString = array_shift($stringTokens); + foreach ($stringTokens as $token) { + $camelizedString .= ucfirst($token); + } - return $camelizedString; + return $camelizedString; }; $mappingPolicy['camel-to-snake'] = static function (string $key): string { $camelizedStringTokens = preg_split('/(?<=[^A-Z])(?=[A-Z])/', $key); - if ($camelizedStringTokens !== false && count($camelizedStringTokens) > 0) { - $key = mb_strtolower(implode('_', $camelizedStringTokens)); - } + if ($camelizedStringTokens !== false && count($camelizedStringTokens) > 0) { + $key = mb_strtolower(implode('_', $camelizedStringTokens)); + } - return $key; + return $key; }; } @@ -426,9 +429,7 @@ public function requirePluginClass(): string public function setPluginClass(?string $pluginClass): self { - $this->pluginClass = $pluginClass; - $this->updateMap['pluginClass'] = true; - return $this; + $this->pluginClass = $pluginClass; $this->updateMap['pluginClass'] = true; return $this; } /** @@ -463,9 +464,7 @@ public function requirePluginFactoryClass(): string */ public function setPluginFactoryClass(?string $pluginFactoryClass): self { - $this->pluginFactoryClass = $pluginFactoryClass; - $this->updateMap['pluginFactoryClass'] = true; - return $this; + $this->pluginFactoryClass = $pluginFactoryClass; $this->updateMap['pluginFactoryClass'] = true; return $this; } /** @@ -500,9 +499,7 @@ public function requireShouldBubble(): bool */ public function setShouldBubble(bool $shouldBubble): self { - $this->shouldBubble = $shouldBubble; - $this->updateMap['shouldBubble'] = true; - return $this; + $this->shouldBubble = $shouldBubble; $this->updateMap['shouldBubble'] = true; return $this; } /** @@ -537,9 +534,7 @@ public function requireMessageType(): int */ public function setMessageType(?int $messageType): self { - $this->messageType = $messageType; - $this->updateMap['messageType'] = true; - return $this; + $this->messageType = $messageType; $this->updateMap['messageType'] = true; return $this; } /** @@ -574,8 +569,6 @@ public function requireExpandNewlines(): bool */ public function setExpandNewlines(bool $expandNewlines): self { - $this->expandNewlines = $expandNewlines; - $this->updateMap['expandNewlines'] = true; - return $this; + $this->expandNewlines = $expandNewlines; $this->updateMap['expandNewlines'] = true; return $this; } } diff --git a/src/Shared/LoggerBasic/Configurator/Plugin/NulleeLoggerPluginConfigurator.php b/src/Shared/LoggerBasic/Configurator/Plugin/NulleeLoggerPluginConfigurator.php index d54b3eb..2e19b1d 100644 --- a/src/Shared/LoggerBasic/Configurator/Plugin/NulleeLoggerPluginConfigurator.php +++ b/src/Shared/LoggerBasic/Configurator/Plugin/NulleeLoggerPluginConfigurator.php @@ -6,7 +6,7 @@ * Everon logger configuration file. Auto-generated. */ -declare(strict_types = 1); +declare(strict_types=1); namespace Everon\Shared\LoggerBasic\Configurator\Plugin; @@ -14,11 +14,14 @@ use DateTimeZone; use Throwable; use UnexpectedValueException; + use function array_filter; use function array_key_exists; use function array_keys; +use function array_replace_recursive; use function in_array; use function sort; + use const ARRAY_FILTER_USE_KEY; use const SORT_STRING; @@ -129,7 +132,7 @@ public function requireAll(): self if (empty($errors) === false) { throw new UnexpectedValueException( - implode("\n", $errors), + implode("\n", $errors) ); } @@ -145,6 +148,7 @@ public function fromArray(array $data): self ]; + foreach ($metadata as $name => $mappedName) { $meta = self::METADATA[$name]; $value = $data[$mappedName] ?? $this->$name ?? null; @@ -264,6 +268,7 @@ public function toArray(): array } + return $data; } @@ -280,9 +285,7 @@ protected function map(array $data, array $mappings): array if (self::METADATA[$name]['type'] === 'popo') { $popo = self::METADATA[$name]['default']; - $value = $this->$name !== null ? $this->$name->toMappedArray(...$mappings) : (new $popo)->toMappedArray( - ...$mappings, - ); + $value = $this->$name !== null ? $this->$name->toMappedArray(...$mappings) : (new $popo)->toMappedArray(...$mappings); } $key = $this->mapKeyName($mappings, $propertyMetadata['mappingPolicyValue']); @@ -316,22 +319,22 @@ static function (string $key): string { $mappingPolicy['snake-to-camel'] = static function (string $key): string { $stringTokens = explode('_', mb_strtolower($key)); - $camelizedString = array_shift($stringTokens); - foreach ($stringTokens as $token) { - $camelizedString .= ucfirst($token); - } + $camelizedString = array_shift($stringTokens); + foreach ($stringTokens as $token) { + $camelizedString .= ucfirst($token); + } - return $camelizedString; + return $camelizedString; }; $mappingPolicy['camel-to-snake'] = static function (string $key): string { $camelizedStringTokens = preg_split('/(?<=[^A-Z])(?=[A-Z])/', $key); - if ($camelizedStringTokens !== false && count($camelizedStringTokens) > 0) { - $key = mb_strtolower(implode('_', $camelizedStringTokens)); - } + if ($camelizedStringTokens !== false && count($camelizedStringTokens) > 0) { + $key = mb_strtolower(implode('_', $camelizedStringTokens)); + } - return $key; + return $key; }; } @@ -390,9 +393,7 @@ public function requirePluginClass(): string public function setPluginClass(?string $pluginClass): self { - $this->pluginClass = $pluginClass; - $this->updateMap['pluginClass'] = true; - return $this; + $this->pluginClass = $pluginClass; $this->updateMap['pluginClass'] = true; return $this; } /** @@ -427,9 +428,7 @@ public function requirePluginFactoryClass(): string */ public function setPluginFactoryClass(?string $pluginFactoryClass): self { - $this->pluginFactoryClass = $pluginFactoryClass; - $this->updateMap['pluginFactoryClass'] = true; - return $this; + $this->pluginFactoryClass = $pluginFactoryClass; $this->updateMap['pluginFactoryClass'] = true; return $this; } /** @@ -464,8 +463,6 @@ public function requireShouldBubble(): bool */ public function setShouldBubble(bool $shouldBubble): self { - $this->shouldBubble = $shouldBubble; - $this->updateMap['shouldBubble'] = true; - return $this; + $this->shouldBubble = $shouldBubble; $this->updateMap['shouldBubble'] = true; return $this; } } diff --git a/src/Shared/LoggerBasic/Configurator/Plugin/StreamLoggerPluginConfigurator.php b/src/Shared/LoggerBasic/Configurator/Plugin/StreamLoggerPluginConfigurator.php index 4341f1b..1e000e1 100644 --- a/src/Shared/LoggerBasic/Configurator/Plugin/StreamLoggerPluginConfigurator.php +++ b/src/Shared/LoggerBasic/Configurator/Plugin/StreamLoggerPluginConfigurator.php @@ -6,7 +6,7 @@ * Everon logger configuration file. Auto-generated. */ -declare(strict_types = 1); +declare(strict_types=1); namespace Everon\Shared\LoggerBasic\Configurator\Plugin; @@ -14,11 +14,14 @@ use DateTimeZone; use Throwable; use UnexpectedValueException; + use function array_filter; use function array_key_exists; use function array_keys; +use function array_replace_recursive; use function in_array; use function sort; + use const ARRAY_FILTER_USE_KEY; use const SORT_STRING; @@ -172,7 +175,7 @@ public function requireAll(): self if (empty($errors) === false) { throw new UnexpectedValueException( - implode("\n", $errors), + implode("\n", $errors) ); } @@ -191,6 +194,7 @@ public function fromArray(array $data): self ]; + foreach ($metadata as $name => $mappedName) { $meta = self::METADATA[$name]; $value = $data[$mappedName] ?? $this->$name ?? null; @@ -313,6 +317,7 @@ public function toArray(): array } + return $data; } @@ -329,9 +334,7 @@ protected function map(array $data, array $mappings): array if (self::METADATA[$name]['type'] === 'popo') { $popo = self::METADATA[$name]['default']; - $value = $this->$name !== null ? $this->$name->toMappedArray(...$mappings) : (new $popo)->toMappedArray( - ...$mappings, - ); + $value = $this->$name !== null ? $this->$name->toMappedArray(...$mappings) : (new $popo)->toMappedArray(...$mappings); } $key = $this->mapKeyName($mappings, $propertyMetadata['mappingPolicyValue']); @@ -365,22 +368,22 @@ static function (string $key): string { $mappingPolicy['snake-to-camel'] = static function (string $key): string { $stringTokens = explode('_', mb_strtolower($key)); - $camelizedString = array_shift($stringTokens); - foreach ($stringTokens as $token) { - $camelizedString .= ucfirst($token); - } + $camelizedString = array_shift($stringTokens); + foreach ($stringTokens as $token) { + $camelizedString .= ucfirst($token); + } - return $camelizedString; + return $camelizedString; }; $mappingPolicy['camel-to-snake'] = static function (string $key): string { $camelizedStringTokens = preg_split('/(?<=[^A-Z])(?=[A-Z])/', $key); - if ($camelizedStringTokens !== false && count($camelizedStringTokens) > 0) { - $key = mb_strtolower(implode('_', $camelizedStringTokens)); - } + if ($camelizedStringTokens !== false && count($camelizedStringTokens) > 0) { + $key = mb_strtolower(implode('_', $camelizedStringTokens)); + } - return $key; + return $key; }; } @@ -439,9 +442,7 @@ public function requirePluginClass(): string public function setPluginClass(?string $pluginClass): self { - $this->pluginClass = $pluginClass; - $this->updateMap['pluginClass'] = true; - return $this; + $this->pluginClass = $pluginClass; $this->updateMap['pluginClass'] = true; return $this; } /** @@ -476,9 +477,7 @@ public function requirePluginFactoryClass(): string */ public function setPluginFactoryClass(?string $pluginFactoryClass): self { - $this->pluginFactoryClass = $pluginFactoryClass; - $this->updateMap['pluginFactoryClass'] = true; - return $this; + $this->pluginFactoryClass = $pluginFactoryClass; $this->updateMap['pluginFactoryClass'] = true; return $this; } /** @@ -513,9 +512,7 @@ public function requireShouldBubble(): bool */ public function setShouldBubble(bool $shouldBubble): self { - $this->shouldBubble = $shouldBubble; - $this->updateMap['shouldBubble'] = true; - return $this; + $this->shouldBubble = $shouldBubble; $this->updateMap['shouldBubble'] = true; return $this; } /** @@ -550,9 +547,7 @@ public function requireStreamLocation(): string */ public function setStreamLocation(?string $streamLocation): self { - $this->streamLocation = $streamLocation; - $this->updateMap['streamLocation'] = true; - return $this; + $this->streamLocation = $streamLocation; $this->updateMap['streamLocation'] = true; return $this; } /** @@ -587,9 +582,7 @@ public function requireFilePermission(): int */ public function setFilePermission(?int $filePermission): self { - $this->filePermission = $filePermission; - $this->updateMap['filePermission'] = true; - return $this; + $this->filePermission = $filePermission; $this->updateMap['filePermission'] = true; return $this; } /** @@ -624,8 +617,6 @@ public function requireUseLocking(): bool */ public function setUseLocking(bool $useLocking): self { - $this->useLocking = $useLocking; - $this->updateMap['useLocking'] = true; - return $this; + $this->useLocking = $useLocking; $this->updateMap['useLocking'] = true; return $this; } } diff --git a/src/Shared/LoggerBasic/Configurator/Plugin/SyslogLoggerPluginConfigurator.php b/src/Shared/LoggerBasic/Configurator/Plugin/SyslogLoggerPluginConfigurator.php index e5df3a4..5b6cc37 100644 --- a/src/Shared/LoggerBasic/Configurator/Plugin/SyslogLoggerPluginConfigurator.php +++ b/src/Shared/LoggerBasic/Configurator/Plugin/SyslogLoggerPluginConfigurator.php @@ -6,7 +6,7 @@ * Everon logger configuration file. Auto-generated. */ -declare(strict_types = 1); +declare(strict_types=1); namespace Everon\Shared\LoggerBasic\Configurator\Plugin; @@ -14,11 +14,14 @@ use DateTimeZone; use Throwable; use UnexpectedValueException; + use function array_filter; use function array_key_exists; use function array_keys; +use function array_replace_recursive; use function in_array; use function sort; + use const ARRAY_FILTER_USE_KEY; use const SORT_STRING; @@ -165,7 +168,7 @@ public function requireAll(): self if (empty($errors) === false) { throw new UnexpectedValueException( - implode("\n", $errors), + implode("\n", $errors) ); } @@ -184,6 +187,7 @@ public function fromArray(array $data): self ]; + foreach ($metadata as $name => $mappedName) { $meta = self::METADATA[$name]; $value = $data[$mappedName] ?? $this->$name ?? null; @@ -306,6 +310,7 @@ public function toArray(): array } + return $data; } @@ -322,9 +327,7 @@ protected function map(array $data, array $mappings): array if (self::METADATA[$name]['type'] === 'popo') { $popo = self::METADATA[$name]['default']; - $value = $this->$name !== null ? $this->$name->toMappedArray(...$mappings) : (new $popo)->toMappedArray( - ...$mappings, - ); + $value = $this->$name !== null ? $this->$name->toMappedArray(...$mappings) : (new $popo)->toMappedArray(...$mappings); } $key = $this->mapKeyName($mappings, $propertyMetadata['mappingPolicyValue']); @@ -358,22 +361,22 @@ static function (string $key): string { $mappingPolicy['snake-to-camel'] = static function (string $key): string { $stringTokens = explode('_', mb_strtolower($key)); - $camelizedString = array_shift($stringTokens); - foreach ($stringTokens as $token) { - $camelizedString .= ucfirst($token); - } + $camelizedString = array_shift($stringTokens); + foreach ($stringTokens as $token) { + $camelizedString .= ucfirst($token); + } - return $camelizedString; + return $camelizedString; }; $mappingPolicy['camel-to-snake'] = static function (string $key): string { $camelizedStringTokens = preg_split('/(?<=[^A-Z])(?=[A-Z])/', $key); - if ($camelizedStringTokens !== false && count($camelizedStringTokens) > 0) { - $key = mb_strtolower(implode('_', $camelizedStringTokens)); - } + if ($camelizedStringTokens !== false && count($camelizedStringTokens) > 0) { + $key = mb_strtolower(implode('_', $camelizedStringTokens)); + } - return $key; + return $key; }; } @@ -432,9 +435,7 @@ public function requirePluginClass(): string public function setPluginClass(?string $pluginClass): self { - $this->pluginClass = $pluginClass; - $this->updateMap['pluginClass'] = true; - return $this; + $this->pluginClass = $pluginClass; $this->updateMap['pluginClass'] = true; return $this; } /** @@ -469,9 +470,7 @@ public function requirePluginFactoryClass(): string */ public function setPluginFactoryClass(?string $pluginFactoryClass): self { - $this->pluginFactoryClass = $pluginFactoryClass; - $this->updateMap['pluginFactoryClass'] = true; - return $this; + $this->pluginFactoryClass = $pluginFactoryClass; $this->updateMap['pluginFactoryClass'] = true; return $this; } /** @@ -506,9 +505,7 @@ public function requireShouldBubble(): bool */ public function setShouldBubble(bool $shouldBubble): self { - $this->shouldBubble = $shouldBubble; - $this->updateMap['shouldBubble'] = true; - return $this; + $this->shouldBubble = $shouldBubble; $this->updateMap['shouldBubble'] = true; return $this; } public function getIdent(): ?string @@ -534,9 +531,7 @@ public function requireIdent(): string public function setIdent(?string $ident): self { - $this->ident = $ident; - $this->updateMap['ident'] = true; - return $this; + $this->ident = $ident; $this->updateMap['ident'] = true; return $this; } /** @@ -571,9 +566,7 @@ public function requireFacility(): int */ public function setFacility(?int $facility): self { - $this->facility = $facility; - $this->updateMap['facility'] = true; - return $this; + $this->facility = $facility; $this->updateMap['facility'] = true; return $this; } /** @@ -608,8 +601,6 @@ public function requireLogopts(): int */ public function setLogopts(?int $logopts): self { - $this->logopts = $logopts; - $this->updateMap['logopts'] = true; - return $this; + $this->logopts = $logopts; $this->updateMap['logopts'] = true; return $this; } }