Skip to content

Commit ea60d1b

Browse files
authored
PHP CS Fixer - ordered_types (#46)
1 parent 501a273 commit ea60d1b

File tree

6 files changed

+22
-22
lines changed

6 files changed

+22
-22
lines changed

src/Arr.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public static function key(mixed $key, array $array, bool $returnValue = false):
6262
* Check is value exists in the array.
6363
* @SuppressWarnings(PHPMD.ShortMethodName)
6464
*/
65-
public static function in(mixed $value, array $array, bool $returnKey = false): string|int|bool|null
65+
public static function in(mixed $value, array $array, bool $returnKey = false): null|bool|int|string
6666
{
6767
$inArray = \in_array($value, $array, true);
6868

@@ -96,7 +96,7 @@ public static function last(array $array): mixed
9696
/**
9797
* Returns the first key in an array.
9898
*/
99-
public static function firstKey(array $array): int|string|null
99+
public static function firstKey(array $array): null|int|string
100100
{
101101
\reset($array);
102102

@@ -106,7 +106,7 @@ public static function firstKey(array $array): int|string|null
106106
/**
107107
* Returns the last key in an array.
108108
*/
109-
public static function lastKey(array $array): int|string|null
109+
public static function lastKey(array $array): null|int|string
110110
{
111111
\end($array);
112112

@@ -148,7 +148,7 @@ static function (mixed $value, int|string $key) use (&$flattened, $preserveKeys)
148148
*/
149149
public static function search(
150150
array $array,
151-
null|bool|int|float|string $search,
151+
null|bool|float|int|string $search,
152152
?string $field = null,
153153
): bool|string {
154154
// *grumbles* stupid PHP type system
@@ -402,11 +402,11 @@ public static function implode(string $glue, array $array): string
402402
/**
403403
* Remove all items from array by value.
404404
*/
405-
public static function removeByValue(array $array, float|bool|int|string|null $value): array
405+
public static function removeByValue(array $array, null|bool|float|int|string $value): array
406406
{
407407
return \array_filter(
408408
$array,
409-
static fn (float|bool|int|string|null $arrayItem): bool => $value !== $arrayItem,
409+
static fn (null|bool|float|int|string $arrayItem): bool => $value !== $arrayItem,
410410
\ARRAY_FILTER_USE_BOTH,
411411
);
412412
}

src/Dates.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ final class Dates
3131
/**
3232
* Convert to timestamp.
3333
*/
34-
public static function toStamp(\DateTime|int|string|null $time = null, bool $currentIsDefault = true): int
34+
public static function toStamp(null|\DateTime|int|string $time = null, bool $currentIsDefault = true): int
3535
{
3636
if ($time instanceof \DateTime) {
3737
return (int)$time->format('U');
@@ -51,7 +51,7 @@ public static function toStamp(\DateTime|int|string|null $time = null, bool $cur
5151
/**
5252
* Build PHP \DateTime object from mixed input.
5353
*/
54-
public static function factory(mixed $time = null, \DateTimeZone|string|null $timeZone = null): \DateTime
54+
public static function factory(mixed $time = null, null|\DateTimeZone|string $timeZone = null): \DateTime
5555
{
5656
$timeZone = self::timezone($timeZone);
5757

@@ -68,7 +68,7 @@ public static function factory(mixed $time = null, \DateTimeZone|string|null $ti
6868
/**
6969
* Returns a DateTimeZone object based on the current timezone.
7070
*/
71-
public static function timezone(\DateTimeZone|string|null $timezone = null): \DateTimeZone
71+
public static function timezone(null|\DateTimeZone|string $timezone = null): \DateTimeZone
7272
{
7373
if ($timezone instanceof \DateTimeZone) {
7474
return $timezone;
@@ -94,7 +94,7 @@ public static function is(?string $date): bool
9494
/**
9595
* Convert time for sql format.
9696
*/
97-
public static function sql(int|string|null $time = null): string
97+
public static function sql(null|int|string $time = null): string
9898
{
9999
return self::factory($time)->format(self::SQL_FORMAT);
100100
}

src/Env.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ final class Env
3030
*/
3131
public static function get(
3232
string $envVarName,
33-
string|float|int|bool|null $default = null,
33+
null|bool|float|int|string $default = null,
3434
int $options = self::VAR_STRING,
35-
): string|float|int|bool|null {
35+
): null|bool|float|int|string {
3636
$envKey = \trim($envVarName);
3737

3838
$value = \getenv($envKey);
@@ -52,7 +52,7 @@ public static function get(
5252
/**
5353
* Converts the type of values like "true", "false", "null" or "123".
5454
*/
55-
public static function convert(?string $value, int $options = self::VAR_STRING): string|float|int|bool|null
55+
public static function convert(?string $value, int $options = self::VAR_STRING): null|bool|float|int|string
5656
{
5757
$cleanedValue = \trim(Filter::stripQuotes((string)$value));
5858

src/Filter.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ public static function float(mixed $value, int $round = 10): float
173173
/**
174174
* Smart convert any string to int.
175175
*/
176-
public static function int(float|bool|int|string|null $value): int
176+
public static function int(null|bool|float|int|string $value): int
177177
{
178178
$cleaned = (string)\preg_replace('#[^0-9-+.,]#', '', (string)$value);
179179
\preg_match('#[-+]?[\d]+#', $cleaned, $matches);
@@ -247,7 +247,7 @@ public static function trimExtend(string $value): string
247247
/**
248248
* Cleanup array. No empty values.
249249
*/
250-
public static function arr(mixed $value, string|\Closure|null $filter = null): array
250+
public static function arr(mixed $value, null|\Closure|string $filter = null): array
251251
{
252252
$array = (array)$value;
253253

@@ -355,7 +355,7 @@ public static function esc(string $string): string
355355
/**
356356
* Returns Data object from array.
357357
*/
358-
public static function data(Data|array $data): Data
358+
public static function data(array|Data $data): Data
359359
{
360360
if ($data instanceof Data) {
361361
return $data;
@@ -367,7 +367,7 @@ public static function data(Data|array $data): Data
367367
/**
368368
* Returns JSON object from array.
369369
*/
370-
public static function json(JSON|array $data): JSON
370+
public static function json(array|JSON $data): JSON
371371
{
372372
if ($data instanceof JSON) {
373373
return $data;

src/Str.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ public static function uuid(): string
606606
/**
607607
* Get class name without namespace.
608608
*/
609-
public static function getClassName(object|string|null $object, bool $toLower = false): ?string
609+
public static function getClassName(null|object|string $object, bool $toLower = false): ?string
610610
{
611611
if (\is_object($object)) {
612612
$className = $object::class;
@@ -789,8 +789,8 @@ public static function listToDescription(array $data, bool $alignByKeys = false)
789789
return $acc;
790790
}
791791

792-
if ($acc < \strlen((string)$key)) {
793-
$acc = \strlen((string)$key);
792+
if ($acc < self::len((string)$key)) {
793+
$acc = self::len((string)$key);
794794
}
795795

796796
return $acc;
@@ -805,7 +805,7 @@ public static function listToDescription(array $data, bool $alignByKeys = false)
805805
if (!isStrEmpty($value)) {
806806
$keyFormated = $key;
807807
if ($alignByKeys) {
808-
$keyFormated = \str_pad($key, $maxWidth, ' ', \STR_PAD_RIGHT);
808+
$keyFormated = $key . \str_repeat(' ', $maxWidth - self::len($key));
809809
}
810810

811811
if (\is_numeric($key) || isStrEmpty($key)) {

src/Xml.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ final class Xml
2424
/**
2525
* Escape string before save it as xml content.
2626
*/
27-
public static function escape(float|int|string|null $rawXmlContent): string
27+
public static function escape(null|float|int|string $rawXmlContent): string
2828
{
2929
$rawXmlContent = (string)$rawXmlContent;
3030

0 commit comments

Comments
 (0)