Skip to content

Commit 82d4a44

Browse files
committed
rename dom
1 parent b298263 commit 82d4a44

File tree

13 files changed

+112
-112
lines changed

13 files changed

+112
-112
lines changed

src/Symfony/Bundle/FrameworkBundle/Resources/config/serializer.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@
6363
use Symfony\Component\Serializer\SerializableResolver\CachedSerializableResolver;
6464
use Symfony\Component\Serializer\SerializableResolver\PathSerializableResolver;
6565
use Symfony\Component\Serializer\SerializableResolver\SerializableResolverInterface;
66-
use Symfony\Component\Serializer\Serialize\Dom\DomTreeBuilder;
67-
use Symfony\Component\Serializer\Serialize\Dom\DomTreeBuilderInterface;
66+
use Symfony\Component\Serializer\Serialize\DataModel\TreeBuilder;
67+
use Symfony\Component\Serializer\Serialize\DataModel\TreeBuilderInterface;
6868
use Symfony\Component\Serializer\Serialize\Encoder\CsvEncoder as ExperimentalCsvEncoder;
6969
use Symfony\Component\Serializer\Serialize\Mapping\PropertyMetadataLoader as SerializePropertyMetadataLoader;
7070
use Symfony\Component\Serializer\Serialize\Mapping\PropertyMetadataLoaderInterface as SerializePropertyMetadataLoaderInterface;
@@ -265,7 +265,7 @@
265265
// Template
266266
->set('serializer.template_factory', TemplateFactory::class)
267267
->args([
268-
service('serializer.dom_tree_builder'),
268+
service('serializer.data_model.tree_builder'),
269269
service('serializer.template_variation_extractor'),
270270
abstract_arg('template generators'),
271271
param('.serializer.cache_dir.template'),
@@ -288,12 +288,12 @@
288288
])
289289
->tag('serializer.template_generator', ['format' => 'csv'])
290290

291-
// DOM tree builders
292-
->set('serializer.dom_tree_builder', DomTreeBuilder::class)
291+
// Data model
292+
->set('serializer.data_model.tree_builder', TreeBuilder::class)
293293
->args([
294294
service('serializer.serialize.metadata.property_loader'),
295295
])
296-
->alias(DomTreeBuilderInterface::class, 'serializer.dom_tree_builder')
296+
->alias(TreeBuilderInterface::class, 'serializer.data_model.tree_builder')
297297

298298
// Deserializer
299299
->set('serializer.deserializer', Deserializer::class)

src/Symfony/Component/Serializer/Serialize/Dom/CollectionDomNode.php renamed to src/Symfony/Component/Serializer/Serialize/DataModel/CollectionNode.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Symfony\Component\Serializer\Serialize\Dom;
12+
namespace Symfony\Component\Serializer\Serialize\DataModel;
1313

14-
use Symfony\Component\Serializer\Serialize\Php\NodeInterface;
14+
use Symfony\Component\Serializer\Serialize\Php\NodeInterface as PhpNodeInterface;
1515

