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

Skip to content

Incorrectly inferred type - DateInterval::format('%a') can be falsy #13693

@adamturcsan

Description

@adamturcsan

Bug report

PHPStan inferres DateInterval::format('%a') to be lowercase-string&non-falsy-string. In case of a difference of the same date the return value can be '0' which is a falsy string.

Code snippet that reproduces the problem

https://phpstan.org/r/1bb0f53b-a6fe-4b17-b6a3-53f0e43be198

Expected output

Based on https://www.php.net/manual/en/dateinterval.format.php

The output might be a numeric string or (unknown).

The expected output: Dumped type: numeric-string|"(unknown)"

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