Skip to content

Commit 5a4d5a8

Browse files
derrabusnicolas-grekas
authored andcommitted
Add types to constructors and private/final/internal methods (Batch III)
1 parent b9e52cb commit 5a4d5a8

File tree

6 files changed

+11
-12
lines changed

6 files changed

+11
-12
lines changed

Caster/Caster.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,11 @@ class Caster
4141
* Casts objects to arrays and adds the dynamic property prefix.
4242
*
4343
* @param object $obj The object to cast
44-
* @param string $class The class of the object
4544
* @param bool $hasDebugInfo Whether the __debugInfo method exists on $obj or not
4645
*
4746
* @return array The array-cast of the object, with prefixed dynamic properties
4847
*/
49-
public static function castObject($obj, $class, $hasDebugInfo = false): array
48+
public static function castObject($obj, string $class, bool $hasDebugInfo = false): array
5049
{
5150
$a = $obj instanceof \Closure ? [] : (array) $obj;
5251

@@ -110,7 +109,7 @@ public static function castObject($obj, $class, $hasDebugInfo = false): array
110109
*
111110
* @return array The filtered array
112111
*/
113-
public static function filter(array $a, $filter, array $listedProperties = [], &$count = 0): array
112+
public static function filter(array $a, int $filter, array $listedProperties = [], ?int &$count = 0): array
114113
{
115114
$count = 0;
116115

@@ -151,7 +150,7 @@ public static function filter(array $a, $filter, array $listedProperties = [], &
151150
return $a;
152151
}
153152

154-
public static function castPhpIncompleteClass(\__PHP_Incomplete_Class $c, array $a, Stub $stub, $isNested)
153+
public static function castPhpIncompleteClass(\__PHP_Incomplete_Class $c, array $a, Stub $stub, bool $isNested): array
155154
{
156155
if (isset($a['__PHP_Incomplete_Class_Name'])) {
157156
$stub->class .= '('.$a['__PHP_Incomplete_Class_Name'].')';

Caster/DateCaster.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public static function castInterval(\DateInterval $interval, array $a, Stub $stu
5252
return $filter & Caster::EXCLUDE_VERBOSE ? $i : $i + $a;
5353
}
5454

55-
private static function formatInterval(\DateInterval $i)
55+
private static function formatInterval(\DateInterval $i): string
5656
{
5757
$format = '%R ';
5858

Caster/MemcachedCaster.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public static function castMemcached(\Memcached $c, array $a, Stub $stub, $isNes
3333
return $a;
3434
}
3535

36-
private static function getNonDefaultOptions(\Memcached $c)
36+
private static function getNonDefaultOptions(\Memcached $c): array
3737
{
3838
self::$defaultOptions = self::$defaultOptions ?? self::discoverDefaultOptions();
3939
self::$optionConstants = self::$optionConstants ?? self::getOptionConstants();
@@ -48,7 +48,7 @@ private static function getNonDefaultOptions(\Memcached $c)
4848
return $nonDefaultOptions;
4949
}
5050

51-
private static function discoverDefaultOptions()
51+
private static function discoverDefaultOptions(): array
5252
{
5353
$defaultMemcached = new \Memcached();
5454
$defaultMemcached->addServer('127.0.0.1', 11211);
@@ -63,7 +63,7 @@ private static function discoverDefaultOptions()
6363
return $defaultOptions;
6464
}
6565

66-
private static function getOptionConstants()
66+
private static function getOptionConstants(): array
6767
{
6868
$reflectedMemcached = new \ReflectionClass(\Memcached::class);
6969

Caster/ReflectionCaster.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ public static function getSignature(array $a)
361361
return $signature;
362362
}
363363

364-
private static function addExtra(&$a, \Reflector $c)
364+
private static function addExtra(array &$a, \Reflector $c)
365365
{
366366
$x = isset($a[Caster::PREFIX_VIRTUAL.'extra']) ? $a[Caster::PREFIX_VIRTUAL.'extra']->value : [];
367367

@@ -377,7 +377,7 @@ private static function addExtra(&$a, \Reflector $c)
377377
}
378378
}
379379

380-
private static function addMap(&$a, \Reflector $c, $map, $prefix = Caster::PREFIX_VIRTUAL)
380+
private static function addMap(array &$a, \Reflector $c, array $map, string $prefix = Caster::PREFIX_VIRTUAL)
381381
{
382382
foreach ($map as $k => $m) {
383383
if (method_exists($c, $m) && false !== ($m = $c->$m()) && null !== $m) {

Caster/SplCaster.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ public static function castWeakReference(\WeakReference $c, array $a, Stub $stub
195195
return $a;
196196
}
197197

198-
private static function castSplArray($c, array $a, Stub $stub, $isNested)
198+
private static function castSplArray($c, array $a, Stub $stub, bool $isNested): array
199199
{
200200
$prefix = Caster::PREFIX_VIRTUAL;
201201
$class = $stub->class;

Test/VarDumperTestTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ protected function getDump($data, $key = null, $filter = 0)
7676
return rtrim($dumper->dump($data, true));
7777
}
7878

79-
private function prepareExpectation($expected, int $filter)
79+
private function prepareExpectation($expected, int $filter): string
8080
{
8181
if (!\is_string($expected)) {
8282
$expected = $this->getDump($expected, null, $filter);

0 commit comments

Comments
 (0)