1616
/**
1717
* @author Mathias Arlaud <[email protected]>
1818
*
1919
* @experimental in 7.0
2020
*/
21-
final readonly class CollectionDomNode implements DomNodeInterface
21+
final readonly class CollectionNode implements NodeInterface
2222
{
2323
public function __construct(
24-
public NodeInterface $accessor,
25-
public DomNodeInterface $childrenDomNode,
24+
public PhpNodeInterface $accessor,
25+
public NodeInterface $childrenNode,
2626
public bool $isList,
2727
public bool $isArray,
2828
) {

src/Symfony/Component/Serializer/Serialize/Dom/DomNodeInterface.php renamed to src/Symfony/Component/Serializer/Serialize/DataModel/NodeInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Symfony\Component\Serializer\Serialize\Dom;
12+
namespace Symfony\Component\Serializer\Serialize\DataModel;
1313

1414
/**
1515
* @author Mathias Arlaud <[email protected]>
1616
*
1717
* @experimental in 7.0
1818
*/
19-
interface DomNodeInterface
19+
interface NodeInterface
2020
{
2121
}

src/Symfony/Component/Serializer/Serialize/Dom/ObjectDomNode.php renamed to src/Symfony/Component/Serializer/Serialize/DataModel/ObjectNode.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,23 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Symfony\Component\Serializer\Serialize\Dom;
12+
namespace Symfony\Component\Serializer\Serialize\DataModel;
1313

14-
use Symfony\Component\Serializer\Serialize\Php\NodeInterface;
14+
use Symfony\Component\Serializer\Serialize\Php\NodeInterface as PhpNodeInterface;
1515

1616
/**
1717
* @author Mathias Arlaud <[email protected]>
1818
*
1919
* @experimental in 7.0
2020
*/
21-
final readonly class ObjectDomNode implements DomNodeInterface
21+
final readonly class ObjectNode implements NodeInterface
2222
{
2323
/**
24-
* @param class-string $className
25-
* @param array<string, DomNode> $properties
24+
* @param class-string $className
25+
* @param array<string, NodeInterface> $properties
2626
*/
2727
public function __construct(
28-
public NodeInterface $accessor,
28+
public PhpNodeInterface $accessor,
2929
public string $className,
3030
public array $properties,
3131
) {

src/Symfony/Component/Serializer/Serialize/Dom/ScalarDomNode.php renamed to src/Symfony/Component/Serializer/Serialize/DataModel/ScalarNode.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Symfony\Component\Serializer\Serialize\Dom;
12+
namespace Symfony\Component\Serializer\Serialize\DataModel;
1313

14-
use Symfony\Component\Serializer\Serialize\Php\NodeInterface;
14+
use Symfony\Component\Serializer\Serialize\Php\NodeInterface as PhpNodeInterface;
1515
use Symfony\Component\Serializer\Type\Type;
1616

1717
/**
1818
* @author Mathias Arlaud <[email protected]>
1919
*
2020
* @experimental in 7.0
2121
*/
22-
final readonly class ScalarDomNode implements DomNodeInterface
22+
final readonly class ScalarNode implements NodeInterface
2323
{
2424
public function __construct(
25-
public NodeInterface $accessor,
25+
public PhpNodeInterface $accessor,
2626
public Type $type,
2727
) {
2828
}

src/Symfony/Component/Serializer/Serialize/Dom/DomTreeBuilder.php renamed to src/Symfony/Component/Serializer/Serialize/DataModel/TreeBuilder.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Symfony\Component\Serializer\Serialize\Dom;
12+
namespace Symfony\Component\Serializer\Serialize\DataModel;
1313

1414
use Symfony\Component\Serializer\Exception\CircularReferenceException;
1515
use Symfony\Component\Serializer\Serialize\Config\SerializeConfig;
1616
use Symfony\Component\Serializer\Serialize\Mapping\PropertyMetadataLoaderInterface;
1717
use Symfony\Component\Serializer\Serialize\Php\FunctionNode;
18-
use Symfony\Component\Serializer\Serialize\Php\NodeInterface;
18+
use Symfony\Component\Serializer\Serialize\Php\NodeInterface as PhpNodeInterface;
1919
use Symfony\Component\Serializer\Serialize\Php\PropertyNode;
2020
use Symfony\Component\Serializer\Serialize\Php\VariableNode;
2121
use Symfony\Component\Serializer\Serialize\VariableNameScoperTrait;
@@ -27,7 +27,7 @@
2727
*
2828
* @experimental in 7.0
2929
*/
30-
final class DomTreeBuilder implements DomTreeBuilderInterface
30+
final class TreeBuilder implements TreeBuilderInterface
3131
{
3232
use VariableNameScoperTrait;
3333

@@ -39,18 +39,18 @@ public function __construct(
3939
$this->typeSorter = new TypeSorter();
4040
}
4141

42-
public function build(Type $type, NodeInterface $accessor, SerializeConfig $config, array $context): DomNodeInterface
42+
public function build(Type $type, PhpNodeInterface $accessor, SerializeConfig $config, array $context): NodeInterface
4343
{
4444
if ($type->isNullable()) {
45-
return new UnionDomNode($accessor, [
46-
new ScalarDomNode($accessor, Type::null()),
45+
return new UnionNode($accessor, [
46+
new ScalarNode($accessor, Type::null()),
4747
$this->build(Type::fromString(substr((string) $type, 1)), $accessor, $config, $context),
4848
]);
4949
}
5050

5151
if ($type->isUnion()) {
52-
return new UnionDomNode($accessor, array_map(
53-
fn (Type $t): DomNodeInterface => $this->build($t, $accessor, $config, $context),
52+
return new UnionNode($accessor, array_map(
53+
fn (Type $t): NodeInterface => $this->build($t, $accessor, $config, $context),
5454
$this->typeSorter->sortByPrecision($type->unionTypes()),
5555
));
5656
}
@@ -64,7 +64,7 @@ public function build(Type $type, NodeInterface $accessor, SerializeConfig $conf
6464

6565
$context['generated_classes'][$className] = true;
6666

67-
$propertiesDomNodes = [];
67+
$propertiesNodes = [];
6868
foreach ($this->propertyMetadataLoader->load($className, $config, $context) as $serializedName => $propertyMetadata) {
6969
$propertyAccessor = new PropertyNode($accessor, $propertyMetadata->name);
7070

@@ -78,10 +78,10 @@ public function build(Type $type, NodeInterface $accessor, SerializeConfig $conf
7878
$propertyAccessor = new FunctionNode($formatterString, [$propertyAccessor, new VariableNode('config')]);
7979
}
8080

81-
$propertiesDomNodes[$serializedName] = $this->build($propertyMetadata->type, $propertyAccessor, $config, $context);
81+
$propertiesNodes[$serializedName] = $this->build($propertyMetadata->type, $propertyAccessor, $config, $context);
8282
}
8383

84-
return new ObjectDomNode($accessor, $type->className(), $propertiesDomNodes);
84+
return new ObjectNode($accessor, $type->className(), $propertiesNodes);
8585
}
8686

8787
if ($type->isEnum()) {
@@ -90,18 +90,18 @@ public function build(Type $type, NodeInterface $accessor, SerializeConfig $conf
9090
throw new \RuntimeException('TODO');
9191
}
9292

93-
return new ScalarDomNode(new PropertyNode($accessor, 'value'), Type::fromString($backedType));
93+
return new ScalarNode(new PropertyNode($accessor, 'value'), Type::fromString($backedType));
9494
}
9595

9696
if ($type->isCollection()) {
97-
return new CollectionDomNode(
97+
return new CollectionNode(
9898
$accessor,
9999
$this->build($type->collectionValueType(), new VariableNode($this->scopeVariableName('value', $context)), $config, $context),
100100
$type->isList(),
101101
'array' === $type->name(),
102102
);
103103
}
104104

105-
return new ScalarDomNode($accessor, $type);
105+
return new ScalarNode($accessor, $type);
106106
}
107107
}

src/Symfony/Component/Serializer/Serialize/Dom/DomTreeBuilderInterface.php renamed to src/Symfony/Component/Serializer/Serialize/DataModel/TreeBuilderInterface.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,21 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Symfony\Component\Serializer\Serialize\Dom;
12+
namespace Symfony\Component\Serializer\Serialize\DataModel;
1313

1414
use Symfony\Component\Serializer\Serialize\Config\SerializeConfig;
15-
use Symfony\Component\Serializer\Serialize\Php\NodeInterface;
15+
use Symfony\Component\Serializer\Serialize\Php\NodeInterface as PhpNodeInterface;
1616
use Symfony\Component\Serializer\Type\Type;
1717

1818
/**
1919
* @author Mathias Arlaud <[email protected]>
2020
*
2121
* @experimental in 7.0
2222
*/
23-
interface DomTreeBuilderInterface
23+
interface TreeBuilderInterface
2424
{
2525
/**
2626
* @param array<string, mixed> $context
2727
*/
28-
public function build(Type $type, NodeInterface $accessor, SerializeConfig $config, array $context): DomNodeInterface;
28+
public function build(Type $type, PhpNodeInterface $accessor, SerializeConfig $config, array $context): NodeInterface;
2929
}

src/Symfony/Component/Serializer/Serialize/Dom/UnionDomNode.php renamed to src/Symfony/Component/Serializer/Serialize/DataModel/UnionNode.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,23 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Symfony\Component\Serializer\Serialize\Dom;
12+
namespace Symfony\Component\Serializer\Serialize\DataModel;
1313

14-
use Symfony\Component\Serializer\Serialize\Php\NodeInterface;
14+
use Symfony\Component\Serializer\Serialize\Php\NodeInterface as PhpNodeInterface;
1515

1616
/**
1717
* @author Mathias Arlaud <[email protected]>
1818
*
1919
* @experimental in 7.0
2020
*/
21-
final readonly class UnionDomNode implements DomNodeInterface
21+
final readonly class UnionNode implements NodeInterface
2222
{
2323
/**
24-
* @param list<DomNode> $domNodes
24+
* @param list<Node> $nodes
2525
*/
2626
public function __construct(
27-
public NodeInterface $accessor,
28-
public array $domNodes,
27+
public PhpNodeInterface $accessor,
28+
public array $nodes,
2929
) {
3030
}
3131
}

src/Symfony/Component/Serializer/Serialize/Template/JsonTemplateGenerator.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313

1414
use Symfony\Component\Serializer\Exception\RuntimeException;
1515
use Symfony\Component\Serializer\Serialize\Config\SerializeConfig;
16-
use Symfony\Component\Serializer\Serialize\Dom\CollectionDomNode;
17-
use Symfony\Component\Serializer\Serialize\Dom\DomNodeInterface;
18-
use Symfony\Component\Serializer\Serialize\Dom\ObjectDomNode;
16+
use Symfony\Component\Serializer\Serialize\DataModel\CollectionNode;
17+
use Symfony\Component\Serializer\Serialize\DataModel\NodeInterface;
18+
use Symfony\Component\Serializer\Serialize\DataModel\ObjectNode;
1919
use Symfony\Component\Serializer\Serialize\Php\AssignNode;
2020
use Symfony\Component\Serializer\Serialize\Php\ExpressionNode;
2121
use Symfony\Component\Serializer\Serialize\Php\ForEachNode;
2222
use Symfony\Component\Serializer\Serialize\Php\FunctionNode;
2323
use Symfony\Component\Serializer\Serialize\Php\MethodNode;
24-
use Symfony\Component\Serializer\Serialize\Php\NodeInterface;
24+
use Symfony\Component\Serializer\Serialize\Php\NodeInterface as PhpNodeInterface;
2525
use Symfony\Component\Serializer\Serialize\Php\ScalarNode;
2626
use Symfony\Component\Serializer\Serialize\Php\TemplateStringNode;
2727
use Symfony\Component\Serializer\Serialize\Php\VariableNode;
@@ -39,19 +39,19 @@ public function __construct(
3939
) {
4040
}
4141

42-
public function doGenerate(DomNodeInterface $domNode, SerializeConfig $config, array $context): array
42+
public function doGenerate(NodeInterface $node, SerializeConfig $config, array $context): array
4343
{
44-
if ($domNode instanceof CollectionDomNode) {
44+
if ($node instanceof CollectionNode) {
4545
$prefixName = $this->scopeVariableName('prefix', $context);
4646

47-
if ($domNode->isList) {
47+
if ($node->isList) {
4848
return [
4949
new ExpressionNode(new FunctionNode('\fwrite', [new VariableNode('resource'), new ScalarNode('[')])),
5050
new ExpressionNode(new AssignNode(new VariableNode($prefixName), new ScalarNode(''))),
5151

52-
new ForEachNode($domNode->accessor, null, $domNode->childrenDomNode->accessor, [
52+
new ForEachNode($node->accessor, null, $node->childrenNode->accessor, [
5353
new ExpressionNode(new FunctionNode('\fwrite', [new VariableNode('resource'), new VariableNode($prefixName)])),
54-
...$this->generate($domNode->childrenDomNode, $config, $context),
54+
...$this->generate($node->childrenNode, $config, $context),
5555
new ExpressionNode(new AssignNode(new VariableNode($prefixName), new ScalarNode(','))),
5656
]),
5757

@@ -65,27 +65,27 @@ public function doGenerate(DomNodeInterface $domNode, SerializeConfig $config, a
6565
new ExpressionNode(new FunctionNode('\fwrite', [new VariableNode('resource'), new ScalarNode('{')])),
6666
new ExpressionNode(new AssignNode(new VariableNode($prefixName), new ScalarNode(''))),
6767

68-
new ForEachNode($domNode->accessor, $keyName, $domNode->childrenDomNode->accessor, [
68+
new ForEachNode($node->accessor, $keyName, $node->childrenNode->accessor, [
6969
new ExpressionNode(new AssignNode(new VariableNode($keyName), $this->escapeString(new VariableNode($keyName)))),
7070
new ExpressionNode(new FunctionNode('\fwrite', [new VariableNode('resource'), new TemplateStringNode(
7171
new VariableNode($prefixName),
7272
'"',
7373
new VariableNode($keyName),
7474
'":',
7575
)])),
76-
...$this->generate($domNode->childrenDomNode, $config, $context),
76+
...$this->generate($node->childrenNode, $config, $context),
7777
new ExpressionNode(new AssignNode(new VariableNode($prefixName), new ScalarNode(','))),
7878
]),
7979

8080
new ExpressionNode(new FunctionNode('\fwrite', [new VariableNode('resource'), new ScalarNode('}')])),
8181
];
8282
}
8383

84-
if ($domNode instanceof ObjectDomNode) {
84+
if ($node instanceof ObjectNode) {
8585
$nodes = [new ExpressionNode(new FunctionNode('\fwrite', [new VariableNode('resource'), new ScalarNode('{')]))];
8686
$separator = '';
8787

88-
foreach ($domNode->properties as $name => $propertyDomNode) {
88+
foreach ($node->properties as $name => $propertyNode) {
8989
$encodedName = json_encode($name);
9090
if (false === $encodedName) {
9191
throw new RuntimeException(sprintf('Cannot encode "%s"', $name));
@@ -99,7 +99,7 @@ public function doGenerate(DomNodeInterface $domNode, SerializeConfig $config, a
9999
new ExpressionNode(new FunctionNode('\fwrite', [new VariableNode('resource'), new ScalarNode('"')])),
100100
new ExpressionNode(new FunctionNode('\fwrite', [new VariableNode('resource'), new ScalarNode($encodedName)])),
101101
new ExpressionNode(new FunctionNode('\fwrite', [new VariableNode('resource'), new ScalarNode('":')])),
102-
...$this->generate($propertyDomNode, $config, $context),
102+
...$this->generate($propertyNode, $config, $context),
103103
);
104104

105105
$separator = ',';
@@ -111,19 +111,19 @@ public function doGenerate(DomNodeInterface $domNode, SerializeConfig $config, a
111111
}
112112

113113
return [
114-
new ExpressionNode(new FunctionNode('\fwrite', [new VariableNode('resource'), $this->encodeValue($domNode->accessor)])),
114+
new ExpressionNode(new FunctionNode('\fwrite', [new VariableNode('resource'), $this->encodeValue($node->accessor)])),
115115
];
116116
}
117117

118-
private function encodeValue(NodeInterface $node): NodeInterface
118+
private function encodeValue(PhpNodeInterface $node): PhpNodeInterface
119119
{
120120
return new FunctionNode('\json_encode', [
121121
$node,
122122
new MethodNode(new MethodNode(new VariableNode('config'), 'json', []), 'flags', []),
123123
]);
124124
}
125125

126-
private function escapeString(NodeInterface $node): NodeInterface
126+
private function escapeString(PhpNodeInterface $node): PhpNodeInterface
127127
{
128128
return new FunctionNode('\substr', [
129129
new FunctionNode('\json_encode', [

0 commit comments

Comments
 (0)