From 9e6512be9817b9b85c632078844ea42567a92217 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Wed, 14 Aug 2019 00:48:59 +0200 Subject: [PATCH] [VarDumper] Add parameter type declarations. --- .../Console/Tests/Helper/DumperTest.php | 5 ++- .../Component/VarDumper/Caster/AmqpCaster.php | 12 +++---- .../Component/VarDumper/Caster/ArgsStub.php | 2 +- .../Component/VarDumper/Caster/Caster.php | 10 +++--- .../Component/VarDumper/Caster/DOMCaster.php | 36 +++++++++---------- .../Component/VarDumper/Caster/DateCaster.php | 12 +++---- .../VarDumper/Caster/DoctrineCaster.php | 6 ++-- .../VarDumper/Caster/ExceptionCaster.php | 20 +++++------ .../Component/VarDumper/Caster/GmpCaster.php | 2 +- .../VarDumper/Caster/ImagineCaster.php | 2 +- .../Component/VarDumper/Caster/IntlCaster.php | 12 +++---- .../VarDumper/Caster/MemcachedCaster.php | 2 +- .../Component/VarDumper/Caster/PdoCaster.php | 4 +-- .../VarDumper/Caster/PgSqlCaster.php | 6 ++-- .../VarDumper/Caster/ProxyManagerCaster.php | 2 +- .../VarDumper/Caster/RedisCaster.php | 6 ++-- .../VarDumper/Caster/ReflectionCaster.php | 24 ++++++------- .../VarDumper/Caster/ResourceCaster.php | 14 ++++---- .../Component/VarDumper/Caster/SplCaster.php | 20 +++++------ .../Component/VarDumper/Caster/StubCaster.php | 8 ++--- .../VarDumper/Caster/SymfonyCaster.php | 6 ++-- .../VarDumper/Caster/XmlReaderCaster.php | 2 +- .../VarDumper/Caster/XmlResourceCaster.php | 2 +- .../VarDumper/Cloner/AbstractCloner.php | 24 +++++-------- .../Component/VarDumper/Cloner/Data.php | 10 ++---- .../VarDumper/Cloner/DumperInterface.php | 8 ++--- .../VarDumper/Dumper/AbstractDumper.php | 18 +++------- .../Component/VarDumper/Dumper/CliDumper.php | 22 +++++------- .../Component/VarDumper/Dumper/HtmlDumper.php | 8 ++--- .../VarDumper/Test/VarDumperTestTrait.php | 6 ++-- 30 files changed, 145 insertions(+), 166 deletions(-) diff --git a/src/Symfony/Component/Console/Tests/Helper/DumperTest.php b/src/Symfony/Component/Console/Tests/Helper/DumperTest.php index 7974527d3615f..8791b08b96b82 100644 --- a/src/Symfony/Component/Console/Tests/Helper/DumperTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/DumperTest.php @@ -37,7 +37,10 @@ public static function tearDownAfterClass(): void */ public function testInvoke($variable) { - $dumper = new Dumper($this->getMockBuilder(OutputInterface::class)->getMock()); + $output = $this->getMockBuilder(OutputInterface::class)->getMock(); + $output->method('isDecorated')->willReturn(false); + + $dumper = new Dumper($output); $this->assertDumpMatchesFormat($dumper($variable), $variable); } diff --git a/src/Symfony/Component/VarDumper/Caster/AmqpCaster.php b/src/Symfony/Component/VarDumper/Caster/AmqpCaster.php index 19bdc29525eab..56299e0e297a3 100644 --- a/src/Symfony/Component/VarDumper/Caster/AmqpCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/AmqpCaster.php @@ -44,7 +44,7 @@ class AmqpCaster AMQP_EX_TYPE_HEADERS => 'AMQP_EX_TYPE_HEADERS', ]; - public static function castConnection(\AMQPConnection $c, array $a, Stub $stub, $isNested) + public static function castConnection(\AMQPConnection $c, array $a, Stub $stub, bool $isNested) { $prefix = Caster::PREFIX_VIRTUAL; @@ -77,7 +77,7 @@ public static function castConnection(\AMQPConnection $c, array $a, Stub $stub, return $a; } - public static function castChannel(\AMQPChannel $c, array $a, Stub $stub, $isNested) + public static function castChannel(\AMQPChannel $c, array $a, Stub $stub, bool $isNested) { $prefix = Caster::PREFIX_VIRTUAL; @@ -100,7 +100,7 @@ public static function castChannel(\AMQPChannel $c, array $a, Stub $stub, $isNes return $a; } - public static function castQueue(\AMQPQueue $c, array $a, Stub $stub, $isNested) + public static function castQueue(\AMQPQueue $c, array $a, Stub $stub, bool $isNested) { $prefix = Caster::PREFIX_VIRTUAL; @@ -123,7 +123,7 @@ public static function castQueue(\AMQPQueue $c, array $a, Stub $stub, $isNested) return $a; } - public static function castExchange(\AMQPExchange $c, array $a, Stub $stub, $isNested) + public static function castExchange(\AMQPExchange $c, array $a, Stub $stub, bool $isNested) { $prefix = Caster::PREFIX_VIRTUAL; @@ -151,7 +151,7 @@ public static function castExchange(\AMQPExchange $c, array $a, Stub $stub, $isN return $a; } - public static function castEnvelope(\AMQPEnvelope $c, array $a, Stub $stub, $isNested, $filter = 0) + public static function castEnvelope(\AMQPEnvelope $c, array $a, Stub $stub, bool $isNested, int $filter = 0) { $prefix = Caster::PREFIX_VIRTUAL; @@ -191,7 +191,7 @@ public static function castEnvelope(\AMQPEnvelope $c, array $a, Stub $stub, $isN return $a; } - private static function extractFlags($flags) + private static function extractFlags(int $flags) { $flagsArray = []; diff --git a/src/Symfony/Component/VarDumper/Caster/ArgsStub.php b/src/Symfony/Component/VarDumper/Caster/ArgsStub.php index 1ca7a86d3a572..e1b4fde0f1db0 100644 --- a/src/Symfony/Component/VarDumper/Caster/ArgsStub.php +++ b/src/Symfony/Component/VarDumper/Caster/ArgsStub.php @@ -49,7 +49,7 @@ public function __construct(array $args, string $function, ?string $class) } } - private static function getParameters($function, $class) + private static function getParameters(string $function, ?string $class) { if (isset(self::$parameters[$k = $class.'::'.$function])) { return self::$parameters[$k]; diff --git a/src/Symfony/Component/VarDumper/Caster/Caster.php b/src/Symfony/Component/VarDumper/Caster/Caster.php index 9e5fe0a40547f..ae330bc102217 100644 --- a/src/Symfony/Component/VarDumper/Caster/Caster.php +++ b/src/Symfony/Component/VarDumper/Caster/Caster.php @@ -40,13 +40,11 @@ class Caster /** * Casts objects to arrays and adds the dynamic property prefix. * - * @param object $obj The object to cast - * @param string $class The class of the object - * @param bool $hasDebugInfo Whether the __debugInfo method exists on $obj or not + * @param bool $hasDebugInfo Whether the __debugInfo method exists on $obj or not * * @return array The array-cast of the object, with prefixed dynamic properties */ - public static function castObject($obj, $class, $hasDebugInfo = false): array + public static function castObject(object $obj, string $class, bool $hasDebugInfo = false): array { $a = $obj instanceof \Closure ? [] : (array) $obj; @@ -110,7 +108,7 @@ public static function castObject($obj, $class, $hasDebugInfo = false): array * * @return array The filtered array */ - public static function filter(array $a, $filter, array $listedProperties = [], &$count = 0): array + public static function filter(array $a, int $filter, array $listedProperties = [], ?int &$count = 0): array { $count = 0; @@ -151,7 +149,7 @@ public static function filter(array $a, $filter, array $listedProperties = [], & return $a; } - public static function castPhpIncompleteClass(\__PHP_Incomplete_Class $c, array $a, Stub $stub, $isNested): array + public static function castPhpIncompleteClass(\__PHP_Incomplete_Class $c, array $a, Stub $stub, bool $isNested): array { if (isset($a['__PHP_Incomplete_Class_Name'])) { $stub->class .= '('.$a['__PHP_Incomplete_Class_Name'].')'; diff --git a/src/Symfony/Component/VarDumper/Caster/DOMCaster.php b/src/Symfony/Component/VarDumper/Caster/DOMCaster.php index 65151b4f4ff74..4b901b24f9fd6 100644 --- a/src/Symfony/Component/VarDumper/Caster/DOMCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/DOMCaster.php @@ -61,7 +61,7 @@ class DOMCaster XML_NAMESPACE_DECL_NODE => 'XML_NAMESPACE_DECL_NODE', ]; - public static function castException(\DOMException $e, array $a, Stub $stub, $isNested) + public static function castException(\DOMException $e, array $a, Stub $stub, bool $isNested) { $k = Caster::PREFIX_PROTECTED.'code'; if (isset($a[$k], self::$errorCodes[$a[$k]])) { @@ -71,7 +71,7 @@ public static function castException(\DOMException $e, array $a, Stub $stub, $is return $a; } - public static function castLength($dom, array $a, Stub $stub, $isNested) + public static function castLength($dom, array $a, Stub $stub, bool $isNested) { $a += [ 'length' => $dom->length, @@ -80,7 +80,7 @@ public static function castLength($dom, array $a, Stub $stub, $isNested) return $a; } - public static function castImplementation($dom, array $a, Stub $stub, $isNested) + public static function castImplementation($dom, array $a, Stub $stub, bool $isNested) { $a += [ Caster::PREFIX_VIRTUAL.'Core' => '1.0', @@ -90,7 +90,7 @@ public static function castImplementation($dom, array $a, Stub $stub, $isNested) return $a; } - public static function castNode(\DOMNode $dom, array $a, Stub $stub, $isNested) + public static function castNode(\DOMNode $dom, array $a, Stub $stub, bool $isNested) { $a += [ 'nodeName' => $dom->nodeName, @@ -114,7 +114,7 @@ public static function castNode(\DOMNode $dom, array $a, Stub $stub, $isNested) return $a; } - public static function castNameSpaceNode(\DOMNameSpaceNode $dom, array $a, Stub $stub, $isNested) + public static function castNameSpaceNode(\DOMNameSpaceNode $dom, array $a, Stub $stub, bool $isNested) { $a += [ 'nodeName' => $dom->nodeName, @@ -130,7 +130,7 @@ public static function castNameSpaceNode(\DOMNameSpaceNode $dom, array $a, Stub return $a; } - public static function castDocument(\DOMDocument $dom, array $a, Stub $stub, $isNested, $filter = 0) + public static function castDocument(\DOMDocument $dom, array $a, Stub $stub, bool $isNested, int $filter = 0) { $a += [ 'doctype' => $dom->doctype, @@ -164,7 +164,7 @@ public static function castDocument(\DOMDocument $dom, array $a, Stub $stub, $is return $a; } - public static function castCharacterData(\DOMCharacterData $dom, array $a, Stub $stub, $isNested) + public static function castCharacterData(\DOMCharacterData $dom, array $a, Stub $stub, bool $isNested) { $a += [ 'data' => $dom->data, @@ -174,7 +174,7 @@ public static function castCharacterData(\DOMCharacterData $dom, array $a, Stub return $a; } - public static function castAttr(\DOMAttr $dom, array $a, Stub $stub, $isNested) + public static function castAttr(\DOMAttr $dom, array $a, Stub $stub, bool $isNested) { $a += [ 'name' => $dom->name, @@ -187,7 +187,7 @@ public static function castAttr(\DOMAttr $dom, array $a, Stub $stub, $isNested) return $a; } - public static function castElement(\DOMElement $dom, array $a, Stub $stub, $isNested) + public static function castElement(\DOMElement $dom, array $a, Stub $stub, bool $isNested) { $a += [ 'tagName' => $dom->tagName, @@ -197,7 +197,7 @@ public static function castElement(\DOMElement $dom, array $a, Stub $stub, $isNe return $a; } - public static function castText(\DOMText $dom, array $a, Stub $stub, $isNested) + public static function castText(\DOMText $dom, array $a, Stub $stub, bool $isNested) { $a += [ 'wholeText' => $dom->wholeText, @@ -206,7 +206,7 @@ public static function castText(\DOMText $dom, array $a, Stub $stub, $isNested) return $a; } - public static function castTypeinfo(\DOMTypeinfo $dom, array $a, Stub $stub, $isNested) + public static function castTypeinfo(\DOMTypeinfo $dom, array $a, Stub $stub, bool $isNested) { $a += [ 'typeName' => $dom->typeName, @@ -216,7 +216,7 @@ public static function castTypeinfo(\DOMTypeinfo $dom, array $a, Stub $stub, $is return $a; } - public static function castDomError(\DOMDomError $dom, array $a, Stub $stub, $isNested) + public static function castDomError(\DOMDomError $dom, array $a, Stub $stub, bool $isNested) { $a += [ 'severity' => $dom->severity, @@ -230,7 +230,7 @@ public static function castDomError(\DOMDomError $dom, array $a, Stub $stub, $is return $a; } - public static function castLocator(\DOMLocator $dom, array $a, Stub $stub, $isNested) + public static function castLocator(\DOMLocator $dom, array $a, Stub $stub, bool $isNested) { $a += [ 'lineNumber' => $dom->lineNumber, @@ -243,7 +243,7 @@ public static function castLocator(\DOMLocator $dom, array $a, Stub $stub, $isNe return $a; } - public static function castDocumentType(\DOMDocumentType $dom, array $a, Stub $stub, $isNested) + public static function castDocumentType(\DOMDocumentType $dom, array $a, Stub $stub, bool $isNested) { $a += [ 'name' => $dom->name, @@ -257,7 +257,7 @@ public static function castDocumentType(\DOMDocumentType $dom, array $a, Stub $s return $a; } - public static function castNotation(\DOMNotation $dom, array $a, Stub $stub, $isNested) + public static function castNotation(\DOMNotation $dom, array $a, Stub $stub, bool $isNested) { $a += [ 'publicId' => $dom->publicId, @@ -267,7 +267,7 @@ public static function castNotation(\DOMNotation $dom, array $a, Stub $stub, $is return $a; } - public static function castEntity(\DOMEntity $dom, array $a, Stub $stub, $isNested) + public static function castEntity(\DOMEntity $dom, array $a, Stub $stub, bool $isNested) { $a += [ 'publicId' => $dom->publicId, @@ -281,7 +281,7 @@ public static function castEntity(\DOMEntity $dom, array $a, Stub $stub, $isNest return $a; } - public static function castProcessingInstruction(\DOMProcessingInstruction $dom, array $a, Stub $stub, $isNested) + public static function castProcessingInstruction(\DOMProcessingInstruction $dom, array $a, Stub $stub, bool $isNested) { $a += [ 'target' => $dom->target, @@ -291,7 +291,7 @@ public static function castProcessingInstruction(\DOMProcessingInstruction $dom, return $a; } - public static function castXPath(\DOMXPath $dom, array $a, Stub $stub, $isNested) + public static function castXPath(\DOMXPath $dom, array $a, Stub $stub, bool $isNested) { $a += [ 'document' => $dom->document, diff --git a/src/Symfony/Component/VarDumper/Caster/DateCaster.php b/src/Symfony/Component/VarDumper/Caster/DateCaster.php index 636615e1d28b4..cd02cd09d02a9 100644 --- a/src/Symfony/Component/VarDumper/Caster/DateCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/DateCaster.php @@ -22,7 +22,7 @@ class DateCaster { private const PERIOD_LIMIT = 3; - public static function castDateTime(\DateTimeInterface $d, array $a, Stub $stub, $isNested, $filter) + public static function castDateTime(\DateTimeInterface $d, array $a, Stub $stub, bool $isNested, int $filter) { $prefix = Caster::PREFIX_VIRTUAL; $location = $d->getTimezone()->getLocation(); @@ -41,7 +41,7 @@ public static function castDateTime(\DateTimeInterface $d, array $a, Stub $stub, return $a; } - public static function castInterval(\DateInterval $interval, array $a, Stub $stub, $isNested, $filter) + public static function castInterval(\DateInterval $interval, array $a, Stub $stub, bool $isNested, int $filter) { $now = new \DateTimeImmutable(); $numberOfSeconds = $now->add($interval)->getTimestamp() - $now->getTimestamp(); @@ -69,7 +69,7 @@ private static function formatInterval(\DateInterval $i) return $i->format(rtrim($format)); } - public static function castTimeZone(\DateTimeZone $timeZone, array $a, Stub $stub, $isNested, $filter) + public static function castTimeZone(\DateTimeZone $timeZone, array $a, Stub $stub, bool $isNested, int $filter) { $location = $timeZone->getLocation(); $formatted = (new \DateTime('now', $timeZone))->format($location ? 'e (P)' : 'P'); @@ -80,7 +80,7 @@ public static function castTimeZone(\DateTimeZone $timeZone, array $a, Stub $stu return $filter & Caster::EXCLUDE_VERBOSE ? $z : $z + $a; } - public static function castPeriod(\DatePeriod $p, array $a, Stub $stub, $isNested, $filter) + public static function castPeriod(\DatePeriod $p, array $a, Stub $stub, bool $isNested, int $filter) { $dates = []; foreach (clone $p as $i => $d) { @@ -108,12 +108,12 @@ public static function castPeriod(\DatePeriod $p, array $a, Stub $stub, $isNeste return $filter & Caster::EXCLUDE_VERBOSE ? $p : $p + $a; } - private static function formatDateTime(\DateTimeInterface $d, $extra = '') + private static function formatDateTime(\DateTimeInterface $d, string $extra = ''): string { return $d->format('Y-m-d H:i:'.self::formatSeconds($d->format('s'), $d->format('u')).$extra); } - private static function formatSeconds($s, $us) + private static function formatSeconds(string $s, string $us): string { return sprintf('%02d.%s', $s, 0 === ($len = \strlen($t = rtrim($us, '0'))) ? '0' : ($len <= 3 ? str_pad($t, 3, '0') : $us)); } diff --git a/src/Symfony/Component/VarDumper/Caster/DoctrineCaster.php b/src/Symfony/Component/VarDumper/Caster/DoctrineCaster.php index 696b87816ea8e..1b945f83c0c7c 100644 --- a/src/Symfony/Component/VarDumper/Caster/DoctrineCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/DoctrineCaster.php @@ -23,7 +23,7 @@ */ class DoctrineCaster { - public static function castCommonProxy(CommonProxy $proxy, array $a, Stub $stub, $isNested) + public static function castCommonProxy(CommonProxy $proxy, array $a, Stub $stub, bool $isNested) { foreach (['__cloner__', '__initializer__'] as $k) { if (\array_key_exists($k, $a)) { @@ -35,7 +35,7 @@ public static function castCommonProxy(CommonProxy $proxy, array $a, Stub $stub, return $a; } - public static function castOrmProxy(OrmProxy $proxy, array $a, Stub $stub, $isNested) + public static function castOrmProxy(OrmProxy $proxy, array $a, Stub $stub, bool $isNested) { foreach (['_entityPersister', '_identifier'] as $k) { if (\array_key_exists($k = "\0Doctrine\\ORM\\Proxy\\Proxy\0".$k, $a)) { @@ -47,7 +47,7 @@ public static function castOrmProxy(OrmProxy $proxy, array $a, Stub $stub, $isNe return $a; } - public static function castPersistentCollection(PersistentCollection $coll, array $a, Stub $stub, $isNested) + public static function castPersistentCollection(PersistentCollection $coll, array $a, Stub $stub, bool $isNested) { foreach (['snapshot', 'association', 'typeClass'] as $k) { if (\array_key_exists($k = "\0Doctrine\\ORM\\PersistentCollection\0".$k, $a)) { diff --git a/src/Symfony/Component/VarDumper/Caster/ExceptionCaster.php b/src/Symfony/Component/VarDumper/Caster/ExceptionCaster.php index 60cffcb6b73a9..064c860d1d371 100644 --- a/src/Symfony/Component/VarDumper/Caster/ExceptionCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/ExceptionCaster.php @@ -44,17 +44,17 @@ class ExceptionCaster private static $framesCache = []; - public static function castError(\Error $e, array $a, Stub $stub, $isNested, $filter = 0) + public static function castError(\Error $e, array $a, Stub $stub, bool $isNested, int $filter = 0) { return self::filterExceptionArray($stub->class, $a, "\0Error\0", $filter); } - public static function castException(\Exception $e, array $a, Stub $stub, $isNested, $filter = 0) + public static function castException(\Exception $e, array $a, Stub $stub, bool $isNested, int $filter = 0) { return self::filterExceptionArray($stub->class, $a, "\0Exception\0", $filter); } - public static function castErrorException(\ErrorException $e, array $a, Stub $stub, $isNested) + public static function castErrorException(\ErrorException $e, array $a, Stub $stub, bool $isNested) { if (isset($a[$s = Caster::PREFIX_PROTECTED.'severity'], self::$errorTypes[$a[$s]])) { $a[$s] = new ConstStub(self::$errorTypes[$a[$s]], $a[$s]); @@ -63,7 +63,7 @@ public static function castErrorException(\ErrorException $e, array $a, Stub $st return $a; } - public static function castThrowingCasterException(ThrowingCasterException $e, array $a, Stub $stub, $isNested) + public static function castThrowingCasterException(ThrowingCasterException $e, array $a, Stub $stub, bool $isNested) { $trace = Caster::PREFIX_VIRTUAL.'trace'; $prefix = Caster::PREFIX_PROTECTED; @@ -82,7 +82,7 @@ public static function castThrowingCasterException(ThrowingCasterException $e, a return $a; } - public static function castSilencedErrorContext(SilencedErrorContext $e, array $a, Stub $stub, $isNested) + public static function castSilencedErrorContext(SilencedErrorContext $e, array $a, Stub $stub, bool $isNested) { $sPrefix = "\0".SilencedErrorContext::class."\0"; @@ -109,7 +109,7 @@ public static function castSilencedErrorContext(SilencedErrorContext $e, array $ return $a; } - public static function castTraceStub(TraceStub $trace, array $a, Stub $stub, $isNested) + public static function castTraceStub(TraceStub $trace, array $a, Stub $stub, bool $isNested) { if (!$isNested) { return $a; @@ -183,7 +183,7 @@ public static function castTraceStub(TraceStub $trace, array $a, Stub $stub, $is return $a; } - public static function castFrameStub(FrameStub $frame, array $a, Stub $stub, $isNested) + public static function castFrameStub(FrameStub $frame, array $a, Stub $stub, bool $isNested) { if (!$isNested) { return $a; @@ -261,7 +261,7 @@ public static function castFrameStub(FrameStub $frame, array $a, Stub $stub, $is return $a; } - private static function filterExceptionArray($xClass, array $a, $xPrefix, $filter) + private static function filterExceptionArray($xClass, array $a, string $xPrefix, int $filter) { if (isset($a[$xPrefix.'trace'])) { $trace = $a[$xPrefix.'trace']; @@ -294,7 +294,7 @@ private static function filterExceptionArray($xClass, array $a, $xPrefix, $filte return $a; } - private static function traceUnshift(&$trace, $class, $file, $line) + private static function traceUnshift(array &$trace, ?string $class, string $file, int $line) { if (isset($trace[0]['file'], $trace[0]['line']) && $trace[0]['file'] === $file && $trace[0]['line'] === $line) { return; @@ -306,7 +306,7 @@ private static function traceUnshift(&$trace, $class, $file, $line) ]); } - private static function extractSource($srcLines, $line, $srcContext, $title, $lang, $file = null) + private static function extractSource(string $srcLines, int $line, int $srcContext, ?string $title, string $lang, string $file = null) { $srcLines = explode("\n", $srcLines); $src = []; diff --git a/src/Symfony/Component/VarDumper/Caster/GmpCaster.php b/src/Symfony/Component/VarDumper/Caster/GmpCaster.php index 504dc078867a8..7c57d5a580daa 100644 --- a/src/Symfony/Component/VarDumper/Caster/GmpCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/GmpCaster.php @@ -21,7 +21,7 @@ */ class GmpCaster { - public static function castGmp(\GMP $gmp, array $a, Stub $stub, $isNested, $filter): array + public static function castGmp(\GMP $gmp, array $a, Stub $stub, bool $isNested, int $filter): array { $a[Caster::PREFIX_VIRTUAL.'value'] = new ConstStub(gmp_strval($gmp), gmp_strval($gmp)); diff --git a/src/Symfony/Component/VarDumper/Caster/ImagineCaster.php b/src/Symfony/Component/VarDumper/Caster/ImagineCaster.php index 10497cdac9cd3..e94d224e5413c 100644 --- a/src/Symfony/Component/VarDumper/Caster/ImagineCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/ImagineCaster.php @@ -19,7 +19,7 @@ */ class ImagineCaster { - public static function castImage(ImageInterface $c, array $a, Stub $stub, $isNested) + public static function castImage(ImageInterface $c, array $a, Stub $stub, bool $isNested) { $imgData = $c->get('png'); if (\strlen($imgData) > 1 * 1000 * 1000) { diff --git a/src/Symfony/Component/VarDumper/Caster/IntlCaster.php b/src/Symfony/Component/VarDumper/Caster/IntlCaster.php index 31d5cb395fbb4..d48cf5807abff 100644 --- a/src/Symfony/Component/VarDumper/Caster/IntlCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/IntlCaster.php @@ -19,7 +19,7 @@ */ class IntlCaster { - public static function castMessageFormatter(\MessageFormatter $c, array $a, Stub $stub, $isNested) + public static function castMessageFormatter(\MessageFormatter $c, array $a, Stub $stub, bool $isNested) { $a += [ Caster::PREFIX_VIRTUAL.'locale' => $c->getLocale(), @@ -29,7 +29,7 @@ public static function castMessageFormatter(\MessageFormatter $c, array $a, Stub return self::castError($c, $a); } - public static function castNumberFormatter(\NumberFormatter $c, array $a, Stub $stub, $isNested, $filter = 0) + public static function castNumberFormatter(\NumberFormatter $c, array $a, Stub $stub, bool $isNested, int $filter = 0) { $a += [ Caster::PREFIX_VIRTUAL.'locale' => $c->getLocale(), @@ -106,7 +106,7 @@ public static function castNumberFormatter(\NumberFormatter $c, array $a, Stub $ return self::castError($c, $a); } - public static function castIntlTimeZone(\IntlTimeZone $c, array $a, Stub $stub, $isNested) + public static function castIntlTimeZone(\IntlTimeZone $c, array $a, Stub $stub, bool $isNested) { $a += [ Caster::PREFIX_VIRTUAL.'display_name' => $c->getDisplayName(), @@ -123,7 +123,7 @@ public static function castIntlTimeZone(\IntlTimeZone $c, array $a, Stub $stub, return self::castError($c, $a); } - public static function castIntlCalendar(\IntlCalendar $c, array $a, Stub $stub, $isNested, $filter = 0) + public static function castIntlCalendar(\IntlCalendar $c, array $a, Stub $stub, bool $isNested, int $filter = 0) { $a += [ Caster::PREFIX_VIRTUAL.'type' => $c->getType(), @@ -140,7 +140,7 @@ public static function castIntlCalendar(\IntlCalendar $c, array $a, Stub $stub, return self::castError($c, $a); } - public static function castIntlDateFormatter(\IntlDateFormatter $c, array $a, Stub $stub, $isNested, $filter = 0) + public static function castIntlDateFormatter(\IntlDateFormatter $c, array $a, Stub $stub, bool $isNested, int $filter = 0) { $a += [ Caster::PREFIX_VIRTUAL.'locale' => $c->getLocale(), @@ -156,7 +156,7 @@ public static function castIntlDateFormatter(\IntlDateFormatter $c, array $a, St return self::castError($c, $a); } - private static function castError($c, array $a): array + private static function castError(object $c, array $a): array { if ($errorCode = $c->getErrorCode()) { $a += [ diff --git a/src/Symfony/Component/VarDumper/Caster/MemcachedCaster.php b/src/Symfony/Component/VarDumper/Caster/MemcachedCaster.php index a32654683dd22..52a4aa61915be 100644 --- a/src/Symfony/Component/VarDumper/Caster/MemcachedCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/MemcachedCaster.php @@ -21,7 +21,7 @@ class MemcachedCaster private static $optionConstants; private static $defaultOptions; - public static function castMemcached(\Memcached $c, array $a, Stub $stub, $isNested) + public static function castMemcached(\Memcached $c, array $a, Stub $stub, bool $isNested) { $a += [ Caster::PREFIX_VIRTUAL.'servers' => $c->getServerList(), diff --git a/src/Symfony/Component/VarDumper/Caster/PdoCaster.php b/src/Symfony/Component/VarDumper/Caster/PdoCaster.php index 8af51829a93fb..73f16c7773a83 100644 --- a/src/Symfony/Component/VarDumper/Caster/PdoCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/PdoCaster.php @@ -57,7 +57,7 @@ class PdoCaster ], ]; - public static function castPdo(\PDO $c, array $a, Stub $stub, $isNested) + public static function castPdo(\PDO $c, array $a, Stub $stub, bool $isNested) { $attr = []; $errmode = $c->getAttribute(\PDO::ATTR_ERRMODE); @@ -106,7 +106,7 @@ public static function castPdo(\PDO $c, array $a, Stub $stub, $isNested) return $a; } - public static function castPdoStatement(\PDOStatement $c, array $a, Stub $stub, $isNested) + public static function castPdoStatement(\PDOStatement $c, array $a, Stub $stub, bool $isNested) { $prefix = Caster::PREFIX_VIRTUAL; $a[$prefix.'errorInfo'] = $c->errorInfo(); diff --git a/src/Symfony/Component/VarDumper/Caster/PgSqlCaster.php b/src/Symfony/Component/VarDumper/Caster/PgSqlCaster.php index cd6bf5b5fe666..b84b7ab939921 100644 --- a/src/Symfony/Component/VarDumper/Caster/PgSqlCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/PgSqlCaster.php @@ -67,14 +67,14 @@ class PgSqlCaster 'function' => PGSQL_DIAG_SOURCE_FUNCTION, ]; - public static function castLargeObject($lo, array $a, Stub $stub, $isNested) + public static function castLargeObject($lo, array $a, Stub $stub, bool $isNested) { $a['seek position'] = pg_lo_tell($lo); return $a; } - public static function castLink($link, array $a, Stub $stub, $isNested) + public static function castLink($link, array $a, Stub $stub, bool $isNested) { $a['status'] = pg_connection_status($link); $a['status'] = new ConstStub(PGSQL_CONNECTION_OK === $a['status'] ? 'PGSQL_CONNECTION_OK' : 'PGSQL_CONNECTION_BAD', $a['status']); @@ -106,7 +106,7 @@ public static function castLink($link, array $a, Stub $stub, $isNested) return $a; } - public static function castResult($result, array $a, Stub $stub, $isNested) + public static function castResult($result, array $a, Stub $stub, bool $isNested) { $a['num rows'] = pg_num_rows($result); $a['status'] = pg_result_status($result); diff --git a/src/Symfony/Component/VarDumper/Caster/ProxyManagerCaster.php b/src/Symfony/Component/VarDumper/Caster/ProxyManagerCaster.php index d8afd704006a8..4af8cf2496cf9 100644 --- a/src/Symfony/Component/VarDumper/Caster/ProxyManagerCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/ProxyManagerCaster.php @@ -19,7 +19,7 @@ */ class ProxyManagerCaster { - public static function castProxy(ProxyInterface $c, array $a, Stub $stub, $isNested) + public static function castProxy(ProxyInterface $c, array $a, Stub $stub, bool $isNested) { if ($parent = get_parent_class($c)) { $stub->class .= ' - '.$parent; diff --git a/src/Symfony/Component/VarDumper/Caster/RedisCaster.php b/src/Symfony/Component/VarDumper/Caster/RedisCaster.php index 558a0804d5834..0c37c0cc48fea 100644 --- a/src/Symfony/Component/VarDumper/Caster/RedisCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/RedisCaster.php @@ -44,7 +44,7 @@ class RedisCaster \RedisCluster::FAILOVER_DISTRIBUTE_SLAVES => 'DISTRIBUTE_SLAVES', ]; - public static function castRedis(\Redis $c, array $a, Stub $stub, $isNested) + public static function castRedis(\Redis $c, array $a, Stub $stub, bool $isNested) { $prefix = Caster::PREFIX_VIRTUAL; @@ -70,7 +70,7 @@ public static function castRedis(\Redis $c, array $a, Stub $stub, $isNested) ]; } - public static function castRedisArray(\RedisArray $c, array $a, Stub $stub, $isNested) + public static function castRedisArray(\RedisArray $c, array $a, Stub $stub, bool $isNested) { $prefix = Caster::PREFIX_VIRTUAL; @@ -82,7 +82,7 @@ public static function castRedisArray(\RedisArray $c, array $a, Stub $stub, $isN ]; } - public static function castRedisCluster(\RedisCluster $c, array $a, Stub $stub, $isNested) + public static function castRedisCluster(\RedisCluster $c, array $a, Stub $stub, bool $isNested) { $prefix = Caster::PREFIX_VIRTUAL; $failover = $c->getOption(\RedisCluster::OPT_SLAVE_FAILOVER); diff --git a/src/Symfony/Component/VarDumper/Caster/ReflectionCaster.php b/src/Symfony/Component/VarDumper/Caster/ReflectionCaster.php index 8dfe7ea5ad749..598b1c14f4de4 100644 --- a/src/Symfony/Component/VarDumper/Caster/ReflectionCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/ReflectionCaster.php @@ -33,7 +33,7 @@ class ReflectionCaster 'isVariadic' => 'isVariadic', ]; - public static function castClosure(\Closure $c, array $a, Stub $stub, $isNested, $filter = 0) + public static function castClosure(\Closure $c, array $a, Stub $stub, bool $isNested, int $filter = 0) { $prefix = Caster::PREFIX_VIRTUAL; $c = new \ReflectionFunction($c); @@ -76,7 +76,7 @@ public static function unsetClosureFileInfo(\Closure $c, array $a) return $a; } - public static function castGenerator(\Generator $c, array $a, Stub $stub, $isNested) + public static function castGenerator(\Generator $c, array $a, Stub $stub, bool $isNested) { if (!class_exists('ReflectionGenerator', false)) { return $a; @@ -94,7 +94,7 @@ public static function castGenerator(\Generator $c, array $a, Stub $stub, $isNes return self::castReflectionGenerator($reflectionGenerator, $a, $stub, $isNested); } - public static function castType(\ReflectionType $c, array $a, Stub $stub, $isNested) + public static function castType(\ReflectionType $c, array $a, Stub $stub, bool $isNested) { $prefix = Caster::PREFIX_VIRTUAL; @@ -107,7 +107,7 @@ public static function castType(\ReflectionType $c, array $a, Stub $stub, $isNes return $a; } - public static function castReflectionGenerator(\ReflectionGenerator $c, array $a, Stub $stub, $isNested) + public static function castReflectionGenerator(\ReflectionGenerator $c, array $a, Stub $stub, bool $isNested) { $prefix = Caster::PREFIX_VIRTUAL; @@ -144,7 +144,7 @@ public static function castReflectionGenerator(\ReflectionGenerator $c, array $a return $a; } - public static function castClass(\ReflectionClass $c, array $a, Stub $stub, $isNested, $filter = 0) + public static function castClass(\ReflectionClass $c, array $a, Stub $stub, bool $isNested, int $filter = 0) { $prefix = Caster::PREFIX_VIRTUAL; @@ -173,7 +173,7 @@ public static function castClass(\ReflectionClass $c, array $a, Stub $stub, $isN return $a; } - public static function castFunctionAbstract(\ReflectionFunctionAbstract $c, array $a, Stub $stub, $isNested, $filter = 0) + public static function castFunctionAbstract(\ReflectionFunctionAbstract $c, array $a, Stub $stub, bool $isNested, int $filter = 0) { $prefix = Caster::PREFIX_VIRTUAL; @@ -229,14 +229,14 @@ public static function castFunctionAbstract(\ReflectionFunctionAbstract $c, arra return $a; } - public static function castMethod(\ReflectionMethod $c, array $a, Stub $stub, $isNested) + public static function castMethod(\ReflectionMethod $c, array $a, Stub $stub, bool $isNested) { $a[Caster::PREFIX_VIRTUAL.'modifiers'] = implode(' ', \Reflection::getModifierNames($c->getModifiers())); return $a; } - public static function castParameter(\ReflectionParameter $c, array $a, Stub $stub, $isNested) + public static function castParameter(\ReflectionParameter $c, array $a, Stub $stub, bool $isNested) { $prefix = Caster::PREFIX_VIRTUAL; @@ -272,7 +272,7 @@ public static function castParameter(\ReflectionParameter $c, array $a, Stub $st return $a; } - public static function castProperty(\ReflectionProperty $c, array $a, Stub $stub, $isNested) + public static function castProperty(\ReflectionProperty $c, array $a, Stub $stub, bool $isNested) { $a[Caster::PREFIX_VIRTUAL.'modifiers'] = implode(' ', \Reflection::getModifierNames($c->getModifiers())); self::addExtra($a, $c); @@ -280,14 +280,14 @@ public static function castProperty(\ReflectionProperty $c, array $a, Stub $stub return $a; } - public static function castReference(\ReflectionReference $c, array $a, Stub $stub, $isNested) + public static function castReference(\ReflectionReference $c, array $a, Stub $stub, bool $isNested) { $a[Caster::PREFIX_VIRTUAL.'id'] = $c->getId(); return $a; } - public static function castExtension(\ReflectionExtension $c, array $a, Stub $stub, $isNested) + public static function castExtension(\ReflectionExtension $c, array $a, Stub $stub, bool $isNested) { self::addMap($a, $c, [ 'version' => 'getVersion', @@ -303,7 +303,7 @@ public static function castExtension(\ReflectionExtension $c, array $a, Stub $st return $a; } - public static function castZendExtension(\ReflectionZendExtension $c, array $a, Stub $stub, $isNested) + public static function castZendExtension(\ReflectionZendExtension $c, array $a, Stub $stub, bool $isNested) { self::addMap($a, $c, [ 'version' => 'getVersion', diff --git a/src/Symfony/Component/VarDumper/Caster/ResourceCaster.php b/src/Symfony/Component/VarDumper/Caster/ResourceCaster.php index 5d9b80de2a51f..d8683f0344a48 100644 --- a/src/Symfony/Component/VarDumper/Caster/ResourceCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/ResourceCaster.php @@ -20,12 +20,12 @@ */ class ResourceCaster { - public static function castCurl($h, array $a, Stub $stub, $isNested) + public static function castCurl($h, array $a, Stub $stub, bool $isNested) { return curl_getinfo($h); } - public static function castDba($dba, array $a, Stub $stub, $isNested) + public static function castDba($dba, array $a, Stub $stub, bool $isNested) { $list = dba_list(); $a['file'] = $list[(int) $dba]; @@ -33,12 +33,12 @@ public static function castDba($dba, array $a, Stub $stub, $isNested) return $a; } - public static function castProcess($process, array $a, Stub $stub, $isNested) + public static function castProcess($process, array $a, Stub $stub, bool $isNested) { return proc_get_status($process); } - public static function castStream($stream, array $a, Stub $stub, $isNested) + public static function castStream($stream, array $a, Stub $stub, bool $isNested) { $a = stream_get_meta_data($stream) + static::castStreamContext($stream, $a, $stub, $isNested); if (isset($a['uri'])) { @@ -48,7 +48,7 @@ public static function castStream($stream, array $a, Stub $stub, $isNested) return $a; } - public static function castStreamContext($stream, array $a, Stub $stub, $isNested) + public static function castStreamContext($stream, array $a, Stub $stub, bool $isNested) { return @stream_context_get_params($stream) ?: $a; } @@ -61,7 +61,7 @@ public static function castGd($gd, array $a, Stub $stub, $isNested) return $a; } - public static function castMysqlLink($h, array $a, Stub $stub, $isNested) + public static function castMysqlLink($h, array $a, Stub $stub, bool $isNested) { $a['host'] = mysql_get_host_info($h); $a['protocol'] = mysql_get_proto_info($h); @@ -70,7 +70,7 @@ public static function castMysqlLink($h, array $a, Stub $stub, $isNested) return $a; } - public static function castOpensslX509($h, array $a, Stub $stub, $isNested) + public static function castOpensslX509($h, array $a, Stub $stub, bool $isNested) { $stub->cut = -1; $info = openssl_x509_parse($h, false); diff --git a/src/Symfony/Component/VarDumper/Caster/SplCaster.php b/src/Symfony/Component/VarDumper/Caster/SplCaster.php index 37260b5b97584..6ecded72a88cf 100644 --- a/src/Symfony/Component/VarDumper/Caster/SplCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/SplCaster.php @@ -27,12 +27,12 @@ class SplCaster \SplFileObject::READ_CSV => 'READ_CSV', ]; - public static function castArrayObject(\ArrayObject $c, array $a, Stub $stub, $isNested) + public static function castArrayObject(\ArrayObject $c, array $a, Stub $stub, bool $isNested) { return self::castSplArray($c, $a, $stub, $isNested); } - public static function castArrayIterator(\ArrayIterator $c, array $a, Stub $stub, $isNested) + public static function castArrayIterator(\ArrayIterator $c, array $a, Stub $stub, bool $isNested) { return self::castSplArray($c, $a, $stub, $isNested); } @@ -46,7 +46,7 @@ public static function castHeap(\Iterator $c, array $a, Stub $stub, $isNested) return $a; } - public static function castDoublyLinkedList(\SplDoublyLinkedList $c, array $a, Stub $stub, $isNested) + public static function castDoublyLinkedList(\SplDoublyLinkedList $c, array $a, Stub $stub, bool $isNested) { $prefix = Caster::PREFIX_VIRTUAL; $mode = $c->getIteratorMode(); @@ -61,7 +61,7 @@ public static function castDoublyLinkedList(\SplDoublyLinkedList $c, array $a, S return $a; } - public static function castFileInfo(\SplFileInfo $c, array $a, Stub $stub, $isNested) + public static function castFileInfo(\SplFileInfo $c, array $a, Stub $stub, bool $isNested) { static $map = [ 'path' => 'getPath', @@ -115,7 +115,7 @@ public static function castFileInfo(\SplFileInfo $c, array $a, Stub $stub, $isNe return $a; } - public static function castFileObject(\SplFileObject $c, array $a, Stub $stub, $isNested) + public static function castFileObject(\SplFileObject $c, array $a, Stub $stub, bool $isNested) { static $map = [ 'csvControl' => 'getCsvControl', @@ -152,7 +152,7 @@ public static function castFileObject(\SplFileObject $c, array $a, Stub $stub, $ return $a; } - public static function castFixedArray(\SplFixedArray $c, array $a, Stub $stub, $isNested) + public static function castFixedArray(\SplFixedArray $c, array $a, Stub $stub, bool $isNested) { $a += [ Caster::PREFIX_VIRTUAL.'storage' => $c->toArray(), @@ -161,7 +161,7 @@ public static function castFixedArray(\SplFixedArray $c, array $a, Stub $stub, $ return $a; } - public static function castObjectStorage(\SplObjectStorage $c, array $a, Stub $stub, $isNested) + public static function castObjectStorage(\SplObjectStorage $c, array $a, Stub $stub, bool $isNested) { $storage = []; unset($a[Caster::PREFIX_DYNAMIC."\0gcdata"]); // Don't hit https://bugs.php.net/65967 @@ -181,21 +181,21 @@ public static function castObjectStorage(\SplObjectStorage $c, array $a, Stub $s return $a; } - public static function castOuterIterator(\OuterIterator $c, array $a, Stub $stub, $isNested) + public static function castOuterIterator(\OuterIterator $c, array $a, Stub $stub, bool $isNested) { $a[Caster::PREFIX_VIRTUAL.'innerIterator'] = $c->getInnerIterator(); return $a; } - public static function castWeakReference(\WeakReference $c, array $a, Stub $stub, $isNested) + public static function castWeakReference(\WeakReference $c, array $a, Stub $stub, bool $isNested) { $a[Caster::PREFIX_VIRTUAL.'object'] = $c->get(); return $a; } - private static function castSplArray($c, array $a, Stub $stub, $isNested) + private static function castSplArray($c, array $a, Stub $stub, bool $isNested): array { $prefix = Caster::PREFIX_VIRTUAL; $class = $stub->class; diff --git a/src/Symfony/Component/VarDumper/Caster/StubCaster.php b/src/Symfony/Component/VarDumper/Caster/StubCaster.php index 9927d42610c18..74162c4c3db0e 100644 --- a/src/Symfony/Component/VarDumper/Caster/StubCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/StubCaster.php @@ -20,7 +20,7 @@ */ class StubCaster { - public static function castStub(Stub $c, array $a, Stub $stub, $isNested) + public static function castStub(Stub $c, array $a, Stub $stub, bool $isNested) { if ($isNested) { $stub->type = $c->type; @@ -41,12 +41,12 @@ public static function castStub(Stub $c, array $a, Stub $stub, $isNested) return $a; } - public static function castCutArray(CutArrayStub $c, array $a, Stub $stub, $isNested) + public static function castCutArray(CutArrayStub $c, array $a, Stub $stub, bool $isNested) { return $isNested ? $c->preservedSubset : $a; } - public static function cutInternals($obj, array $a, Stub $stub, $isNested) + public static function cutInternals($obj, array $a, Stub $stub, bool $isNested) { if ($isNested) { $stub->cut += \count($a); @@ -57,7 +57,7 @@ public static function cutInternals($obj, array $a, Stub $stub, $isNested) return $a; } - public static function castEnum(EnumStub $c, array $a, Stub $stub, $isNested) + public static function castEnum(EnumStub $c, array $a, Stub $stub, bool $isNested) { if ($isNested) { $stub->class = $c->dumpKeys ? '' : null; diff --git a/src/Symfony/Component/VarDumper/Caster/SymfonyCaster.php b/src/Symfony/Component/VarDumper/Caster/SymfonyCaster.php index aa10465861296..4010e29b1e985 100644 --- a/src/Symfony/Component/VarDumper/Caster/SymfonyCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/SymfonyCaster.php @@ -25,7 +25,7 @@ class SymfonyCaster 'format' => 'getRequestFormat', ]; - public static function castRequest(Request $request, array $a, Stub $stub, $isNested) + public static function castRequest(Request $request, array $a, Stub $stub, bool $isNested) { $clone = null; @@ -41,7 +41,7 @@ public static function castRequest(Request $request, array $a, Stub $stub, $isNe return $a; } - public static function castHttpClient($client, array $a, Stub $stub, $isNested) + public static function castHttpClient($client, array $a, Stub $stub, bool $isNested) { $multiKey = sprintf("\0%s\0multi", \get_class($client)); $a[$multiKey] = new CutStub($a[$multiKey]); @@ -49,7 +49,7 @@ public static function castHttpClient($client, array $a, Stub $stub, $isNested) return $a; } - public static function castHttpClientResponse($response, array $a, Stub $stub, $isNested) + public static function castHttpClientResponse($response, array $a, Stub $stub, bool $isNested) { $stub->cut += \count($a); $a = []; diff --git a/src/Symfony/Component/VarDumper/Caster/XmlReaderCaster.php b/src/Symfony/Component/VarDumper/Caster/XmlReaderCaster.php index 3ae9ec0ba19a0..e36cbcdd07682 100644 --- a/src/Symfony/Component/VarDumper/Caster/XmlReaderCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/XmlReaderCaster.php @@ -40,7 +40,7 @@ class XmlReaderCaster \XMLReader::XML_DECLARATION => 'XML_DECLARATION', ]; - public static function castXmlReader(\XMLReader $reader, array $a, Stub $stub, $isNested) + public static function castXmlReader(\XMLReader $reader, array $a, Stub $stub, bool $isNested) { $props = Caster::PREFIX_VIRTUAL.'parserProperties'; $info = [ diff --git a/src/Symfony/Component/VarDumper/Caster/XmlResourceCaster.php b/src/Symfony/Component/VarDumper/Caster/XmlResourceCaster.php index 117138c7848c0..4aa70c8679c22 100644 --- a/src/Symfony/Component/VarDumper/Caster/XmlResourceCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/XmlResourceCaster.php @@ -45,7 +45,7 @@ class XmlResourceCaster XML_ERROR_EXTERNAL_ENTITY_HANDLING => 'XML_ERROR_EXTERNAL_ENTITY_HANDLING', ]; - public static function castXml($h, array $a, Stub $stub, $isNested) + public static function castXml($h, array $a, Stub $stub, bool $isNested) { $a['current_byte_index'] = xml_get_current_byte_index($h); $a['current_column_number'] = xml_get_current_column_number($h); diff --git a/src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php b/src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php index 6aec3e49249b1..4981d48a7959a 100644 --- a/src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php +++ b/src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php @@ -199,33 +199,27 @@ public function addCasters(array $casters) /** * Sets the maximum number of items to clone past the minimum depth in nested structures. - * - * @param int $maxItems */ - public function setMaxItems($maxItems) + public function setMaxItems(int $maxItems) { - $this->maxItems = (int) $maxItems; + $this->maxItems = $maxItems; } /** * Sets the maximum cloned length for strings. - * - * @param int $maxString */ - public function setMaxString($maxString) + public function setMaxString(int $maxString) { - $this->maxString = (int) $maxString; + $this->maxString = $maxString; } /** * Sets the minimum tree depth where we are guaranteed to clone all the items. After this * depth is reached, only setMaxItems items will be cloned. - * - * @param int $minDepth */ - public function setMinDepth($minDepth) + public function setMinDepth(int $minDepth) { - $this->minDepth = (int) $minDepth; + $this->minDepth = $minDepth; } /** @@ -236,7 +230,7 @@ public function setMinDepth($minDepth) * * @return Data The cloned variable represented by a Data object */ - public function cloneVar($var, $filter = 0) + public function cloneVar($var, int $filter = 0) { $this->prevErrorHandler = set_error_handler(function ($type, $msg, $file, $line, $context = []) { if (E_RECOVERABLE_ERROR === $type || E_USER_ERROR === $type) { @@ -282,7 +276,7 @@ abstract protected function doClone($var); * * @return array The object casted as array */ - protected function castObject(Stub $stub, $isNested) + protected function castObject(Stub $stub, bool $isNested) { $obj = $stub->value; $class = $stub->class; @@ -341,7 +335,7 @@ protected function castObject(Stub $stub, $isNested) * * @return array The resource casted as array */ - protected function castResource(Stub $stub, $isNested) + protected function castResource(Stub $stub, bool $isNested) { $a = []; $res = $stub->value; diff --git a/src/Symfony/Component/VarDumper/Cloner/Data.php b/src/Symfony/Component/VarDumper/Cloner/Data.php index 5a37ac96b5605..1d6792721c0e9 100644 --- a/src/Symfony/Component/VarDumper/Cloner/Data.php +++ b/src/Symfony/Component/VarDumper/Cloner/Data.php @@ -166,11 +166,9 @@ public function __toString() /** * Returns a depth limited clone of $this. * - * @param int $maxDepth The max dumped depth level - * * @return static */ - public function withMaxDepth($maxDepth) + public function withMaxDepth(int $maxDepth) { $data = clone $this; $data->maxDepth = (int) $maxDepth; @@ -181,11 +179,9 @@ public function withMaxDepth($maxDepth) /** * Limits the number of elements per depth level. * - * @param int $maxItemsPerDepth The max number of items dumped per depth level - * * @return static */ - public function withMaxItemsPerDepth($maxItemsPerDepth) + public function withMaxItemsPerDepth(int $maxItemsPerDepth) { $data = clone $this; $data->maxItemsPerDepth = (int) $maxItemsPerDepth; @@ -200,7 +196,7 @@ public function withMaxItemsPerDepth($maxItemsPerDepth) * * @return static */ - public function withRefHandles($useRefHandles) + public function withRefHandles(bool $useRefHandles) { $data = clone $this; $data->useRefHandles = $useRefHandles ? -1 : 0; diff --git a/src/Symfony/Component/VarDumper/Cloner/DumperInterface.php b/src/Symfony/Component/VarDumper/Cloner/DumperInterface.php index ec8ef2727894d..6d60b723c7f79 100644 --- a/src/Symfony/Component/VarDumper/Cloner/DumperInterface.php +++ b/src/Symfony/Component/VarDumper/Cloner/DumperInterface.php @@ -24,7 +24,7 @@ interface DumperInterface * @param string $type The PHP type of the value being dumped * @param string|int|float|bool $value The scalar value being dumped */ - public function dumpScalar(Cursor $cursor, $type, $value); + public function dumpScalar(Cursor $cursor, string $type, $value); /** * Dumps a string. @@ -33,7 +33,7 @@ public function dumpScalar(Cursor $cursor, $type, $value); * @param bool $bin Whether $str is UTF-8 or binary encoded * @param int $cut The number of characters $str has been cut by */ - public function dumpString(Cursor $cursor, $str, $bin, $cut); + public function dumpString(Cursor $cursor, string $str, bool $bin, int $cut); /** * Dumps while entering an hash. @@ -42,7 +42,7 @@ public function dumpString(Cursor $cursor, $str, $bin, $cut); * @param string|int $class The object class, resource type or array count * @param bool $hasChild When the dump of the hash has child item */ - public function enterHash(Cursor $cursor, $type, $class, $hasChild); + public function enterHash(Cursor $cursor, int $type, $class, bool $hasChild); /** * Dumps while leaving an hash. @@ -52,5 +52,5 @@ public function enterHash(Cursor $cursor, $type, $class, $hasChild); * @param bool $hasChild When the dump of the hash has child item * @param int $cut The number of items the hash has been cut by */ - public function leaveHash(Cursor $cursor, $type, $class, $hasChild, $cut); + public function leaveHash(Cursor $cursor, int $type, $class, bool $hasChild, int $cut); } diff --git a/src/Symfony/Component/VarDumper/Dumper/AbstractDumper.php b/src/Symfony/Component/VarDumper/Dumper/AbstractDumper.php index c4153ba58b0bd..0fc44d5b7b2cf 100644 --- a/src/Symfony/Component/VarDumper/Dumper/AbstractDumper.php +++ b/src/Symfony/Component/VarDumper/Dumper/AbstractDumper.php @@ -82,11 +82,9 @@ public function setOutput($output) /** * Sets the default character encoding to use for non-UTF8 strings. * - * @param string $charset The default character encoding to use for non-UTF8 strings - * * @return string The previous charset */ - public function setCharset($charset) + public function setCharset(string $charset) { $prev = $this->charset; @@ -105,7 +103,7 @@ public function setCharset($charset) * * @return string The previous indent pad */ - public function setIndentPad($pad) + public function setIndentPad(string $pad) { $prev = $this->indentPad; $this->indentPad = $pad; @@ -161,7 +159,7 @@ public function dump(Data $data, $output = null) * @param int $depth The recursive depth in the dumped structure for the line being dumped, * or -1 to signal the end-of-dump to the line dumper callable */ - protected function dumpLine($depth) + protected function dumpLine(int $depth) { ($this->lineDumper)($this->line, $depth, $this->indentPad); $this->line = ''; @@ -169,12 +167,8 @@ protected function dumpLine($depth) /** * Generic line dumper callback. - * - * @param string $line The line to write - * @param int $depth The recursive depth in the dumped structure - * @param string $indentPad The line indent pad */ - protected function echoLine($line, $depth, $indentPad) + protected function echoLine(string $line, int $depth, string $indentPad) { if (-1 !== $depth) { fwrite($this->outputStream, str_repeat($indentPad, $depth).$line."\n"); @@ -184,11 +178,9 @@ protected function echoLine($line, $depth, $indentPad) /** * Converts a non-UTF-8 string to UTF-8. * - * @param string|null $s The non-UTF-8 string to convert - * * @return string|null The string converted to UTF-8 */ - protected function utf8Encode($s) + protected function utf8Encode(?string $s) { if (null === $s || preg_match('//u', $s)) { return $s; diff --git a/src/Symfony/Component/VarDumper/Dumper/CliDumper.php b/src/Symfony/Component/VarDumper/Dumper/CliDumper.php index 50a5ba457828c..0c25c075f37f1 100644 --- a/src/Symfony/Component/VarDumper/Dumper/CliDumper.php +++ b/src/Symfony/Component/VarDumper/Dumper/CliDumper.php @@ -88,22 +88,18 @@ public function __construct($output = null, string $charset = null, int $flags = /** * Enables/disables colored output. - * - * @param bool $colors */ - public function setColors($colors) + public function setColors(bool $colors) { - $this->colors = (bool) $colors; + $this->colors = $colors; } /** * Sets the maximum number of characters per line for dumped strings. - * - * @param int $maxStringWidth */ - public function setMaxStringWidth($maxStringWidth) + public function setMaxStringWidth(int $maxStringWidth) { - $this->maxStringWidth = (int) $maxStringWidth; + $this->maxStringWidth = $maxStringWidth; } /** @@ -129,7 +125,7 @@ public function setDisplayOptions(array $displayOptions) /** * {@inheritdoc} */ - public function dumpScalar(Cursor $cursor, $type, $value) + public function dumpScalar(Cursor $cursor, string $type, $value) { $this->dumpKey($cursor); @@ -183,7 +179,7 @@ public function dumpScalar(Cursor $cursor, $type, $value) /** * {@inheritdoc} */ - public function dumpString(Cursor $cursor, $str, $bin, $cut) + public function dumpString(Cursor $cursor, string $str, bool $bin, int $cut) { $this->dumpKey($cursor); $attr = $cursor->attr; @@ -271,7 +267,7 @@ public function dumpString(Cursor $cursor, $str, $bin, $cut) /** * {@inheritdoc} */ - public function enterHash(Cursor $cursor, $type, $class, $hasChild) + public function enterHash(Cursor $cursor, int $type, $class, bool $hasChild) { $this->dumpKey($cursor); $attr = $cursor->attr; @@ -308,7 +304,7 @@ public function enterHash(Cursor $cursor, $type, $class, $hasChild) /** * {@inheritdoc} */ - public function leaveHash(Cursor $cursor, $type, $class, $hasChild, $cut) + public function leaveHash(Cursor $cursor, int $type, $class, bool $hasChild, int $cut) { $this->dumpEllipsis($cursor, $hasChild, $cut); $this->line .= Cursor::HASH_OBJECT === $type ? '}' : (Cursor::HASH_RESOURCE !== $type ? ']' : ($hasChild ? '}' : '')); @@ -538,7 +534,7 @@ protected function supportsColors() /** * {@inheritdoc} */ - protected function dumpLine($depth, $endOfValue = false) + protected function dumpLine(int $depth, bool $endOfValue = false) { if ($this->colors) { $this->line = sprintf("\033[%sm%s\033[m", $this->styles['default'], $this->line); diff --git a/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php b/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php index 1eb02bcbee8af..65f0d6b291111 100644 --- a/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php +++ b/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php @@ -802,7 +802,7 @@ function showCurrent(state) /** * {@inheritdoc} */ - public function dumpString(Cursor $cursor, $str, $bin, $cut) + public function dumpString(Cursor $cursor, string $str, bool $bin, int $cut) { if ('' === $str && isset($cursor->attr['img-data'], $cursor->attr['content-type'])) { $this->dumpKey($cursor); @@ -819,7 +819,7 @@ public function dumpString(Cursor $cursor, $str, $bin, $cut) /** * {@inheritdoc} */ - public function enterHash(Cursor $cursor, $type, $class, $hasChild) + public function enterHash(Cursor $cursor, int $type, $class, bool $hasChild) { parent::enterHash($cursor, $type, $class, false); @@ -849,7 +849,7 @@ public function enterHash(Cursor $cursor, $type, $class, $hasChild) /** * {@inheritdoc} */ - public function leaveHash(Cursor $cursor, $type, $class, $hasChild, $cut) + public function leaveHash(Cursor $cursor, int $type, $class, bool $hasChild, int $cut) { $this->dumpEllipsis($cursor, $hasChild, $cut); if ($hasChild) { @@ -957,7 +957,7 @@ protected function style($style, $value, $attr = []) /** * {@inheritdoc} */ - protected function dumpLine($depth, $endOfValue = false) + protected function dumpLine(int $depth, bool $endOfValue = false) { if (-1 === $this->lastDepth) { $this->line = sprintf($this->dumpPrefix, $this->dumpId, $this->indentPad).$this->line; diff --git a/src/Symfony/Component/VarDumper/Test/VarDumperTestTrait.php b/src/Symfony/Component/VarDumper/Test/VarDumperTestTrait.php index ca896e30be08b..4674382d08e43 100644 --- a/src/Symfony/Component/VarDumper/Test/VarDumperTestTrait.php +++ b/src/Symfony/Component/VarDumper/Test/VarDumperTestTrait.php @@ -42,17 +42,17 @@ protected function tearDownVarDumper(): void $this->varDumperConfig['flags'] = null; } - public function assertDumpEquals($expected, $data, $filter = 0, $message = '') + public function assertDumpEquals($expected, $data, int $filter = 0, string $message = '') { $this->assertSame($this->prepareExpectation($expected, $filter), $this->getDump($data, null, $filter), $message); } - public function assertDumpMatchesFormat($expected, $data, $filter = 0, $message = '') + public function assertDumpMatchesFormat($expected, $data, int $filter = 0, string $message = '') { $this->assertStringMatchesFormat($this->prepareExpectation($expected, $filter), $this->getDump($data, null, $filter), $message); } - protected function getDump($data, $key = null, $filter = 0) + protected function getDump($data, $key = null, int $filter = 0) { if (null === $flags = $this->varDumperConfig['flags']) { $flags = getenv('DUMP_LIGHT_ARRAY') ? CliDumper::DUMP_LIGHT_ARRAY : 0;