Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 448a017

Browse filesBrowse files
committed
[String] Fix implicit float-to-int casts
Signed-off-by: Alexander M. Turek <me@derrabus.de>
1 parent 475ddaf commit 448a017
Copy full SHA for 448a017

File tree

1 file changed

+4
-4
lines changed
Filter options

1 file changed

+4
-4
lines changed

‎src/Symfony/Component/String/AbstractUnicodeString.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/String/AbstractUnicodeString.php
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -480,22 +480,22 @@ private function pad(int $len, self $pad, int $type): parent
480480

481481
switch ($type) {
482482
case \STR_PAD_RIGHT:
483-
return $this->append(str_repeat($pad->string, $freeLen / $padLen).($len ? $pad->slice(0, $len) : ''));
483+
return $this->append(str_repeat($pad->string, intdiv($freeLen, $padLen)).($len ? $pad->slice(0, $len) : ''));
484484

485485
case \STR_PAD_LEFT:
486-
return $this->prepend(str_repeat($pad->string, $freeLen / $padLen).($len ? $pad->slice(0, $len) : ''));
486+
return $this->prepend(str_repeat($pad->string, intdiv($freeLen, $padLen)).($len ? $pad->slice(0, $len) : ''));
487487

488488
case \STR_PAD_BOTH:
489489
$freeLen /= 2;
490490

491491
$rightLen = ceil($freeLen);
492492
$len = $rightLen % $padLen;
493-
$str = $this->append(str_repeat($pad->string, $rightLen / $padLen).($len ? $pad->slice(0, $len) : ''));
493+
$str = $this->append(str_repeat($pad->string, intdiv($rightLen, $padLen)).($len ? $pad->slice(0, $len) : ''));
494494

495495
$leftLen = floor($freeLen);
496496
$len = $leftLen % $padLen;
497497

498-
return $str->prepend(str_repeat($pad->string, $leftLen / $padLen).($len ? $pad->slice(0, $len) : ''));
498+
return $str->prepend(str_repeat($pad->string, intdiv($leftLen, $padLen)).($len ? $pad->slice(0, $len) : ''));
499499

500500
default:
501501
throw new InvalidArgumentException('Invalid padding type.');

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.