From 75e28cebb03efb93463a98c01d79a82f5ce06de9 Mon Sep 17 00:00:00 2001 From: Marc Beinder Date: Thu, 30 Oct 2025 15:17:38 -0500 Subject: [PATCH 1/5] Deprecate Once --- src/Objects/Once.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Objects/Once.php b/src/Objects/Once.php index 82d46a6..fad0ff7 100644 --- a/src/Objects/Once.php +++ b/src/Objects/Once.php @@ -1,4 +1,8 @@ Date: Thu, 30 Oct 2025 20:25:46 +0000 Subject: [PATCH 2/5] Rectifying --- src/Objects/Serializers/JsonSerializer.php | 34 +++++++++++----------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/Objects/Serializers/JsonSerializer.php b/src/Objects/Serializers/JsonSerializer.php index 9f8ab26..3aae760 100644 --- a/src/Objects/Serializers/JsonSerializer.php +++ b/src/Objects/Serializers/JsonSerializer.php @@ -59,16 +59,16 @@ private static function hasMapNameAttributes(string|object $classOrObject): bool { $reflection = new ReflectionClass($classOrObject); - if (!empty($reflection->getAttributes(MapName::class)) || - !empty($reflection->getAttributes(MapInputName::class)) || - !empty($reflection->getAttributes(MapOutputName::class))) { + if ($reflection->getAttributes(MapName::class) !== [] || + $reflection->getAttributes(MapInputName::class) !== [] || + $reflection->getAttributes(MapOutputName::class) !== []) { return true; } - foreach ($reflection->getProperties() as $property) { - if (!empty($property->getAttributes(MapName::class)) || - !empty($property->getAttributes(MapInputName::class)) || - !empty($property->getAttributes(MapOutputName::class))) { + foreach ($reflection->getProperties() as $reflectionProperty) { + if (!empty($reflectionProperty->getAttributes(MapName::class)) || + !empty($reflectionProperty->getAttributes(MapInputName::class)) || + !empty($reflectionProperty->getAttributes(MapOutputName::class))) { return true; } } @@ -81,18 +81,18 @@ private static function serializeWithMapName(object $object): string $reflection = new ReflectionClass($object); $data = []; - foreach ($reflection->getProperties() as $property) { - $property->setAccessible(true); - $propertyName = $property->getName(); - $value = $property->getValue($object); + foreach ($reflection->getProperties() as $reflectionProperty) { + $reflectionProperty->setAccessible(true); + $propertyName = $reflectionProperty->getName(); + $value = $reflectionProperty->getValue($object); - $mappedName = self::getMappedOutputName($property, $reflection) ?? $propertyName; + $mappedName = self::getMappedOutputName($reflectionProperty, $reflection) ?? $propertyName; $data[$mappedName] = $value; } $json = json_encode($data); if ($json === false) { - throw new RuntimeException('Failed to encode JSON'); + throw new RuntimeException("Failed to encode JSON"); } return $json; @@ -112,8 +112,8 @@ private static function deserializeWithMapName(string $class, string $jsonData): } $args = []; - foreach ($constructor->getParameters() as $parameter) { - $args[] = self::resolveParameterValue($parameter, $reflection, $data); + foreach ($constructor->getParameters() as $reflectionParameter) { + $args[] = self::resolveParameterValue($reflectionParameter, $reflection, $data); } return $reflection->newInstanceArgs($args); @@ -170,12 +170,12 @@ private static function getMapperForDirection(ReflectionProperty|ReflectionClass $specificAttributeClass = $direction === self::MAPPER_DIRECTION_INPUT ? MapInputName::class : MapOutputName::class; $specificAttributes = $reflector->getAttributes($specificAttributeClass); - if (!empty($specificAttributes)) { + if ($specificAttributes !== []) { return self::getMapperResult($specificAttributes[0]->newInstance()->mapper, $propertyName); } $mapNameAttributes = $reflector->getAttributes(MapName::class); - if (!empty($mapNameAttributes)) { + if ($mapNameAttributes !== []) { $mapNameInstance = $mapNameAttributes[0]->newInstance(); $mapper = $direction === self::MAPPER_DIRECTION_OUTPUT ? ($mapNameInstance->output ?? $mapNameInstance->input) From 6817876286107cd21ac9682a7b594da79deef601 Mon Sep 17 00:00:00 2001 From: EncoreBot Date: Thu, 30 Oct 2025 20:25:46 +0000 Subject: [PATCH 3/5] Ignore Rector Commit in Git Blame --- .git-blame-ignore-revs | 1 + 1 file changed, 1 insertion(+) diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index 3170dc3..3dc6451 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -51,3 +51,4 @@ e85fae4f7290329ac9cfae159e19c1bb55062e4b c400a3c655b1157b8ff30f5c2ead30563fad972a 13d4e52a568b9263cefd6830a1759c7c2a2f0ea3 9ceb35f77a0bfefe8bf4b51d5026399f12ad79b0 +8614c245e767ac74c2ca65697553b70bf54394ad From e7d3e86c6e045f09131ec7cdb3e2cf0887e7eb21 Mon Sep 17 00:00:00 2001 From: EncoreBot Date: Thu, 30 Oct 2025 20:26:04 +0000 Subject: [PATCH 4/5] Dusting --- src/Objects/Once.php | 2 ++ .../Serializers/Attributes/MapInputName.php | 1 + .../Serializers/Attributes/MapName.php | 6 ++-- .../Serializers/Attributes/MapOutputName.php | 1 + src/Objects/Serializers/JsonSerializer.php | 35 ++++++++++--------- .../Serializers/Mappers/CamelCaseMapper.php | 1 + .../Serializers/Mappers/IPropertyMapper.php | 1 + .../Serializers/Mappers/PascalCaseMapper.php | 1 + .../Mappers/ProvidedNameMapper.php | 1 + .../Serializers/Mappers/SnakeCaseMapper.php | 1 + 10 files changed, 31 insertions(+), 19 deletions(-) diff --git a/src/Objects/Once.php b/src/Objects/Once.php index fad0ff7..3eeb94b 100644 --- a/src/Objects/Once.php +++ b/src/Objects/Once.php @@ -1,4 +1,5 @@ output)) { $this->output = $input; diff --git a/src/Objects/Serializers/Attributes/MapOutputName.php b/src/Objects/Serializers/Attributes/MapOutputName.php index 14bdce9..9748f1d 100644 --- a/src/Objects/Serializers/Attributes/MapOutputName.php +++ b/src/Objects/Serializers/Attributes/MapOutputName.php @@ -1,4 +1,5 @@ newInstanceArgs($args); } - private static function resolveParameterValue(\ReflectionParameter $parameter, ReflectionClass $reflection, array $data): mixed + private static function resolveParameterValue(ReflectionParameter $parameter, ReflectionClass $reflection, array $data): mixed { $parameterName = $parameter->getName(); $property = $reflection->hasProperty($parameterName) ? $reflection->getProperty($parameterName) : null; @@ -154,11 +156,12 @@ private static function getMapperResult(string|IPropertyMapper $mapper, string $ { if (is_string($mapper)) { if (class_exists($mapper)) { - $mapperInstance = new $mapper(); + $mapperInstance = new $mapper; if ($mapperInstance instanceof IPropertyMapper) { return $mapperInstance->map($propertyName); } } + return $mapper; } diff --git a/src/Objects/Serializers/Mappers/CamelCaseMapper.php b/src/Objects/Serializers/Mappers/CamelCaseMapper.php index 01abc95..22848db 100644 --- a/src/Objects/Serializers/Mappers/CamelCaseMapper.php +++ b/src/Objects/Serializers/Mappers/CamelCaseMapper.php @@ -1,4 +1,5 @@ Date: Thu, 30 Oct 2025 20:26:04 +0000 Subject: [PATCH 5/5] Ignore Duster Commit in Git Blame --- .git-blame-ignore-revs | 1 + 1 file changed, 1 insertion(+) diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index 3dc6451..6336d8e 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -52,3 +52,4 @@ c400a3c655b1157b8ff30f5c2ead30563fad972a 13d4e52a568b9263cefd6830a1759c7c2a2f0ea3 9ceb35f77a0bfefe8bf4b51d5026399f12ad79b0 8614c245e767ac74c2ca65697553b70bf54394ad +e7d3e86c6e045f09131ec7cdb3e2cf0887e7eb21