| 1 | <?php |
||
| 22 | trait ForumsUserTrait |
||
| 23 | { |
||
| 24 | /** |
||
| 25 | * {@inheritDoc} |
||
| 26 | */ |
||
| 27 | public function getId(): int |
||
| 31 | |||
| 32 | /** |
||
| 33 | * {@inheritDoc} |
||
| 34 | */ |
||
| 35 | public function isUser(ForumsUserInterface $user): bool |
||
| 39 | |||
| 40 | /** |
||
| 41 | * Checks if user is forbidden. |
||
| 42 | * |
||
| 43 | * @return bool |
||
| 44 | */ |
||
| 45 | public function isLocked(): bool |
||
| 49 | |||
| 50 | /** |
||
| 51 | * Checks if user is forbidden. |
||
| 52 | * |
||
| 53 | * @return bool |
||
| 54 | */ |
||
| 55 | public function isActivated(): bool |
||
| 59 | |||
| 60 | /** |
||
| 61 | * Get role. |
||
| 62 | * |
||
| 63 | * @return string |
||
| 64 | */ |
||
| 65 | public function getRole(): string |
||
| 69 | |||
| 70 | /** |
||
| 71 | * {@inheritDoc} |
||
| 72 | */ |
||
| 73 | public function numberOfPostings(): int |
||
| 77 | |||
| 78 | /** |
||
| 79 | * {@inheritDoc} |
||
| 80 | */ |
||
| 81 | public function permission(string $resource, IdentifierInterface ...$identifiers): bool |
||
| 87 | } |
||
| 88 |
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idableprovides a methodequalsIdthat in turn relies on the methodgetId(). If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()as an abstract method to the trait will make sure it is available.