Passed
Push — master ( 235569...65c96d )
by Paul
03:43
created
plugin/Modules/System.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 			'setting' => 'Plugin Settings',
41 41
 			'reviews' => 'Review Counts',
42 42
 		];
43
-		$systemInfo = array_reduce( array_keys( $details ), function( $carry, $key ) use( $details ) {
43
+		$systemInfo = array_reduce( array_keys( $details ), function( $carry, $key ) use($details) {
44 44
 			$methodName = glsr( Helper::class )->buildMethodName( 'get-'.$key.'-details' );
45 45
 			if( method_exists( $this, $methodName ) && $systemDetails = $this->$methodName() ) {
46 46
 				return $carry.$this->implode( strtoupper( $details[$key] ), $systemDetails );
@@ -57,8 +57,8 @@  discard block
 block discarded – undo
57 57
 	{
58 58
 		$plugins = get_plugins();
59 59
 		$activePlugins = (array)get_option( 'active_plugins', [] );
60
-		$inactive = array_diff_key( $plugins, array_flip( $activePlugins ));
61
-		return $this->normalizePluginList( array_diff_key( $plugins, $inactive ));
60
+		$inactive = array_diff_key( $plugins, array_flip( $activePlugins ) );
61
+		return $this->normalizePluginList( array_diff_key( $plugins, $inactive ) );
62 62
 	}
63 63
 
64 64
 	/**
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 	public function getInactivePluginDetails()
93 93
 	{
94 94
 		$activePlugins = (array)get_option( 'active_plugins', [] );
95
-		return $this->normalizePluginList( array_diff_key( get_plugins(), array_flip( $activePlugins )));
95
+		return $this->normalizePluginList( array_diff_key( get_plugins(), array_flip( $activePlugins ) ) );
96 96
 	}
97 97
 
98 98
 	/**
@@ -102,9 +102,9 @@  discard block
 block discarded – undo
102 102
 	{
103 103
 		$plugins = array_merge(
104 104
 			get_mu_plugins(),
105
-			get_plugins( '/../'.basename( WPMU_PLUGIN_DIR ))
105
+			get_plugins( '/../'.basename( WPMU_PLUGIN_DIR ) )
106 106
 		);
107
-		if( empty( $plugins ))return;
107
+		if( empty($plugins) )return;
108 108
 		return $this->normalizePluginList( $plugins );
109 109
 	}
110 110
 
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 	 */
114 114
 	public function getMultisitePluginDetails()
115 115
 	{
116
-		if( !is_multisite() || empty( get_site_option( 'active_sitewide_plugins', [] )))return;
116
+		if( !is_multisite() || empty(get_site_option( 'active_sitewide_plugins', [] )) )return;
117 117
 		return $this->normalizePluginList( wp_get_active_network_plugins() );
118 118
 	}
119 119
 
@@ -139,11 +139,11 @@  discard block
 block discarded – undo
139 139
 			'Max Input Vars' => ini_get( 'max_input_vars' ),
140 140
 			'Memory Limit' => ini_get( 'memory_limit' ),
141 141
 			'Post Max Size' => ini_get( 'post_max_size' ),
142
-			'Session Cookie Path' => esc_html( ini_get( 'session.cookie_path' )),
143
-			'Session Name' => esc_html( ini_get( 'session.name' )),
144
-			'Session Save Path' => esc_html( ini_get( 'session.save_path' )),
145
-			'Session Use Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_cookies' )), true ),
146
-			'Session Use Only Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_only_cookies' )), true ),
142
+			'Session Cookie Path' => esc_html( ini_get( 'session.cookie_path' ) ),
143
+			'Session Name' => esc_html( ini_get( 'session.name' ) ),
144
+			'Session Save Path' => esc_html( ini_get( 'session.save_path' ) ),
145
+			'Session Use Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_cookies' ) ), true ),
146
+			'Session Use Only Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_only_cookies' ) ), true ),
147 147
 			'Upload Max Filesize' => ini_get( 'upload_max_filesize' ),
148 148
 		];
149 149
 	}
@@ -155,8 +155,8 @@  discard block
 block discarded – undo
