wordpress-interop icon indicating copy to clipboard operation
wordpress-interop copied to clipboard

Raise PHPStan level to 2

Open szepeviktor opened this issue 2 years ago • 5 comments

Under level 4 👺 viktor says: broken application/package (not polite)

szepeviktor avatar May 07 '23 15:05 szepeviktor

Yes, many return types are interfaces, not concrete implementations. So: many methods are missing.

But there are exceptions 🤯 https://github.com/williarin/wordpress-interop/blob/b8e5fff62b045eb6df5de16c61819488f5d1ff3e/test/Test/Bridge/Repository/ShopOrderRepositoryTest.php#L15

szepeviktor avatar May 07 '23 15:05 szepeviktor

Let me pull out my secret laser gun 🔫 https://github.com/williarin/wordpress-interop/blob/b8e5fff62b045eb6df5de16c61819488f5d1ff3e/test/Test/Bridge/Repository/TermRepositoryTest.php#L21-L22

szepeviktor avatar May 07 '23 16:05 szepeviktor

Errors on Level 2 reduced from 140 to 51 🎉

Supporting RepositoryClass attribute: https://github.com/phpstan/phpstan/issues/9279

I do not know how to go on as there is no mechanism in PHPStan getRepository(string $entityClassName): RepositoryInterface to find out the repository class from entity class.

... although one can write a tiny type specifying extension.

szepeviktor avatar May 07 '23 18:05 szepeviktor

The above so called "PHPStan extension" finds out Repository names using str_replace :( But reduces the number of problems to 38!

szepeviktor avatar May 10 '23 06:05 szepeviktor

@williarin Could you help fixing remaining ones?

szepeviktor avatar May 10 '23 06:05 szepeviktor