JetBrains / JetBrains/phpstorm-attributes
Parameter Attribute for expected class attributes
Open
- Dominant language
- PHP
- Stars
- 416
- Forks
- 11
- PR merge metrics
- No merged PRs in 30d
Description
Suggestion to add an attribute to ensure an instance has a class attribute.
```php
class ExpectsAttribute
{
public function __construct(
#[ExpectedAttribute(CustomAttribute::class)]
object $instance,
) {
$this->instance = $instance;
}
}
```
```php
#[CustomAttribute]
class MyOKClass
{
}
```
```php
class NotOKClass
{
}
```
```php
// OK
new ExpectsAttribute(new MyOKClass());
// Expects parameter 1 to have CustomAttribute
new ExpectsAttribute(new NotOKClass());
```
Thoughts?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.