Open Geolim4 opened 10 months ago
This bug report is missing a link to reproduction at phpstan.org/try.
It will most likely be closed after manual review.
It shouldn't that hard to create a reproducer...
If I understood correctly the phpfastcache code, it should be something like https://phpstan.org/r/78c48681-6423-4652-a7f3-0f46c516505b
It shouldn't that hard to create a reproducer...
If I understood correctly the phpfastcache code, it should be something like https://phpstan.org/r/78c48681-6423-4652-a7f3-0f46c516505b
Yeah, exactly, I struggled trying to reproduce it for an hour, but I gave up after being unable to reproduce the behavior. Thanks
@VincentLanglet @Geolim4 After the latest push in 2.0.x, PHPStan now reports different result with your code snippet:
@@ @@
-PHP 8.0 – 8.3 (1 error)
+PHP 8.1 – 8.3 (1 error)
==========
12: Dead catch - Exception is never thrown in the try block.
-PHP 7.2 – 7.4 (3 errors)
+PHP 8.0 (4 errors)
==========
+39: Tip: Method Foo2::doThings() always throws an exception, it should have return type "never".
+39: Method Foo2::doThings() has invalid return type never.
12: Dead catch - Exception is never thrown in the try block.
+11: Method Foo2::driverReadMultiple() should return array but returns never.
+
+PHP 7.2 – 7.4 (6 errors)
+==========
+
+39: Tip: Method Foo2::doThings() always throws an exception, it should have return type "never".
+39: Method Foo2::doThings() has invalid return type never.
+12: Dead catch - Exception is never thrown in the try block.
12: Non-capturing catch is supported only on PHP 8.0 and later.
+11: Method Foo2::driverReadMultiple() should return array but returns never.
12: Non-capturing catch is supported only on PHP 8.0 and later.
@VincentLanglet @Geolim4 After the latest push in 2.0.x, PHPStan now reports different result with your code snippet:
@@ @@
-PHP 8.0 – 8.3 (1 error)
+PHP 8.1 – 8.3 (1 error)
==========
12: Dead catch - Exception is never thrown in the try block.
-PHP 7.2 – 7.4 (3 errors)
+PHP 8.0 (4 errors)
==========
+39: Tip: Method Foo2::doThings() always throws an exception, it should have return type "never".
+39: Method Foo2::doThings() has invalid return type never.
12: Dead catch - Exception is never thrown in the try block.
+11: Method Foo2::driverReadMultiple() should return array<mixed> but returns never.
+
+PHP 7.2 – 7.4 (6 errors)
+==========
+
+39: Tip: Method Foo2::doThings() always throws an exception, it should have return type "never".
+39: Method Foo2::doThings() has invalid return type never.
+12: Dead catch - Exception is never thrown in the try block.
12: Non-capturing catch is supported only on PHP 8.0 and later.
+11: Method Foo2::driverReadMultiple() should return array<mixed> but returns never.
12: Non-capturing catch is supported only on PHP 8.0 and later.
Bug report
I'm working on a new version of my library and I have an abstract class that contain this method:
\Phpfastcache\Core\Pool\DriverPoolAbstractTrait
And I do have multiple child class that extends the abstract class, but for compatibility reason some child class override the
driverReadMultiple
method, and some aren't.But Phpstan still returns me this error:
\Phpfastcache\Core\Pool\CacheItemPoolTrait This is the "guilty" code:
At the moment of this call, from a static analysis point of view, the code is not aware of the child implementing it.
I tried to reproduce it with Phpstan playground, but I think its too specific to Phpfastcache architecture :(
Code snippet that reproduces the problem
No response
Expected output
No error
Did PHPStan help you today? Did it make you happy in any way?
It helps me a lot since years thanks again :smi