[ are not escaped in string property value
[ are not escaped in string property value. Sample code
<?php
use Trappar\AliceGenerator\FixtureGeneratorBuilder;
class MyObject
{
public $foo;
}
$obj = new MyObject();
$obj->foo = 'bar [value]';
$yaml = FixtureGeneratorBuilder::create()->build()->generateYaml($obj);
echo $yaml;
it output
AppBundle\Command\MyObject:
MyObject-1:
foo: 'bar [value]'
correct output
AppBundle\Command\MyObject:
MyObject-1:
foo: 'bar \[value\]'
This may be an issue for the Symfony Yaml component... I'm not sure. I'll look into it later, or you can if you'd like.
Actually, it looks like this is by design. Brackets only need to be inside quotes, they don't need to be escaped. Are you seeing an issue as a result of this?
yes, such fixtures generate "Notice: Array to string conversion" (ContextErrorException)
Added screenshot of debugger, not sure how to explain better
sample fixture
ENTITY:
Commentary-1:
commentary: 'Welcome to [venue] where we are eagerly awaiting the arrival of the two teams'

@trappar any ideas regarding how can it be fixed?
@trappar sorry for annoying, do you have any ideas regarding how can it be fixed? Right now I use dirty patches like
public static function patchIssue12($content)
{
return preg_replace_callback('/^\s*commentary\:\s*\'(.+)\'$/mui',
function($matches) {
return str_replace(['[',']','%'],['\[','\]','\%'],$matches[0]);
},
$content
);
}
I use patchIssue12() function before generating yaml files.
Do you have any ideas about clean way of fixing this issue?
@trappar any ideas regarding how can we fix it in clean way?