New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@phpstan-require-use
for requiring implementors/subclasses to use certain traits
#9899
Comments
This could be paired with annotations similar to |
Those would be great as well! |
@brandonkelly @ben-challis or anyone else in need of Recently I started implementing Afterwards I can make |
I don't think that |
|
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Feature request
Interfaces and abstract classes should be able to specify a
@phpstan-require-use
tag, which tells PHPStan that implementors and subclasses are expected to use a specified trait.For example,
yii\db\QueryInterface
in Yii 2 expects that implementors will useyii\db\QueryTrait
.We’ve followed that convention in Craft CMS, e.g. with
craft\base\FieldInterface
+craft\base\FieldTrait
.With this convention, it’s not currently possible to make PHPStan happy when targeting PHP 8.2. (Prior PHP versions were only passable thanks to PHPStan assuming that trait-defined properties were actually just dynamic properties.)
Did PHPStan help you today? Did it make you happy in any way?
It was a huge help ensuring our unit tests looked good as we were upgrading to Codeception 5!
The text was updated successfully, but these errors were encountered: