diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/json_encoder.php b/src/Symfony/Bundle/FrameworkBundle/Resources/config/json_encoder.php index 421f10c9a71b9..24f596fd459a4 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/json_encoder.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/json_encoder.php @@ -32,7 +32,6 @@ tagged_locator('json_encoder.normalizer'), service('json_encoder.encode.property_metadata_loader'), param('.json_encoder.encoders_dir'), - false, ]) ->set('json_encoder.decoder', JsonDecoder::class) ->args([ @@ -113,7 +112,6 @@ service('json_encoder.decode.property_metadata_loader'), param('.json_encoder.encoders_dir'), param('.json_encoder.decoders_dir'), - false, service('logger')->ignoreOnInvalid(), ]) ->tag('kernel.cache_warmer') diff --git a/src/Symfony/Component/JsonEncoder/CacheWarmer/EncoderDecoderCacheWarmer.php b/src/Symfony/Component/JsonEncoder/CacheWarmer/EncoderDecoderCacheWarmer.php index d5d00afbeec4a..a01bb63794bfd 100644 --- a/src/Symfony/Component/JsonEncoder/CacheWarmer/EncoderDecoderCacheWarmer.php +++ b/src/Symfony/Component/JsonEncoder/CacheWarmer/EncoderDecoderCacheWarmer.php @@ -41,10 +41,9 @@ public function __construct( PropertyMetadataLoaderInterface $decodePropertyMetadataLoader, string $encodersDir, string $decodersDir, - bool $forceEncodeChunks = false, private LoggerInterface $logger = new NullLogger(), ) { - $this->encoderGenerator = new EncoderGenerator($encodePropertyMetadataLoader, $encodersDir, $forceEncodeChunks); + $this->encoderGenerator = new EncoderGenerator($encodePropertyMetadataLoader, $encodersDir); $this->decoderGenerator = new DecoderGenerator($decodePropertyMetadataLoader, $decodersDir); } diff --git a/src/Symfony/Component/JsonEncoder/DataModel/Encode/ObjectNode.php b/src/Symfony/Component/JsonEncoder/DataModel/Encode/ObjectNode.php index a5ac0f956d34e..561fb48e59846 100644 --- a/src/Symfony/Component/JsonEncoder/DataModel/Encode/ObjectNode.php +++ b/src/Symfony/Component/JsonEncoder/DataModel/Encode/ObjectNode.php @@ -30,7 +30,6 @@ public function __construct( private DataAccessorInterface $accessor, private ObjectType $type, private array $properties, - private bool $transformed, ) { } @@ -51,9 +50,4 @@ public function getProperties(): array { return $this->properties; } - - public function isTransformed(): bool - { - return $this->transformed; - } } diff --git a/src/Symfony/Component/JsonEncoder/Encode/EncoderGenerator.php b/src/Symfony/Component/JsonEncoder/Encode/EncoderGenerator.php index e1abbb130b905..cc0fbf93580aa 100644 --- a/src/Symfony/Component/JsonEncoder/Encode/EncoderGenerator.php +++ b/src/Symfony/Component/JsonEncoder/Encode/EncoderGenerator.php @@ -31,7 +31,6 @@ use Symfony\Component\JsonEncoder\Exception\MaxDepthException; use Symfony\Component\JsonEncoder\Exception\RuntimeException; use Symfony\Component\JsonEncoder\Exception\UnsupportedException; -use Symfony\Component\JsonEncoder\Mapping\PropertyMetadata; use Symfony\Component\JsonEncoder\Mapping\PropertyMetadataLoaderInterface; use Symfony\Component\TypeInfo\Type; use Symfony\Component\TypeInfo\Type\BackedEnumType; @@ -57,13 +56,9 @@ final class EncoderGenerator private ?PrettyPrinter $phpPrinter = null; private ?Filesystem $fs = null; - /** - * @param bool $forceEncodeChunks enforces chunking the JSON string even if a simple `json_encode` is enough - */ public function __construct( private PropertyMetadataLoaderInterface $propertyMetadataLoader, private string $encodersDir, - private bool $forceEncodeChunks, ) { } @@ -79,7 +74,7 @@ public function generate(Type $type, array $options = []): string return $path; } - $this->phpAstBuilder ??= new PhpAstBuilder($this->forceEncodeChunks); + $this->phpAstBuilder ??= new PhpAstBuilder(); $this->phpOptimizer ??= new PhpOptimizer(); $this->phpPrinter ??= new Standard(['phpVersion' => PhpVersion::fromComponents(8, 2)]); $this->fs ??= new Filesystem(); @@ -110,7 +105,7 @@ public function generate(Type $type, array $options = []): string private function getPath(Type $type): string { - return \sprintf('%s%s%s.json%s.php', $this->encodersDir, \DIRECTORY_SEPARATOR, hash('xxh128', (string) $type), $this->forceEncodeChunks ? '.stream' : ''); + return \sprintf('%s%s%s.json.php', $this->encodersDir, \DIRECTORY_SEPARATOR, hash('xxh128', (string) $type)); } /** @@ -142,7 +137,6 @@ private function createDataModel(Type $type, DataAccessorInterface $accessor, ar if ($type instanceof ObjectType && !$type instanceof EnumType) { ++$context['depth']; - $transformed = false; $className = $type->getClassName(); $propertiesMetadata = $this->propertyMetadataLoader->load($className, $options, ['original_type' => $type] + $context); @@ -152,20 +146,12 @@ private function createDataModel(Type $type, DataAccessorInterface $accessor, ar throw new RuntimeException($e->getMessage(), $e->getCode(), $e); } - if (\count($classReflection->getProperties()) !== \count($propertiesMetadata) - || array_values(array_map(fn (PropertyMetadata $m): string => $m->getName(), $propertiesMetadata)) !== array_keys($propertiesMetadata) - ) { - $transformed = true; - } - $propertiesNodes = []; foreach ($propertiesMetadata as $encodedName => $propertyMetadata) { $propertyAccessor = new PropertyDataAccessor($accessor, $propertyMetadata->getName()); foreach ($propertyMetadata->getNormalizers() as $normalizer) { - $transformed = true; - if (\is_string($normalizer)) { $normalizerServiceAccessor = new FunctionDataAccessor('get', [new ScalarDataAccessor($normalizer)], new VariableDataAccessor('normalizers')); $propertyAccessor = new FunctionDataAccessor('normalize', [$propertyAccessor, new VariableDataAccessor('options')], $normalizerServiceAccessor); @@ -190,7 +176,7 @@ private function createDataModel(Type $type, DataAccessorInterface $accessor, ar $propertiesNodes[$encodedName] = $this->createDataModel($propertyMetadata->getType(), $propertyAccessor, $options, $context); } - return new ObjectNode($accessor, $type, $propertiesNodes, $transformed); + return new ObjectNode($accessor, $type, $propertiesNodes); } if ($type instanceof CollectionType) { diff --git a/src/Symfony/Component/JsonEncoder/Encode/PhpAstBuilder.php b/src/Symfony/Component/JsonEncoder/Encode/PhpAstBuilder.php index 9315c63e633bb..dc4dee96507be 100644 --- a/src/Symfony/Component/JsonEncoder/Encode/PhpAstBuilder.php +++ b/src/Symfony/Component/JsonEncoder/Encode/PhpAstBuilder.php @@ -59,9 +59,8 @@ final class PhpAstBuilder { private BuilderFactory $builder; - public function __construct( - private bool $forceEncodeChunks = false, - ) { + public function __construct() + { $this->builder = new BuilderFactory(); } @@ -103,7 +102,7 @@ private function buildClosureStatements(DataModelNodeInterface $dataModelNode, a ]; } - if (!$this->forceEncodeChunks && $this->nodeOnlyNeedsEncode($dataModelNode)) { + if ($this->nodeOnlyNeedsEncode($dataModelNode)) { return [ new Expression(new Yield_($this->encodeValue($accessor))), ]; @@ -276,21 +275,12 @@ private function nodeOnlyNeedsEncode(DataModelNodeInterface $node, int $nestingL return $this->nodeOnlyNeedsEncode($node->getItemNode(), $nestingLevel + 1); } - if ($node instanceof ObjectNode && !$node->isTransformed()) { - foreach ($node->getProperties() as $property) { - if (!$this->nodeOnlyNeedsEncode($property, $nestingLevel + 1)) { - return false; - } - } - - return true; - } - if ($node instanceof ScalarNode) { $type = $node->getType(); // "null" will be written directly using the "null" string // "bool" will be written directly using the "true" or "false" string + // but it must not prevent any json_encode if nested if ($type->isIdentifiedBy(TypeIdentifier::NULL) || $type->isIdentifiedBy(TypeIdentifier::BOOL)) { return $nestingLevel > 0; } diff --git a/src/Symfony/Component/JsonEncoder/JsonEncoder.php b/src/Symfony/Component/JsonEncoder/JsonEncoder.php index be9301d808ac6..f518bb08d49fd 100644 --- a/src/Symfony/Component/JsonEncoder/JsonEncoder.php +++ b/src/Symfony/Component/JsonEncoder/JsonEncoder.php @@ -37,16 +37,12 @@ final class JsonEncoder implements EncoderInterface { private EncoderGenerator $encoderGenerator; - /** - * @param bool $forceEncodeChunks enforces chunking the JSON string even if a simple `json_encode` is enough - */ public function __construct( private ContainerInterface $normalizers, PropertyMetadataLoaderInterface $propertyMetadataLoader, string $encodersDir, - bool $forceEncodeChunks = false, ) { - $this->encoderGenerator = new EncoderGenerator($propertyMetadataLoader, $encodersDir, $forceEncodeChunks); + $this->encoderGenerator = new EncoderGenerator($propertyMetadataLoader, $encodersDir); } public function encode(mixed $data, Type $type, array $options = []): \Traversable&\Stringable @@ -58,9 +54,8 @@ public function encode(mixed $data, Type $type, array $options = []): \Traversab /** * @param array $normalizers - * @param bool $forceEncodeChunks enforces chunking the JSON string even if a simple `json_encode` is enough */ - public static function create(array $normalizers = [], ?string $encodersDir = null, bool $forceEncodeChunks = false): self + public static function create(array $normalizers = [], ?string $encodersDir = null): self { $encodersDir ??= sys_get_temp_dir().'/json_encoder/encoder'; $normalizers += [ @@ -97,6 +92,6 @@ public function get(string $id): NormalizerInterface $typeContextFactory, ); - return new self($normalizersContainer, $propertyMetadataLoader, $encodersDir, $forceEncodeChunks); + return new self($normalizersContainer, $propertyMetadataLoader, $encodersDir); } } diff --git a/src/Symfony/Component/JsonEncoder/Tests/DataModel/Encode/CompositeNodeTest.php b/src/Symfony/Component/JsonEncoder/Tests/DataModel/Encode/CompositeNodeTest.php index bf11dcb1a0d48..e8c19e215b7f7 100644 --- a/src/Symfony/Component/JsonEncoder/Tests/DataModel/Encode/CompositeNodeTest.php +++ b/src/Symfony/Component/JsonEncoder/Tests/DataModel/Encode/CompositeNodeTest.php @@ -48,7 +48,7 @@ public function testSortNodesOnCreation() { $composite = new CompositeNode(new VariableDataAccessor('data'), [ $scalar = new ScalarNode(new VariableDataAccessor('data'), Type::int()), - $object = new ObjectNode(new VariableDataAccessor('data'), Type::object(self::class), [], false), + $object = new ObjectNode(new VariableDataAccessor('data'), Type::object(self::class), []), $collection = new CollectionNode(new VariableDataAccessor('data'), Type::list(), new ScalarNode(new VariableDataAccessor('data'), Type::int())), ]); diff --git a/src/Symfony/Component/JsonEncoder/Tests/Encode/EncoderGeneratorTest.php b/src/Symfony/Component/JsonEncoder/Tests/Encode/EncoderGeneratorTest.php index 34c6433329b4f..75f026324bf61 100644 --- a/src/Symfony/Component/JsonEncoder/Tests/Encode/EncoderGeneratorTest.php +++ b/src/Symfony/Component/JsonEncoder/Tests/Encode/EncoderGeneratorTest.php @@ -66,19 +66,12 @@ public function testGeneratedEncoder(string $fixture, Type $type) new TypeContextFactory(new StringTypeResolver()), ); - $generator = new EncoderGenerator($propertyMetadataLoader, $this->encodersDir, forceEncodeChunks: false); + $generator = new EncoderGenerator($propertyMetadataLoader, $this->encodersDir); $this->assertStringEqualsFile( \sprintf('%s/Fixtures/encoder/%s.php', \dirname(__DIR__), $fixture), file_get_contents($generator->generate($type)), ); - - $generator = new EncoderGenerator($propertyMetadataLoader, $this->encodersDir, forceEncodeChunks: true); - - $this->assertStringEqualsFile( - \sprintf('%s/Fixtures/encoder/%s.stream.php', \dirname(__DIR__), $fixture), - file_get_contents($generator->generate($type)), - ); } /** @@ -117,7 +110,7 @@ public static function generatedEncoderDataProvider(): iterable public function testDoNotSupportIntersectionType() { - $generator = new EncoderGenerator(new PropertyMetadataLoader(TypeResolver::create()), $this->encodersDir, false); + $generator = new EncoderGenerator(new PropertyMetadataLoader(TypeResolver::create()), $this->encodersDir); $this->expectException(UnsupportedException::class); $this->expectExceptionMessage('"Stringable&Traversable" type is not supported.'); @@ -127,7 +120,7 @@ public function testDoNotSupportIntersectionType() public function testDoNotSupportEnumType() { - $generator = new EncoderGenerator(new PropertyMetadataLoader(TypeResolver::create()), $this->encodersDir, false); + $generator = new EncoderGenerator(new PropertyMetadataLoader(TypeResolver::create()), $this->encodersDir); $this->expectException(UnsupportedException::class); $this->expectExceptionMessage(\sprintf('"%s" type is not supported.', DummyEnum::class)); diff --git a/src/Symfony/Component/JsonEncoder/Tests/Fixtures/encoder/backed_enum.stream.php b/src/Symfony/Component/JsonEncoder/Tests/Fixtures/encoder/backed_enum.stream.php deleted file mode 100644 index a1a44fe635a11..0000000000000 --- a/src/Symfony/Component/JsonEncoder/Tests/Fixtures/encoder/backed_enum.stream.php +++ /dev/null @@ -1,5 +0,0 @@ -value); -}; diff --git a/src/Symfony/Component/JsonEncoder/Tests/Fixtures/encoder/bool.stream.php b/src/Symfony/Component/JsonEncoder/Tests/Fixtures/encoder/bool.stream.php deleted file mode 100644 index 2695b4beea962..0000000000000 --- a/src/Symfony/Component/JsonEncoder/Tests/Fixtures/encoder/bool.stream.php +++ /dev/null @@ -1,5 +0,0 @@ - $value) { - $key = \substr(\json_encode($key), 1, -1); - yield "{$prefix}\"{$key}\":"; - yield \json_encode($value); - $prefix = ','; - } - yield '}'; -}; diff --git a/src/Symfony/Component/JsonEncoder/Tests/Fixtures/encoder/iterable_dict.stream.php b/src/Symfony/Component/JsonEncoder/Tests/Fixtures/encoder/iterable_dict.stream.php deleted file mode 100644 index 4f2a4567cdfb1..0000000000000 --- a/src/Symfony/Component/JsonEncoder/Tests/Fixtures/encoder/iterable_dict.stream.php +++ /dev/null @@ -1,13 +0,0 @@ - $value) { - $key = \substr(\json_encode($key), 1, -1); - yield "{$prefix}\"{$key}\":"; - yield \json_encode($value); - $prefix = ','; - } - yield '}'; -}; diff --git a/src/Symfony/Component/JsonEncoder/Tests/Fixtures/encoder/iterable_list.stream.php b/src/Symfony/Component/JsonEncoder/Tests/Fixtures/encoder/iterable_list.stream.php deleted file mode 100644 index dba1712fd3bd7..0000000000000 --- a/src/Symfony/Component/JsonEncoder/Tests/Fixtures/encoder/iterable_list.stream.php +++ /dev/null @@ -1,12 +0,0 @@ -value); - } elseif (null === $data) { - yield 'null'; - } else { - throw new \Symfony\Component\JsonEncoder\Exception\UnexpectedValueException(\sprintf('Unexpected "%s" value.', \get_debug_type($data))); - } -}; diff --git a/src/Symfony/Component/JsonEncoder/Tests/Fixtures/encoder/nullable_object.stream.php b/src/Symfony/Component/JsonEncoder/Tests/Fixtures/encoder/nullable_object.stream.php deleted file mode 100644 index 69cc96454706f..0000000000000 --- a/src/Symfony/Component/JsonEncoder/Tests/Fixtures/encoder/nullable_object.stream.php +++ /dev/null @@ -1,15 +0,0 @@ -id); - yield ',"name":'; - yield \json_encode($data->name); - yield '}'; - } elseif (null === $data) { - yield 'null'; - } else { - throw new \Symfony\Component\JsonEncoder\Exception\UnexpectedValueException(\sprintf('Unexpected "%s" value.', \get_debug_type($data))); - } -}; diff --git a/src/Symfony/Component/JsonEncoder/Tests/Fixtures/encoder/nullable_object_dict.stream.php b/src/Symfony/Component/JsonEncoder/Tests/Fixtures/encoder/nullable_object_dict.stream.php deleted file mode 100644 index d52de84897efc..0000000000000 --- a/src/Symfony/Component/JsonEncoder/Tests/Fixtures/encoder/nullable_object_dict.stream.php +++ /dev/null @@ -1,23 +0,0 @@ - $value) { - $key = \substr(\json_encode($key), 1, -1); - yield "{$prefix}\"{$key}\":"; - yield '{"@id":'; - yield \json_encode($value->id); - yield ',"name":'; - yield \json_encode($value->name); - yield '}'; - $prefix = ','; - } - yield '}'; - } elseif (null === $data) { - yield 'null'; - } else { - throw new \Symfony\Component\JsonEncoder\Exception\UnexpectedValueException(\sprintf('Unexpected "%s" value.', \get_debug_type($data))); - } -}; diff --git a/src/Symfony/Component/JsonEncoder/Tests/Fixtures/encoder/nullable_object_list.stream.php b/src/Symfony/Component/JsonEncoder/Tests/Fixtures/encoder/nullable_object_list.stream.php deleted file mode 100644 index e610ff442f855..0000000000000 --- a/src/Symfony/Component/JsonEncoder/Tests/Fixtures/encoder/nullable_object_list.stream.php +++ /dev/null @@ -1,22 +0,0 @@ -id); - yield ',"name":'; - yield \json_encode($value->name); - yield '}'; - $prefix = ','; - } - yield ']'; - } elseif (null === $data) { - yield 'null'; - } else { - throw new \Symfony\Component\JsonEncoder\Exception\UnexpectedValueException(\sprintf('Unexpected "%s" value.', \get_debug_type($data))); - } -}; diff --git a/src/Symfony/Component/JsonEncoder/Tests/Fixtures/encoder/object.stream.php b/src/Symfony/Component/JsonEncoder/Tests/Fixtures/encoder/object.stream.php deleted file mode 100644 index 5ceace515fe7c..0000000000000 --- a/src/Symfony/Component/JsonEncoder/Tests/Fixtures/encoder/object.stream.php +++ /dev/null @@ -1,9 +0,0 @@ -id); - yield ',"name":'; - yield \json_encode($data->name); - yield '}'; -}; diff --git a/src/Symfony/Component/JsonEncoder/Tests/Fixtures/encoder/object_dict.stream.php b/src/Symfony/Component/JsonEncoder/Tests/Fixtures/encoder/object_dict.stream.php deleted file mode 100644 index 7297d6eee139b..0000000000000 --- a/src/Symfony/Component/JsonEncoder/Tests/Fixtures/encoder/object_dict.stream.php +++ /dev/null @@ -1,17 +0,0 @@ - $value) { - $key = \substr(\json_encode($key), 1, -1); - yield "{$prefix}\"{$key}\":"; - yield '{"@id":'; - yield \json_encode($value->id); - yield ',"name":'; - yield \json_encode($value->name); - yield '}'; - $prefix = ','; - } - yield '}'; -}; diff --git a/src/Symfony/Component/JsonEncoder/Tests/Fixtures/encoder/object_in_object.php b/src/Symfony/Component/JsonEncoder/Tests/Fixtures/encoder/object_in_object.php index b2472d17bb843..8815a1c2d2f63 100644 --- a/src/Symfony/Component/JsonEncoder/Tests/Fixtures/encoder/object_in_object.php +++ b/src/Symfony/Component/JsonEncoder/Tests/Fixtures/encoder/object_in_object.php @@ -7,7 +7,9 @@ yield \json_encode($data->otherDummyOne->id); yield ',"name":'; yield \json_encode($data->otherDummyOne->name); - yield '},"otherDummyTwo":'; - yield \json_encode($data->otherDummyTwo); - yield '}'; + yield '},"otherDummyTwo":{"id":'; + yield \json_encode($data->otherDummyTwo->id); + yield ',"name":'; + yield \json_encode($data->otherDummyTwo->name); + yield '}}'; }; diff --git a/src/Symfony/Component/JsonEncoder/Tests/Fixtures/encoder/object_in_object.stream.php b/src/Symfony/Component/JsonEncoder/Tests/Fixtures/encoder/object_in_object.stream.php deleted file mode 100644 index 8815a1c2d2f63..0000000000000 --- a/src/Symfony/Component/JsonEncoder/Tests/Fixtures/encoder/object_in_object.stream.php +++ /dev/null @@ -1,15 +0,0 @@ -name); - yield ',"otherDummyOne":{"@id":'; - yield \json_encode($data->otherDummyOne->id); - yield ',"name":'; - yield \json_encode($data->otherDummyOne->name); - yield '},"otherDummyTwo":{"id":'; - yield \json_encode($data->otherDummyTwo->id); - yield ',"name":'; - yield \json_encode($data->otherDummyTwo->name); - yield '}}'; -}; diff --git a/src/Symfony/Component/JsonEncoder/Tests/Fixtures/encoder/object_list.stream.php b/src/Symfony/Component/JsonEncoder/Tests/Fixtures/encoder/object_list.stream.php deleted file mode 100644 index 73c8517f7b755..0000000000000 --- a/src/Symfony/Component/JsonEncoder/Tests/Fixtures/encoder/object_list.stream.php +++ /dev/null @@ -1,16 +0,0 @@ -id); - yield ',"name":'; - yield \json_encode($value->name); - yield '}'; - $prefix = ','; - } - yield ']'; -}; diff --git a/src/Symfony/Component/JsonEncoder/Tests/Fixtures/encoder/object_with_normalizer.stream.php b/src/Symfony/Component/JsonEncoder/Tests/Fixtures/encoder/object_with_normalizer.stream.php deleted file mode 100644 index 194dbfa14d8ad..0000000000000 --- a/src/Symfony/Component/JsonEncoder/Tests/Fixtures/encoder/object_with_normalizer.stream.php +++ /dev/null @@ -1,13 +0,0 @@ -get('Symfony\Component\JsonEncoder\Tests\Fixtures\Normalizer\DoubleIntAndCastToStringNormalizer')->normalize($data->id, $options)); - yield ',"active":'; - yield \json_encode($normalizers->get('Symfony\Component\JsonEncoder\Tests\Fixtures\Normalizer\BooleanStringNormalizer')->normalize($data->active, $options)); - yield ',"name":'; - yield \json_encode(strtolower($data->name)); - yield ',"range":'; - yield \json_encode(Symfony\Component\JsonEncoder\Tests\Fixtures\Model\DummyWithNormalizerAttributes::concatRange($data->range, $options)); - yield '}'; -}; diff --git a/src/Symfony/Component/JsonEncoder/Tests/Fixtures/encoder/object_with_union.stream.php b/src/Symfony/Component/JsonEncoder/Tests/Fixtures/encoder/object_with_union.stream.php deleted file mode 100644 index b1dd0c6480b2a..0000000000000 --- a/src/Symfony/Component/JsonEncoder/Tests/Fixtures/encoder/object_with_union.stream.php +++ /dev/null @@ -1,15 +0,0 @@ -value instanceof \Symfony\Component\JsonEncoder\Tests\Fixtures\Enum\DummyBackedEnum) { - yield \json_encode($data->value->value); - } elseif (null === $data->value) { - yield 'null'; - } elseif (\is_string($data->value)) { - yield \json_encode($data->value); - } else { - throw new \Symfony\Component\JsonEncoder\Exception\UnexpectedValueException(\sprintf('Unexpected "%s" value.', \get_debug_type($data->value))); - } - yield '}'; -}; diff --git a/src/Symfony/Component/JsonEncoder/Tests/Fixtures/encoder/scalar.stream.php b/src/Symfony/Component/JsonEncoder/Tests/Fixtures/encoder/scalar.stream.php deleted file mode 100644 index 6eec711284d61..0000000000000 --- a/src/Symfony/Component/JsonEncoder/Tests/Fixtures/encoder/scalar.stream.php +++ /dev/null @@ -1,5 +0,0 @@ -value); - $prefix = ','; - } - yield ']'; - } elseif ($data instanceof \Symfony\Component\JsonEncoder\Tests\Fixtures\Model\DummyWithNameAttributes) { - yield '{"@id":'; - yield \json_encode($data->id); - yield ',"name":'; - yield \json_encode($data->name); - yield '}'; - } elseif (\is_int($data)) { - yield \json_encode($data); - } else { - throw new \Symfony\Component\JsonEncoder\Exception\UnexpectedValueException(\sprintf('Unexpected "%s" value.', \get_debug_type($data))); - } -}; diff --git a/src/Symfony/Component/JsonEncoder/Tests/JsonEncoderTest.php b/src/Symfony/Component/JsonEncoder/Tests/JsonEncoderTest.php index 34e3373f6d332..de584c64f29e0 100644 --- a/src/Symfony/Component/JsonEncoder/Tests/JsonEncoderTest.php +++ b/src/Symfony/Component/JsonEncoder/Tests/JsonEncoderTest.php @@ -202,8 +202,5 @@ private function assertEncoded(string $expected, mixed $data, Type $type, array { $encoder = JsonEncoder::create(encodersDir: $this->encodersDir, normalizers: $normalizers); $this->assertSame($expected, (string) $encoder->encode($data, $type, $options)); - - $encoder = JsonEncoder::create(encodersDir: $this->encodersDir, normalizers: $normalizers, forceEncodeChunks: true); - $this->assertSame($expected, (string) $encoder->encode($data, $type, $options)); } }