diff --git a/packages/CodingStyle/src/Rector/String_/ManualJsonStringToJsonEncodeArrayRector.php b/packages/CodingStyle/src/Rector/String_/ManualJsonStringToJsonEncodeArrayRector.php index 874f52ed7fe..14b4efc1948 100644 --- a/packages/CodingStyle/src/Rector/String_/ManualJsonStringToJsonEncodeArrayRector.php +++ b/packages/CodingStyle/src/Rector/String_/ManualJsonStringToJsonEncodeArrayRector.php @@ -149,7 +149,7 @@ CODE_SAMPLE private function isJsonString(string $stringValue): bool { - if (! (bool) Strings::match($stringValue, '#{(.*?\:.*?)}#')) { + if (! (bool) Strings::match($stringValue, '#{(.*?\:.*?)}#s')) { return false; } diff --git a/packages/CodingStyle/tests/Rector/String_/ManualJsonStringToJsonEncodeArrayRector/Fixture/simple_row_with_spaces.php.inc b/packages/CodingStyle/tests/Rector/String_/ManualJsonStringToJsonEncodeArrayRector/Fixture/simple_row_with_spaces.php.inc new file mode 100644 index 00000000000..206efd2c2b7 --- /dev/null +++ b/packages/CodingStyle/tests/Rector/String_/ManualJsonStringToJsonEncodeArrayRector/Fixture/simple_row_with_spaces.php.inc @@ -0,0 +1,29 @@ + +----- + 'Paulie', 'surname' => 'Garand']; + $json = \Nette\Utils\Json::encode($jsonData); + } +} + +?> diff --git a/packages/CodingStyle/tests/Rector/String_/ManualJsonStringToJsonEncodeArrayRector/ManualJsonStringToJsonEncodeArrayRectorTest.php b/packages/CodingStyle/tests/Rector/String_/ManualJsonStringToJsonEncodeArrayRector/ManualJsonStringToJsonEncodeArrayRectorTest.php index c961d329c74..38ec18881f0 100644 --- a/packages/CodingStyle/tests/Rector/String_/ManualJsonStringToJsonEncodeArrayRector/ManualJsonStringToJsonEncodeArrayRectorTest.php +++ b/packages/CodingStyle/tests/Rector/String_/ManualJsonStringToJsonEncodeArrayRector/ManualJsonStringToJsonEncodeArrayRectorTest.php @@ -18,6 +18,7 @@ final class ManualJsonStringToJsonEncodeArrayRectorTest extends AbstractRectorTe __DIR__ . '/Fixture/with_implode.php.inc', __DIR__ . '/Fixture/without_assign.php.inc', __DIR__ . '/Fixture/array_concat.php.inc', + __DIR__ . '/Fixture/simple_row_with_spaces.php.inc', ]); }