symfony-usePutenv默认更改弃用警告修复

symfony-usePutenv默认更改弃用警告修复,symfony,symfony4,deprecated,deprecation-warning,Symfony,Symfony4,Deprecated,Deprecation Warning,将symfony升级到4.3后,在运行单元测试时,我收到以下警告: Other deprecation notices (1) 1x: The default value of "$usePutenv" argument of "Symfony\Component\Dotenv\Dotenv::__construct" will be changed from "true" to "false" in Symfony 5.0. You should define its value exp

将symfony升级到4.3后,在运行单元测试时,我收到以下警告:

Other deprecation notices (1)

  1x: The default value of "$usePutenv" argument of "Symfony\Component\Dotenv\Dotenv::__construct" will be changed from "true" to "false" in Symfony 5.0. You should define its value explicitly.
    1x in Dotenv::__construct from Symfony\Component\Dotenv
警告本身是相当清楚的,修复应该是清楚的,但是。。。我找不到显式定义该值的配置(实际上我很想先读取它的当前值以进行双重检查)。你知道如何解决这个问题(在哪里定义它)

另外,我知道它现在不会干扰任何事情,但我认为没有理由不拥有一个干净的输出和没有“隐藏惊喜”的代码

编辑:据我所见,对Dotenv的调用直接在引导程序中硬编码:

(new Dotenv())->loadEnv(dirname(__DIR__).'/.env');

我应该在那里修改它还是有更好的方法?

如果安装新的Symfony 4.4(-dev),config/bootstrap.php中的行将是:

//old
(new Dotenv())->loadEnv(dirname(__DIR__).'/.env');

//new
(new Dotenv(false))->loadEnv(dirname(__DIR__).'/.env');
只需输入
false
即可清除消息并继续执行,并且要明确且兼容Symfony 5.0,除非您需要知道您正在使用
$usePutenv=true
的结果。(不太可能,否则将违约)