Skip to content

Commit a9892a8

Browse files
committed
Replace TypeMetadata's accessors to properties
1 parent 18efb94 commit a9892a8

File tree

5 files changed

+15
-19
lines changed

5 files changed

+15
-19
lines changed

src/Mapping/Metadata/PropertyMetadata.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function getTypeStatement(Context $context): ?TypeStatement
5151
return null;
5252
}
5353

54-
$statement = clone $info->getTypeStatement();
54+
$statement = clone $info->statement;
5555

5656
if ($context->isDetailedTypes() || !$statement instanceof NamedTypeNode) {
5757
return $statement;

src/Mapping/Metadata/TypeMetadata.php

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,16 @@
1010
final class TypeMetadata extends Metadata
1111
{
1212
public function __construct(
13-
private readonly TypeInterface $type,
14-
private readonly TypeStatement $statement,
13+
/**
14+
* Gets type reference.
15+
*/
16+
public readonly TypeInterface $type,
17+
/**
18+
* Gets declarative type representation.
19+
*/
20+
public readonly TypeStatement $statement,
1521
?int $createdAt = null,
1622
) {
1723
parent::__construct($createdAt);
1824
}
19-
20-
public function getType(): TypeInterface
21-
{
22-
return $this->type;
23-
}
24-
25-
public function getTypeStatement(): TypeStatement
26-
{
27-
return $this->statement;
28-
}
2925
}

src/Type/ClassType/ClassTypeDenormalizer.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ private function getPropertyType(PropertyMetadata $meta, Context $context): Type
5151
return $context->getTypeByDefinition('mixed');
5252
}
5353

54-
return $info->getType();
54+
return $info->type;
5555
}
5656

5757
/**
@@ -134,7 +134,7 @@ private function castOverDiscriminator(DiscriminatorMapMetadata $map, array $val
134134
{
135135
// Default mapping type
136136
$default = $map->getDefaultType()
137-
?->getType();
137+
?->type;
138138

139139
$field = $map->getField();
140140

@@ -189,7 +189,7 @@ private function castOverDiscriminator(DiscriminatorMapMetadata $map, array $val
189189
);
190190
}
191191

192-
$mappingType = $mapping->getType();
192+
$mappingType = $mapping->type;
193193

194194
return $mappingType->cast($value, $context);
195195
}

src/Type/ClassType/ClassTypeNormalizer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ protected function normalizeObject(object $object, Context $context): array
9999

100100
// Fetch field type
101101
$info = $meta->findTypeInfo();
102-
$type = $info !== null ? $info->getType() : $context->getTypeByDefinition('mixed');
102+
$type = $info !== null ? $info->type : $context->getTypeByDefinition('mixed');
103103

104104
try {
105105
// Insert field value into result

tests/Mapping/Metadata/TypeMetadataTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ public function testAccessors(): void
1818
$stmt = new NamedTypeNode('int');
1919
$m = new TypeMetadata($type, $stmt, 1);
2020

21-
self::assertSame($type, $m->getType());
22-
self::assertSame($stmt, $m->getTypeStatement());
21+
self::assertSame($type, $m->type);
22+
self::assertSame($stmt, $m->statement);
2323
self::assertSame(1, $m->getTimestamp());
2424
}
2525
}

0 commit comments

Comments
 (0)