php - 转储函数在使用 TaggedValue 时忽略内联参数
问题描述
我的Yaml::Dump()
功能有问题。当我使用 TaggedValue 时,转储函数会忽略参数 $inline
如果我没有使用 TaggedValues,它会按预期工作。
这是使用的示例代码
use Symfony\Component\Yaml\Yaml;
use Symfony\Component\Yaml\Tag\TaggedValue;
$Admins = array(
array(
'samaccountname' => ['user1'],
'cn' => ['Louisa Nicolas'],
'mail' => ['mail@domain.com'],
),
array(
'samaccountname' => ['user2'],
'cn' => ['Telper Max'],
'mail' => ['mail@domain.com'],
)
);
$rootYaml = array();
foreach ($Admins as $Admin) {
$adm = array(
'id' => $Admin['samaccountname'][0],
'annotations' => array(
'name' => $Admin['cn'][0],
'email' => $Admin['mail'][0]
));
$rootYaml[] = $adm;
$rootYamlTagged[] = new TaggedValue('user', $adm);
}
echo "##### Works without tags\n";
print Yaml::dump($rootYaml, 3);
echo "##### not working with tags\n";
print Yaml::dump($rootYamlTagged, 3);
结果 :
##### Works without tags
-
id: user1
annotations:
name: 'Louisa Nicolas'
email: mail@domain.com
-
id: user2
annotations:
name: 'Telper Max'
email: mail@domain.com
##### not working with tags
- !user { id: user1, annotations: { name: 'Louisa Nicolas', email: mail@domain.com } }
- !user { id: user2, annotations: { name: 'Telper Max', email: mail@domain.com } }
我希望有标记
- !user
id: user1,
annotations:
name: 'Louisa Nicolas'
email: mail@domain.com
- !user
id: user2
annotations:
name: 'Telper Max'
email: mail@domain.com
我在支持团队中为此打开了一个错误,并确认了错误。
解决方案
Bug has been approved. It's fixed in version 3.4.
The pull request [Yaml] fix inline handling when dumping tagged values has the actual code changes.
推荐阅读
- laravel-5 - 使用工厂测试 Laravel 发布请求
- html - 在弹性项目前渲染块
- javascript - 通过导航传递状态时,我的 this.props.navigation.state 未定义?
- vba - 如何在vba Outlook中获取邮件发件人
- c# - jquery .valid() 在重新发送相同的表单时不起作用
- angular-cli - 如何生成一个尊重指定缩进样式的新 Angular 项目
- spring-boot - 在多 pod spring 应用程序中获取请求/秒
- vue.js - Vuetify 底部导航更新:活动事件
- python - 从python字典中的第N个键获取值
- javascript - D3 刻度线在 xAxis 上略微偏离