Skip to content

Commit abe4dcd

Browse files
committed
Remove PathProviderInterface
1 parent 3dd4026 commit abe4dcd

File tree

4 files changed

+12
-19
lines changed

4 files changed

+12
-19
lines changed

src/Runtime/Context.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,14 @@
1111
use TypeLang\Mapper\Runtime\Extractor\TypeExtractorInterface;
1212
use TypeLang\Mapper\Runtime\Parser\TypeParserInterface;
1313
use TypeLang\Mapper\Runtime\Path\Entry\EntryInterface;
14-
use TypeLang\Mapper\Runtime\Path\Path;
1514
use TypeLang\Mapper\Runtime\Path\PathInterface;
16-
use TypeLang\Mapper\Runtime\Path\PathProviderInterface;
1715
use TypeLang\Mapper\Runtime\Repository\TypeRepositoryInterface;
1816
use TypeLang\Mapper\Runtime\Tracing\TracerInterface;
1917
use TypeLang\Mapper\Type\TypeInterface;
2018
use TypeLang\Parser\Node\Stmt\TypeStatement;
2119

2220
abstract class Context implements
2321
ConfigurationInterface,
24-
PathProviderInterface,
2522
TypeExtractorInterface,
2623
TypeParserInterface,
2724
TypeRepositoryInterface
@@ -98,10 +95,7 @@ public function isDenormalization(): bool
9895
return $this->direction === Direction::Denormalize;
9996
}
10097

101-
public function getPath(): PathInterface
102-
{
103-
return new Path();
104-
}
98+
abstract public function getPath(): PathInterface;
10599

106100
public function getTypeByStatement(TypeStatement $statement, ?\ReflectionClass $context = null): TypeInterface
107101
{

src/Runtime/Context/RootContext.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
use TypeLang\Mapper\Runtime\Context;
1010
use TypeLang\Mapper\Runtime\Extractor\TypeExtractorInterface;
1111
use TypeLang\Mapper\Runtime\Parser\TypeParserInterface;
12+
use TypeLang\Mapper\Runtime\Path\Path;
13+
use TypeLang\Mapper\Runtime\Path\PathInterface;
1214
use TypeLang\Mapper\Runtime\Repository\TypeRepositoryInterface;
1315

1416
/**
@@ -17,6 +19,8 @@
1719
*/
1820
final class RootContext extends Context
1921
{
22+
private PathInterface $path;
23+
2024
public static function forNormalization(
2125
mixed $value,
2226
ConfigurationInterface $config,
@@ -68,4 +72,9 @@ public static function forDenormalization(
6872
config: $config,
6973
);
7074
}
75+
76+
public function getPath(): PathInterface
77+
{
78+
return $this->path ??= new Path();
79+
}
7180
}

src/Runtime/Path/Path.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
/**
1010
* @template-implements \IteratorAggregate<array-key, EntryInterface>
1111
*/
12-
class Path implements PathInterface, \IteratorAggregate
12+
final class Path implements PathInterface, \IteratorAggregate
1313
{
1414
public function __construct(
1515
/**
1616
* @var list<EntryInterface>
1717
*/
18-
protected array $entries = [],
18+
protected readonly array $entries = [],
1919
) {}
2020

2121
public function getIterator(): \Traversable

src/Runtime/Path/PathProviderInterface.php

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)