@@ -35,6 +35,8 @@ public function __construct()
3535 * subfolder of that name.
3636 *
3737 * @throws BlogException
38+ *
39+ * @return Post[]
3840 */
3941 public function getRecentPosts (int $ limit = 5 , int $ offset = 0 , ?string $ category = null )
4042 {
@@ -134,6 +136,8 @@ public function getPopularPosts(int $limit = 5)
134136
135137 /**
136138 * Gets a single post
139+ *
140+ * @return Post|null
137141 */
138142 public function getPost (string $ slug )
139143 {
@@ -142,7 +146,7 @@ public function getPost(string $slug)
142146 if (! $ post = cache ($ cacheKey )) {
143147 $ files = glob ("{$ this ->config ->contentPath }*. {$ slug }.md " );
144148
145- if (! ( is_countable ( $ files) ? count ( $ files ) : 0 )) {
149+ if (empty ( $ files )) {
146150 throw PageNotFoundException::forPageNotFound ();
147151 }
148152
@@ -185,7 +189,7 @@ public function recentPostsWidget(int $limit, string $view = 'blog/_widget'): st
185189 {
186190 $ posts = $ this ->getRecentPosts ($ limit );
187191
188- if (! ( is_countable ( $ posts) ? count ( $ posts ) : 0 ) ) {
192+ if ($ posts === [] ) {
189193 return '' ;
190194 }
191195
@@ -203,7 +207,7 @@ public function popularPostsWidget(int $limit): string
203207 {
204208 $ posts = $ this ->getPopularPosts ($ limit );
205209
206- if (! ( is_countable ($ posts ) ? count ($ posts ) : 0 ) ) {
210+ if (is_countable ($ posts ) ? count ($ posts ) : 0 ) {
207211 return '' ;
208212 }
209213
@@ -216,6 +220,8 @@ public function popularPostsWidget(int $limit): string
216220 /**
217221 * Reads in a post from file and parses it
218222 * into a Post Entity.
223+ *
224+ * @return Post|null
219225 */
220226 protected function readPost (string $ folder , string $ filename )
221227 {
@@ -230,7 +236,7 @@ protected function readPost(string $folder, string $filename)
230236 // Get slug and date
231237 preg_match ('|^([\d-]+).(\S+).md$|i ' , $ filename , $ matches );
232238
233- if (! count ( $ matches) ) {
239+ if ($ matches === [] ) {
234240 return null ;
235241 }
236242
@@ -289,7 +295,7 @@ protected function parseVideoTags(?string $html = null)
289295 // ![[ https://youtube.com/watch?v=xlkjsdfhlk ]]
290296 preg_match_all ('|!video\[([\s\w:/.?=&;]*)\]|i ' , $ html , $ matches );
291297
292- if (! count ( $ matches) ) {
298+ if ($ matches === [] ) {
293299 return $ html ;
294300 }
295301
0 commit comments