assert icon indicating copy to clipboard operation
assert copied to clipboard

Fix `implementsInterface()` PHPDoc

Open herndlm opened this issue 3 years ago • 3 comments

class_implements accepts either an object or a class-string, but the PHPDoc for the assert function is wrong and limits its functionality to a class-string only. I'm not entirely sure if this was on purpose, the README just mentions "Check that a class implements an interface", but it would work with either an instance of a class or a class-string and the assertion is under the "object" category.

See also https://phpstan.org/r/c72bb8af-4f27-462b-85f6-e2d3b81b9786 where this is tested in PHPStan (which just got support for PHPDoc-based type narrowing, this is not released yet)

Refs: https://github.com/phpstan/phpstan-webmozart-assert/pull/144#issuecomment-1268122389

I could not cleanly run psalm locally without unrelated errors, let's see what happens on CI 🤞

herndlm avatar Oct 05 '22 12:10 herndlm

The docs look good, could you add some test cases using objects, so we cover it in our unit tests?

BackEndTea avatar Oct 07 '22 07:10 BackEndTea

The docs look good, could you add some test cases using objects, so we cover it in our unit tests?

sure, adapted

herndlm avatar Oct 07 '22 18:10 herndlm

@BackEndTea in case you didn't see it: should be adapted. In case you're just busy: no worries, this is not important 😊

herndlm avatar Oct 16 '22 17:10 herndlm