8000 feature #59863 [JsonEncoder] Rename the component to `JsonStreamer` (… · symfony/symfony@af2f36b · GitHub
[go: up one dir, main page]

Skip to content

Commit af2f36b

Browse files
committed
feature #59863 [JsonEncoder] Rename the component to JsonStreamer (mtarld)
This PR was merged into the 7.3 branch. Discussion ---------- [JsonEncoder] Rename the component to `JsonStreamer` | Q | A | ------------- | --- | Branch? | 7.3 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | | License | MIT In order to make the intent of the component clearer, the `JsonEncoder` component should be renamed to `JsonStreamer`, as its main goal is to handle JSON streams as efficiently as possible. In that way, it'll be harder for developers to get confused between this component and the `Serializer`'s JSON encoder. In that PR, the following public API has been updated: - `EncoderInterface::encode()` has been renamed to `StreamWriterInterface::write()` - `DecoderInterface::decode()` has been renamed to `StreamReaderInterface::read()` - the `JsonEncoder` class has been renamed to `JsonStreamWriter` - the `JsonDecoder` class has been renamed to `JsonStreamReader` - the `JsonEncodable` attribute has been renamed to `JsonStreamable` - the `EncodedName` attribute has been renamed to `StreamedName` - `ValueTransformerInterface::getJsonValueType()` has been renamed to `ValueTransformerInterface::getStreamValueType()` - `ValueTransformer::$toJsonValue` has been renamed to `ValueTransformer::$nativeToStream` - `ValueTransformer::$toNativeValue` has been renamed to `ValueTransformer::$streamToNative` Commits ------- 924a01d [JsonStreamer] Rename the component
2 parents 0d92f86 + 924a01d commit af2f36b

File tree

251 files changed

+2522
-2544
lines changed

Some content is hidden

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

251 files changed

+2522
-2544
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
"symfony/http-foundation": "self.version",
8484
"symfony/http-kernel": "self.version",
8585
"symfony/intl": "self.version",
86-
"symfony/json-encoder": "self.version",
86+
"symfony/json-streamer": "self.version",
8787
"symfony/ldap": "self.version",
8888
"symfony/lock": "self.version",
8989
"symfony/mailer": "self.version",

src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ CHANGELOG
66

77
* Add support for assets pre-compression
88
* Rename `TranslationUpdateCommand` to `TranslationExtractCommand`
9-
* Add JsonEncoder services and configuration
9+
* Add JsonStreamer services and configuration
1010
* Add new `framework.property_info.with_constructor_extractor` option to allow enabling or disabling the constructor extractor integration
1111
* Deprecate the `--show-arguments` option of the `container:debug` command, as arguments are now always shown
1212
* Add `RateLimiterFactoryInterface` as an alias of the `limiter` service

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/UnusedTagsPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class UnusedTagsPass implements CompilerPassInterface
5353
'form.type_guesser',
5454
'html_sanitizer',
5555
'http_client.client',
56-
'json_encoder.value_transformer',
56+
'json_streamer.value_transformer',
5757
'kernel.cache_clearer',
5858
'kernel.cache_warmer',
5959
'kernel.event_listener',

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
use Symfony\Component\HttpClient\HttpClient;
3232
use Symfony\Component\HttpFoundation\Cookie;
3333
use Symfony\Component\HttpFoundation\IpUtils;
34-
use Symfony\Component\JsonEncoder\EncoderInterface;
34+
use Symfony\Component\JsonStreamer\StreamWriterInterface;
3535
use Symfony\Component\Lock\Lock;
3636
use Symfony\Component\Lock\Store\SemaphoreStore;
3737
use Symfony\Component\Mailer\Mailer;
@@ -182,7 +182,7 @@ public function getConfigTreeBuilder(): TreeBuilder
182182
$this->addHtmlSanitizerSection($rootNode, $enableIfStandalone);
183183
$this->addWebhookSection($rootNode, $enableIfStandalone);
184184
$this->addRemoteEventSection($rootNode, $enableIfStandalone);
185-
$this->addJsonEncoderSection($rootNode, $enableIfStandalone);
185+
$this->addJsonStreamerSection($rootNode, $enableIfStandalone);
186186

