Test Failed
Push — master ( 21e3e7...365a0a )
by Paul
03:49
created
plugin/Controllers/AdminController.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	 */
25 25
 	public function enqueueAssets()
26 26
 	{
27
-		$command = new EnqueueAdminAssets([
27
+		$command = new EnqueueAdminAssets( [
28 28
 			'pointers' => [[
29 29
 				'content' => __( 'You can pin exceptional reviews so that they are always shown first.', 'site-reviews' ),
30 30
 				'id' => 'glsr-pointer-pinned',
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 				'target' => '#misc-pub-pinned',
37 37
 				'title' => __( 'Pin Your Reviews', 'site-reviews' ),
38 38
 			]],
39
-		]);
39
+		] );
40 40
 		$this->execute( $command );
41 41
 	}
42 42
 
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 	{
49 49
 		$links['settings'] = glsr( Builder::class )->a( __( 'Settings', 'site-reviews' ), [
50 50
 			'href' => admin_url( 'edit.php?post_type='.Application::POST_TYPE.'&page=settings' ),
51
-		]);
51
+		] );
52 52
 		return $links;
53 53
 	}
54 54
 
@@ -59,19 +59,19 @@  discard block
 block discarded – undo
59 59
 	public function filterDashboardGlanceItems( array $items )
60 60
 	{
61 61
 		$postCount = wp_count_posts( Application::POST_TYPE );
62
-		if( empty( $postCount->publish )) {
62
+		if( empty($postCount->publish) ) {
63 63
 			return $items;
64 64
 		}
65 65
 		$text = _n( '%s Review', '%s Reviews', $postCount->publish, 'site-reviews' );
66
-		$text = sprintf( $text, number_format_i18n( $postCount->publish ));
66
+		$text = sprintf( $text, number_format_i18n( $postCount->publish ) );
67 67
 		$items[] = current_user_can( get_post_type_object( Application::POST_TYPE )->cap->edit_posts )
68 68
 			? glsr( Builder::class )->a( $text, [
69 69
 				'class' => 'glsr-review-count',
70 70
 				'href' => 'edit.php?post_type='.Application::POST_TYPE,
71
-			])
71
+			] )
72 72
 			: glsr( Builder::class )->span( $text, [
73 73
 				'class' => 'glsr-review-count',
74
-			]);
74
+			] );
75 75
 		return $items;
76 76
 	}
77 77
 
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 	public function filterTinymcePlugins( array $plugins )
83 83
 	{
84 84
 		if( user_can_richedit()
85
-			&& ( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' ))) {
85
+			&& (current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' )) ) {
86 86
 			$plugins['glsr_shortcode'] = glsr()->url( 'assets/scripts/mce-plugin.js' );
87 87
 		}
88 88
 		return $plugins;
@@ -94,11 +94,11 @@  discard block
 block discarded – undo
94 94
 	 */
95 95
 	public function registerShortcodeButtons()
96 96
 	{
97
-		$command = new RegisterShortcodeButtons([
97
+		$command = new RegisterShortcodeButtons( [
98 98
 			'site_reviews' => esc_html__( 'Recent Reviews', 'site-reviews' ),
99 99
 			'site_reviews_form' => esc_html__( 'Submit a Review', 'site-reviews' ),
100 100
 			'site_reviews_summary' => esc_html__( 'Summary of Reviews', 'site-reviews' ),
101
-		]);
101
+		] );
102 102
 		$this->execute( $command );
103 103
 	}
104 104
 
@@ -108,10 +108,10 @@  discard block
 block discarded – undo
108 108
 	 */
109 109
 	public function renderReviewEditor( WP_Post $post )
110 110
 	{
111
-		if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ))return;
111
+		if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ) )return;
112 112
 		glsr()->render( 'partials/editor/review', [
113 113
 			'post' => $post,
114
-		]);
114
+		] );
115 115
 	}
116 116
 
117 117
 	/**
@@ -120,13 +120,13 @@  discard block
 block discarded – undo
120 120
 	 */
121 121
 	public function renderReviewNotice( WP_Post $post )
122 122
 	{
123
-		if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ))return;
124
-		glsr( Notice::class )->addWarning( __( 'This review is read-only.', 'site-reviews' ));
123
+		if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ) )return;
124
+		glsr( Notice::class )->addWarning( __( 'This review is read-only.', 'site-reviews' ) );
125 125
 		glsr( Html::class )->renderTemplate( 'partials/editor/notice', [
126 126
 			'context' => [
127 127
 				'notices' => glsr( Notice::class )->get(),
128 128
 			],
129
-		]);
129
+		] );
130 130
 	}
131 131
 
