Skip to content

Commit 2ce017a

Browse files
author
Kirill Nesmeyanov
committed
Move name from base metadata class
1 parent 9118f6e commit 2ce017a

File tree

3 files changed

+29
-25
lines changed

3 files changed

+29
-25
lines changed

src/Mapping/Metadata/ClassMetadata.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ final class ClassMetadata extends Metadata
2626
* @throws \Exception
2727
*/
2828
public function __construct(
29-
string $name,
29+
private readonly string $name,
3030
iterable $properties = [],
3131
?int $createdAt = null,
3232
) {
33-
parent::__construct($name, $createdAt);
33+
parent::__construct($createdAt);
3434

3535
foreach ($properties as $property) {
3636
$this->addProperty($property);
@@ -66,13 +66,13 @@ public function getTypeStatement(LocalContext $context): TypeStatement
6666
}
6767

6868
/**
69+
* Returns class name.
70+
*
6971
* @return class-string<T>
7072
*/
71-
#[\Override]
7273
public function getName(): string
7374
{
74-
/** @var class-string<T> */
75-
return parent::getName();
75+
return $this->name;
7676
}
7777

7878
/**

src/Mapping/Metadata/Metadata.php

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,8 @@ abstract class Metadata
88
{
99
private readonly int $timestamp;
1010

11-
/**
12-
* @param non-empty-string $name
13-
*/
14-
public function __construct(
15-
private readonly string $name,
16-
?int $createdAt = null,
17-
) {
11+
public function __construct(?int $createdAt = null)
12+
{
1813
$this->timestamp = $createdAt ?? $this->getCurrentTimestamp();
1914
}
2015

@@ -29,18 +24,6 @@ private function getCurrentTimestamp(): int
2924
}
3025
}
3126

32-
/**
33-
* Returns entry name.
34-
*
35-
* @api
36-
*
37-
* @return non-empty-string
38-
*/
39-
public function getName(): string
40-
{
41-
return $this->name;
42-
}
43-
4427
/**
4528
* Returns the metadata creation timestamp in seconds.
4629
*

src/Mapping/Metadata/PropertyMetadata.php

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111

1212
final class PropertyMetadata extends Metadata
1313
{
14+
/**
15+
* @var non-empty-string
16+
*/
17+
private readonly string $name;
18+
1419
private mixed $defaultValue = null;
1520

1621
private bool $hasDefaultValue = false;
@@ -25,7 +30,9 @@ public function __construct(
2530
private ?TypeInterface $type = null,
2631
?int $createdAt = null,
2732
) {
28-
parent::__construct($this->export, $createdAt);
33+
$this->name = $this->export;
34+
35+
parent::__construct($createdAt);
2936
}
3037

3138
/**
@@ -66,6 +73,18 @@ public function getFieldNode(LocalContext $context): ?NamedFieldNode
6673
);
6774
}
6875

76+
/**
77+
* Returns property real name.
78+
*
79+
* @api
80+
*
81+
* @return non-empty-string
82+
*/
83+
public function getName(): string
84+
{
85+
return $this->name;
86+
}
87+
6988
/**
7089
* @api
7190
*
@@ -77,6 +96,8 @@ public function setExportName(string $name): void
7796
}
7897

7998
/**
99+
* Returns property public name.
100+
*
80101
* @api
81102
*
82103
* @return non-empty-string

0 commit comments

Comments
 (0)