187187
return $treeBuilder;
188188
}
@@ -2692,13 +2692,13 @@ private function addHtmlSanitizerSection(ArrayNodeDefinition $rootNode, callable
26922692
;
26932693
}
26942694

2695-
private function addJsonEncoderSection(ArrayNodeDefinition $rootNode, callable $enableIfStandalone): void
2695+
private function addJsonStreamerSection(ArrayNodeDefinition $rootNode, callable $enableIfStandalone): void
26962696
{
26972697
$rootNode
26982698
->children()
2699-
->arrayNode('json_encoder')
2700-
->info('JSON encoder configuration')
2701-
->{$enableIfStandalone('symfony/json-encoder', EncoderInterface::class)}()
2699+
->arrayNode('json_streamer')
2700+
->info('JSON streamer configuration')
2701+
->{$enableIfStandalone('symfony/json-streamer', StreamWriterInterface::class)}()
27022702
->end()
27032703
->end()
27042704
;

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,11 @@
100100
use Symfony\Component\HttpKernel\DataCollector\DataCollectorInterface;
101101
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
102102
use Symfony\Component\HttpKernel\Log\DebugLoggerConfigurator;
103-
use Symfony\Component\JsonEncoder\Attribute\JsonEncodable;
104-
use Symfony\Component\JsonEncoder\DecoderInterface as JsonEncoderDecoderInterface;
105-
use Symfony\Component\JsonEncoder\EncoderInterface as JsonEncoderEncoderInterface;
106-
use Symfony\Component\JsonEncoder\JsonEncoder;
107-
use Symfony\Component\JsonEncoder\ValueTransformer\ValueTransformerInterface;
103+
use Symfony\Component\JsonStreamer\Attribute\JsonStreamable;
104+
use Symfony\Component\JsonStreamer\JsonStreamWriter;
105+
use Symfony\Component\JsonStreamer\StreamReaderInterface;
106+
use Symfony\Component\JsonStreamer\StreamWriterInterface;
107+
use Symfony\Component\JsonStreamer\ValueTransformer\ValueTransformerInterface;
108108
use Symfony\Component\Lock\LockFactory;
109109
use Symfony\Component\Lock\LockInterface;
110110
use Symfony\Component\Lock\PersistingStoreInterface;
@@ -436,12 +436,12 @@ public function load(array $configs, ContainerBuilder $container): void
436436
$this->registerPropertyInfoConfiguration($config['property_info'], $container, $loader);
437437
}
438438