132 132
 	/**
@@ -138,13 +138,13 @@  discard block
 block discarded – undo
138 138
 		if( glsr_current_screen()->base != 'post' )return;
139 139
 		$shortcodes = [];
140 140
 		foreach( glsr()->mceShortcodes as $shortcode => $values ) {
141
-			if( !apply_filters( sanitize_title( $shortcode ).'_condition', true ))continue;
141
+			if( !apply_filters( sanitize_title( $shortcode ).'_condition', true ) )continue;
142 142
 			$shortcodes[$shortcode] = $values;
143 143
 		}
144
-		if( empty( $shortcodes ))return;
144
+		if( empty($shortcodes) )return;
145 145
 		glsr()->render( 'partials/editor/tinymce', [
146 146
 			'shortcodes' => $shortcodes,
147
-		]);
147
+		] );
148 148
 	}
149 149
 
150 150
 	/**
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 	public function routerClearConsole()
154 154
 	{
155 155
 		glsr( Console::class )->clear();
156
-		glsr( Notice::class )->addSuccess( __( 'Console cleared.', 'site-reviews' ));
156
+		glsr( Notice::class )->addSuccess( __( 'Console cleared.', 'site-reviews' ) );
157 157
 	}
158 158
 
159 159
 	/**
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 	{
164 164
 		$counts = glsr( CountsManager::class )->buildCounts();
165 165
 		glsr( OptionManager::class )->set( 'counts', $counts );
166
-		glsr( Notice::class )->addSuccess( __( 'Recalculated review counts.', 'site-reviews' ));
166
+		glsr( Notice::class )->addSuccess( __( 'Recalculated review counts.', 'site-reviews' ) );
167 167
 	}
168 168
 
169 169
 	/**
@@ -197,17 +197,17 @@  discard block
 block discarded – undo
197 197
 	{
198 198
 		$file = $_FILES['import-file'];
199 199
 		if( $file['error'] !== UPLOAD_ERR_OK ) {
200
-			return glsr( Notice::class )->addError( $this->getUploadError( $file['error'] ));
200
+			return glsr( Notice::class )->addError( $this->getUploadError( $file['error'] ) );
201 201
 		}
202
-		if( $file['type'] !== 'application/json' || !glsr( Helper::class )->endsWith( '.json', $file['name'] )) {
203
-			return glsr( Notice::class )->addError( __( 'Please use a valid Site Reviews settings file.', 'site-reviews' ));
202
+		if( $file['type'] !== 'application/json' || !glsr( Helper::class )->endsWith( '.json', $file['name'] ) ) {
203
+			return glsr( Notice::class )->addError( __( 'Please use a valid Site Reviews settings file.', 'site-reviews' ) );
204 204
 		}
205 205
 		$settings = json_decode( file_get_contents( $file['tmp_name'] ), true );
206
-		if( empty( $settings )) {
207
-			return glsr( Notice::class )->addWarning( __( 'There were no settings found to import.', 'site-reviews' ));
206
+		if( empty($settings) ) {
207
+			return glsr( Notice::class )->addWarning( __( 'There were no settings found to import.', 'site-reviews' ) );
208 208
 		}
209
-		glsr( OptionManager::class )->set( glsr( OptionManager::class )->normalize( $settings ));
210
-		glsr( Notice::class )->addSuccess( __( 'Settings imported.', 'site-reviews' ));
209
+		glsr( OptionManager::class )->set( glsr( OptionManager::class )->normalize( $settings ) );
210
+		glsr( Notice::class )->addSuccess( __( 'Settings imported.', 'site-reviews' ) );
211 211
 	}
212 212
 
213 213
 	/**
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 			UPLOAD_ERR_CANT_WRITE => __( 'Failed to write file to disk.', 'site-reviews' ),
226 226
 			UPLOAD_ERR_EXTENSION => __( 'A PHP extension stopped the file upload.', 'site-reviews' ),
227 227
 		];
228
-		return !isset( $errors[$errorCode] )
228
+		return !isset($errors[$errorCode])
229 229
 			? __( 'Unknown upload error.', 'site-reviews' )
230 230
 			: $errors[$errorCode];
231 231
 	}
Please login to merge, or discard this patch.
plugin/Database/CountsManager.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 	 */
47 47
 	public function decrease( array $reviewCounts, $type, $rating )
