Skip to content

Commit

Permalink
Add missing PHPdoc return types
Browse files Browse the repository at this point in the history
  • Loading branch information
wouterj authored and nicolas-grekas committed Feb 13, 2023
1 parent 54f93ba commit 129d0c0
Show file tree
Hide file tree
Showing 21 changed files with 309 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Caster/AmqpCaster.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ class AmqpCaster
\AMQP_EX_TYPE_HEADERS => 'AMQP_EX_TYPE_HEADERS',
];

/**
* @return array
*/
public static function castConnection(\AMQPConnection $c, array $a, Stub $stub, bool $isNested)
{
$prefix = Caster::PREFIX_VIRTUAL;
Expand Down Expand Up @@ -79,6 +82,9 @@ public static function castConnection(\AMQPConnection $c, array $a, Stub $stub,
return $a;
}

/**
* @return array
*/
public static function castChannel(\AMQPChannel $c, array $a, Stub $stub, bool $isNested)
{
$prefix = Caster::PREFIX_VIRTUAL;
Expand All @@ -102,6 +108,9 @@ public static function castChannel(\AMQPChannel $c, array $a, Stub $stub, bool $
return $a;
}

/**
* @return array
*/
public static function castQueue(\AMQPQueue $c, array $a, Stub $stub, bool $isNested)
{
$prefix = Caster::PREFIX_VIRTUAL;
Expand All @@ -125,6 +134,9 @@ public static function castQueue(\AMQPQueue $c, array $a, Stub $stub, bool $isNe
return $a;
}

/**
* @return array
*/
public static function castExchange(\AMQPExchange $c, array $a, Stub $stub, bool $isNested)
{
$prefix = Caster::PREFIX_VIRTUAL;
Expand Down Expand Up @@ -153,6 +165,9 @@ public static function castExchange(\AMQPExchange $c, array $a, Stub $stub, bool
return $a;
}

/**
* @return array
*/
public static function castEnvelope(\AMQPEnvelope $c, array $a, Stub $stub, bool $isNested, int $filter = 0)
{
$prefix = Caster::PREFIX_VIRTUAL;
Expand Down
45 changes: 45 additions & 0 deletions Caster/DOMCaster.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ class DOMCaster
\XML_NAMESPACE_DECL_NODE => 'XML_NAMESPACE_DECL_NODE',
];

/**
* @return array
*/
public static function castException(\DOMException $e, array $a, Stub $stub, bool $isNested)
{
$k = Caster::PREFIX_PROTECTED.'code';
Expand All @@ -73,6 +76,9 @@ public static function castException(\DOMException $e, array $a, Stub $stub, boo
return $a;
}

/**
* @return array
*/
public static function castLength($dom, array $a, Stub $stub, bool $isNested)
{
$a += [
Expand All @@ -82,6 +88,9 @@ public static function castLength($dom, array $a, Stub $stub, bool $isNested)
return $a;
}

/**
* @return array
*/
public static function castImplementation(\DOMImplementation $dom, array $a, Stub $stub, bool $isNested)
{
$a += [
Expand All @@ -92,6 +101,9 @@ public static function castImplementation(\DOMImplementation $dom, array $a, Stu
return $a;
}

/**
* @return array
*/
public static function castNode(\DOMNode $dom, array $a, Stub $stub, bool $isNested)
{
$a += [
Expand All @@ -116,6 +128,9 @@ public static function castNode(\DOMNode $dom, array $a, Stub $stub, bool $isNes
return $a;
}

/**
* @return array
*/
public static function castNameSpaceNode(\DOMNameSpaceNode $dom, array $a, Stub $stub, bool $isNested)
{
$a += [
Expand All @@ -132,6 +147,9 @@ public static function castNameSpaceNode(\DOMNameSpaceNode $dom, array $a, Stub
return $a;
}

/**
* @return array
*/
public static function castDocument(\DOMDocument $dom, array $a, Stub $stub, bool $isNested, int $filter = 0)
{
$a += [
Expand Down Expand Up @@ -166,6 +184,9 @@ public static function castDocument(\DOMDocument $dom, array $a, Stub $stub, boo
return $a;
}

/**
* @return array
*/
public static function castCharacterData(\DOMCharacterData $dom, array $a, Stub $stub, bool $isNested)
{
$a += [
Expand All @@ -176,6 +197,9 @@ public static function castCharacterData(\DOMCharacterData $dom, array $a, Stub
return $a;
}

/**
* @return array
*/
public static function castAttr(\DOMAttr $dom, array $a, Stub $stub, bool $isNested)
{
$a += [
Expand All @@ -189,6 +213,9 @@ public static function castAttr(\DOMAttr $dom, array $a, Stub $stub, bool $isNes
return $a;
}

/**
* @return array
*/
public static function castElement(\DOMElement $dom, array $a, Stub $stub, bool $isNested)
{
$a += [
Expand All @@ -199,6 +226,9 @@ public static function castElement(\DOMElement $dom, array $a, Stub $stub, bool
return $a;
}

/**
* @return array
*/
public static function castText(\DOMText $dom, array $a, Stub $stub, bool $isNested)
{
$a += [
Expand All @@ -208,6 +238,9 @@ public static function castText(\DOMText $dom, array $a, Stub $stub, bool $isNes
return $a;
}

/**
* @return array
*/
public static function castDocumentType(\DOMDocumentType $dom, array $a, Stub $stub, bool $isNested)
{
$a += [
Expand All @@ -222,6 +255,9 @@ public static function castDocumentType(\DOMDocumentType $dom, array $a, Stub $s
return $a;
}

/**
* @return array
*/
public static function castNotation(\DOMNotation $dom, array $a, Stub $stub, bool $isNested)
{
$a += [
Expand All @@ -232,6 +268,9 @@ public static function castNotation(\DOMNotation $dom, array $a, Stub $stub, boo
return $a;
}

/**
* @return array
*/
public static function castEntity(\DOMEntity $dom, array $a, Stub $stub, bool $isNested)
{
$a += [
Expand All @@ -246,6 +285,9 @@ public static function castEntity(\DOMEntity $dom, array $a, Stub $stub, bool $i
return $a;
}

/**
* @return array
*/
public static function castProcessingInstruction(\DOMProcessingInstruction $dom, array $a, Stub $stub, bool $isNested)
{
$a += [
Expand All @@ -256,6 +298,9 @@ public static function castProcessingInstruction(\DOMProcessingInstruction $dom,
return $a;
}

/**
* @return array
*/
public static function castXPath(\DOMXPath $dom, array $a, Stub $stub, bool $isNested)
{
$a += [
Expand Down
12 changes: 12 additions & 0 deletions Caster/DateCaster.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ class DateCaster
{
private const PERIOD_LIMIT = 3;

/**
* @return array
*/
public static function castDateTime(\DateTimeInterface $d, array $a, Stub $stub, bool $isNested, int $filter)
{
$prefix = Caster::PREFIX_VIRTUAL;
Expand All @@ -47,6 +50,9 @@ public static function castDateTime(\DateTimeInterface $d, array $a, Stub $stub,
return $a;
}

/**
* @return array
*/
public static function castInterval(\DateInterval $interval, array $a, Stub $stub, bool $isNested, int $filter)
{
$now = new \DateTimeImmutable('@0', new \DateTimeZone('UTC'));
Expand Down Expand Up @@ -76,6 +82,9 @@ private static function formatInterval(\DateInterval $i): string
return $i->format(rtrim($format));
}

/**
* @return array
*/
public static function castTimeZone(\DateTimeZone $timeZone, array $a, Stub $stub, bool $isNested, int $filter)
{
$location = $timeZone->getLocation();
Expand All @@ -87,6 +96,9 @@ public static function castTimeZone(\DateTimeZone $timeZone, array $a, Stub $stu
return $filter & Caster::EXCLUDE_VERBOSE ? $z : $z + $a;
}

/**
* @return array
*/
public static function castPeriod(\DatePeriod $p, array $a, Stub $stub, bool $isNested, int $filter)
{
$dates = [];
Expand Down
9 changes: 9 additions & 0 deletions Caster/DoctrineCaster.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
*/
class DoctrineCaster
{
/**
* @return array
*/
public static function castCommonProxy(CommonProxy $proxy, array $a, Stub $stub, bool $isNested)
{
foreach (['__cloner__', '__initializer__'] as $k) {
Expand All @@ -37,6 +40,9 @@ public static function castCommonProxy(CommonProxy $proxy, array $a, Stub $stub,
return $a;
}

/**
* @return array
*/
public static function castOrmProxy(OrmProxy $proxy, array $a, Stub $stub, bool $isNested)
{
foreach (['_entityPersister', '_identifier'] as $k) {
Expand All @@ -49,6 +55,9 @@ public static function castOrmProxy(OrmProxy $proxy, array $a, Stub $stub, bool
return $a;
}

/**
* @return array
*/
public static function castPersistentCollection(PersistentCollection $coll, array $a, Stub $stub, bool $isNested)
{
foreach (['snapshot', 'association', 'typeClass'] as $k) {
Expand Down
21 changes: 21 additions & 0 deletions Caster/ExceptionCaster.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,25 @@ class ExceptionCaster

private static array $framesCache = [];

/**
* @return array
*/
public static function castError(\Error $e, array $a, Stub $stub, bool $isNested, int $filter = 0)
{
return self::filterExceptionArray($stub->class, $a, "\0Error\0", $filter);
}

/**
* @return array
*/
public static function castException(\Exception $e, array $a, Stub $stub, bool $isNested, int $filter = 0)
{
return self::filterExceptionArray($stub->class, $a, "\0Exception\0", $filter);
}

/**
* @return array
*/
public static function castErrorException(\ErrorException $e, array $a, Stub $stub, bool $isNested)
{
if (isset($a[$s = Caster::PREFIX_PROTECTED.'severity'], self::$errorTypes[$a[$s]])) {
Expand All @@ -65,6 +74,9 @@ public static function castErrorException(\ErrorException $e, array $a, Stub $st
return $a;
}

/**
* @return array
*/
public static function castThrowingCasterException(ThrowingCasterException $e, array $a, Stub $stub, bool $isNested)
{
$trace = Caster::PREFIX_VIRTUAL.'trace';
Expand All @@ -83,6 +95,9 @@ public static function castThrowingCasterException(ThrowingCasterException $e, a
return $a;
}

/**
* @return array
*/
public static function castSilencedErrorContext(SilencedErrorContext $e, array $a, Stub $stub, bool $isNested)
{
$sPrefix = "\0".SilencedErrorContext::class."\0";
Expand Down Expand Up @@ -110,6 +125,9 @@ public static function castSilencedErrorContext(SilencedErrorContext $e, array $
return $a;
}

/**
* @return array
*/
public static function castTraceStub(TraceStub $trace, array $a, Stub $stub, bool $isNested)
{
if (!$isNested) {
Expand Down Expand Up @@ -184,6 +202,9 @@ public static function castTraceStub(TraceStub $trace, array $a, Stub $stub, boo
return $a;
}

/**
* @return array
*/
public static function castFrameStub(FrameStub $frame, array $a, Stub $stub, bool $isNested)
{
if (!$isNested) {
Expand Down
3 changes: 3 additions & 0 deletions Caster/FiberCaster.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
*/
final class FiberCaster
{
/**
* @return array
*/
public static function castFiber(\Fiber $fiber, array $a, Stub $stub, bool $isNested, int $filter = 0)
{
$prefix = Caster::PREFIX_VIRTUAL;
Expand Down
15 changes: 15 additions & 0 deletions Caster/IntlCaster.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
*/
class IntlCaster
{
/**
* @return array
*/
public static function castMessageFormatter(\MessageFormatter $c, array $a, Stub $stub, bool $isNested)
{
$a += [
Expand All @@ -31,6 +34,9 @@ public static function castMessageFormatter(\MessageFormatter $c, array $a, Stub
return self::castError($c, $a);
}

/**
* @return array
*/
public static function castNumberFormatter(\NumberFormatter $c, array $a, Stub $stub, bool $isNested, int $filter = 0)
{
$a += [
Expand Down Expand Up @@ -108,6 +114,9 @@ public static function castNumberFormatter(\NumberFormatter $c, array $a, Stub $
return self::castError($c, $a);
}

/**
* @return array
*/
public static function castIntlTimeZone(\IntlTimeZone $c, array $a, Stub $stub, bool $isNested)
{
$a += [
Expand All @@ -125,6 +134,9 @@ public static function castIntlTimeZone(\IntlTimeZone $c, array $a, Stub $stub,
return self::castError($c, $a);
}

/**
* @return array
*/
public static function castIntlCalendar(\IntlCalendar $c, array $a, Stub $stub, bool $isNested, int $filter = 0)
{
$a += [
Expand All @@ -142,6 +154,9 @@ public static function castIntlCalendar(\IntlCalendar $c, array $a, Stub $stub,
return self::castError($c, $a);
}

/**
* @return array
*/
public static function castIntlDateFormatter(\IntlDateFormatter $c, array $a, Stub $stub, bool $isNested, int $filter = 0)
{
$a += [
Expand Down
Loading

0 comments on commit 129d0c0

Please sign in to comment.