1 | <?php |
||
15 | trait NewsManagerAwareTrait |
||
16 | { |
||
17 | /** |
||
18 | * Currently displayed news. |
||
19 | * @var array $news City/Object/News |
||
20 | */ |
||
21 | private $currentNews; |
||
22 | |||
23 | /** |
||
24 | * @var NewsManager $newsManager |
||
25 | */ |
||
26 | private $newsManager; |
||
27 | |||
28 | // ========================================================================== |
||
29 | // FUNCTIONS |
||
30 | // ========================================================================== |
||
31 | |||
32 | /** |
||
33 | * Formatted news list |
||
34 | * Returns the entries for the current page. |
||
35 | * @return \Generator|void |
||
36 | */ |
||
37 | public function newsList() |
||
44 | |||
45 | /** |
||
46 | * Formatted news archive list |
||
47 | * Returns the entries for the current page. |
||
48 | * @return \Generator|void |
||
49 | */ |
||
50 | public function newsArchiveList() |
||
57 | |||
58 | /** |
||
59 | * Current news. |
||
60 | * @return array The properties of the current news |
||
61 | */ |
||
62 | public function currentNews() |
||
78 | |||
79 | /** |
||
80 | * @return \Generator |
||
81 | */ |
||
82 | public function featNews() |
||
94 | |||
95 | /** |
||
96 | * Next news in list. |
||
97 | * @return array The next news properties. |
||
98 | */ |
||
99 | public function nextNews() |
||
109 | |||
110 | /** |
||
111 | * Next news in list. |
||
112 | * @return array The next news properties. |
||
113 | */ |
||
114 | public function prevNews() |
||
124 | |||
125 | /** |
||
126 | * Amount of news (total) |
||
127 | * @return integer How many news? |
||
128 | */ |
||
129 | public function numNews() |
||
133 | |||
134 | /** |
||
135 | * @return float |
||
136 | */ |
||
137 | public function numNewsPages() |
||
141 | |||
142 | /** |
||
143 | * @return boolean |
||
144 | */ |
||
145 | public function newsHasPager() |
||
149 | |||
150 | /** |
||
151 | * @return \Generator |
||
152 | */ |
||
153 | public function newsCategoryList() |
||
160 | |||
161 | /** |
||
162 | * @param NewsInterface $news Charcoal\Cms\NewsInterface. |
||
163 | * @return CategoryInterface |
||
164 | */ |
||
165 | public function newsCategory(NewsInterface $news) |
||
171 | |||
172 | // ========================================================================== |
||
173 | // FORMATTER |
||
174 | // ========================================================================== |
||
175 | |||
176 | /** |
||
177 | * @param NewsInterface $news Charcoal\Cms\NewsInterface. |
||
178 | * @return string |
||
179 | */ |
||
180 | protected function getNewsDateFormat(NewsInterface $news) |
||
186 | |||
187 | /** |
||
188 | * Formatting expected in templates |
||
189 | * @param NewsInterface $news A single news. |
||
190 | * @return array The needed news properties. |
||
191 | */ |
||
192 | protected function newsFormatShort(NewsInterface $news) |
||
203 | |||
204 | /** |
||
205 | * Formatting expected in templates |
||
206 | * @param NewsInterface $news A single news. |
||
207 | * @return array The needed news properties. |
||
208 | */ |
||
209 | protected function newsFormatNav(NewsInterface $news) |
||
219 | |||
220 | /** |
||
221 | * @param NewsInterface $news The current news. |
||
222 | * @return array The needed properties. |
||
223 | */ |
||
224 | protected function newsFormatFull(NewsInterface $news) |
||
249 | |||
250 | /** |
||
251 | * @param CategoryInterface $category The category item. |
||
252 | * @return array The formatted category item. |
||
253 | */ |
||
254 | protected function newsFormatCategory(CategoryInterface $category) |
||
261 | |||
262 | // ========================================================================== |
||
263 | // DEPENDENCIES |
||
264 | // ========================================================================== |
||
265 | |||
266 | /** |
||
267 | * @return NewsManager |
||
268 | * @throws ContainerException When dependency is missing. |
||
269 | */ |
||
270 | protected function newsManager() |
||
282 | |||
283 | /** |
||
284 | * @param NewsManager $newsManager The news Manager class. |
||
285 | * @return self |
||
286 | */ |
||
287 | protected function setNewsManager(NewsManager $newsManager) |
||
293 | |||
294 | /** |
||
295 | * dateHelperAwareTrait dependency |
||
296 | * @return mixed |
||
297 | */ |
||
298 | abstract protected function dateHelper(); |
||
299 | } |
||
300 |
There are different options of fixing this problem.
If you want to be on the safe side, you can add an additional type-check:
If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:
Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.