From b2006fbe9c31821edd6b169f5b72ed60bfceab6e Mon Sep 17 00:00:00 2001 From: Subhan Shamsoddini Date: Tue, 24 May 2022 23:42:10 +0430 Subject: [PATCH] replace 'for' loop with 'str_repeat' function (#10788) --- src/Composer/Json/JsonFormatter.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/Composer/Json/JsonFormatter.php b/src/Composer/Json/JsonFormatter.php index 8ea6f7509..e75012fa3 100644 --- a/src/Composer/Json/JsonFormatter.php +++ b/src/Composer/Json/JsonFormatter.php @@ -108,9 +108,7 @@ class JsonFormatter // If this character is the end of an element, // output a new line and indent the next line $result .= $newLine; - for ($j = 0; $j < $pos; $j++) { - $result .= $indentStr; - } + $result .= str_repeat($indentStr, $pos); } else { // Collapse empty {} and [] $result = rtrim($result); @@ -128,9 +126,7 @@ class JsonFormatter $pos++; } - for ($j = 0; $j < $pos; $j++) { - $result .= $indentStr; - } + $result .= str_repeat($indentStr, $pos); } }