48 48
 	{
49
-		if( isset( $reviewCounts[$type][$rating] )) {
49
+		if( isset($reviewCounts[$type][$rating]) ) {
50 50
 			$reviewCounts[$type][$rating] = max( 0, $reviewCounts[$type][$rating] - 1 );
51 51
 		}
52 52
 		return $reviewCounts;
@@ -58,8 +58,8 @@  discard block
 block discarded – undo
58 58
 	public function flatten( array $reviewCounts )
59 59
 	{
60 60
 		$counts = [];
61
-		array_walk_recursive( $reviewCounts, function( $num, $index ) use( &$counts ) {
62
-			$counts[$index] = isset( $counts[$index] )
61
+		array_walk_recursive( $reviewCounts, function( $num, $index ) use(&$counts) {
62
+			$counts[$index] = isset($counts[$index])
63 63
 				? $num + $counts[$index]
64 64
 				: $num;
65 65
 		});
@@ -99,10 +99,10 @@  discard block
 block discarded – undo
99 99
 	 */
100 100
 	public function increase( array $reviewCounts, $type, $rating )
101 101
 	{
102
-		if( !array_key_exists( $type, glsr()->reviewTypes )) {
102
+		if( !array_key_exists( $type, glsr()->reviewTypes ) ) {
103 103
 			return $reviewCounts;
104 104
 		}
105
-		if( !array_key_exists( $type, $reviewCounts )) {
105
+		if( !array_key_exists( $type, $reviewCounts ) ) {
106 106
 			$reviewCounts[$type] = [];
107 107
 		}
108 108
 		$reviewCounts = $this->normalize( $reviewCounts );
@@ -118,10 +118,10 @@  discard block
 block discarded – undo
118 118
 	{
119 119
 		$counts = [];
120 120
 		$lastPostId = 0;
121
-		while( $reviews = $this->queryReviews( $args, $lastPostId, $limit )) {
122
-			$types = array_keys( array_flip( array_column( $reviews, 'type' )));
121
+		while( $reviews = $this->queryReviews( $args, $lastPostId, $limit ) ) {
122
+			$types = array_keys( array_flip( array_column( $reviews, 'type' ) ) );
123 123
 			foreach( $types as $type ) {
124
-				if( isset( $counts[$type] ))continue;
124
+				if( isset($counts[$type]) )continue;
125 125
 				$counts[$type] = array_fill_keys( range( 0, Rating::MAX_RATING ), 0 );
126 126
 			}
127 127
 			foreach( $reviews as $review ) {
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 	{
140 140
 		foreach( $reviewCounts as &$counts ) {
141 141
 			foreach( range( 0, Rating::MAX_RATING ) as $index ) {
142
-				if( isset( $counts[$index] ))continue;
142
+				if( isset($counts[$index]) )continue;
143 143
 				$counts[$index] = 0;
144 144
 			}
145 145
 			ksort( $counts );
@@ -154,14 +154,14 @@  discard block
 block discarded – undo
154 154
 	 */
155 155
 	protected function queryReviews( array $args = [], $lastPostId, $limit )
156 156
 	{
157
-		$args = wp_parse_args( $args, array_fill_keys( ['post_id', 'term_id'], '' ));
158
-		if( empty( array_filter( $args ))) {
157
+		$args = wp_parse_args( $args, array_fill_keys( ['post_id', 'term_id'], '' ) );
158
+		if( empty(array_filter( $args )) ) {
159 159
 			return glsr( SqlQueries::class )->getCounts( $lastPostId, $limit );
160 160
 		}
161
-		if( !empty( $args['post_id'] )) {
161
+		if( !empty($args['post_id']) ) {
162 162
 			return glsr( SqlQueries::class )->getPostCounts( $args['post_id'], $lastPostId, $limit );
163 163
 		}
164
-		if( !empty( $args['term_id'] )) {
164
+		if( !empty($args['term_id']) ) {
165 165
 			return glsr( SqlQueries::class )->getTermCounts( $args['term_id'], $lastPostId, $limit );
166 166
 		}
167 167
 	}
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -121,7 +121,9 @@  discard block
 block discarded – undo
121 121
 		while( $reviews = $this->queryReviews( $args, $lastPostId, $limit )) {
122 122
 			$types = array_keys( array_flip( array_column( $reviews, 'type' )));
123 123
 			foreach( $types as $type ) {
124
-				if( isset( $counts[$type] ))continue;
124
+				if( isset( $counts[$type] )) {
125
+					continue;
126
+				}
125 127
 				$counts[$type] = array_fill_keys( range( 0, Rating::MAX_RATING ), 0 );
126 128
 			}
127 129
 			foreach( $reviews as $review ) {
@@ -139,7 +141,9 @@  discard block
 block discarded – undo
139 141
 	{
140 142
 		foreach( $reviewCounts as &$counts ) {
141 143
 			foreach( range( 0, Rating::MAX_RATING ) as $index ) {
142
-				if( isset( $counts[$index] ))continue;
144
+				if( isset( $counts[$index] )) {
145
+					continue;
146
+				}
143 147
 				$counts[$index] = 0;
144 148
 			}
145 149
 			ksort( $counts );
Please login to merge, or discard this patch.