[FrameworkBundle] Replace var_export with VarExporter to use array short syntax

This commit is contained in:
Alexandre Daubois 2021-06-22 20:21:40 +02:00
parent 8445564d02
commit 7f1c76212f
1 changed files with 3 additions and 2 deletions

View File

@ -12,6 +12,7 @@
namespace Symfony\Bundle\FrameworkBundle\Secrets;
use Symfony\Component\DependencyInjection\EnvVarLoaderInterface;
use Symfony\Component\VarExporter\VarExporter;
/**
* @author Tobias Schultze <http://tobion.de>
@ -89,7 +90,7 @@ class SodiumVault extends AbstractVault implements EnvVarLoaderInterface
$list = $this->list();
$list[$name] = null;
uksort($list, 'strnatcmp');
file_put_contents($this->pathPrefix.'list.php', sprintf("<?php\n\nreturn %s;\n", var_export($list, true), \LOCK_EX));
file_put_contents($this->pathPrefix.'list.php', sprintf("<?php\n\nreturn %s;\n", VarExporter::export($list), \LOCK_EX));
$this->lastMessage = sprintf('Secret "%s" encrypted in "%s"; you can commit it.', $name, $this->getPrettyPath(\dirname($this->pathPrefix).\DIRECTORY_SEPARATOR));
}
@ -141,7 +142,7 @@ class SodiumVault extends AbstractVault implements EnvVarLoaderInterface
$list = $this->list();
unset($list[$name]);
file_put_contents($this->pathPrefix.'list.php', sprintf("<?php\n\nreturn %s;\n", var_export($list, true), \LOCK_EX));
file_put_contents($this->pathPrefix.'list.php', sprintf("<?php\n\nreturn %s;\n", VarExporter::export($list), \LOCK_EX));
$this->lastMessage = sprintf('Secret "%s" removed from "%s".', $name, $this->getPrettyPath(\dirname($this->pathPrefix).\DIRECTORY_SEPARATOR));