Test Failed
Push — hotfix/fix-counts ( 1fe4ce...872cd6 )
by Paul
03:14
created
plugin/Filters.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -41,33 +41,33 @@
 block discarded – undo
41 41
 	 */
42 42
 	public function run()
43 43
 	{
44
-		add_filter( 'map_meta_cap',                                            [$this->admin, 'filterCreateCapability'], 10, 2 );
45
-		add_filter( 'mce_external_plugins',                                    [$this->admin, 'filterTinymcePlugins'], 15 );
46
-		add_filter( 'plugin_action_links_'.$this->basename,                    [$this->admin, 'filterActionLinks'] );
47
-		add_filter( 'dashboard_glance_items',                                  [$this->admin, 'filterDashboardGlanceItems'] );
48
-		add_filter( 'block_categories',                                        [$this->blocks, 'filterBlockCategories'] );
49
-		add_filter( 'classic_editor_enabled_editors_for_post_type',            [$this->blocks, 'filterEnabledEditors'], 10, 2 );
50
-		add_filter( 'use_block_editor_for_post_type',                          [$this->blocks, 'filterUseBlockEditor'], 10, 2 );
51
-		add_filter( 'wp_editor_settings',                                      [$this->editor, 'filterEditorSettings'] );
52
-		add_filter( 'the_editor',                                              [$this->editor, 'filterEditorTextarea'] );
53
-		add_filter( 'gettext',                                                 [$this->editor, 'filterPostStatusLabels'], 10, 3 );
54
-		add_filter( 'gettext_with_context',                                    [$this->editor, 'filterPostStatusLabelsWithContext'], 10, 4 );
55
-		add_filter( 'post_updated_messages',                                   [$this->editor, 'filterUpdateMessages'] );
56
-		add_filter( 'bulk_post_updated_messages',                              [$this->listtable, 'filterBulkUpdateMessages'], 10, 2 );
57
-		add_filter( 'manage_'.Application::POST_TYPE.'_posts_columns',         [$this->listtable, 'filterColumnsForPostType'] );
58
-		add_filter( 'post_date_column_status',                                 [$this->listtable, 'filterDateColumnStatus'], 10, 2 );
59
-		add_filter( 'default_hidden_columns',                                  [$this->listtable, 'filterDefaultHiddenColumns'], 10, 2 );
60
-		add_filter( 'display_post_states',                                     [$this->listtable, 'filterPostStates'], 10, 2 );
61
-		add_filter( 'post_row_actions',                                        [$this->listtable, 'filterRowActions'], 10, 2 );
44
+		add_filter( 'map_meta_cap', [$this->admin, 'filterCreateCapability'], 10, 2 );
45
+		add_filter( 'mce_external_plugins', [$this->admin, 'filterTinymcePlugins'], 15 );
46
+		add_filter( 'plugin_action_links_'.$this->basename, [$this->admin, 'filterActionLinks'] );
47
+		add_filter( 'dashboard_glance_items', [$this->admin, 'filterDashboardGlanceItems'] );
48
+		add_filter( 'block_categories', [$this->blocks, 'filterBlockCategories'] );
49
+		add_filter( 'classic_editor_enabled_editors_for_post_type', [$this->blocks, 'filterEnabledEditors'], 10, 2 );
50
+		add_filter( 'use_block_editor_for_post_type', [$this->blocks, 'filterUseBlockEditor'], 10, 2 );
51
+		add_filter( 'wp_editor_settings', [$this->editor, 'filterEditorSettings'] );
52
+		add_filter( 'the_editor', [$this->editor, 'filterEditorTextarea'] );
53
+		add_filter( 'gettext', [$this->editor, 'filterPostStatusLabels'], 10, 3 );
54
+		add_filter( 'gettext_with_context', [$this->editor, 'filterPostStatusLabelsWithContext'], 10, 4 );
55
+		add_filter( 'post_updated_messages', [$this->editor, 'filterUpdateMessages'] );
56
+		add_filter( 'bulk_post_updated_messages', [$this->listtable, 'filterBulkUpdateMessages'], 10, 2 );
57
+		add_filter( 'manage_'.Application::POST_TYPE.'_posts_columns', [$this->listtable, 'filterColumnsForPostType'] );
58
+		add_filter( 'post_date_column_status', [$this->listtable, 'filterDateColumnStatus'], 10, 2 );
59
+		add_filter( 'default_hidden_columns', [$this->listtable, 'filterDefaultHiddenColumns'], 10, 2 );
60
+		add_filter( 'display_post_states', [$this->listtable, 'filterPostStates'], 10, 2 );
61
+		add_filter( 'post_row_actions', [$this->listtable, 'filterRowActions'], 10, 2 );
62 62
 		add_filter( 'manage_edit-'.Application::POST_TYPE.'_sortable_columns', [$this->listtable, 'filterSortableColumns'] );
63
-		add_filter( 'ngettext',                                                [$this->listtable, 'filterStatusText'], 10, 5 );
64
-		add_filter( 'script_loader_tag',                                       [$this->public, 'filterEnqueuedScripts'], 10, 2 );
65
-		add_filter( 'site-reviews/config/forms/submission-form',               [$this->public, 'filterFieldOrder'], 11 );
66
-		add_filter( 'query_vars',                                              [$this->public, 'filterQueryVars'] );
67
-		add_filter( 'site-reviews/render/view',                                [$this->public, 'filterRenderView'] );
68
-		add_filter( 'gettext',                                                 [$this->translator, 'filterGettext'], 10, 3 );
69
-		add_filter( 'gettext_with_context',                                    [$this->translator, 'filterGettextWithContext'], 10, 4 );
70
-		add_filter( 'ngettext',                                                [$this->translator, 'filterNgettext'], 10, 5 );
71
-		add_filter( 'ngettext_with_context',                                   [$this->translator, 'filterNgettextWithContext'], 10, 6 );
63
+		add_filter( 'ngettext', [$this->listtable, 'filterStatusText'], 10, 5 );
64
+		add_filter( 'script_loader_tag', [$this->public, 'filterEnqueuedScripts'], 10, 2 );
65
+		add_filter( 'site-reviews/config/forms/submission-form', [$this->public, 'filterFieldOrder'], 11 );
66
+		add_filter( 'query_vars', [$this->public, 'filterQueryVars'] );
67
+		add_filter( 'site-reviews/render/view', [$this->public, 'filterRenderView'] );
68
+		add_filter( 'gettext', [$this->translator, 'filterGettext'], 10, 3 );
69
+		add_filter( 'gettext_with_context', [$this->translator, 'filterGettextWithContext'], 10, 4 );
70
+		add_filter( 'ngettext', [$this->translator, 'filterNgettext'], 10, 5 );
71
+		add_filter( 'ngettext_with_context', [$this->translator, 'filterNgettextWithContext'], 10, 6 );
72 72
 	}
