Skip to content

Commit a30a89f

Browse files
authored
[12.x] Modernize typecasting (#58037)
* run only modernize typecasting * for styleci
1 parent dce9d65 commit a30a89f

File tree

13 files changed

+14
-14
lines changed

13 files changed

+14
-14
lines changed

src/Illuminate/Collections/Collection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1595,7 +1595,7 @@ protected function sortByMany(array $comparisons = [], int $options = SORT_REGUL
15951595
}
15961596
} else {
15971597
$result = match ($options) {
1598-
SORT_NUMERIC => intval($values[0]) <=> intval($values[1]),
1598+
SORT_NUMERIC => (int) $values[0] <=> (int) $values[1],
15991599
SORT_STRING => strcmp($values[0], $values[1]),
16001600
SORT_NATURAL => strnatcmp((string) $values[0], (string) $values[1]),
16011601
SORT_LOCALE_STRING => strcoll($values[0], $values[1]),

src/Illuminate/Database/Concerns/BuildsQueries.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function chunk($count, callable $callback)
4545
$page = 1;
4646

4747
do {
48-
$offset = (($page - 1) * $count) + intval($skip);
48+
$offset = (($page - 1) * $count) + (int) $skip;
4949

5050
$limit = is_null($remaining) ? $count : min($count, $remaining);
5151

src/Illuminate/Database/MySqlConnection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ protected function escapeBinary($value)
7979
*/
8080
protected function isUniqueConstraintError(Exception $exception)
8181
{
82-
return boolval(preg_match('#Integrity constraint violation: 1062#i', $exception->getMessage()));
82+
return (bool) preg_match('#Integrity constraint violation: 1062#i', $exception->getMessage());
8383
}
8484

8585
/**

src/Illuminate/Database/SQLiteConnection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ protected function escapeBinary($value)
5959
*/
6060
protected function isUniqueConstraintError(Exception $exception)
6161
{
62-
return boolval(preg_match('#(column(s)? .* (is|are) not unique|UNIQUE constraint failed: .*)#i', $exception->getMessage()));
62+
return (bool) preg_match('#(column(s)? .* (is|are) not unique|UNIQUE constraint failed: .*)#i', $exception->getMessage());
6363
}
6464

6565
/**

src/Illuminate/Database/SqlServerConnection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ protected function escapeBinary($value)
8383
*/
8484
protected function isUniqueConstraintError(Exception $exception)
8585
{
86-
return boolval(preg_match('#Cannot insert duplicate key row in object#i', $exception->getMessage()));
86+
return (bool) preg_match('#Cannot insert duplicate key row in object#i', $exception->getMessage());
8787
}
8888

8989
/**

src/Illuminate/Queue/SqsQueue.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ protected function getQueueableOptions($job, $queue, $payload, $delay = null): a
234234
return $options;
235235
}
236236

237-
$transformToString = fn ($value) => strval($value);
237+
$transformToString = fn ($value) => (string) $value;
238238

239239
// The message group ID is required for FIFO queues and is optional for
240240
// standard queues. Job objects contain a group ID. With string jobs

src/Illuminate/Support/Number.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ protected static function summarize(int|float $number, int $precision = 0, ?int
277277
}
278278

279279
switch (true) {
280-
case floatval($number) === 0.0:
280+
case (float) $number === 0.0:
281281
return $precision > 0 ? static::format(0, $precision, $maxPrecision) : '0';
282282
case $number < 0:
283283
return sprintf('-%s', static::summarize(abs($number), $precision, $maxPrecision, $units));

src/Illuminate/Support/Stringable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1493,7 +1493,7 @@ public function toInteger($base = 10)
14931493
*/
14941494
public function toFloat()
14951495
{
1496-
return floatval($this->value);
1496+
return (float) $this->value;
14971497
}
14981498

14991499
/**

src/Illuminate/Support/Timebox.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function call(callable $callback, int $microseconds)
3636
$exception = $caught;
3737
}
3838

39-
$remainder = intval($microseconds - ((microtime(true) - $start) * 1000000));
39+
$remainder = (int) ($microseconds - ((microtime(true) - $start) * 1000000));
4040

4141
if (! $this->earlyReturn && $remainder > 0) {
4242
$this->usleep($remainder);

src/Illuminate/Support/Traits/InteractsWithData.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ public function boolean($key = null, $default = false)
269269
*/
270270
public function integer($key, $default = 0)
271271
{
272-
return intval($this->data($key, $default));
272+
return (int) $this->data($key, $default);
273273
}
274274

275275
/**
@@ -281,7 +281,7 @@ public function integer($key, $default = 0)
281281
*/
282282
public function float($key, $default = 0.0)
283283
{
284-
return floatval($this->data($key, $default));
284+
return (float) $this->data($key, $default);
285285
}
286286

287287
/**

0 commit comments

Comments
 (0)