Skip to content

Commit cd87bde

Browse files
committed
feature #60731 [JsonStreamer] Add PHPDoc to generated code (mtarld)
This PR was merged into the 7.4 branch. Discussion ---------- [JsonStreamer] Add PHPDoc to generated code | Q | A | ------------- | --- | Branch? | 7.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | | License | MIT In order to ease debugging of generated code, it is useful to know which type is related to a given generated PHP file. That's why this PR add some PHPDoc in order know which type is handled. Commits ------- 78be7eb [JsonStreamer] Add PHPDoc to generated code
2 parents f24ffa0 + 78be7eb commit cd87bde

Some content is hidden

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

65 files changed

+198
-0
lines changed

src/Symfony/Component/JsonStreamer/Read/PhpGenerator.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ public function generate(DataModelNodeInterface $dataModel, bool $decodeFromStre
5151
if ($decodeFromStream) {
5252
return $this->line('<?php', $context)
5353
.$this->line('', $context)
54+
.$this->line('/**', $context)
55+
.$this->line(' * @return '.$dataModel->getType(), $context)
56+
.$this->line(' */', $context)
5457
.$this->line('return static function (mixed $stream, \\'.ContainerInterface::class.' $valueTransformers, \\'.LazyInstantiator::class.' $instantiator, array $options): mixed {', $context)
5558
.$providers
5659
.($this->canBeDecodedWithJsonDecode($dataModel, $decodeFromStream)
@@ -61,6 +64,9 @@ public function generate(DataModelNodeInterface $dataModel, bool $decodeFromStre
6164

6265
return $this->line('<?php', $context)
6366
.$this->line('', $context)
67+
.$this->line('/**', $context)
68+
.$this->line(' * @return '.$dataModel->getType(), $context)
69+
.$this->line(' */', $context)
6470
.$this->line('return static function (string|\\Stringable $string, \\'.ContainerInterface::class.' $valueTransformers, \\'.Instantiator::class.' $instantiator, array $options): mixed {', $context)
6571
.$providers
6672
.($this->canBeDecodedWithJsonDecode($dataModel, $decodeFromStream)

src/Symfony/Component/JsonStreamer/Tests/Fixtures/stream_reader/backed_enum.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?php
22

3+
/**
4+
* @return Symfony\Component\JsonStreamer\Tests\Fixtures\Enum\DummyBackedEnum
5+
*/
36
return static function (string|\Stringable $string, \Psr\Container\ContainerInterface $valueTransformers, \Symfony\Component\JsonStreamer\Read\Instantiator $instantiator, array $options): mixed {
47
$providers['Symfony\Component\JsonStreamer\Tests\Fixtures\Enum\DummyBackedEnum'] = static function ($data) {
58
return \Symfony\Component\JsonStreamer\Tests\Fixtures\Enum\DummyBackedEnum::from($data);

src/Symfony/Component/JsonStreamer/Tests/Fixtures/stream_reader/backed_enum.stream.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?php
22

3+
/**
4+
* @return Symfony\Component\JsonStreamer\Tests\Fixtures\Enum\DummyBackedEnum
5+
*/
36
return static function (mixed $stream, \Psr\Container\ContainerInterface $valueTransformers, \Symfony\Component\JsonStreamer\Read\LazyInstantiator $instantiator, array $options): mixed {
47
$providers['Symfony\Component\JsonStreamer\Tests\Fixtures\Enum\DummyBackedEnum'] = static function ($stream, $offset, $length) {
58
return \Symfony\Component\JsonStreamer\Tests\Fixtures\Enum\DummyBackedEnum::from(\Symfony\Component\JsonStreamer\Read\Decoder::decodeStream($stream, $offset, $length));
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?php
22

3+
/**
4+
* @return array<string,mixed>
5+
*/
36
return static function (string|\Stringable $string, \Psr\Container\ContainerInterface $valueTransformers, \Symfony\Component\JsonStreamer\Read\Instantiator $instantiator, array $options): mixed {
47
return \Symfony\Component\JsonStreamer\Read\Decoder::decodeString((string) $string);
58
};

src/Symfony/Component/JsonStreamer/Tests/Fixtures/stream_reader/dict.stream.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?php
22

3+
/**
4+
* @return array<string,mixed>
5+
*/
36
return static function (mixed $stream, \Psr\Container\ContainerInterface $valueTransformers, \Symfony\Component\JsonStreamer\Read\LazyInstantiator $instantiator, array $options): mixed {
47
$providers['array<string,mixed>'] = static function ($stream, $offset, $length) use ($options, $valueTransformers, $instantiator, &$providers) {
58
$data = \Symfony\Component\JsonStreamer\Read\Splitter::splitDict($stream, $offset, $length);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?php
22

3+
/**
4+
* @return iterable
5+
*/
36
return static function (string|\Stringable $string, \Psr\Container\ContainerInterface $valueTransformers, \Symfony\Component\JsonStreamer\Read\Instantiator $instantiator, array $options): mixed {
47
return \Symfony\Component\JsonStreamer\Read\Decoder::decodeString((string) $string);
58
};

src/Symfony/Component/JsonStreamer/Tests/Fixtures/stream_reader/iterable.stream.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?php
22

3+
/**
4+
* @return iterable
5+
*/
36
return static function (mixed $stream, \Psr\Container\ContainerInterface $valueTransformers, \Symfony\Component\JsonStreamer\Read\LazyInstantiator $instantiator, array $options): mixed {
47
$providers['iterable'] = static function ($stream, $offset, $length) use ($options, $valueTransformers, $instantiator, &$providers) {
58
$data = \Symfony\Component\JsonStreamer\Read\Splitter::splitDict($stream, $offset, $length);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?php
22

3+
/**
4+
* @return array<int,mixed>
5+
*/
36
return static function (string|\Stringable $string, \Psr\Container\ContainerInterface $valueTransformers, \Symfony\Component\JsonStreamer\Read\Instantiator $instantiator, array $options): mixed {
47
return \Symfony\Component\JsonStreamer\Read\Decoder::decodeString((string) $string);
58
};

src/Symfony/Component/JsonStreamer/Tests/Fixtures/stream_reader/list.stream.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?php
22

3+
/**
4+
* @return array<int,mixed>
5+
*/
36
return static function (mixed $stream, \Psr\Container\ContainerInterface $valueTransformers, \Symfony\Component\JsonStreamer\Read\LazyInstantiator $instantiator, array $options): mixed {
47
$providers['array<int,mixed>'] = static function ($stream, $offset, $length) use ($options, $valueTransformers, $instantiator, &$providers) {
58
$data = \Symfony\Component\JsonStreamer\Read\Splitter::splitList($stream, $offset, $length);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?php
22

3+
/**
4+
* @return mixed
5+
*/
36
return static function (string|\Stringable $string, \Psr\Container\ContainerInterface $valueTransformers, \Symfony\Component\JsonStreamer\Read\Instantiator $instantiator, array $options): mixed {
47
return \Symfony\Component\JsonStreamer\Read\Decoder::decodeString((string) $string);
58
};

0 commit comments

Comments
 (0)