找出可选链里的 bug

来自 PHP 8.0 新特性
PHP 8.3.33 进阶 4分钟 找出 1处问题

找出 destination() 在 Order 对象存在时仍可能产生警告的原因。

php
<?php
final class Address
{
    public function __construct(public string $city) {}
}
final class Customer
{
    public function __construct(public ?Address $address = null) {}
}
final class Order
{
    public function __construct(public ?Customer $customer = null) {}
}
function destination(?Order $order): string
{
    return $order?->customer->address?->city ?? 'pickup';
}
在试验场中打开
报告错误