1 | <?php |
||
22 | trait UserPostingTrait |
||
23 | { |
||
24 | /** |
||
25 | * @var array |
||
26 | */ |
||
27 | protected $_cache = []; |
||
28 | |||
29 | /** |
||
30 | * @var CurrentUserInterface |
||
31 | */ |
||
32 | protected $_CurrentUser; |
||
33 | |||
34 | /** |
||
35 | * Get current-user. |
||
36 | * |
||
37 | * @return CurrentUserInterface |
||
38 | */ |
||
39 | public function getCurrentUser() |
||
43 | |||
44 | /** |
||
45 | * Set current user. |
||
46 | * |
||
47 | * @param CurrentUserInterface $CurrentUser current user |
||
48 | * @return void |
||
49 | */ |
||
50 | public function setCurrentUser($CurrentUser) |
||
54 | |||
55 | /** |
||
56 | * {@inheritDoc} |
||
57 | */ |
||
58 | public function isAnsweringForbidden() |
||
67 | |||
68 | /** |
||
69 | * {@inheritDoc} |
||
70 | */ |
||
71 | public function isBookmarked(): bool |
||
75 | |||
76 | /** |
||
77 | * {@inheritDoc} |
||
78 | */ |
||
79 | public function isEditingAllowed(): bool |
||
83 | |||
84 | /** |
||
85 | * {@inheritDoc} |
||
86 | */ |
||
87 | public function isEditingAsUserAllowed(): bool |
||
94 | |||
95 | /** |
||
96 | * Check if editing on the posting is forbidden. |
||
97 | * |
||
98 | * @param BasicPostingInterface $posting The posting. |
||
99 | * @param CurrentUserInterface $User The user. |
||
100 | * @return bool|string string if a reason is available. |
||
101 | */ |
||
102 | protected function _isEditingAllowed(BasicPostingInterface $posting, CurrentUserInterface $User) |
||
130 | |||
131 | /** |
||
132 | * {@inheritDoc} |
||
133 | */ |
||
134 | public function isIgnored(): bool |
||
138 | |||
139 | /** |
||
140 | * {@inheritDoc} |
||
141 | */ |
||
142 | public function isUnread(): bool |
||
153 | |||
154 | /** |
||
155 | * {@inheritDoc} |
||
156 | */ |
||
157 | public function hasNewAnswers(): bool |
||
172 | } |
||
173 |
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
Idable
provides a methodequalsId
that 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.