[5.x]: App::parseEnv doesn't return booleans
bug
### What happened?
### Description
Using `App::parseEnv()` doesn't return a boolean when the value of the env variable is `true` or `false`. Instead, it returns the string `'true'` or `'false'`.
```dotenv
FOOBAR=true
```
```php
App::parseEnv('$FOOBAR'); // 'true'
```
The docblock clearly indicates that the function should return boolean:
> If the string references an environment variable with a value of `true` or `false`, a boolean value will be returned.
This was apparently changed in #18418. However, if `App::env()` returns a `boolean`, it's converted back to a string in `App::parseEnv`:
```php
if (is_bool($result)) {
return $result ? 'true' : 'false';
}
```
Not sure if that is intended and the docblock is just outdated, or the other way around?
I'll just use `App::env` for now which _does_ handle boolean conversion. That said, _this_ method _doesn't_ actually mention that it does that.
### Craft CMS version
5.10.1
### PHP version
_No response_
### Operating system and version
_No response_
### Database type and version
_No response_
### Image driver and version
_No response_
### Installed plugins and versions
-
关闭于 2026-06-04 2 条评论