Skip to content

Commit e31d26b

Browse files
committed
style: update and fix some code style
1 parent beb436a commit e31d26b

26 files changed

+73
-73
lines changed

src/Arr/ArrayHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public static function valueTrim(array $data): array
7575
public static function getKeyMaxWidth(array $data, bool $excludeInt = true): int
7676
{
7777
$maxWidth = 0;
78-
foreach ($data as $key => $value) {
78+
foreach ($data as $key => $_) {
7979
// key is not a integer
8080
if (!$excludeInt || !is_numeric($key)) {
8181
$width = mb_strlen((string)$key, 'UTF-8');

src/Arr/Traits/ArrayMergeTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ trait ArrayMergeTrait
3131
*/
3232
public static function replace(array $base, array $replacements): array
3333
{
34-
foreach ($base as $key => $value) {
34+
foreach ($base as $key => $_) {
3535
if (isset($replacements[$key])) {
3636
$base[$key] = $replacements[$key];
3737
}

src/Helper/BasePhpTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ protected function tryCatchRun(callable $cb): Throwable
8585
*
8686
* @return void
8787
*/
88-
public function assertException(Throwable $e, string $msg, int $code = null): void
88+
public function assertException(Throwable $e, string $msg, ?int $code = null): void
8989
{
9090
$this->assertEquals($msg, $e->getMessage());
9191

src/Helper/DateHelper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public static function isTimestamp(int|string $timestamp): bool
4141
*
4242
* @param string $date 日期
4343
*
44-
* @return boolean
44+
* @return bool
4545
*/
4646
public static function isDate(string $date): bool
4747
{
@@ -54,7 +54,7 @@ public static function isDate(string $date): bool
5454
* @param string $date 日期
5555
* @param string $format 需要检验的格式数组
5656
*
57-
* @return boolean
57+
* @return bool
5858
*/
5959
public static function isDateFormat(string $date, string $format = 'Y-m-d'): bool
6060
{

src/Helper/IntHelper.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,26 +47,26 @@ public static function getMin(int $val1, int $val2): int
4747
// ----- http://cn2.php.net/manual/zh/function.pack.php#119402
4848

4949
/**
50-
* @param $i
50+
* @param int|string $i
5151
*
5252
* @return false|mixed|string
5353
*/
54-
public static function int8($i): mixed
54+
public static function int8(int|string $i): mixed
5555
{
5656
return is_int($i) ? pack('c', $i) : unpack('c', $i)[1];
5757
}
5858

59-
public static function uInt8($i)
59+
public static function uInt8(int|string $i)
6060
{
6161
return is_int($i) ? pack('C', $i) : unpack('C', $i)[1];
6262
}
6363

64-
public static function int16($i)
64+
public static function int16(int|string $i)
6565
{
6666
return is_int($i) ? pack('s', $i) : unpack('s', $i)[1];
6767
}
6868

69-
public static function uint16($i, $endianness = false)
69+
public static function uint16(int|string $i, $endianness = false)
7070
{
7171
$f = is_int($i) ? 'pack' : 'unpack';
7272

src/Helper/JsonHelper.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,11 @@ public static function encodeCN(
8484
}
8585

8686
/**
87-
* @param $data
87+
* @param mixed $data
8888
*
8989
* @return string
9090
*/
91-
public static function pretty($data): string
91+
public static function pretty(mixed $data): string
9292
{
9393
return self::encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
9494
}
@@ -107,21 +107,21 @@ public static function prettyJSON(
107107
}
108108

109109
/**
110-
* @param $data
110+
* @param mixed $data
111111
*
112112
* @return string
113113
*/
114-
public static function unescaped($data): string
114+
public static function unescaped(mixed $data): string
115115
{
116116
return self::encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
117117
}
118118

119119
/**
120-
* @param $data
120+
* @param mixed $data
121121
*
122122
* @return string
123123
*/
124-
public static function unescapedSlashes($data): string
124+
public static function unescapedSlashes(mixed $data): string
125125
{
126126
return self::encode($data, JSON_UNESCAPED_SLASHES);
127127
}

src/Helper/NumHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public static function roundInt(float|int $value): int
8282
*
8383
* @return int
8484
*/
85-
public static function random(int $min, int $max, int $fallback = null): int
85+
public static function random(int $min, int $max, ?int $fallback = null): int
8686
{
8787
try {
8888
return random_int($min, $max);

src/Helper/PhpHelper.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public static function reflectMethod(object|string $classOrObj, string $method):
105105
*
106106
* @return Generator
107107
*/
108-
public static function getReflectMethods(ReflectionClass $reflectClass, int $flags = 0, Closure $nameFilter = null): ?Generator
108+
public static function getReflectMethods(ReflectionClass $reflectClass, int $flags = 0, ?Closure $nameFilter = null): ?Generator
109109
{
110110
foreach ($reflectClass->getMethods($flags) as $m) {
111111
$mName = $m->getName();
@@ -119,11 +119,11 @@ public static function getReflectMethods(ReflectionClass $reflectClass, int $fla
119119
}
120120

121121
/**
122-
* @param $value
122+
* @param mixed $value
123123
*
124124
* @return mixed
125125
*/
126-
public static function value($value): mixed
126+
public static function value(mixed $value): mixed
127127
{
128128
if (is_callable($value)) {
129129
return $value();
@@ -376,7 +376,7 @@ public static function lastError2array(): array
376376
*
377377
* @return string
378378
*/
379-
public static function exception2string(Throwable $e, bool $getTrace = true, string $catcher = null): string
379+
public static function exception2string(Throwable $e, bool $getTrace = true, ?string $catcher = null): string
380380
{
381381
return PhpException::toString($e, $getTrace, $catcher);
382382
}
@@ -388,17 +388,17 @@ public static function exception2string(Throwable $e, bool $getTrace = true, str
388388
*
389389
* @return string
390390
*/
391-
public static function exception2html(Throwable $e, bool $getTrace = true, string $catcher = null): string
391+
public static function exception2html(Throwable $e, bool $getTrace = true, ?string $catcher = null): string
392392
{
393393
return PhpException::toHtml($e, $getTrace, $catcher);
394394
}
395395

396396
/**
397-
* @param $anyData
397+
* @param mixed $anyData
398398
*
399399
* @return string
400400
*/
401-
public static function toString($anyData): string
401+
public static function toString(mixed $anyData): string
402402
{
403403
return DataHelper::toString($anyData);
404404
}

src/OS.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ public static function getNullDevice(): string
368368
*
369369
* @param int|resource|mixed $fileDescriptor
370370
*
371-
* @return boolean
371+
* @return bool
372372
*/
373373
public static function isInteractive(mixed $fileDescriptor): bool
374374
{

src/Obj/DataObject.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ public function toArray(): array
268268
public function getKeys(): array
269269
{
270270
$keys = [];
271-
foreach ($this as $key => $val) {
271+
foreach ($this as $key => $_) {
272272
$keys[] = $key;
273273
}
274274

0 commit comments

Comments
 (0)