73 73
 }
Please login to merge, or discard this patch.
plugin/Database/SqlQueries.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -22,11 +22,11 @@  discard block
 block discarded – undo
22 22
 	 */
23 23
 	public function deleteAllSessions( $sessionCookiePrefix )
24 24
 	{
25
-		return $this->db->query("
25
+		return $this->db->query( "
26 26
 			DELETE
27 27
 			FROM {$this->db->options}
28 28
 			WHERE option_name LIKE '{$sessionCookiePrefix}_%'
29
-		");
29
+		" );
30 30
 	}
31 31
 
32 32
 	/**
@@ -35,11 +35,11 @@  discard block
 block discarded – undo
35 35
 	 */
36 36
 	public function deleteExpiredSessions( $expiredSessions )
37 37
 	{
38
-		return $this->db->query("
38
+		return $this->db->query( "
39 39
 			DELETE
40 40
 			FROM {$this->db->options}
41 41
 			WHERE option_name IN ('{$expiredSessions}')
42
-		");
42
+		" );
43 43
 	}
44 44
 
45 45
 	/**
@@ -49,13 +49,13 @@  discard block
 block discarded – undo
49 49
 	 */
50 50
 	public function getExpiredSessions( $sessionCookiePrefix, $limit )
51 51
 	{
52
-		return (array) $this->db->get_results("
52
+		return (array)$this->db->get_results( "
53 53
 			SELECT option_name AS name, option_value AS expiration
54 54
 			FROM {$this->db->options}
55 55
 			WHERE option_name LIKE '{$sessionCookiePrefix}_expires_%'
56 56
 			ORDER BY option_value ASC
57 57
 			LIMIT 0, {$limit}
58
-		");
58
+		" );
59 59
 	}
60 60
 
61 61
 	/**
@@ -64,14 +64,14 @@  discard block
 block discarded – undo
64 64
 	 */
65 65
 	public function getPostIdFromReviewId( $metaReviewId )
66 66
 	{
67
-		$postId = $this->db->get_var("
67
+		$postId = $this->db->get_var( "
68 68
 			SELECT p.ID
69 69
 			FROM {$this->db->posts} AS p
70 70
 			INNER JOIN {$this->db->postmeta} AS m ON p.ID = m.post_id
71 71
 			WHERE p.post_type = '{$this->postType}'
72 72
 			AND m.meta_key = 'review_id'
73 73
 			AND m.meta_value = '{$metaReviewId}'
74
-		");
74
+		" );
75 75
 		return intval( $postId );
76 76
 	}
77 77
 
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 	 */
83 83
 	public function getReviewCounts( array $args, $lastPostId = 0, $limit = 500 )
84 84
 	{
85
-		return (array) $this->db->get_results("
85
+		return (array)$this->db->get_results( "
86 86
 			SELECT DISTINCT p.ID, m1.meta_value AS rating, m2.meta_value AS type
87 87
 			FROM {$this->db->posts} AS p
88 88
 			INNER JOIN {$this->db->postmeta} AS m1 ON p.ID = m1.post_id
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 			{$this->getAndForCounts( $args )}
97 97
 			ORDER By p.ID ASC
98 98
 			LIMIT {$limit}
99
-		");
99
+		" );
100 100
 	}
101 101
 
102 102
 	/**
@@ -106,14 +106,14 @@  discard block
 block discarded – undo
106 106
 	 */
107 107
 	public function getReviewCountsFor( $metaKey )
108 108
 	{
109
-		return (array) $this->db->get_results("
109
+		return (array)$this->db->get_results( "
110 110
 			SELECT DISTINCT m.meta_value AS name, COUNT(*) num_posts
111 111
 			FROM {$this->db->posts} AS p
112 112
 			INNER JOIN {$this->db->postmeta} AS m ON p.ID = m.post_id
113 113
 			WHERE p.post_type = '{$this->postType}'
114 114
 			AND m.meta_key = '{$metaKey}'
115 115
 			GROUP BY name
116
-		");
116
+		" );
117 117
 	}
118 118
 
119 119
 	/**
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 	 */
124 124
 	public function getReviewIdsByType( $reviewType )
125 125
 	{
126
-		$results = $this->db->get_col("
126
+		$results = $this->db->get_col( "
127 127
 			SELECT DISTINCT m1.meta_value AS review_id
128 128
 			FROM {$this->db->posts} AS p
129 129
 			INNER JOIN {$this->db->postmeta} AS m1 ON p.ID = m1.post_id
@@ -132,8 +132,8 @@  discard block
 block discarded – undo
132 132
 			AND m1.meta_key = 'review_id'
133 133
 			AND m2.meta_key = 'review_type'
134 134
 			AND m2.meta_value = '{$reviewType}'
135
-		");
136
-		return array_keys( array_flip( $results ));
135
+		" );
136
+		return array_keys( array_flip( $results ) );
137 137
 	}
138 138
 
139 139
 	/**
@@ -144,9 +144,9 @@  discard block
 block discarded – undo
144 144
 	public function getReviewRatingsFromIds( array $postIds, $greaterThanId = 0, $limit = 100 )
145 145
 	{
146 146
 		sort( $postIds );
147
-		$postIds = array_slice( $postIds, intval( array_search( $greaterThanId, $postIds )), $limit );
147
+		$postIds = array_slice( $postIds, intval( array_search( $greaterThanId, $postIds ) ), $limit );
148 148
 		$postIds = implode( ',', $postIds );
149
-		return (array) $this->db->get_results("
149
+		return (array)$this->db->get_results( "
150 150
 			SELECT p.ID, m.meta_value AS rating
151 151
 			FROM {$this->db->posts} AS p
152 152
 			INNER JOIN {$this->db->postmeta} AS m ON p.ID = m.post_id
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 			GROUP BY p.ID
159 159
 			ORDER By p.ID ASC
160 160
 			LIMIT {$limit}
161
-		");
161
+		" );
162 162
 	}
163 163
 
164 164
 	/**
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 	 */
169 169
 	public function getReviewsMeta( $key, $status = 'publish' )
170 170
 	{
171
-		$values = $this->db->get_col("
171
+		$values = $this->db->get_col( "
172 172
 			SELECT DISTINCT m.meta_value
173 173
 			FROM {$this->db->postmeta} m
174 174
 			LEFT JOIN {$this->db->posts} p ON p.ID = m.post_id
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 			AND p.post_status = '{$status}'
179 179
 			GROUP BY p.ID -- remove duplicate meta_value entries
180 180
 			ORDER BY m.meta_id ASC -- sort by oldest meta_value
181
-		");
181
+		" );
182 182
 		sort( $values );
183 183
 		return $values;
184 184
 	}
@@ -189,16 +189,16 @@  discard block
 block discarded – undo
189 189
 	 */
190 190
 	protected function getAndForCounts( array $args, $and = '' )
191 191
 	{
192
-		$postIds = implode( ',', array_filter( glsr_get( $args, 'post_ids')));
193
-		$termIds = implode( ',', array_filter( glsr_get( $args, 'term_ids')));
194
-		if( !empty( $args['type'] )) {
195
-			$and.= "AND m2.meta_value = '{$args['type']}' ";
192
+		$postIds = implode( ',', array_filter( glsr_get( $args, 'post_ids' ) ) );
193
+		$termIds = implode( ',', array_filter( glsr_get( $args, 'term_ids' ) ) );
194
+		if( !empty($args['type']) ) {
195
+			$and .= "AND m2.meta_value = '{$args['type']}' ";
196 196
 		}
197 197
 		if( $postIds ) {
198
-			$and.= "AND m3.meta_key = 'assigned_to' AND m3.meta_value IN ({$postIds}) ";
198
+			$and .= "AND m3.meta_key = 'assigned_to' AND m3.meta_value IN ({$postIds}) ";
199 199
 		}
200 200
 		if( $termIds ) {
201
-			$and.= "AND tr.term_taxonomy_id IN ({$termIds}) ";
201
+			$and .= "AND tr.term_taxonomy_id IN ({$termIds}) ";
202 202
 		}
203 203
 		return $and;
204 204
 	}
@@ -209,11 +209,11 @@  discard block
 block discarded – undo
209 209
 	 */
210 210
 	protected function getInnerJoinForCounts( array $args, $innerJoin = '' )
211 211
 	{
212
-		if( !empty( glsr_get( $args, 'post_ids'))) {
213
-			$innerJoin.= "INNER JOIN {$this->db->postmeta} AS m3 ON p.ID = m3.post_id ";
212
+		if( !empty(glsr_get( $args, 'post_ids' )) ) {
213
+			$innerJoin .= "INNER JOIN {$this->db->postmeta} AS m3 ON p.ID = m3.post_id ";
214 214
 		}
215
-		if( !empty( glsr_get( $args, 'term_ids'))) {
216
-			$innerJoin.= "INNER JOIN {$this->db->term_relationships} AS tr ON p.ID = tr.object_id ";
215
+		if( !empty(glsr_get( $args, 'term_ids' )) ) {
216
+			$innerJoin .= "INNER JOIN {$this->db->term_relationships} AS tr ON p.ID = tr.object_id ";
217 217
 		}
218 218
 		return $innerJoin;
219 219
 	}
Please login to merge, or discard this patch.
plugin/Database/CountsManager.php 1 patch
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -30,12 +30,12 @@  discard block
 block discarded – undo
30 30
 		$query = $this->queryReviews( $args );
31 31
 		while( $query ) {
32 32
 			// glsr_log($query);
33
-			$types = array_keys( array_flip( glsr_array_column( $query->reviews, 'type' )));
34
-			$types = array_unique( array_merge( ['local'], $types ));
33
+			$types = array_keys( array_flip( glsr_array_column( $query->reviews, 'type' ) ) );
34
+			$types = array_unique( array_merge( ['local'], $types ) );
35 35
 			foreach( $types as $type ) {
36 36
 				$type = $this->normalizeType( $type );
37
-				if( isset( $counts[$type] ))continue;
38
-				$counts[$type] = array_fill_keys( range( 0, glsr()->constant( 'MAX_RATING', Rating::class )), 0 );
37
+				if( isset($counts[$type]) )continue;
38
+				$counts[$type] = array_fill_keys( range( 0, glsr()->constant( 'MAX_RATING', Rating::class ) ), 0 );
39 39
 			}
40 40
 			foreach( $query->reviews as $review ) {
41 41
 				$type = $this->normalizeType( $review->type );
@@ -73,11 +73,11 @@  discard block
 block discarded – undo
73 73
 	{
74 74
 		$terms = glsr( Database::class )->getTerms( ['fields' => 'all'] );
75 75
 		foreach( $terms as $term ) {
76
-			$this->setTermCounts( $term->term_id, $this->buildTermCounts( $term->term_taxonomy_id ));
76
+			$this->setTermCounts( $term->term_id, $this->buildTermCounts( $term->term_taxonomy_id ) );
77 77
 		}
78 78
 		$postIds = glsr( SqlQueries::class )->getReviewsMeta( 'assigned_to' );
79 79
 		foreach( $postIds as $postId ) {
80
-			$this->setPostCounts( $postId, $this->buildPostCounts( $postId ));
80
+			$this->setPostCounts( $postId, $this->buildPostCounts( $postId ) );
81 81
 		}
82 82
 		$this->setCounts( $this->buildCounts() );
83 83
 	}
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 			$this->getCounts(),
102 102
 			$review->review_type,
103 103
 			$review->rating
104
-		));
104
+		) );
105 105
 	}
106 106
 
107 107
 	/**
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 	 */
110 110
 	public function decreasePostCounts( Review $review )
111 111
 	{
112
-		if( empty( $counts = $this->getPostCounts( $review->assigned_to )))return;
112
+		if( empty($counts = $this->getPostCounts( $review->assigned_to )) )return;
113 113
 		$counts = $this->decreaseRating( $counts, $review->review_type, $review->rating );
114 114
 		$this->setPostCounts( $review->assigned_to, $counts );
115 115
 	}
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 	public function decreaseTermCounts( Review $review )
121 121
 	{
122 122
 		foreach( $review->term_ids as $termId ) {
123
-			if( empty( $counts = $this->getTermCounts( $termId )))continue;
123
+			if( empty($counts = $this->getTermCounts( $termId )) )continue;
124 124
 			$counts = $this->decreaseRating( $counts, $review->review_type, $review->rating );
125 125
 			$this->setTermCounts( $termId, $counts );
126 126
 		}
@@ -132,15 +132,15 @@  discard block
 block discarded – undo
132 132
 	public function flatten( array $reviewCounts, array $args = [] )
133 133
 	{
134 134
 		$counts = [];
135
-		array_walk_recursive( $reviewCounts, function( $num, $index ) use( &$counts ) {
136
-			$counts[$index] = $num + intval( glsr_get( $counts, $index, 0 ));
135
+		array_walk_recursive( $reviewCounts, function( $num, $index ) use(&$counts) {
136
+			$counts[$index] = $num + intval( glsr_get( $counts, $index, 0 ) );
137 137
 		});
138 138
 		$args = wp_parse_args( $args, [
139 139
 			'max' => glsr()->constant( 'MAX_RATING', Rating::class ),
140 140
 			'min' => glsr()->constant( 'MIN_RATING', Rating::class ),
141
-		]);
141
+		] );
142 142
 		foreach( $counts as $index => &$num ) {
143
-			if( $index >= intval( $args['min'] ) && $index <= intval( $args['max'] ))continue;
143
+			if( $index >= intval( $args['min'] ) && $index <= intval( $args['max'] ) )continue;
144 144
 			$num = 0;
145 145
 		}
146 146
 		return $counts;
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 	{
154 154
 		$args = $this->normalizeArgs( $args );
155 155
 		$counts = [];
156
-		if( $this->isMixedCount( $args )) {
156
+		if( $this->isMixedCount( $args ) ) {
157 157
 			$counts = [$this->buildCounts( $args )]; // force query the database
158 158
 		}
159 159
 		else {
@@ -163,13 +163,13 @@  discard block
 block discarded – undo
163 163
 			foreach( $args['term_ids'] as $termId ) {
164 164
 				$counts[] = $this->getTermCounts( $termId );
165 165
 			}
166
-			if( empty( $counts )) {
166
+			if( empty($counts) ) {
167 167
 				$counts[] = $this->getCounts();
168 168
 			}
169 169
 		}
170 170
 		return in_array( $args['type'], ['', 'all'] )
171 171
 			? $this->normalize( [$this->flatten( $counts )] )
172
-			: $this->normalize( glsr_array_column( $counts, $args['type'] ));
172
+			: $this->normalize( glsr_array_column( $counts, $args['type'] ) );
173 173
 	}
174 174
 
175 175
 	/**
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 	public function getCounts()
179 179
 	{
180 180
 		$counts = glsr( OptionManager::class )->get( 'counts', [] );
181
-		if( !is_array( $counts )) {
181
+		if( !is_array( $counts ) ) {
182 182
 			glsr_log()->error( '$counts is not an array' )->debug( $counts );
183 183
 			return [];
184 184
 		}
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 	 */
192 192
 	public function getPostCounts( $postId )
193 193
 	{
194
-		return array_filter( (array)get_post_meta( $postId, static::META_COUNT, true ));
194
+		return array_filter( (array)get_post_meta( $postId, static::META_COUNT, true ) );
195 195
 	}
196 196
 
197 197
 	/**
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 	 */
201 201
 	public function getTermCounts( $termId )
202 202
 	{
203
-		return array_filter( (array)get_term_meta( $termId, static::META_COUNT, true ));
203
+		return array_filter( (array)get_term_meta( $termId, static::META_COUNT, true ) );
204 204
 	}
205 205
 
206 206
 	/**
@@ -218,10 +218,10 @@  discard block
 block discarded – undo
218 218
 	 */
219 219
 	public function increaseCounts( Review $review )
220 220
 	{
221
-		if( empty( $counts = $this->getCounts() )) {
221
+		if( empty($counts = $this->getCounts()) ) {
222 222
 			$counts = $this->buildCounts();
223 223
 		}
224
-		$this->setCounts( $this->increaseRating( $counts, $review->review_type, $review->rating ));
224
+		$this->setCounts( $this->increaseRating( $counts, $review->review_type, $review->rating ) );
225 225
 	}
226 226
 
227 227
 	/**
@@ -229,9 +229,9 @@  discard block
 block discarded – undo
229 229
 	 */
230 230
 	public function increasePostCounts( Review $review )
231 231
 	{
232
-		if( !( get_post( $review->assigned_to ) instanceof WP_Post ))return;
232
+		if( !(get_post( $review->assigned_to ) instanceof WP_Post) )return;
233 233
 		$counts = $this->getPostCounts( $review->assigned_to );
234
-		$counts = empty( $counts )
234
+		$counts = empty($counts)
235 235
 			? $this->buildPostCounts( $review->assigned_to )
236 236
 			: $this->increaseRating( $counts, $review->review_type, $review->rating );
237 237
 		$this->setPostCounts( $review->assigned_to, $counts );
@@ -242,10 +242,10 @@  discard block
 block discarded – undo
242 242
 	 */
243 243
 	public function increaseTermCounts( Review $review )
244 244
 	{
245
-		$terms = glsr( ReviewManager::class )->normalizeTerms( implode( ',', $review->term_ids ));
245
+		$terms = glsr( ReviewManager::class )->normalizeTerms( implode( ',', $review->term_ids ) );
246 246
 		foreach( $terms as $term ) {
247 247
 			$counts = $this->getTermCounts( $term['term_id'] );
248
-			$counts = empty( $counts )
248
+			$counts = empty($counts)
249 249
 				? $this->buildTermCounts( $term['term_taxonomy_id'] )
250 250
 				: $this->increaseRating( $counts, $review->review_type, $review->rating );
251 251
 			$this->setTermCounts( $term['term_id'], $counts );
@@ -268,8 +268,8 @@  discard block
 block discarded – undo
268 268
 	{
269 269
 		$ratingCounts = $this->flatten( $reviewCounts );
270 270
 		update_post_meta( $postId, static::META_COUNT, $reviewCounts );
271
-		update_post_meta( $postId, static::META_AVERAGE, glsr( Rating::class )->getAverage( $ratingCounts ));
272
-		update_post_meta( $postId, static::META_RANKING, glsr( Rating::class )->getRanking( $ratingCounts ));
271
+		update_post_meta( $postId, static::META_AVERAGE, glsr( Rating::class )->getAverage( $ratingCounts ) );
272
+		update_post_meta( $postId, static::META_RANKING, glsr( Rating::class )->getRanking( $ratingCounts ) );
273 273
 	}
274 274
 
275 275
 	/**
@@ -279,11 +279,11 @@  discard block
 block discarded – undo
279 279
 	public function setTermCounts( $termId, array $reviewCounts )
280 280
 	{
281 281
 		$term = get_term( $termId, Application::TAXONOMY );
282
-		if( !isset( $term->term_id ))return;
282
+		if( !isset($term->term_id) )return;
283 283
 		$ratingCounts = $this->flatten( $reviewCounts );
284 284
 		update_term_meta( $termId, static::META_COUNT, $reviewCounts );
285
-		update_term_meta( $termId, static::META_AVERAGE, glsr( Rating::class )->getAverage( $ratingCounts ));
286
-		update_term_meta( $termId, static::META_RANKING, glsr( Rating::class )->getRanking( $ratingCounts ));
285
+		update_term_meta( $termId, static::META_AVERAGE, glsr( Rating::class )->getAverage( $ratingCounts ) );
286
+		update_term_meta( $termId, static::META_RANKING, glsr( Rating::class )->getRanking( $ratingCounts ) );
287 287
 	}
288 288
 
289 289
 	/**
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 	 */
294 294
 	protected function decreaseRating( array $reviewCounts, $type, $rating )
295 295
 	{
296
-		if( isset( $reviewCounts[$type][$rating] )) {
296
+		if( isset($reviewCounts[$type][$rating]) ) {
297 297
 			$reviewCounts[$type][$rating] = max( 0, $reviewCounts[$type][$rating] - 1 );
298 298
 		}
299 299
 		return $reviewCounts;
@@ -306,10 +306,10 @@  discard block
 block discarded – undo
306 306
 	 */
307 307
 	protected function increaseRating( array $reviewCounts, $type, $rating )
308 308
 	{
309
-		if( !array_key_exists( $type, glsr()->reviewTypes )) {
309
+		if( !array_key_exists( $type, glsr()->reviewTypes ) ) {
310 310
 			return $reviewCounts;
311 311
 		}
312
-		if( !array_key_exists( $type, $reviewCounts )) {
312
+		if( !array_key_exists( $type, $reviewCounts ) ) {
313 313
 			$reviewCounts[$type] = [];
314 314
 		}
315 315
 		$reviewCounts = $this->normalize( $reviewCounts );
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 	 */
323 323
 	protected function isMixedCount( array $args )
324 324
 	{
325
-		return !empty( $args['post_ids'] ) && !empty( $args['term_ids'] );
325
+		return !empty($args['post_ids']) && !empty($args['term_ids']);
326 326
 	}
327 327
 
328 328
 	/**
@@ -330,12 +330,12 @@  discard block
 block discarded – undo
330 330
 	 */
331 331
 	protected function normalize( array $reviewCounts )
332 332
 	{
333
-		if( empty( $reviewCounts )) {
333
+		if( empty($reviewCounts) ) {
334 334
 			$reviewCounts = [[]];
335 335
 		}
336 336
 		foreach( $reviewCounts as &$counts ) {
337
-			foreach( range( 0, glsr()->constant( 'MAX_RATING', Rating::class )) as $index ) {
338
-				if( isset( $counts[$index] ))continue;
337
+			foreach( range( 0, glsr()->constant( 'MAX_RATING', Rating::class ) ) as $index ) {
338
+				if( isset($counts[$index]) )continue;
339 339
 				$counts[$index] = 0;
340 340
 			}
341 341
 			ksort( $counts );
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
 			'post_ids' => [],
353 353
 			'term_ids' => [],
354 354
 			'type' => 'local',
355
-		]);
355
+		] );
356 356
 		$args['post_ids'] = glsr( Polylang::class )->getPostIds( $args['post_ids'] );
357 357
 		$args['type'] = $this->normalizeType( $args['type'] );
358 358
 		return $args;
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
 	 */
365 365
 	protected function normalizeType( $type )
366 366
 	{
367
-		return empty( $type ) || !is_string( $type )
367
+		return empty($type) || !is_string( $type )
368 368
 			? 'local'
369 369
 			: $type;
370 370
 	}
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
 		$hasMore = is_array( $reviews )
380 380
 			? count( $reviews ) == static::LIMIT
381 381
 			: false;
382
-		return (object) [
382
+		return (object)[
383 383
 			'has_more' => $hasMore,
384 384
 			'reviews' => $reviews,
385 385
 		];
Please login to merge, or discard this patch.