439-
if ($this->readConfigEnabled('json_encoder', $container, $config['json_encoder'])) {
439+
if ($this->readConfigEnabled('json_streamer', $container, $config['json_streamer'])) {
440440
if (!$typeInfoEnabled) {
441-
throw new LogicException('JsonEncoder support cannot be enabled as the TypeInfo component is not '.(interface_exists(TypeResolverInterface::class) ? 'enabled.' : 'installed. Try running "composer require symfony/type-info".'));
441+
throw new LogicException('JsonStreamer support cannot be enabled as the TypeInfo component is not '.(interface_exists(TypeResolverInterface::class) ? 'enabled.' : 'installed. Try running "composer require symfony/type-info".'));
442442
}
443443

444-
$this->registerJsonEncoderConfiguration($config['json_encoder'], $container, $loader);
444+
$this->registerJsonStreamerConfiguration($config['json_streamer'], $container, $loader);
445445
}
446446

447447
if ($this->readConfigEnabled('lock', $container, $config['lock'])) {
@@ -755,8 +755,8 @@ static function (ChildDefinition $definition, AsPeriodicTask|AsCronTask $attribu
755755
}
756756
);
757757
}
758-
$container->registerAttributeForAutoconfiguration(JsonEncodable::class, static function (ChildDefinition $definition, JsonEncodable $attribute): void {
759-
$definition->addTag('json_encoder.encodable', [
758+
$container->registerAttributeForAutoconfiguration(JsonStreamable::class, static function (ChildDefinition $definition, JsonStreamable $attribute): void {
759+
$definition->addTag('json_streamer.streamable', [
760760
'object' => $attribute->asObject,
761761
'list' => $attribute->asList,
762762
]);
@@ -2033,26 +2033,26 @@ private function registerSerializerConfiguration(array $config, ContainerBuilder
20332033
$container->setParameter('.serializer.named_serializers', $config['named_serializers'] ?? []);
20342034
}
20352035

2036-
private function registerJsonEncoderConfiguration(array $config, ContainerBuilder $container, PhpFileLoader $loader): void
2036+
private function registerJsonStreamerConfiguration(array $config, ContainerBuilder $container, PhpFileLoader $loader): void
20372037
{
2038-
if (!class_exists(JsonEncoder::class)) {
2039-
throw new LogicException('JsonEncoder support cannot be enabled as the JsonEncoder component is not installed. Try running "composer require symfony/json-encoder".');
2038+
if (!class_exists(JsonStreamWriter::class)) {
2039+
throw new LogicException('JsonStreamer support cannot be enabled as the JsonStreamer component is not installed. Try running "composer require symfony/json-streamer".');
20402040
}
20412041

20422042
$container->registerForAutoconfiguration(ValueTransformerInterface::class)
2043-
->addTag('json_encoder.value_transformer');
2043+
->addTag('json_streamer.value_transformer');
20442044

2045-
$loader->load('json_encoder.php');
2045+
$loader->load('json_streamer.php');
20462046

2047-
$container->registerAliasForArgument('json_encoder.encoder', JsonEncoderEncoderInterface::class, 'json.encoder');
2048-
$container->registerAliasForArgument('json_encoder.decoder', JsonEncoderDecoderInterface::class, 'json.decoder');
2047+
$container->registerAliasForArgument('json_streamer.stream_writer', StreamWriterInterface::class, 'json.stream_writer');
2048+
$container->registerAliasForArgument('json_streamer.stream_reader', StreamReaderInterface::class, 'json.stream_reader');
20492049

2050-
$container->setParameter('.json_encoder.encoders_dir', '%kernel.cache_dir%/json_encoder/encoder');
2051-
$container->setParameter('.json_encoder.decoders_dir', '%kernel.cache_dir%/json_encoder/decoder');
2052-
$container->setParameter('.json_encoder.lazy_ghosts_dir', '%kernel.cache_dir%/json_encoder/lazy_ghost');
2050+
$container->setParameter('.json_streamer.stream_writers_dir', '%kernel.cache_dir%/json_streamer/stream_writer');
2051+
$container->setParameter('.json_streamer.stream_readers_dir', '%kernel.cache_dir%/json_streamer/stream_reader');
2052+
$container->setParameter('.json_streamer.lazy_ghosts_dir', '%kernel.cache_dir%/json_streamer/lazy_ghost');
20532053

20542054
if (\PHP_VERSION_ID >= 80400) {
2055-
$container->removeDefinition('.json_encoder.cache_warmer.lazy_ghost');
2055+
$container->removeDefinition('.json_streamer.cache_warmer.lazy_ghost');
20562056
}
20572057
}
20582058

src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
use Symfony\Component\HttpKernel\DependencyInjection\RemoveEmptyControllerArgumentLocatorsPass;
5555
use Symfony\Component\HttpKernel\DependencyInjection\ResettableServicePass;
5656
use Symfony\Component\HttpKernel\KernelEvents;
57-
use Symfony\Component\JsonEncoder\DependencyInjection\EncodablePass;
57+
use Symfony\Component\JsonStreamer\DependencyInjection\StreamablePass;
5858
use Symfony\Component\Messenger\DependencyInjection\MessengerPass;
5959
use Symfony\Component\Mime\DependencyInjection\AddMimeTypeGuesserPass;
6060
use Symfony\Component\PropertyInfo\DependencyInjection\PropertyInfoConstructorPass;
@@ -189,7 +189,7 @@ public function build(ContainerBuilder $container): void
189189
$container->addCompilerPass(new ErrorLoggerCompilerPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, -32);
190190
$container->addCompilerPass(new VirtualRequestStackPass());
191191
$container->addCompilerPass(new TranslationUpdateCommandPass(), PassConfig::TYPE_BEFORE_REMOVING);
192-
$this->addCompilerPassIfExists($container, EncodablePass::class);
192+
$this->addCompilerPassIfExists($container, StreamablePass::class);
193193

194194
if ($container->getParameter('kernel.debug')) {
195195
$container->addCompilerPass(new AddDebugLogProcessorPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, 2);

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

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

0 commit comments

Comments
 (0)
0