From d37d28adb8a776ba699cc11a80a18a5d25f3f11b Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Willms <tleilax+github@gmail.com> Date: Tue, 28 Mar 2023 09:16:10 +0200 Subject: [PATCH] simplify indentation shortener via regexp, re #2470 --- tests/_support/Helper/Jsonapi.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/_support/Helper/Jsonapi.php b/tests/_support/Helper/Jsonapi.php index 93750d979c5..81d112c36cd 100644 --- a/tests/_support/Helper/Jsonapi.php +++ b/tests/_support/Helper/Jsonapi.php @@ -206,9 +206,7 @@ class Jsonapi extends \Codeception\Module $json = json_encode($jsonBody, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); // This converts the default indentation of 4 spaces to 2 spaces - $json = preg_replace_callback('/^( +)(?=\S)/m', function ($match) { - return str_pad('', strlen($match[1]) / 2, ' '); - }, $json); + $json = preg_replace('/^( +)\1/m', '$1', $json); $dirname = codecept_output_dir() . 'json-for-slate/'; if (!file_exists($dirname)) { -- GitLab