Skip to content

Loosing narrowed type on Symfony\Contracts\Cache\CacheInterface #449

@mvhirsch

Description

@mvhirsch

Bug report

I'm passing a non-negative-int in my method, which is correctly detected by PHPStan. However, it looses it's narrowed type on the way passing through CacheInterface. I'm not sure why.

I created a reproducer repo, as I'm unable to reproduce this issue on Playground.

https://github.com/mvhirsch/phpstan-symfony-cache-reproducer

Code snippet that reproduces the problem

No response

Expected output

No issues. Return type of $this->cache->get() should be int<0, max>, not int.

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

It helps me keeping calm and settled in a hasty project.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions