diff --git a/composer.json b/composer.json index ab47a56..079c380 100644 --- a/composer.json +++ b/composer.json @@ -11,8 +11,8 @@ "mammatus/app": "dev-master", "mammatus/kubernetes-attributes": "^1", "mammatus/kubernetes-contracts": "^1", - "mammatus/kubernetes-events": "^1", - "mammatus/life-cycle-events": "^2", + "mammatus/kubernetes-events": "^2.0.0", + "mammatus/life-cycle-events": "^2.3.0", "mammatus/queue-attributes": "^0.1.0", "mammatus/queue-contracts": "^0.1.0", "open-telemetry/api": "^1.4.0", diff --git a/composer.lock b/composer.lock index f7cde4e..b64b1b6 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "38771d692be57d49b95cabf2dcd6cb81", + "content-hash": "c00c7c95fc86c376322895cac95d73de", "packages": [ { "name": "bramus/ansi-php", @@ -1381,23 +1381,25 @@ }, { "name": "mammatus/kubernetes-events", - "version": "1.0.1", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/MammatusPHP/kubernetes-events.git", - "reference": "86826fe5b3be715c16773f85f94a2d214dfd08d8" + "reference": "25d3a7a49b0163b927bea3c0830380d43a7dacdf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/MammatusPHP/kubernetes-events/zipball/86826fe5b3be715c16773f85f94a2d214dfd08d8", - "reference": "86826fe5b3be715c16773f85f94a2d214dfd08d8", + "url": "https://api.github.com/repos/MammatusPHP/kubernetes-events/zipball/25d3a7a49b0163b927bea3c0830380d43a7dacdf", + "reference": "25d3a7a49b0163b927bea3c0830380d43a7dacdf", "shasum": "" }, "require": { - "php": "^8.2" + "php": "^8.4", + "symfony/yaml": "^7.3" }, "require-dev": { - "wyrihaximus/test-utilities": "^6.0.10" + "wyrihaximus/makefiles": "^0.7.10", + "wyrihaximus/test-utilities": "^8.5" }, "type": "library", "extra": { @@ -1421,10 +1423,10 @@ "license": [ "MIT" ], - "description": "⏱️ Cron manager", + "description": "☸📣 Kubernetes related Events", "support": { "issues": "https://github.com/MammatusPHP/kubernetes-events/issues", - "source": "https://github.com/MammatusPHP/kubernetes-events/tree/1.0.1" + "source": "https://github.com/MammatusPHP/kubernetes-events/tree/2.0.0" }, "funding": [ { @@ -1432,7 +1434,7 @@ "type": "github" } ], - "time": "2024-10-16T22:11:30+00:00" + "time": "2025-10-20T10:46:50+00:00" }, { "name": "mammatus/life-cycle-events", @@ -4236,6 +4238,82 @@ ], "time": "2025-09-11T14:36:48+00:00" }, + { + "name": "symfony/yaml", + "version": "v7.3.3", + "source": { + "type": "git", + "url": "https://github.com/symfony/yaml.git", + "reference": "d4f4a66866fe2451f61296924767280ab5732d9d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/yaml/zipball/d4f4a66866fe2451f61296924767280ab5732d9d", + "reference": "d4f4a66866fe2451f61296924767280ab5732d9d", + "shasum": "" + }, + "require": { + "php": ">=8.2", + "symfony/deprecation-contracts": "^2.5|^3.0", + "symfony/polyfill-ctype": "^1.8" + }, + "conflict": { + "symfony/console": "<6.4" + }, + "require-dev": { + "symfony/console": "^6.4|^7.0" + }, + "bin": [ + "Resources/bin/yaml-lint" + ], + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Yaml\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Loads and dumps YAML files", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/yaml/tree/v7.3.3" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2025-08-27T11:34:33+00:00" + }, { "name": "twig/twig", "version": "v3.21.1", @@ -11596,28 +11674,28 @@ }, { "name": "webmozart/assert", - "version": "1.11.0", + "version": "1.12.0", "source": { "type": "git", "url": "https://github.com/webmozarts/assert.git", - "reference": "11cb2199493b2f8a3b53e7f19068fc6aac760991" + "reference": "541057574806f942c94662b817a50f63f7345360" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozarts/assert/zipball/11cb2199493b2f8a3b53e7f19068fc6aac760991", - "reference": "11cb2199493b2f8a3b53e7f19068fc6aac760991", + "url": "https://api.github.com/repos/webmozarts/assert/zipball/541057574806f942c94662b817a50f63f7345360", + "reference": "541057574806f942c94662b817a50f63f7345360", "shasum": "" }, "require": { "ext-ctype": "*", + "ext-date": "*", + "ext-filter": "*", "php": "^7.2 || ^8.0" }, - "conflict": { - "phpstan/phpstan": "<0.12.20", - "vimeo/psalm": "<4.6.1 || 4.6.2" - }, - "require-dev": { - "phpunit/phpunit": "^8.5.13" + "suggest": { + "ext-intl": "", + "ext-simplexml": "", + "ext-spl": "" }, "type": "library", "extra": { @@ -11648,9 +11726,9 @@ ], "support": { "issues": "https://github.com/webmozarts/assert/issues", - "source": "https://github.com/webmozarts/assert/tree/1.11.0" + "source": "https://github.com/webmozarts/assert/tree/1.12.0" }, - "time": "2022-06-03T18:03:27+00:00" + "time": "2025-10-20T12:43:39+00:00" }, { "name": "webmozart/glob", diff --git a/etc/qa/infection.json5 b/etc/qa/infection.json5 index cd44882..34450b8 100644 --- a/etc/qa/infection.json5 +++ b/etc/qa/infection.json5 @@ -18,4 +18,4 @@ "mutators": { "@default": true } -} +} diff --git a/src/Generated/Hydrator.php b/src/Generated/Hydrator.php index 603d9c4..5567c0a 100644 --- a/src/Generated/Hydrator.php +++ b/src/Generated/Hydrator.php @@ -6,62 +6,49 @@ use EventSauce\ObjectHydrator\IterableList; use EventSauce\ObjectHydrator\ObjectMapper; -use EventSauce\ObjectHydrator\PropertySerializers\SerializeArrayItems; -use EventSauce\ObjectHydrator\PropertySerializers\SerializeDateTime; -use EventSauce\ObjectHydrator\PropertySerializers\SerializeUuidToString; use EventSauce\ObjectHydrator\UnableToHydrateObject; use EventSauce\ObjectHydrator\UnableToSerializeObject; use Generator; -use LogicException; -use Mammatus\Queue\BuildIn\EmptyMessage; -use Throwable; - -use function assert; -use function count; class Hydrator implements ObjectMapper { private array $hydrationStack = []; - - public function __construct() - { - } + public function __construct() {} /** + * @template T of object * @param class-string $className - * * @return T - * - * @template T of object */ public function hydrateObject(string $className, array $payload): object { - return match ($className) { - EmptyMessage::class => $this->hydrateMammatus⚡️Queue⚡️BuildIn⚡️EmptyMessage($payload), + return match($className) { + \Mammatus\Queue\BuildIn\EmptyMessage::class => $this->hydrateMammatus⚡️Queue⚡️BuildIn⚡️EmptyMessage($payload), default => throw UnableToHydrateObject::noHydrationDefined($className, $this->hydrationStack), }; } - - private function hydrateMammatus⚡️Queue⚡️BuildIn⚡️EmptyMessage(array $payload): EmptyMessage + + + private function hydrateMammatus⚡️Queue⚡️BuildIn⚡️EmptyMessage(array $payload): \Mammatus\Queue\BuildIn\EmptyMessage { - $properties = []; + $properties = []; $missingFields = []; try { - } catch (Throwable $exception) { - throw UnableToHydrateObject::dueToError(EmptyMessage::class, $exception, stack: $this->hydrationStack); + } catch (\Throwable $exception) { + throw UnableToHydrateObject::dueToError(\Mammatus\Queue\BuildIn\EmptyMessage::class, $exception, stack: $this->hydrationStack); } if (count($missingFields) > 0) { - throw UnableToHydrateObject::dueToMissingFields(EmptyMessage::class, $missingFields, stack: $this->hydrationStack); + throw UnableToHydrateObject::dueToMissingFields(\Mammatus\Queue\BuildIn\EmptyMessage::class, $missingFields, stack: $this->hydrationStack); } try { - return new EmptyMessage(...$properties); - } catch (Throwable $exception) { - throw UnableToHydrateObject::dueToError(EmptyMessage::class, $exception, stack: $this->hydrationStack); + return new \Mammatus\Queue\BuildIn\EmptyMessage(...$properties); + } catch (\Throwable $exception) { + throw UnableToHydrateObject::dueToError(\Mammatus\Queue\BuildIn\EmptyMessage::class, $exception, stack: $this->hydrationStack); } } - + private function serializeViaTypeMap(string $accessor, object $object, array $payloadToTypeMap): array { foreach ($payloadToTypeMap as $payloadType => [$valueType, $method]) { @@ -70,7 +57,7 @@ private function serializeViaTypeMap(string $accessor, object $object, array $pa } } - throw new LogicException('No type mapped for object of class: ' . $object::class); + throw new \LogicException('No type mapped for object of class: ' . $object::class); } public function serializeObject(object $object): mixed @@ -79,99 +66,114 @@ public function serializeObject(object $object): mixed } /** + * @template T + * * @param T $object * @param class-string $className - * - * @template T */ public function serializeObjectOfType(object $object, string $className): mixed { try { - return match ($className) { + return match($className) { 'array' => $this->serializeValuearray($object), - 'Ramsey\Uuid\UuidInterface' => $this->serializeValueRamsey⚡️Uuid⚡️UuidInterface($object), - 'DateTime' => $this->serializeValueDateTime($object), - 'DateTimeImmutable' => $this->serializeValueDateTimeImmutable($object), - 'DateTimeInterface' => $this->serializeValueDateTimeInterface($object), - EmptyMessage::class => $this->serializeObjectMammatus⚡️Queue⚡️BuildIn⚡️EmptyMessage($object), - default => throw new LogicException("No serialization defined for $className"), + 'Ramsey\Uuid\UuidInterface' => $this->serializeValueRamsey⚡️Uuid⚡️UuidInterface($object), + 'DateTime' => $this->serializeValueDateTime($object), + 'DateTimeImmutable' => $this->serializeValueDateTimeImmutable($object), + 'DateTimeInterface' => $this->serializeValueDateTimeInterface($object), + \Mammatus\Queue\BuildIn\EmptyMessage::class => $this->serializeObjectMammatus⚡️Queue⚡️BuildIn⚡️EmptyMessage($object), + default => throw new \LogicException("No serialization defined for $className"), }; - } catch (Throwable $exception) { + } catch (\Throwable $exception) { throw UnableToSerializeObject::dueToError($className, $exception); } } - + + private function serializeValuearray(mixed $value): mixed { static $serializer; - + if ($serializer === null) { - $serializer = new SerializeArrayItems(...[]); + $serializer = new \EventSauce\ObjectHydrator\PropertySerializers\SerializeArrayItems(... [ +]); } - + return $serializer->serialize($value, $this); } + private function serializeValueRamsey⚡️Uuid⚡️UuidInterface(mixed $value): mixed { static $serializer; - + if ($serializer === null) { - $serializer = new SerializeUuidToString(...[]); + $serializer = new \EventSauce\ObjectHydrator\PropertySerializers\SerializeUuidToString(... [ +]); } - + return $serializer->serialize($value, $this); } + private function serializeValueDateTime(mixed $value): mixed { static $serializer; - + if ($serializer === null) { - $serializer = new SerializeDateTime(...[]); + $serializer = new \EventSauce\ObjectHydrator\PropertySerializers\SerializeDateTime(... [ +]); } - + return $serializer->serialize($value, $this); } + private function serializeValueDateTimeImmutable(mixed $value): mixed { static $serializer; - + if ($serializer === null) { - $serializer = new SerializeDateTime(...[]); + $serializer = new \EventSauce\ObjectHydrator\PropertySerializers\SerializeDateTime(... [ +]); } - + return $serializer->serialize($value, $this); } + private function serializeValueDateTimeInterface(mixed $value): mixed { static $serializer; - + if ($serializer === null) { - $serializer = new SerializeDateTime(...[]); + $serializer = new \EventSauce\ObjectHydrator\PropertySerializers\SerializeDateTime(... [ +]); } - + return $serializer->serialize($value, $this); } + private function serializeObjectMammatus⚡️Queue⚡️BuildIn⚡️EmptyMessage(mixed $object): mixed { - assert($object instanceof EmptyMessage); + \assert($object instanceof \Mammatus\Queue\BuildIn\EmptyMessage); + $result = []; - return []; + + return $result; } + + /** + * @template T + * * @param class-string $className * @param iterable $payloads; * * @return IterableList * * @throws UnableToHydrateObject - * - * @template T */ public function hydrateObjects(string $className, iterable $payloads): IterableList { @@ -186,14 +188,14 @@ private function doHydrateObjects(string $className, iterable $payloads): Genera } /** + * @template T + * * @param class-string $className * @param iterable $payloads; * * @return IterableList * * @throws UnableToSerializeObject - * - * @template T */ public function serializeObjects(iterable $payloads): IterableList { @@ -206,4 +208,4 @@ private function doSerializeObjects(iterable $objects): Generator yield $index => $this->serializeObject($object); } } -} +} \ No newline at end of file diff --git a/tests/Kubernetes/Helm/QueueConsumersValuesTest.php b/tests/Kubernetes/Helm/QueueConsumersValuesTest.php index 0b1b747..207ba94 100644 --- a/tests/Kubernetes/Helm/QueueConsumersValuesTest.php +++ b/tests/Kubernetes/Helm/QueueConsumersValuesTest.php @@ -9,12 +9,14 @@ use PHPUnit\Framework\Attributes\Test; use WyriHaximus\TestUtilities\TestCase; +use const DIRECTORY_SEPARATOR; + final class QueueConsumersValuesTest extends TestCase { #[Test] public function none(): void { - $values = new Values(new Values\Registry()); + $values = new Values(new Values\Registry(Values\ValuesFile::createFromFile(__DIR__ . DIRECTORY_SEPARATOR . 'values.yaml'))); new QueueConsumersValues()->values($values); self::assertSame([ @@ -25,7 +27,7 @@ public function none(): void #[Test] public function all(): void { - $values = new Values(new Values\Registry()); + $values = new Values(new Values\Registry(Values\ValuesFile::createFromFile(__DIR__ . DIRECTORY_SEPARATOR . 'values.yaml'))); new QueueConsumersValues(false)->values($values); self::assertSame([ diff --git a/tests/Kubernetes/Helm/values.yaml b/tests/Kubernetes/Helm/values.yaml new file mode 100644 index 0000000..e69de29