Skip to content

Commit bbeb388

Browse files
committed
sonarcube cloud
1 parent 8489388 commit bbeb388

10 files changed

Lines changed: 5 additions & 23 deletions

‎src/FloatToString.php‎

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,9 @@ public static function floatToString(float $value): string
2020
return INF === $value ? 'Infinity' : '-Infinity';
2121
}
2222

23-
if (0.0 === $value) {
24-
return '0';
25-
}
23+
$sign = $value < 0 ? '-' : '';
2624

27-
return ($value < 0 ? '-' : '').self::formatAbsolute(abs($value));
25+
return 0.0 === $value ? '0' : $sign.self::formatAbsolute(abs($value));
2826
}
2927

3028
private static function formatAbsolute(float $value): string
@@ -50,11 +48,9 @@ private static function formatAbsolute(float $value): string
5048
$pointPosition = (int) $exponent + 1;
5149

5250
// fixed notation between 1e-6 and 1e21, exponential notation beyond
53-
if (-6 < $pointPosition && $pointPosition <= 21) {
54-
return self::fixedNotation($digits, $pointPosition);
55-
}
56-
57-
return self::exponentialNotation($digits, $pointPosition - 1);
51+
return -6 < $pointPosition && $pointPosition <= 21
52+
? self::fixedNotation($digits, $pointPosition)
53+
: self::exponentialNotation($digits, $pointPosition - 1);
5854
}
5955

6056
private static function fixedNotation(string $digits, int $pointPosition): string

‎tests/Unit/Test262ArrayPrototypeEveryTest.php‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1003,7 +1003,6 @@ public function test1544167CII4(): void
10031003
{
10041004
$arr = new Arr(0, 1, 2, 3, 4, 5);
10051005
$lastIdx = 0;
1006-
$called = 0;
10071006

10081007
$callbackfn = static function (int $val, int $idx) use (&$lastIdx, &$called): bool {
10091008
++$called;

‎tests/Unit/Test262ArrayPrototypeFindIndexTest.php‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,6 @@ public function testPredicateCallParameters(): void
113113
*/
114114
public function testPredicateCallThisNonStrict(): void
115115
{
116-
$result = null;
117-
118116
Arr::of(1)->findIndex(function () use (&$result) {
119117
$result = $this;
120118

‎tests/Unit/Test262ArrayPrototypeFindLastIndexTest.php‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,6 @@ public function testPredicateCallParameters(): void
115115
*/
116116
public function testPredicateCallThisNonStrict(): void
117117
{
118-
$result = null;
119-
120118
Arr::of(1)->findLastIndex(function () use (&$result) {
121119
$result = $this;
122120

‎tests/Unit/Test262ArrayPrototypeFindLastTest.php‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,6 @@ public function testPredicateCallParameters(): void
115115
*/
116116
public function testPredicateCallThisNonStrict(): void
117117
{
118-
$result = null;
119-
120118
Arr::of(1)->findLast(function () use (&$result) {
121119
$result = $this;
122120

‎tests/Unit/Test262ArrayPrototypeFindTest.php‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,6 @@ public function testPredicateCallParameters(): void
113113
*/
114114
public function testPredicateCallThisNonStrict(): void
115115
{
116-
$result = null;
117-
118116
Arr::of(1)->find(function () use (&$result) {
119117
$result = $this;
120118

‎tests/Unit/Test262ArrayPrototypeForEachTest.php‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,6 @@ public function test15441851(): void
267267
{
268268
// Adapted: when thisArg is not passed a non-static Closure keeps its original
269269
// $this (the JS test expects the global object rather than a local binding).
270-
$result = null;
271270

272271
$callbackfn = function () use (&$result): void {
273272
$result = $this;
@@ -1053,7 +1052,6 @@ public function test1544187Cii4(): void
10531052
{
10541053
$arr = new Arr(0, 1, 2, 3, 4, 5);
10551054
$lastIdx = 0;
1056-
$called = 0;
10571055
$result = true;
10581056

10591057
$callbackfn = static function (mixed $val, int $idx) use (&$lastIdx, &$called, &$result): void {

‎tests/Unit/Test262ArrayPrototypeMapTest.php‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1027,7 +1027,6 @@ public function test1544198CII4(): void
10271027
{
10281028
$arr = new Arr(0, 1, 2, 3, 4, 5);
10291029
$lastIdx = 0;
1030-
$called = 0;
10311030
$result = true;
10321031

10331032
$callbackfn = static function (int $val, int $idx) use (&$lastIdx, &$called, &$result): void {

‎tests/Unit/Test262ArrayPrototypeSomeTest.php‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -939,7 +939,6 @@ public function test1544177CII4(): void
939939
{
940940
$arr = new Arr(0, 1, 2, 3, 4, 5);
941941
$lastIdx = 0;
942-
$called = 0;
943942

944943
$callbackfn = static function (int $val, int $idx) use (&$lastIdx, &$called): bool {
945944
++$called;

‎tests/Unit/Test262MapPrototypeGetOrInsertComputedTest.php‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ public function testCheckCallbackFnArgs(): void
161161
{
162162
$map = new Map();
163163

164-
$args = null;
165164
$map->getOrInsertComputed(1, static function (mixed ...$receivedArgs) use (&$args): void {
166165
$args = $receivedArgs;
167166
});

0 commit comments

Comments
 (0)