allow multiline empty spaces strings (#1828)

allow multiline empty spaces strings
This commit is contained in:
Tomáš Votruba 2019-08-08 11:47:56 +02:00 committed by GitHub
commit f80d4459e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 1 deletions

View File

@ -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;
}

View File

@ -0,0 +1,29 @@
<?php
namespace Rector\CodingStyle\Tests\Rector\String_\ManualJsonStringToJsonEncodeArrayRector\Fixture;
final class SimpleRowWithSpaces
{
public function run()
{
$json = '{"name":"Paulie",
"surname":"Garand"}';
}
}
?>
-----
<?php
namespace Rector\CodingStyle\Tests\Rector\String_\ManualJsonStringToJsonEncodeArrayRector\Fixture;
final class SimpleRowWithSpaces
{
public function run()
{
$jsonData = ['name' => 'Paulie', 'surname' => 'Garand'];
$json = \Nette\Utils\Json::encode($jsonData);
}
}
?>

View File

@ -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',
]);
}