Skip to content

Commit 880ce49

Browse files
committed
Rename mapping to runtime context
1 parent 1f8f46d commit 880ce49

61 files changed

Lines changed: 191 additions & 191 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

example/03.types/02.custom-type.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
use TypeLang\Mapper\Context\MappingContext;
5+
use TypeLang\Mapper\Context\RuntimeContext;
66
use TypeLang\Mapper\Exception\Runtime\InvalidValueException;
77
use TypeLang\Mapper\Mapper;
88
use TypeLang\Mapper\Platform\StandardPlatform;
@@ -14,12 +14,12 @@
1414
// Add new type (must implement TypeInterface)
1515
class MyNonEmptyStringType implements TypeInterface
1616
{
17-
public function match(mixed $value, MappingContext $context): bool
17+
public function match(mixed $value, RuntimeContext $context): bool
1818
{
1919
return \is_string($value) && $value !== '';
2020
}
2121

22-
public function cast(mixed $value, MappingContext $context): string
22+
public function cast(mixed $value, RuntimeContext $context): string
2323
{
2424
if (\is_string($value) && $value !== '') {
2525
return $value;

example/03.types/03.custom-type-template-arguments.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
use TypeLang\Mapper\Context\MappingContext;
5+
use TypeLang\Mapper\Context\RuntimeContext;
66
use TypeLang\Mapper\Exception\Runtime\InvalidValueException;
77
use TypeLang\Mapper\Mapper;
88
use TypeLang\Mapper\Platform\DelegatePlatform;
@@ -52,12 +52,12 @@ public function __construct(
5252
private readonly TypeInterface $type,
5353
) {}
5454

55-
public function match(mixed $value, MappingContext $context): bool
55+
public function match(mixed $value, RuntimeContext $context): bool
5656
{
5757
return !empty($value);
5858
}
5959

60-
public function cast(mixed $value, MappingContext $context): mixed
60+
public function cast(mixed $value, RuntimeContext $context): mixed
6161
{
6262
if (!empty($value)) {
6363
return $this->type->cast($value, $context);

example/03.types/05.custom-type-callable.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
declare(strict_types=1);
44

55
use Psr\Container\ContainerInterface;
6-
use TypeLang\Mapper\Context\MappingContext;
6+
use TypeLang\Mapper\Context\RuntimeContext;
77
use TypeLang\Mapper\Exception\Runtime\InvalidValueException;
88
use TypeLang\Mapper\Mapper;
99
use TypeLang\Mapper\Platform\DelegatePlatform;
@@ -45,12 +45,12 @@ public function has(string $id): bool
4545
// Add new type (must implement TypeInterface)
4646
class MyNonEmptyStringType implements TypeInterface
4747
{
48-
public function match(mixed $value, MappingContext $context): bool
48+
public function match(mixed $value, RuntimeContext $context): bool
4949
{
5050
return \is_string($value) && $value !== '';
5151
}
5252

53-
public function cast(mixed $value, MappingContext $context): string
53+
public function cast(mixed $value, RuntimeContext $context): string
5454
{
5555
if (\is_string($value) && $value !== '') {
5656
return $value;

example/03.types/06.custom-type-psr-container.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
declare(strict_types=1);
44

55
use Psr\Container\ContainerInterface;
6-
use TypeLang\Mapper\Context\MappingContext;
6+
use TypeLang\Mapper\Context\RuntimeContext;
77
use TypeLang\Mapper\Exception\Runtime\InvalidValueException;
88
use TypeLang\Mapper\Mapper;
99
use TypeLang\Mapper\Platform\DelegatePlatform;
@@ -43,12 +43,12 @@ public function has(string $id): bool
4343
// Add new type (must implement TypeInterface)
4444
class MyNonEmptyStringType implements TypeInterface
4545
{
46-
public function match(mixed $value, MappingContext $context): bool
46+
public function match(mixed $value, RuntimeContext $context): bool
4747
{
4848
return \is_string($value) && $value !== '';
4949
}
5050

51-
public function cast(mixed $value, MappingContext $context): string
51+
public function cast(mixed $value, RuntimeContext $context): string
5252
{
5353
if (\is_string($value) && $value !== '') {
5454
return $value;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
use TypeLang\Mapper\Type\Parser\TypeParserInterface;
1313
use TypeLang\Mapper\Type\Repository\TypeRepositoryInterface;
1414

15-
final class ChildMappingContext extends MappingContext
15+
final class ChildRuntimeContext extends RuntimeContext
1616
{
1717
protected function __construct(
18-
public readonly MappingContext $parent,
18+
public readonly RuntimeContext $parent,
1919
public readonly EntryInterface $entry,
2020
mixed $value,
2121
DirectionInterface $direction,

src/Context/Context.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ public function __construct(
2424
* If you need to retrieve configuration's settings, it is recommended
2525
* to use the following methods:
2626
*
27-
* - {@see MappingContext::isObjectAsArray()}
28-
* - {@see MappingContext::isStrictTypesEnabled()}
27+
* - {@see RuntimeContext::isObjectAsArray()}
28+
* - {@see RuntimeContext::isStrictTypesEnabled()}
2929
*/
3030
public readonly Configuration $config,
3131
/**
@@ -37,7 +37,7 @@ public function __construct(
3737
* You can safely use all the methods of this interface, but for ease of
3838
* use, the following methods are available to you:
3939
*
40-
* - {@see MappingContext::getDefinitionByValue()} - returns definition string
40+
* - {@see RuntimeContext::getDefinitionByValue()} - returns definition string
4141
* by the passed value.
4242
*/
4343
public readonly TypeExtractorInterface $extractor,
@@ -51,9 +51,9 @@ public function __construct(
5151
* You can safely use all the methods of this interface, but for ease of
5252
* use, the following methods are available to you:
5353
*
54-
* - {@see MappingContext::getStatementByValue()} - returns statement node by
54+
* - {@see RuntimeContext::getStatementByValue()} - returns statement node by
5555
* the value.
56-
* - {@see MappingContext::getStatementByDefinition()} - returns statement node
56+
* - {@see RuntimeContext::getStatementByDefinition()} - returns statement node
5757
* by the definition string.
5858
*/
5959
public readonly TypeParserInterface $parser,
@@ -67,11 +67,11 @@ public function __construct(
6767
* You can safely use all the methods of this interface, but for ease of
6868
* use, the following methods are available to you:
6969
*
70-
* - {@see MappingContext::getTypeByValue()} - returns type instance by the
70+
* - {@see RuntimeContext::getTypeByValue()} - returns type instance by the
7171
* passed value.
72-
* - {@see MappingContext::getTypeByDefinition()} - returns type instance by
72+
* - {@see RuntimeContext::getTypeByDefinition()} - returns type instance by
7373
* the type definition string.
74-
* - {@see MappingContext::getTypeByStatement()} - returns type instance by
74+
* - {@see RuntimeContext::getTypeByStatement()} - returns type instance by
7575
* the type statement.
7676
*/
7777
public readonly TypeRepositoryInterface $types,
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* @internal this is an internal library class, please do not use it in your code
1616
* @psalm-internal TypeLang\Mapper
1717
*/
18-
final class RootMappingContext extends MappingContext
18+
final class RootRuntimeContext extends RuntimeContext
1919
{
2020
private PathInterface $path;
2121

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
use TypeLang\Mapper\Type\Repository\TypeRepositoryInterface;
1818

1919
/**
20-
* @template-implements \IteratorAggregate<array-key, MappingContext>
20+
* @template-implements \IteratorAggregate<array-key, RuntimeContext>
2121
*/
22-
abstract class MappingContext extends Context implements
22+
abstract class RuntimeContext extends Context implements
2323
\IteratorAggregate,
2424
\Countable
2525
{
@@ -30,7 +30,7 @@ protected function __construct(
3030
* Please note that the value may be changed during type manipulation
3131
* (casting), for example, using {@see TypeCoercerInterface}.
3232
*
33-
* In this case, the `$value` in the {@see MappingContext} remains the original
33+
* In this case, the `$value` in the {@see RuntimeContext} remains the original
3434
* value, without any mutations from type coercions.
3535
*/
3636
public readonly mixed $value,
@@ -76,7 +76,7 @@ public function enter(mixed $value, EntryInterface $entry, ?Configuration $confi
7676
$original = null;
7777
}
7878

79-
return new ChildMappingContext(
79+
return new ChildRuntimeContext(
8080
parent: $this,
8181
entry: $entry,
8282
value: $value,
@@ -143,7 +143,7 @@ public function enterIntoUnionLeaf(mixed $value, int $index, ?Configuration $ove
143143
*
144144
* Note that the {@see $config} property contains the **current** context
145145
* configuration settings, which may differ from the original ones.
146-
* Therefore, method {@see MappingContext::withObjectAsArray()} is not equivalent
146+
* Therefore, method {@see RuntimeContext::withObjectAsArray()} is not equivalent
147147
* to calling {@see Configuration::withObjectAsArray()}.
148148
*/
149149
public function withObjectAsArray(?bool $enabled): Configuration
@@ -162,7 +162,7 @@ public function withObjectAsArray(?bool $enabled): Configuration
162162
*
163163
* Note that the {@see $config} property contains the **current** context
164164
* configuration settings, which may differ from the original ones.
165-
* Therefore, method {@see MappingContext::withStrictTypes()} is not equivalent
165+
* Therefore, method {@see RuntimeContext::withStrictTypes()} is not equivalent
166166
* to calling {@see Configuration::withStrictTypes()}.
167167
*/
168168
public function withStrictTypes(?bool $enabled): Configuration

src/Exception/Runtime/InvalidIterableKeyException.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace TypeLang\Mapper\Exception\Runtime;
66

7-
use TypeLang\Mapper\Context\MappingContext;
7+
use TypeLang\Mapper\Context\RuntimeContext;
88
use TypeLang\Mapper\Context\Path\PathInterface;
99

1010
/**
@@ -49,7 +49,7 @@ public static function createFromPath(
4949
public static function createFromContext(
5050
int $index,
5151
mixed $key,
52-
MappingContext $context,
52+
RuntimeContext $context,
5353
?\Throwable $previous = null,
5454
): self {
5555
/** @var iterable<array-key, mixed> $value */

src/Exception/Runtime/InvalidIterableValueException.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace TypeLang\Mapper\Exception\Runtime;
66

7-
use TypeLang\Mapper\Context\MappingContext;
7+
use TypeLang\Mapper\Context\RuntimeContext;
88
use TypeLang\Mapper\Context\Path\PathInterface;
99

1010
/**
@@ -58,7 +58,7 @@ public static function createFromContext(
5858
mixed $element,
5959
int $index,
6060
mixed $key,
61-
MappingContext $context,
61+
RuntimeContext $context,
6262
?\Throwable $previous = null,
6363
): self {
6464
/** @var iterable<array-key, mixed> $value */

0 commit comments

Comments
 (0)