Repository: symfony/symfony
File: src/Symfony/Component/JsonStreamer/Tests/JsonStreamWriterTest.php (PHP)

Code before:
    {
        $dummy = new DummyWithDateTimes();
        $dummy->interface = new \DateTimeImmutable('2024-11-20');
        $dummy->immutable = new \DateTimeImmutable('2025-11-20');

        $this->assertWritten(
            '{"interface":"2024-11-20","immutable":"2025-11-20"}',
            $dummy,
            Type::object(DummyWithDateTimes::class),
            options: [DateTimeToStringValueTransformer::FORMAT_KEY => 'Y-m-d'],
        );
    }

    public function testWriteObjectWithDollarNamedProperties()
    {
        $this->assertWritten('{"$foo":true,"{$foo->bar}":true}', new DummyWithDollarNamedProperties(), Type::object(DummyWithDollarNamedProperties::class));
    }

    public function testWriteObjectWithSyntheticProperty()
    {
        $writer = new JsonStreamWriter($this->createMock(ContainerInterface::class), new SyntheticPropertyMetadataLoader(), $this->streamWritersDir);

        $this->assertSame('{"synthetic":true}', (string) $writer->write(new DummyWithSyntheticProperties(), Type::object(DummyWithSyntheticProperties::class)));
    }

    public function testWriteNestedSelfCollection()
    {
        $dummy = new SelfReferencingDummyList();
        $dummy->items = [new SelfReferencingDummyList(), new SelfReferencingDummyList(), new SelfReferencingDummyList()];

        $this->assertWritten(
            '{"items":[{"items":[]},{"items":[]},{"items":[]}]}',
            $dummy,
            Type::object(SelfReferencingDummyList::class)
        );

        $dummy = new DummyWithNestedDummies();
        $dummy->dummies = [new DummyWithNestedDummies(), new DummyWithNestedDummies(), new DummyWithNestedDummies()];

        $this->assertWritten(
            '{"dummies":[{"dummies":[]},{"dummies":[]},{"dummies":[]}]}',
            $dummy,
            Type::object(DummyWithNestedDummies::class)
        );
    }

    public function testWriteNestedSelfDict()
    {
        $dummy = new DummyWithNestedDictDummies();
        $dummy->dummies = [
            'first' => new DummyWithNestedDictDummies(),

Review comment (suggestion):
```suggestion
    public function testWriteNestedSelfList()
```

Code after:
    public function testWriteObjectWithDateTimes()
    {
        $dummy = new DummyWithDateTimes();
        $dummy->interface = new \DateTimeImmutable('2024-11-20');
        $dummy->immutable = new \DateTimeImmutable('2025-11-20');

        $this->assertWritten(
            '{"interface":"2024-11-20","immutable":"2025-11-20"}',
            $dummy,
            Type::object(DummyWithDateTimes::class),
            options: [DateTimeToStringValueTransformer::FORMAT_KEY => 'Y-m-d'],
        );
    }

    public function testWriteObjectWithDollarNamedProperties()
    {
        $this->assertWritten('{"$foo":true,"{$foo->bar}":true}', new DummyWithDollarNamedProperties(), Type::object(DummyWithDollarNamedProperties::class));
    }

    public function testWriteObjectWithSyntheticProperty()
    {
        $writer = new JsonStreamWriter($this->createMock(ContainerInterface::class), new SyntheticPropertyMetadataLoader(), $this->streamWritersDir);

        $this->assertSame('{"synthetic":true}', (string) $writer->write(new DummyWithSyntheticProperties(), Type::object(DummyWithSyntheticProperties::class)));
    }

    public function testWriteNestedSelfList()
    {
        $dummy = new SelfReferencingDummyList();
        $dummy->items = [new SelfReferencingDummyList(), new SelfReferencingDummyList(), new SelfReferencingDummyList()];

        $this->assertWritten(
            '{"items":[{"items":[]},{"items":[]},{"items":[]}]}',
            $dummy,
            Type::object(SelfReferencingDummyList::class)
        );

        $dummy = new DummyWithNestedListDummies();
        $dummy->dummies = [new DummyWithNestedListDummies(), new DummyWithNestedListDummies(), new DummyWithNestedListDummies()];

        $this->assertWritten(
            '{"dummies":[{"dummies":[]},{"dummies":[]},{"dummies":[]}]}',
            $dummy,
            Type::object(DummyWithNestedListDummies::class)
        );
    }

    public function testWriteNestedSelfDict()
    {
        $dummy = new SelfReferencingDummyDict();
        $dummy->items = [