Skip to content

Commit 36666da

Browse files
committed
Remove unused config interface
1 parent ed55bb3 commit 36666da

File tree

7 files changed

+43
-91
lines changed

7 files changed

+43
-91
lines changed

src/Context/ChildContext.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use TypeLang\Mapper\Context\Path\Entry\EntryInterface;
88
use TypeLang\Mapper\Context\Path\Path;
99
use TypeLang\Mapper\Context\Path\PathInterface;
10-
use TypeLang\Mapper\Runtime\ConfigurationInterface;
10+
use TypeLang\Mapper\Runtime\Configuration;
1111
use TypeLang\Mapper\Runtime\Extractor\TypeExtractorInterface;
1212
use TypeLang\Mapper\Runtime\Parser\TypeParserInterface;
1313
use TypeLang\Mapper\Runtime\Repository\TypeRepositoryInterface;
@@ -19,7 +19,7 @@ protected function __construct(
1919
private readonly EntryInterface $entry,
2020
mixed $value,
2121
Direction $direction,
22-
ConfigurationInterface $config,
22+
Configuration $config,
2323
TypeExtractorInterface $extractor,
2424
TypeParserInterface $parser,
2525
TypeRepositoryInterface $types,

src/Context/Context.php

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,24 @@
55
namespace TypeLang\Mapper\Context;
66

77
use JetBrains\PhpStorm\Language;
8-
use Psr\Log\LoggerInterface;
98
use TypeLang\Mapper\Context\Path\Entry\EntryInterface;
109
use TypeLang\Mapper\Context\Path\PathInterface;
11-
use TypeLang\Mapper\Runtime\ConfigurationInterface;
10+
use TypeLang\Mapper\Runtime\Configuration;
1211
use TypeLang\Mapper\Runtime\Extractor\TypeExtractorInterface;
1312
use TypeLang\Mapper\Runtime\Parser\TypeParserInterface;
1413
use TypeLang\Mapper\Runtime\Repository\TypeRepositoryInterface;
15-
use TypeLang\Mapper\Runtime\Tracing\TracerInterface;
1614
use TypeLang\Mapper\Type\TypeInterface;
1715
use TypeLang\Parser\Node\Stmt\TypeStatement;
1816

1917
abstract class Context implements
20-
ConfigurationInterface,
2118
TypeExtractorInterface,
2219
TypeParserInterface,
2320
TypeRepositoryInterface
2421
{
2522
protected function __construct(
2623
protected readonly mixed $value,
2724
protected readonly Direction $direction,
28-
protected readonly ConfigurationInterface $config,
25+
protected readonly Configuration $config,
2926
protected readonly TypeExtractorInterface $extractor,
3027
protected readonly TypeParserInterface $parser,
3128
protected readonly TypeRepositoryInterface $types,
@@ -69,16 +66,6 @@ public function isStrictTypesEnabled(): bool
6966
return $this->config->isStrictTypesEnabled();
7067
}
7168

72-
public function findLogger(): ?LoggerInterface
73-
{
74-
return $this->config->findLogger();
75-
}
76-
77-
public function findTracer(): ?TracerInterface
78-
{
79-
return $this->config->findTracer();
80-
}
81-
8269
/**
8370
* @api
8471
*/

src/Context/RootContext.php

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use TypeLang\Mapper\Context\Path\Path;
88
use TypeLang\Mapper\Context\Path\PathInterface;
99
use TypeLang\Mapper\Runtime\Configuration;
10-
use TypeLang\Mapper\Runtime\ConfigurationInterface;
1110
use TypeLang\Mapper\Runtime\Extractor\TypeExtractorInterface;
1211
use TypeLang\Mapper\Runtime\Parser\TypeParserInterface;
1312
use TypeLang\Mapper\Runtime\Repository\TypeRepositoryInterface;
@@ -22,20 +21,18 @@ final class RootContext extends Context
2221

2322
public static function forNormalization(
2423
mixed $value,
25-
ConfigurationInterface $config,
24+
Configuration $config,
2625
TypeExtractorInterface $extractor,
2726
TypeParserInterface $parser,
2827
TypeRepositoryInterface $types,
2928
): self {
30-
if ($config instanceof Configuration) {
31-
// Disable strict-types for normalization if option is not set
32-
if (!$config->isStrictTypesOptionDefined()) {
33-
$config = $config->withStrictTypes(false);
34-
}
35-
36-
// ...
29+
// Disable strict-types for normalization if option is not set
30+
if (!$config->isStrictTypesOptionDefined()) {
31+
$config = $config->withStrictTypes(false);
3732
}
3833

34+
// ...
35+
3936
return new self(
4037
value: $value,
4138
direction: Direction::Normalize,
@@ -48,20 +45,18 @@ public static function forNormalization(
4845

4946
public static function forDenormalization(
5047
mixed $value,
51-
ConfigurationInterface $config,
48+
Configuration $config,
5249
TypeExtractorInterface $extractor,
5350
TypeParserInterface $parser,
5451
TypeRepositoryInterface $types,
5552
): self {
56-
if ($config instanceof Configuration) {
57-
// Enable strict-types for denormalization if option is not set
58-
if (!$config->isStrictTypesOptionDefined()) {
59-
$config = $config->withStrictTypes(true);
60-
}
61-
62-
// ...
53+
// Enable strict-types for denormalization if option is not set
54+
if (!$config->isStrictTypesOptionDefined()) {
55+
$config = $config->withStrictTypes(true);
6356
}
6457

58+
// ...
59+
6560
return new self(
6661
value: $value,
6762
direction: Direction::Denormalize,

src/Runtime/Configuration.php

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use Psr\Log\LoggerInterface;
88
use TypeLang\Mapper\Runtime\Tracing\TracerInterface;
99

10-
final class Configuration implements ConfigurationInterface
10+
final class Configuration
1111
{
1212
/**
1313
* Default value for {@see $isObjectsAsArrays} option.
@@ -65,9 +65,16 @@ public function withObjectsAsArrays(?bool $enabled = null): self
6565
);
6666
}
6767

68+
/**
69+
* Specifies the default normalization settings for the object.
70+
*
71+
* In case of the method returns {@see true}, the object will be converted
72+
* to an associative array (hash map) unless otherwise specified.
73+
*/
6874
public function isObjectAsArray(): bool
6975
{
70-
return $this->isObjectsAsArrays ?? self::OBJECTS_AS_ARRAYS_DEFAULT_VALUE;
76+
return $this->isObjectsAsArrays
77+
?? self::OBJECTS_AS_ARRAYS_DEFAULT_VALUE;
7178
}
7279

7380
/**
@@ -97,9 +104,17 @@ public function withStrictTypes(?bool $enabled = null): self
97104
);
98105
}
99106

107+
/**
108+
* In case of method returns {@see true}, all types will be checked
109+
* for compliance.
110+
*
111+
* Otherwise, the value will attempt to be converted to the
112+
* required type if possible.
113+
*/
100114
public function isStrictTypesEnabled(): bool
101115
{
102-
return $this->isStrictTypes ?? self::STRICT_TYPES_DEFAULT_VALUE;
116+
return $this->isStrictTypes
117+
?? self::STRICT_TYPES_DEFAULT_VALUE;
103118
}
104119

105120
/**
@@ -128,6 +143,10 @@ public function withLogger(?LoggerInterface $logger = null): self
128143
);
129144
}
130145

146+
/**
147+
* If this method returns {@see LoggerInterface}, then the given logger
148+
* will be enabled. Otherwise logger should be disabled.
149+
*/
131150
public function findLogger(): ?LoggerInterface
132151
{
133152
return $this->logger;
@@ -150,6 +169,10 @@ public function withTracer(?TracerInterface $tracer = null): self
150169
);
151170
}
152171

172+
/**
173+
* If this method returns {@see TracerInterface}, then the application
174+
* tracing will be enabled. Otherwise tracing should be disabled.
175+
*/
153176
public function findTracer(): ?TracerInterface
154177
{
155178
return $this->tracer;

src/Runtime/ConfigurationInterface.php

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

tests/Mapping/MappingTestCase.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,6 @@
44

55
namespace TypeLang\Mapper\Tests\Mapping;
66

7-
use TypeLang\Mapper\Platform\PlatformInterface;
8-
use TypeLang\Mapper\Platform\StandardPlatform;
9-
use TypeLang\Mapper\Runtime\Configuration;
10-
use TypeLang\Mapper\Runtime\ConfigurationInterface;
11-
use TypeLang\Mapper\Context\Direction;
12-
use TypeLang\Mapper\Context\RootContext;
13-
use TypeLang\Mapper\Runtime\Extractor\NativeTypeExtractor;
14-
use TypeLang\Mapper\Runtime\Extractor\TypeExtractorInterface;
15-
use TypeLang\Mapper\Runtime\Parser\TypeLangParser;
16-
use TypeLang\Mapper\Runtime\Parser\TypeParserInterface;
17-
use TypeLang\Mapper\Runtime\Repository\TypeRepository;
18-
use TypeLang\Mapper\Runtime\Repository\TypeRepositoryInterface;
197
use TypeLang\Mapper\Tests\TestCase;
208

219
abstract class MappingTestCase extends TestCase {}

tests/TestCase.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
use TypeLang\Mapper\Platform\PlatformInterface;
1212
use TypeLang\Mapper\Platform\StandardPlatform;
1313
use TypeLang\Mapper\Runtime\Configuration;
14-
use TypeLang\Mapper\Runtime\ConfigurationInterface;
1514
use TypeLang\Mapper\Runtime\Extractor\NativeTypeExtractor;
1615
use TypeLang\Mapper\Runtime\Extractor\TypeExtractorInterface;
1716
use TypeLang\Mapper\Runtime\Parser\TypeLangParser;
@@ -42,7 +41,7 @@ private static function dataProviderKeyOf(mixed $value): string
4241
]);
4342
}
4443

45-
protected function createConfiguration(bool $strictTypes = true): ConfigurationInterface
44+
protected function createConfiguration(bool $strictTypes = true): Configuration
4645
{
4746
return new Configuration(
4847
isStrictTypes: $strictTypes,

0 commit comments

Comments
 (0)