diff --git a/lib/Fhp/Syntax/Serializer.php b/lib/Fhp/Syntax/Serializer.php index 6c2ff267..155263c9 100644 --- a/lib/Fhp/Syntax/Serializer.php +++ b/lib/Fhp/Syntax/Serializer.php @@ -130,6 +130,7 @@ private static function serializeElements($obj, BaseDescriptor $descriptor): arr $value === null || $repetition >= count($value) ? null : $value[$repetition], $elementDescriptor->type, $isSegment); } + $index += $numOutputElements - 1; // The outer loop will increment by 1 as well. } } return $serializedElements; diff --git a/lib/Tests/Fhp/Segment/UpdSerializationTest.php b/lib/Tests/Fhp/Segment/UpdSerializationTest.php new file mode 100644 index 00000000..8df47a6a --- /dev/null +++ b/lib/Tests/Fhp/Segment/UpdSerializationTest.php @@ -0,0 +1,33 @@ +assertEquals(static::HIUPD, Serializer::serializeSegment($hiupd)); + } + + public function testNativePhpSerialization(): void + { + /** @var HIUPDv6 $hiupd */ + $hiupd = Parser::parseSegment(static::HIUPD, HIUPDv6::class); + $before = $hiupd->getErlaubteGeschaeftsvorfaelle(); + + /** @var HIUPDv6 $hiupd */ + $hiupd = unserialize(serialize($hiupd)); + $after = $hiupd->getErlaubteGeschaeftsvorfaelle(); + + $this->assertEquals($before, $after); + } +}