phpstan-symfony icon indicating copy to clipboard operation
phpstan-symfony copied to clipboard

Loosing narrowed type on `Symfony\Contracts\Cache\CacheInterface`

Open mvhirsch opened this issue 7 months ago • 6 comments

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.

mvhirsch avatar May 06 '25 14:05 mvhirsch