在PHP 7.4中无法访问具有有效密钥的数组



当我试图用查看数组的实际键时

dd(array_keys($this->credentials));

它向我展示了以下内容:

Array (4) (
[0] => String (7) "*data"
[1] => String (14) "*insensitive"
[2] => String (12) "*lowerKeys"
[3] => String (16) "*pathDelimiter"
)

但当我试图访问这里列出的密钥时,比如

dd($this->credentials['*data']);

dd($this->credentials['data']);

则返回CCD_ 1。

有什么想法吗?提前感谢(

编辑:

在我的案例中,问题是关于将对象转换为数组。在旧版本的PHP中,我做得像

$this->credentials = (array) $this->config->smth->{$key};

这在7.4中不起作用($this->config返回对象(。我需要把它改成

$this->credentials = $this->config->smth->{$key}->toArray();

但仍然有人能解释新版本到底发生了什么变化。

$this->credentials可能是转换后的对象/类吗?如果是,星号表示这些是私人财产。

最新更新