Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 67167c1

Browse files
committed
Add conditional return types
1 parent f417d8e commit 67167c1

3 files changed

Lines changed: 17 additions & 3 deletions

File tree

src/Symfony/Component/HttpFoundation/Request.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,6 +1440,7 @@ public function getProtocolVersion(): ?string
14401440
* @param bool $asResource If true, a resource will be returned
14411441
*
14421442
* @return string|resource
1443+
* @psalm-return ($asResource is true ? resource : string)
14431444
*/
14441445
public function getContent(bool $asResource = false)
14451446
{

src/Symfony/Component/Messenger/Envelope.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,13 @@ public function last(string $stampFqcn): ?StampInterface
106106
}
107107

108108
/**
109+
* @template TStamp of StampInterface
110+
*
111+
* @param class-string<TStamp>|null $stampFqcn
112+
*
109113
* @return StampInterface[]|StampInterface[][] The stamps for the specified FQCN, or all stamps by their class name
114+
*
115+
* @psalm-return ($stampFqcn is string ? list<TStamp> : array<class-string<StampInterface>, list<StampInterface>>)
110116
*/
111117
public function all(string $stampFqcn = null): array
112118
{

src/Symfony/Component/Serializer/SerializerInterface.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,21 @@ interface SerializerInterface
1919
/**
2020
* Serializes data in the appropriate format.
2121
*
22-
* @param mixed $data Any data
23-
* @param string $format Format name
24-
* @param array $context Options normalizers/encoders have access to
22+
* @param $data Any data
23+
* @param $format Format name
24+
* @param $context Options normalizers/encoders have access to
2525
*/
2626
public function serialize(mixed $data, string $format, array $context = []): string;
2727

2828
/**
2929
* Deserializes data into the given type.
30+
*
31+
* @template TObject of object
32+
* @template TType of string|class-string<TObject>
33+
*
34+
* @param TType of $type
35+
*
36+
* @return (TType is class-string<TObject> ? TObject : mixed)
3037
*/
3138
public function deserialize(mixed $data, string $type, string $format, array $context = []): mixed;
3239
}

0 commit comments

Comments
 (0)