155 155
 	{
156 156
 		$counts = glsr( CountsManager::class )->getCounts();
157 157
 		$counts = glsr( Helper::class )->flattenArray( $counts );
158
-		array_walk( $counts, function( &$ratings ) use( $counts ) {
159
-			if( !is_array( $ratings )) {
158
+		array_walk( $counts, function( &$ratings ) use($counts) {
159
+			if( !is_array( $ratings ) ) {
160 160
 				glsr_log()->error( 'System: ratings is not an array' )->debug( $ratings )->debug( $counts );
161 161
 				return;
162 162
 			}
@@ -192,8 +192,8 @@  discard block
 block discarded – undo
192 192
 		ksort( $settings );
193 193
 		$details = [];
194 194
 		foreach( $settings as $key => $value ) {
195
-			if( $helper->startsWith( 'strings', $key ) && $helper->endsWith( 'id', $key ))continue;
196
-			$value = htmlspecialchars( trim( preg_replace('/\s\s+/', '\\n', $value )), ENT_QUOTES, 'UTF-8' );
195
+			if( $helper->startsWith( 'strings', $key ) && $helper->endsWith( 'id', $key ) )continue;
196
+			$value = htmlspecialchars( trim( preg_replace( '/\s\s+/', '\\n', $value ) ), ENT_QUOTES, 'UTF-8' );
197 197
 			$details[$key] = $value;
198 198
 		}
199 199
 		return $details;
@@ -265,10 +265,10 @@  discard block
 block discarded – undo
265 265
 			'WPE_APIKEY' => 'WP Engine',
266 266
 		];
267 267
 		foreach( $checks as $key => $value ) {
268
-			if( !$this->isWebhostCheckValid( $key ))continue;
268
+			if( !$this->isWebhostCheckValid( $key ) )continue;
269 269
 			return $value;
270 270
 		}
271
-		return implode( ',', array_filter( [DB_HOST, filter_input( INPUT_SERVER, 'SERVER_NAME' )] ));
271
+		return implode( ',', array_filter( [DB_HOST, filter_input( INPUT_SERVER, 'SERVER_NAME' )] ) );
272 272
 	}
273 273
 
274 274
 	/**
@@ -289,8 +289,8 @@  discard block
 block discarded – undo
289 289
 	{
290 290
 		$plugins = get_plugins();
291 291
 		$activePlugins = (array)get_option( 'active_plugins', [] );
292
-		$inactive = $this->normalizePluginList( array_diff_key( $plugins, array_flip( $activePlugins )));
293
-		$active = $this->normalizePluginList( array_diff_key( $plugins, $inactive ));
292
+		$inactive = $this->normalizePluginList( array_diff_key( $plugins, array_flip( $activePlugins ) ) );
293
+		$active = $this->normalizePluginList( array_diff_key( $plugins, $inactive ) );
294 294
 		return $active + $inactive;
295 295
 	}
296 296
 
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
 	protected function implode( $title, array $details )
302 302
 	{
303 303
 		$strings = ['['.$title.']'];
304
-		$padding = max( array_map( 'strlen', array_keys( $details )) );
304
+		$padding = max( array_map( 'strlen', array_keys( $details ) ) );
305 305
 		$padding = max( [$padding, static::PAD] );
306 306
 		foreach( $details as $key => $value ) {
307 307
 			$strings[] = is_string( $key )
@@ -344,9 +344,9 @@  discard block
 block discarded – undo
344 344
 		$keys = [
345 345
 			'licenses.', 'submissions.recaptcha.key', 'submissions.recaptcha.secret',
346 346
 		];
347
-		array_walk( $settings, function( &$value, $setting ) use( $keys ) {
347
+		array_walk( $settings, function( &$value, $setting ) use($keys) {
348 348
 			foreach( $keys as $key ) {
349
-				if( !glsr( Helper::class )->startsWith( $key, $setting ) || empty( $value ))continue;
349
+				if( !glsr( Helper::class )->startsWith( $key, $setting ) || empty($value) )continue;
350 350
 				$value = str_repeat( '•', 13 );
351 351
 				return;
352 352
 			}
Please login to merge, or discard this patch.
plugin/Database/CountsManager.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 			$this->getCounts(),
67 67
 			$review->review_type,
68 68
 			$review->rating
69
-		));
69
+		) );
70 70
 	}
71 71
 
72 72
 	/**
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 	 */
75 75
 	public function decreasePostCounts( Review $review )
76 76
 	{
77
-		if( empty( $counts = $this->getPostCounts( $review->assigned_to )))return;
77
+		if( empty($counts = $this->getPostCounts( $review->assigned_to )) )return;
78 78
 		$counts = $this->decreaseRating( $counts, $review->review_type, $review->rating );
79 79
 		$this->setPostCounts( $review->assigned_to, $counts );
80 80
 	}
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	public function decreaseTermCounts( Review $review )
86 86
 	{
87 87
 		foreach( $review->term_ids as $termId ) {
88
-			if( empty( $counts = $this->getTermCounts( $termId )))continue;
88
+			if( empty($counts = $this->getTermCounts( $termId )) )continue;
89 89
 			$counts = $this->decreaseRating( $counts, $review->review_type, $review->rating );
90 90
 			$this->setTermCounts( $termId, $counts );
91 91
 		}
@@ -97,17 +97,17 @@  discard block
 block discarded – undo
97 97
 	public function flatten( array $reviewCounts, array $args = [] )
98 98
 	{
99 99
 		$counts = [];
100
-		array_walk_recursive( $reviewCounts, function( $num, $index ) use( &$counts ) {
101
-			$counts[$index] = isset( $counts[$index] )
100
+		array_walk_recursive( $reviewCounts, function( $num, $index ) use(&$counts) {
101
+			$counts[$index] = isset($counts[$index])
102 102
 				? $num + $counts[$index]
103 103
 				: $num;
104 104
 		});
105 105
 		$args = wp_parse_args( $args, [
106 106
 			'max' => Rating::MAX_RATING,
107 107
 			'min' => Rating::MIN_RATING,
108
-		]);
108
+		] );
109 109
 		foreach( $counts as $index => &$num ) {
110
-			if( $index >= intval( $args['min'] ) && $index <= intval( $args['max'] ))continue;
110
+			if( $index >= intval( $args['min'] ) && $index <= intval( $args['max'] ) )continue;
111 111
 			$num = 0;
112 112
 		}
113 113
 		return $counts;
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 			'post_ids' => [],
123 123
 			'term_ids' => [],
124 124
 			'type' => 'local',
125
-		]);
125
+		] );
126 126
 		$counts = [];
127 127
 		foreach( glsr( Polylang::class )->getPostIds( $args['post_ids'] ) as $postId ) {
128 128
 			$counts[] = $this->getPostCounts( $postId );
@@ -130,12 +130,12 @@  discard block
 block discarded – undo
130 130
 		foreach( $args['term_ids'] as $termId ) {
131 131
 			$counts[] = $this->getTermCounts( $termId );
132 132
 		}
133
-		if( empty( $counts )) {
133
+		if( empty($counts) ) {
134 134
 			$counts[] = $this->getCounts();
135 135
 		}
136 136
 		return in_array( $args['type'], ['', 'all'] )
137 137
 			? $this->normalize( [$this->flatten( $counts )] )
138
-			: $this->normalize( array_column( $counts, $args['type'] ));
138
+			: $this->normalize( array_column( $counts, $args['type'] ) );
139 139
 	}
140 140
 
141 141
 	/**
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 	public function getCounts()
145 145
 	{
146 146
 		$counts = glsr( OptionManager::class )->get( 'counts', [] );
147
-		if( !is_array( $counts )) {
147
+		if( !is_array( $counts ) ) {
148 148
 			glsr_log()->error( 'CountsManager: counts is not an array' )->debug( $counts );
149 149
 			return [];
150 150
 		}
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 	 */
158 158
 	public function getPostCounts( $postId )
159 159
 	{
160
-		return array_filter( (array)get_post_meta( $postId, static::META_COUNT, true ));
160
+		return array_filter( (array)get_post_meta( $postId, static::META_COUNT, true ) );
161 161
 	}
162 162
 
163 163
 	/**
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 	 */
167 167
 	public function getTermCounts( $termId )
168 168
 	{
169
-		return array_filter( (array)get_term_meta( $termId, static::META_COUNT, true ));
169
+		return array_filter( (array)get_term_meta( $termId, static::META_COUNT, true ) );
170 170
 	}
171 171
 
172 172
 	/**
@@ -184,14 +184,14 @@  discard block
 block discarded – undo
184 184
 	 */
185 185
 	public function increaseCounts( Review $review )
186 186
 	{
187
-		if( empty( $counts = $this->getCounts() )) {
187
+		if( empty($counts = $this->getCounts()) ) {
188 188
 			$counts = $this->buildCounts();
189 189
 		}
190 190
 		$this->setCounts( $this->increaseRating(
191 191
 			$counts,
192 192
 			$review->review_type,
193 193
 			$review->rating
194
-		));
194
+		) );
195 195
 	}
196 196
 
197 197
 	/**
@@ -199,9 +199,9 @@  discard block
 block discarded – undo
199 199
 	 */
200 200
 	public function increasePostCounts( Review $review )
201 201
 	{
202
-		if( !( get_post( $review->assigned_to ) instanceof WP_Post ))return;
202
+		if( !(get_post( $review->assigned_to ) instanceof WP_Post) )return;
203 203
 		$counts = $this->getPostCounts( $review->assigned_to );
204
-		$counts = empty( $counts )
204
+		$counts = empty($counts)
205 205
 			? $this->buildPostCounts( $review->assigned_to )
206 206
 			: $this->increaseRating( $counts, $review->review_type, $review->rating );
207 207
 		$this->setPostCounts( $review->assigned_to, $counts );
@@ -212,10 +212,10 @@  discard block
 block discarded – undo
212 212
 	 */
213 213
 	public function increaseTermCounts( Review $review )
214 214
 	{
215
-		$termIds = glsr( ReviewManager::class )->normalizeTerms( implode( ',', $review->term_ids ));
215
+		$termIds = glsr( ReviewManager::class )->normalizeTerms( implode( ',', $review->term_ids ) );
216 216
 		foreach( $termIds as $termId ) {
217 217
 			$counts = $this->getTermCounts( $termId );
218
-			$counts = empty( $counts )
218
+			$counts = empty($counts)
219 219
 				? $this->buildTermCounts( $termId )
220 220
 				: $this->increaseRating( $counts, $review->review_type, $review->rating );
221 221
 			$this->setTermCounts( $termId, $counts );
@@ -238,8 +238,8 @@  discard block
 block discarded – undo
238 238
 	{
239 239
 		$ratingCounts = $this->flatten( $reviewCounts );
240 240
 		update_post_meta( $postId, static::META_COUNT, $reviewCounts );
241
-		update_post_meta( $postId, static::META_AVERAGE, glsr( Rating::class )->getAverage( $ratingCounts ));
242
-		update_post_meta( $postId, static::META_RANKING, glsr( Rating::class )->getRanking( $ratingCounts ));
241
+		update_post_meta( $postId, static::META_AVERAGE, glsr( Rating::class )->getAverage( $ratingCounts ) );
242
+		update_post_meta( $postId, static::META_RANKING, glsr( Rating::class )->getRanking( $ratingCounts ) );
243 243
 	}
244 244
 
245 245
 	/**
@@ -248,11 +248,11 @@  discard block
 block discarded – undo
248 248
 	 */
249 249
 	public function setTermCounts( $termId, array $reviewCounts )
250 250
 	{
251
-		if( !term_exists( $termId ))return;
251
+		if( !term_exists( $termId ) )return;
252 252
 		$ratingCounts = $this->flatten( $reviewCounts );
253 253
 		update_term_meta( $termId, static::META_COUNT, $reviewCounts );
254
-		update_term_meta( $termId, static::META_AVERAGE, glsr( Rating::class )->getAverage( $ratingCounts ));
255
-		update_term_meta( $termId, static::META_RANKING, glsr( Rating::class )->getRanking( $ratingCounts ));
254
+		update_term_meta( $termId, static::META_AVERAGE, glsr( Rating::class )->getAverage( $ratingCounts ) );
255
+		update_term_meta( $termId, static::META_RANKING, glsr( Rating::class )->getRanking( $ratingCounts ) );
256 256
 	}
257 257
 
258 258
 	/**
@@ -263,10 +263,10 @@  discard block
 block discarded – undo
263 263
 	{
264 264
 		$counts = [];
265 265
 		$lastPostId = 0;
266
-		while( $reviews = $this->queryReviews( $args, $lastPostId, $limit )) {
267
-			$types = array_keys( array_flip( array_column( $reviews, 'type' )));
266
+		while( $reviews = $this->queryReviews( $args, $lastPostId, $limit ) ) {
267
+			$types = array_keys( array_flip( array_column( $reviews, 'type' ) ) );
268 268
 			foreach( $types as $type ) {
269
-				if( isset( $counts[$type] ))continue;
269
+				if( isset($counts[$type]) )continue;
270 270
 				$counts[$type] = array_fill_keys( range( 0, Rating::MAX_RATING ), 0 );
271 271
 			}
272 272
 			foreach( $reviews as $review ) {
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 	 */
285 285
 	protected function decreaseRating( array $reviewCounts, $type, $rating )
286 286
 	{
287
-		if( isset( $reviewCounts[$type][$rating] )) {
287
+		if( isset($reviewCounts[$type][$rating]) ) {
288 288
 			$reviewCounts[$type][$rating] = max( 0, $reviewCounts[$type][$rating] - 1 );
289 289
 		}
290 290
 		return $reviewCounts;
@@ -297,10 +297,10 @@  discard block
 block discarded – undo
297 297
 	 */
298 298
 	protected function increaseRating( array $reviewCounts, $type, $rating )
299 299
 	{
300
-		if( !array_key_exists( $type, glsr()->reviewTypes )) {
300
+		if( !array_key_exists( $type, glsr()->reviewTypes ) ) {
301 301
 			return $reviewCounts;
302 302
 		}
303
-		if( !array_key_exists( $type, $reviewCounts )) {
303
+		if( !array_key_exists( $type, $reviewCounts ) ) {
304 304
 			$reviewCounts[$type] = [];
305 305
 		}
306 306
 		$reviewCounts = $this->normalize( $reviewCounts );
@@ -313,12 +313,12 @@  discard block
 block discarded – undo
313 313
 	 */
314 314
 	protected function normalize( array $reviewCounts )
315 315
 	{
316
-		if( empty( $reviewCounts )) {
316
+		if( empty($reviewCounts) ) {
317 317
 			$reviewCounts = [[]];
318 318
 		}
319 319
 		foreach( $reviewCounts as &$counts ) {
320 320
 			foreach( range( 0, Rating::MAX_RATING ) as $index ) {
321
-				if( isset( $counts[$index] ))continue;
321
+				if( isset($counts[$index]) )continue;
322 322
 				$counts[$index] = 0;
323 323
 			}
324 324
 			ksort( $counts );
@@ -333,14 +333,14 @@  discard block
 block discarded – undo
333 333
 	 */
334 334
 	protected function queryReviews( array $args = [], $lastPostId, $limit )
335 335
 	{
336
-		$args = wp_parse_args( $args, array_fill_keys( ['post_id', 'term_id'], '' ));
337
-		if( empty( array_filter( $args ))) {
336
+		$args = wp_parse_args( $args, array_fill_keys( ['post_id', 'term_id'], '' ) );
337
+		if( empty(array_filter( $args )) ) {
338 338
 			return glsr( SqlQueries::class )->getReviewCounts( $lastPostId, $limit );
339 339
 		}
340
-		if( !empty( $args['post_id'] )) {
340
+		if( !empty($args['post_id']) ) {
341 341
 			return glsr( SqlQueries::class )->getReviewPostCounts( $args['post_id'], $lastPostId, $limit );
342 342
 		}
343
-		if( !empty( $args['term_id'] )) {
343
+		if( !empty($args['term_id']) ) {
344 344
 			return glsr( SqlQueries::class )->getReviewTermCounts( $args['term_id'], $lastPostId, $limit );
345 345
 		}
346 346
 	}
Please login to merge, or discard this patch.