Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Nullsafe operator chaining #11073

@kamil-zacek

Description

@kamil-zacek

Bug report

When the $date is null, whole remaining part of call chain should be resolved as null. When $date is not null, even the result of modify('+1 year') is resolved as not null and ?-> call for ?->setTime() is not necessary.

I also didn't find what is "officially correct way". But according to https://wiki.php.net/rfc/nullsafe_operator this should be equivalent to

if ($date !== null) {
$plus= $date->modify('+1 year');

return $plus->setTime(23, 59, 59);
}

return null;

Code snippet that reproduces the problem

https://phpstan.org/r/ba9428d7-9b8b-4029-9ba8-423be023a767

Expected output

No errors!

Did PHPStan help you today? Did it make you happy in any way?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions