Description
Symfony version(s) affected
6.4.8
Description
I'm updating my app from symfony v6.1.12 to v6.4.8 and behavior of env processor changed.
Before update env %env(string:default::ENV_NAME)%
return null, but now it return empty string.
I found some PRs and issues, but there was fix to fix to fix, and I'm little bit confused what is the right way.
-
[DependencyInjection] Fix casting scalar env vars from null #50517
-
[DependencyInjection] Fix autocasting null env values to empty string #50837
-
Environment variable typecast processors return null when used in conjunction with default: #50415
In documentation there is "When the fallback parameter is omitted (e.g. env(default::API_KEY)), then the returned value is null.". I think 3rd PR says that null value shouldn't be casted to empty string.
Also, I modified my env to default::ENV_NAME
and i have the same problem as described here
Invalid type for path "infrastructure_tools.healthChecks.baseAuthUser". Exp
ected one of "bool", "int", "float", "string", but got one of "bool", "int"
, "float", "string", "array".
How to reproduce
Pass the following as an argument to a Symfony service. Do not set the value of ENV.
final class EnvironmentService
{
public function __construct(
private ?string $env,
) {}
}
# services.yaml
\EnvironmentService:
arguments:
$env: '%env(string:default::ENV)%'
Symfony container build will fail due to null being passed as the $boolFlag which has to be a bool.
Possible Solution
No response
Additional Context
No response