vimeo / psalm

A static analysis tool for finding errors in PHP applications
https://psalm.dev
MIT License
5.57k stars 660 forks source link

request for user-friendliness in template-hints errors #6096

Open SignpostMarv opened 3 years ago

SignpostMarv commented 3 years ago

In the case of

/** @template T1 as scalar */
interface Foo {}

/** @template-implements Foo<string> */
class Bar {}

psalm reports @template-implements must include the name of an implemented class, got Foo<string>, which while a little obtuse does more-or-less explain itself, I feel like it might be helpful to rephrase it along the lines of class Bar does not implement interface Foo, sourced from @template-implements Foo<string>

whereas in the case of

interface Baz {}

/** @template-implements Baz */
class Bat {}

psalm reports refers Baz as an "invalid class". I feel like the error message should be consistent with the templated first case, whether it's rephrased or just @template-implements must include the name of an implemented class, got Baz

The lesser issue is the reference to interfaces as classes.

https://psalm.dev/r/c717c176ad

psalm-github-bot[bot] commented 3 years ago

I found these snippets:

https://psalm.dev/r/c717c176ad ```php */ class Bar {} interface Baz {} /** @template-implements Baz */ class Bat {} ``` ``` Psalm output (using commit 35b6a93): ERROR: InvalidDocblock - 6:1 - @template-implements must include the name of an implemented class, got Foo ERROR: InvalidDocblock - 11:1 - @template-implements has invalid class Baz ```