Completed
Push — master ( f6bd31...2d18f7 )
by
unknown
02:24
created
src/ConstraintParameterRenderer.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -62,20 +62,20 @@  discard block
 block discarded – undo
62 62
 	 *
63 63
 	 * @return string HTML
64 64
 	 */
65
-	public function formatValue( $value ) {
66
-		if ( is_string( $value ) ) {
65
+	public function formatValue($value) {
66
+		if (is_string($value)) {
67 67
 			// Cases like 'Format' 'pattern' or 'minimum'/'maximum' values, which we have stored as
68 68
 			// strings
69
-			return htmlspecialchars( $value );
70
-		} elseif ( $value instanceof EntityId ) {
69
+			return htmlspecialchars($value);
70
+		} elseif ($value instanceof EntityId) {
71 71
 			// Cases like 'Conflicts with' 'property', to which we can link
72
-			return $this->formatEntityId( $value );
73
-		} elseif ( $value instanceof ItemIdSnakValue ) {
72
+			return $this->formatEntityId($value);
73
+		} elseif ($value instanceof ItemIdSnakValue) {
74 74
 			// Cases like EntityId but can also be somevalue or novalue
75
-			return $this->formatItemIdSnakValue( $value );
75
+			return $this->formatItemIdSnakValue($value);
76 76
 		} else {
77 77
 			// Cases where we format a DataValue
78
-			return $this->formatDataValue( $value );
78
+			return $this->formatDataValue($value);
79 79
 		}
80 80
 	}
81 81
 
@@ -86,23 +86,23 @@  discard block
 block discarded – undo
86 86
 	 *
87 87
 	 * @return string HTML
88 88
 	 */
89
-	public function formatParameters( $parameters ) {
90
-		if ( $parameters === null || count( $parameters ) == 0 ) {
89
+	public function formatParameters($parameters) {
90
+		if ($parameters === null || count($parameters) == 0) {
91 91
 			return null;
92 92
 		}
93 93
 
94
-		$valueFormatter = function ( $value ) {
95
-			return $this->formatValue( $value );
94
+		$valueFormatter = function($value) {
95
+			return $this->formatValue($value);
96 96
 		};
97 97
 
98 98
 		$formattedParameters = [];
99
-		foreach ( $parameters as $parameterName => $parameterValue ) {
100
-			$formattedParameterValues = implode( ', ',
101
-				$this->limitArrayLength( array_map( $valueFormatter, $parameterValue ) ) );
102
-			$formattedParameters[] = sprintf( '%s: %s', $parameterName, $formattedParameterValues );
99
+		foreach ($parameters as $parameterName => $parameterValue) {
100
+			$formattedParameterValues = implode(', ',
101
+				$this->limitArrayLength(array_map($valueFormatter, $parameterValue)));
102
+			$formattedParameters[] = sprintf('%s: %s', $parameterName, $formattedParameterValues);
103 103
 		}
104 104
 
105
-		return implode( '; ', $formattedParameters );
105
+		return implode('; ', $formattedParameters);
106 106
 	}
107 107
 
108 108
 	/**
@@ -112,10 +112,10 @@  discard block
 block discarded – undo
112 112
 	 *
113 113
 	 * @return array
114 114
 	 */
115
-	private function limitArrayLength( array $array ) {
116
-		if ( count( $array ) > self::MAX_PARAMETER_ARRAY_LENGTH ) {
117
-			$array = array_slice( $array, 0, self::MAX_PARAMETER_ARRAY_LENGTH );
118
-			array_push( $array, '...' );
115
+	private function limitArrayLength(array $array) {
116
+		if (count($array) > self::MAX_PARAMETER_ARRAY_LENGTH) {
117
+			$array = array_slice($array, 0, self::MAX_PARAMETER_ARRAY_LENGTH);
118
+			array_push($array, '...');
119 119
 		}
120 120
 
121 121
 		return $array;
@@ -125,16 +125,16 @@  discard block
 block discarded – undo
125 125
 	 * @param DataValue $value
126 126
 	 * @return string HTML
127 127
 	 */
128
-	public function formatDataValue( DataValue $value ) {
129
-		return $this->dataValueFormatter->format( $value );
128
+	public function formatDataValue(DataValue $value) {
129
+		return $this->dataValueFormatter->format($value);
130 130
 	}
131 131
 
132 132
 	/**
133 133
 	 * @param EntityId $entityId
134 134
 	 * @return string HTML
135 135
 	 */
136
-	public function formatEntityId( EntityId $entityId ) {
137
-		return $this->entityIdLabelFormatter->formatEntityId( $entityId );
136
+	public function formatEntityId(EntityId $entityId) {
137
+		return $this->entityIdLabelFormatter->formatEntityId($entityId);
138 138
 	}
139 139
 
140 140
 	/**
@@ -143,14 +143,14 @@  discard block
 block discarded – undo
143 143
 	 * @param ItemIdSnakValue $value
144 144
 	 * @return string HTML
145 145
 	 */
146
-	public function formatItemIdSnakValue( ItemIdSnakValue $value ) {
147
-		switch ( true ) {
146
+	public function formatItemIdSnakValue(ItemIdSnakValue $value) {
147
+		switch (true) {
148 148
 			case $value->isValue():
149
-				return $this->formatEntityId( $value->getItemId() );
149
+				return $this->formatEntityId($value->getItemId());
150 150
 			case $value->isSomeValue():
151
-				return wfMessage( 'wikibase-snakview-snaktypeselector-somevalue' )->escaped();
151
+				return wfMessage('wikibase-snakview-snaktypeselector-somevalue')->escaped();
152 152
 			case $value->isNoValue():
153
-				return wfMessage( 'wikibase-snakview-snaktypeselector-novalue' )->escaped();
153
+				return wfMessage('wikibase-snakview-snaktypeselector-novalue')->escaped();
154 154
 		}
155 155
 	}
156 156
 
Please login to merge, or discard this patch.
src/ConstraintCheck/Cache/DependencyMetadata.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	 * @param EntityId $entityId An entity ID from which the value was derived.
38 38
 	 * @return self Indication that a value was derived from the entity with the given ID.
39 39
 	 */
40
-	public static function ofEntityId( EntityId $entityId ) {
40
+	public static function ofEntityId(EntityId $entityId) {
41 41
 		$ret = new self;
42 42
 		$ret->entityIds[] = $entityId;
43 43
 		return $ret;
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	 * @return self Indication that a value will only remain valid
50 50
 	 * as long as the given time value is in the future, not in the past.
51 51
 	 */
52
-	public static function ofFutureTime( TimeValue $timeValue ) {
52
+	public static function ofFutureTime(TimeValue $timeValue) {
53 53
 		$ret = new self;
54 54
 		$ret->timeValue = $timeValue;
55 55
 		return $ret;
@@ -59,17 +59,17 @@  discard block
 block discarded – undo
59 59
 	 * @param self[] $metadatas
60 60
 	 * @return self
61 61
 	 */
62
-	public static function merge( array $metadatas ) {
63
-		Assert::parameterElementType( self::class, $metadatas, '$metadatas' );
62
+	public static function merge(array $metadatas) {
63
+		Assert::parameterElementType(self::class, $metadatas, '$metadatas');
64 64
 		$ret = new self;
65 65
 		$entityIds = [];
66
-		foreach ( $metadatas as $metadata ) {
67
-			foreach ( $metadata->entityIds as $entityId ) {
66
+		foreach ($metadatas as $metadata) {
67
+			foreach ($metadata->entityIds as $entityId) {
68 68
 				$entityIds[$entityId->getSerialization()] = $entityId;
69 69
 			}
70
-			$ret->timeValue = self::minTimeValue( $ret->timeValue, $metadata->timeValue );
70
+			$ret->timeValue = self::minTimeValue($ret->timeValue, $metadata->timeValue);
71 71
 		}
72
-		$ret->entityIds = array_values( $entityIds );
72
+		$ret->entityIds = array_values($entityIds);
73 73
 		return $ret;
74 74
 	}
75 75
 
@@ -78,14 +78,14 @@  discard block
 block discarded – undo
78 78
 	 * @param TimeValue|null $t2
79 79
 	 * @return TimeValue|null
80 80
 	 */
81
-	private static function minTimeValue( TimeValue $t1 = null, TimeValue $t2 = null ) {
82
-		if ( $t1 === null ) {
81
+	private static function minTimeValue(TimeValue $t1 = null, TimeValue $t2 = null) {
82
+		if ($t1 === null) {
83 83
 			return $t2;
84 84
 		}
85
-		if ( $t2 === null ) {
85
+		if ($t2 === null) {
86 86
 			return $t1;
87 87
 		}
88
-		return ( new TimeValueComparer() )->getMinimum( $t1, $t2 );
88
+		return (new TimeValueComparer())->getMinimum($t1, $t2);
89 89
 	}
90 90
 
91 91
 	/**
Please login to merge, or discard this patch.
src/ConstraintCheck/Helper/LoggingHelper.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -47,8 +47,8 @@  discard block
 block discarded – undo
47 47
 		$this->dataFactory = $dataFactory;
48 48
 		$this->logger = $logger;
49 49
 		$this->constraintCheckDurationLimits = [
50
-			'info' => $config->get( 'WBQualityConstraintsCheckDurationInfoSeconds' ),
51
-			'warning' => $config->get( 'WBQualityConstraintsCheckDurationWarningSeconds' ),
50
+			'info' => $config->get('WBQualityConstraintsCheckDurationInfoSeconds'),
51
+			'warning' => $config->get('WBQualityConstraintsCheckDurationWarningSeconds'),
52 52
 		];
53 53
 	}
54 54
 
@@ -74,46 +74,46 @@  discard block
 block discarded – undo
74 74
 		$durationSeconds,
75 75
 		$method
76 76
 	) {
77
-		$constraintCheckerClassShortName = substr( strrchr( $constraintCheckerClass, '\\' ), 1 );
77
+		$constraintCheckerClassShortName = substr(strrchr($constraintCheckerClass, '\\'), 1);
78 78
 		$constraintTypeItemId = $constraint->getConstraintTypeItemId();
79 79
 
80 80
 		$this->dataFactory->timing(
81
-			'wikibase.quality.constraints.check.timing.' .
82
-				$constraintTypeItemId . '-' .
81
+			'wikibase.quality.constraints.check.timing.'.
82
+				$constraintTypeItemId.'-'.
83 83
 				$constraintCheckerClassShortName,
84 84
 			$durationSeconds * 1000
85 85
 		);
86 86
 
87 87
 		// find the longest limit (and associated log level) that the duration exceeds
88
-		foreach ( $this->constraintCheckDurationLimits as $level => $limit ) {
88
+		foreach ($this->constraintCheckDurationLimits as $level => $limit) {
89 89
 			if (
90 90
 				// duration exceeds this limit
91
-				isset( $limit ) && $durationSeconds > $limit &&
91
+				isset($limit) && $durationSeconds > $limit &&
92 92
 				// this limit is longer than previous longest limit
93
-				( !isset( $limitSeconds ) || $limit > $limitSeconds )
93
+				(!isset($limitSeconds) || $limit > $limitSeconds)
94 94
 			) {
95 95
 				$limitSeconds = $limit;
96 96
 				$logLevel = $level;
97 97
 			}
98 98
 		}
99 99
 
100
-		if ( !isset( $limitSeconds ) ) {
100
+		if (!isset($limitSeconds)) {
101 101
 			return;
102 102
 		}
103
-		if ( $context->getType() !== Context::TYPE_STATEMENT ) {
103
+		if ($context->getType() !== Context::TYPE_STATEMENT) {
104 104
 			// TODO log less details but still log something
105 105
 			return;
106 106
 		}
107 107
 
108 108
 		$resultMessage = $result->getMessage();
109
-		if ( $resultMessage instanceof ViolationMessage ) {
109
+		if ($resultMessage instanceof ViolationMessage) {
110 110
 			$resultMessage = $resultMessage->getMessageKey();
111 111
 		}
112 112
 
113 113
 		$this->logger->log(
114 114
 			$logLevel,
115
-			'Constraint check with {constraintCheckerClassShortName} ' .
116
-			'took longer than {limitSeconds} second(s) ' .
115
+			'Constraint check with {constraintCheckerClassShortName} '.
116
+			'took longer than {limitSeconds} second(s) '.
117 117
 			'(duration: {durationSeconds} seconds).',
118 118
 			[
119 119
 				'method' => $method,
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 	 *
141 141
 	 * @param EntityId $entityId
142 142
 	 */
143
-	public function logCheckConstraintsCacheHit( EntityId $entityId ) {
143
+	public function logCheckConstraintsCacheHit(EntityId $entityId) {
144 144
 		$this->dataFactory->increment(
145 145
 			'wikibase.quality.constraints.cache.entity.hit'
146 146
 		);
@@ -151,10 +151,10 @@  discard block
 block discarded – undo
151 151
 	 *
152 152
 	 * @param EntityId[] $entityIds
153 153
 	 */
154
-	public function logCheckConstraintsCacheMisses( array $entityIds ) {
154
+	public function logCheckConstraintsCacheMisses(array $entityIds) {
155 155
 		$this->dataFactory->updateCount(
156 156
 			'wikibase.quality.constraints.cache.entity.miss',
157
-			count( $entityIds )
157
+			count($entityIds)
158 158
 		);
159 159
 	}
160 160
 
@@ -181,16 +181,16 @@  discard block
 block discarded – undo
181 181
 	 * @param EntityId[] $entityIds
182 182
 	 * @param int $maxRevisionIds
183 183
 	 */
184
-	public function logHugeDependencyMetadata( array $entityIds, $maxRevisionIds ) {
184
+	public function logHugeDependencyMetadata(array $entityIds, $maxRevisionIds) {
185 185
 		$this->logger->log(
186 186
 			'warning',
187
-			'Dependency metadata for constraint check result has huge set of entity IDs ' .
188
-			'(count ' . count( $entityIds ) . ', limit ' . $maxRevisionIds . '); ' .
187
+			'Dependency metadata for constraint check result has huge set of entity IDs '.
188
+			'(count '.count($entityIds).', limit '.$maxRevisionIds.'); '.
189 189
 			'caching disabled for this check result.',
190 190
 			[
191 191
 				'loggingMethod' => __METHOD__,
192 192
 				'entityIds' => array_map(
193
-					function ( EntityId $entityId ) {
193
+					function(EntityId $entityId) {
194 194
 						return $entityId->getSerialization();
195 195
 					},
196 196
 					$entityIds
Please login to merge, or discard this patch.
src/ConstraintCheck/Context/ContextCursor.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -86,6 +86,6 @@
 block discarded – undo
86 86
 	 * @param array|null $result
87 87
 	 * @param array[] &$container
88 88
 	 */
89
-	public function storeCheckResultInArray( array $result = null, array &$container );
89
+	public function storeCheckResultInArray(array $result = null, array &$container);
90 90
 
91 91
 }
Please login to merge, or discard this patch.
src/ConstraintCheck/Result/CheckResult.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -122,12 +122,12 @@  discard block
 block discarded – undo
122 122
 		$status = self::STATUS_TODO,
123 123
 		$message = null
124 124
 	) {
125
-		if ( $contextCursor instanceof Context ) {
125
+		if ($contextCursor instanceof Context) {
126 126
 			$context = $contextCursor;
127 127
 			$this->contextCursor = $context->getCursor();
128 128
 			$this->snakType = $context->getSnak()->getType();
129 129
 			$mainSnak = $context->getSnak();
130
-			if ( $mainSnak instanceof PropertyValueSnak ) {
130
+			if ($mainSnak instanceof PropertyValueSnak) {
131 131
 				$this->dataValue = $mainSnak->getDataValue();
132 132
 			} else {
133 133
 				$this->dataValue = null;
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 	 * @param string $key
191 191
 	 * @param string $value
192 192
 	 */
193
-	public function addParameter( $key, $value ) {
193
+	public function addParameter($key, $value) {
194 194
 		$this->parameters[$key][] = $value;
195 195
 	}
196 196
 
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 	/**
205 205
 	 * @param string $status
206 206
 	 */
207
-	public function setStatus( $status ) {
207
+	public function setStatus($status) {
208 208
 		$this->status = $status;
209 209
 	}
210 210
 
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 	 * @param Metadata $metadata
220 220
 	 * @return self
221 221
 	 */
222
-	public function withMetadata( Metadata $metadata ) {
222
+	public function withMetadata(Metadata $metadata) {
223 223
 		$this->metadata = $metadata;
224 224
 		return $this;
225 225
 	}
Please login to merge, or discard this patch.
src/Specials/SpecialConstraintReport.php 1 patch
Spacing   +115 added lines, -116 removed lines patch added patch discarded remove patch
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 		Config $config,
135 135
 		IBufferingStatsdDataFactory $dataFactory
136 136
 	) {
137
-		parent::__construct( 'ConstraintReport' );
137
+		parent::__construct('ConstraintReport');
138 138
 
139 139
 		$this->entityLookup = $entityLookup;
140 140
 		$this->entityTitleLookup = $entityTitleLookup;
@@ -143,13 +143,13 @@  discard block
 block discarded – undo
143 143
 		$language = $this->getLanguage();
144 144
 
145 145
 		$formatterOptions = new FormatterOptions();
146
-		$formatterOptions->setOption( SnakFormatter::OPT_LANG, $language->getCode() );
146
+		$formatterOptions->setOption(SnakFormatter::OPT_LANG, $language->getCode());
147 147
 		$this->dataValueFormatter = $valueFormatterFactory->getValueFormatter(
148 148
 			SnakFormatter::FORMAT_HTML,
149 149
 			$formatterOptions
150 150
 		);
151 151
 
152
-		$labelLookup = $fallbackLabelDescLookupFactory->newLabelDescriptionLookup( $language );
152
+		$labelLookup = $fallbackLabelDescLookupFactory->newLabelDescriptionLookup($language);
153 153
 
154 154
 		$this->entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter(
155 155
 			$labelLookup
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 	 * @return array
183 183
 	 */
184 184
 	private function getModules() {
185
-		return [ 'SpecialConstraintReportPage' ];
185
+		return ['SpecialConstraintReportPage'];
186 186
 	}
187 187
 
188 188
 	/**
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 	 * @return string
201 201
 	 */
202 202
 	public function getDescription() {
203
-		return $this->msg( 'wbqc-constraintreport' )->escaped();
203
+		return $this->msg('wbqc-constraintreport')->escaped();
204 204
 	}
205 205
 
206 206
 	/**
@@ -212,42 +212,42 @@  discard block
 block discarded – undo
212 212
 	 * @throws EntityIdParsingException
213 213
 	 * @throws UnexpectedValueException
214 214
 	 */
215
-	public function execute( $subPage ) {
215
+	public function execute($subPage) {
216 216
 		$out = $this->getOutput();
217 217
 
218
-		$postRequest = $this->getContext()->getRequest()->getVal( 'entityid' );
219
-		if ( $postRequest ) {
220
-			$out->redirect( $this->getPageTitle( strtoupper( $postRequest ) )->getLocalURL() );
218
+		$postRequest = $this->getContext()->getRequest()->getVal('entityid');
219
+		if ($postRequest) {
220
+			$out->redirect($this->getPageTitle(strtoupper($postRequest))->getLocalURL());
221 221
 			return;
222 222
 		}
223 223
 
224
-		$out->addModules( $this->getModules() );
224
+		$out->addModules($this->getModules());
225 225
 
226 226
 		$this->setHeaders();
227 227
 
228
-		$out->addHTML( $this->getExplanationText() );
228
+		$out->addHTML($this->getExplanationText());
229 229
 		$this->buildEntityIdForm();
230 230
 
231
-		if ( !$subPage ) {
231
+		if (!$subPage) {
232 232
 			return;
233 233
 		}
234 234
 
235
-		if ( !is_string( $subPage ) ) {
236
-			throw new InvalidArgumentException( '$subPage must be string.' );
235
+		if (!is_string($subPage)) {
236
+			throw new InvalidArgumentException('$subPage must be string.');
237 237
 		}
238 238
 
239 239
 		try {
240
-			$entityId = $this->entityIdParser->parse( $subPage );
241
-		} catch ( EntityIdParsingException $e ) {
240
+			$entityId = $this->entityIdParser->parse($subPage);
241
+		} catch (EntityIdParsingException $e) {
242 242
 			$out->addHTML(
243
-				$this->buildNotice( 'wbqc-constraintreport-invalid-entity-id', true )
243
+				$this->buildNotice('wbqc-constraintreport-invalid-entity-id', true)
244 244
 			);
245 245
 			return;
246 246
 		}
247 247
 
248
-		if ( !$this->entityLookup->hasEntity( $entityId ) ) {
248
+		if (!$this->entityLookup->hasEntity($entityId)) {
249 249
 			$out->addHTML(
250
-				$this->buildNotice( 'wbqc-constraintreport-not-existent-entity', true )
250
+				$this->buildNotice('wbqc-constraintreport-not-existent-entity', true)
251 251
 			);
252 252
 			return;
253 253
 		}
@@ -255,18 +255,18 @@  discard block
 block discarded – undo
255 255
 		$this->dataFactory->increment(
256 256
 			'wikibase.quality.constraints.specials.specialConstraintReport.executeCheck'
257 257
 		);
258
-		$results = $this->constraintChecker->checkAgainstConstraintsOnEntityId( $entityId );
258
+		$results = $this->constraintChecker->checkAgainstConstraintsOnEntityId($entityId);
259 259
 
260
-		if ( count( $results ) > 0 ) {
260
+		if (count($results) > 0) {
261 261
 			$out->addHTML(
262
-				$this->buildResultHeader( $entityId )
263
-				. $this->buildSummary( $results )
264
-				. $this->buildResultTable( $entityId, $results )
262
+				$this->buildResultHeader($entityId)
263
+				. $this->buildSummary($results)
264
+				. $this->buildResultTable($entityId, $results)
265 265
 			);
266 266
 		} else {
267 267
 			$out->addHTML(
268
-				$this->buildResultHeader( $entityId )
269
-				. $this->buildNotice( 'wbqc-constraintreport-empty-result' )
268
+				$this->buildResultHeader($entityId)
269
+				. $this->buildNotice('wbqc-constraintreport-empty-result')
270 270
 			);
271 271
 		}
272 272
 	}
@@ -282,15 +282,15 @@  discard block
 block discarded – undo
282 282
 				'name' => 'entityid',
283 283
 				'label-message' => 'wbqc-constraintreport-form-entityid-label',
284 284
 				'cssclass' => 'wbqc-constraintreport-form-entity-id',
285
-				'placeholder' => $this->msg( 'wbqc-constraintreport-form-entityid-placeholder' )->escaped()
285
+				'placeholder' => $this->msg('wbqc-constraintreport-form-entityid-placeholder')->escaped()
286 286
 			]
287 287
 		];
288
-		$htmlForm = HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext(), 'wbqc-constraintreport-form' );
289
-		$htmlForm->setSubmitText( $this->msg( 'wbqc-constraintreport-form-submit-label' )->escaped() );
290
-		$htmlForm->setSubmitCallback( function() {
288
+		$htmlForm = HTMLForm::factory('ooui', $formDescriptor, $this->getContext(), 'wbqc-constraintreport-form');
289
+		$htmlForm->setSubmitText($this->msg('wbqc-constraintreport-form-submit-label')->escaped());
290
+		$htmlForm->setSubmitCallback(function() {
291 291
 			return false;
292 292
 		} );
293
-		$htmlForm->setMethod( 'post' );
293
+		$htmlForm->setMethod('post');
294 294
 		$htmlForm->show();
295 295
 	}
296 296
 
@@ -304,16 +304,16 @@  discard block
 block discarded – undo
304 304
 	 *
305 305
 	 * @return string HTML
306 306
 	 */
307
-	private function buildNotice( $messageKey, $error = false ) {
308
-		if ( !is_string( $messageKey ) ) {
309
-			throw new InvalidArgumentException( '$message must be string.' );
307
+	private function buildNotice($messageKey, $error = false) {
308
+		if (!is_string($messageKey)) {
309
+			throw new InvalidArgumentException('$message must be string.');
310 310
 		}
311
-		if ( !is_bool( $error ) ) {
312
-			throw new InvalidArgumentException( '$error must be bool.' );
311
+		if (!is_bool($error)) {
312
+			throw new InvalidArgumentException('$error must be bool.');
313 313
 		}
314 314
 
315 315
 		$cssClasses = 'wbqc-constraintreport-notice';
316
-		if ( $error ) {
316
+		if ($error) {
317 317
 			$cssClasses .= ' wbqc-constraintreport-notice-error';
318 318
 		}
319 319
 
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 				[
323 323
 					'class' => $cssClasses
324 324
 				],
325
-				$this->msg( $messageKey )->escaped()
325
+				$this->msg($messageKey)->escaped()
326 326
 			);
327 327
 	}
328 328
 
@@ -332,16 +332,16 @@  discard block
 block discarded – undo
332 332
 	private function getExplanationText() {
333 333
 		return Html::rawElement(
334 334
 			'div',
335
-			[ 'class' => 'wbqc-explanation' ],
335
+			['class' => 'wbqc-explanation'],
336 336
 			Html::rawElement(
337 337
 				'p',
338 338
 				[],
339
-				$this->msg( 'wbqc-constraintreport-explanation-part-one' )->escaped()
339
+				$this->msg('wbqc-constraintreport-explanation-part-one')->escaped()
340 340
 			)
341 341
 			. Html::rawElement(
342 342
 				'p',
343 343
 				[],
344
-				$this->msg( 'wbqc-constraintreport-explanation-part-two' )->escaped()
344
+				$this->msg('wbqc-constraintreport-explanation-part-two')->escaped()
345 345
 			)
346 346
 		);
347 347
 	}
@@ -352,82 +352,81 @@  discard block
 block discarded – undo
352 352
 	 *
353 353
 	 * @return string HTML
354 354
 	 */
355
-	private function buildResultTable( EntityId $entityId, array $results ) {
355
+	private function buildResultTable(EntityId $entityId, array $results) {
356 356
 		// Set table headers
357 357
 		$table = new HtmlTableBuilder(
358 358
 			[
359 359
 				new HtmlTableHeaderBuilder(
360
-					$this->msg( 'wbqc-constraintreport-result-table-header-status' )->escaped(),
360
+					$this->msg('wbqc-constraintreport-result-table-header-status')->escaped(),
361 361
 					true
362 362
 				),
363 363
 				new HtmlTableHeaderBuilder(
364
-					$this->msg( 'wbqc-constraintreport-result-table-header-claim' )->escaped(),
364
+					$this->msg('wbqc-constraintreport-result-table-header-claim')->escaped(),
365 365
 					true
366 366
 				),
367 367
 				new HtmlTableHeaderBuilder(
368
-					$this->msg( 'wbqc-constraintreport-result-table-header-constraint' )->escaped(),
368
+					$this->msg('wbqc-constraintreport-result-table-header-constraint')->escaped(),
369 369
 					true
370 370
 				)
371 371
 			]
372 372
 		);
373 373
 
374
-		foreach ( $results as $result ) {
375
-			$table = $this->appendToResultTable( $table, $entityId, $result );
374
+		foreach ($results as $result) {
375
+			$table = $this->appendToResultTable($table, $entityId, $result);
376 376
 		}
377 377
 
378 378
 		return $table->toHtml();
379 379
 	}
380 380
 
381
-	private function appendToResultTable( HtmlTableBuilder $table, EntityId $entityId, CheckResult $result ) {
381
+	private function appendToResultTable(HtmlTableBuilder $table, EntityId $entityId, CheckResult $result) {
382 382
 		// Status column
383 383
 		$statusColumn = $this->buildTooltipElement(
384
-			$this->formatStatus( $result->getStatus() ),
384
+			$this->formatStatus($result->getStatus()),
385 385
 			$result->getMessage() !== null ?
386
-				$this->violationMessageRenderer->render( $result->getMessage() ) :
387
-				null,
386
+				$this->violationMessageRenderer->render($result->getMessage()) : null,
388 387
 			'[?]'
389 388
 		);
390 389
 
391 390
 		// Claim column
392 391
 		$property = $this->entityIdLabelFormatter->formatEntityId(
393
-			new PropertyId( $result->getContextCursor()->getSnakPropertyId() )
392
+			new PropertyId($result->getContextCursor()->getSnakPropertyId())
394 393
 		);
395 394
 		$value = null;
396 395
 		$snakType = $result->getSnakType();
397
-		if ( $snakType === 'value' ) {
396
+		if ($snakType === 'value') {
398 397
 			$dataValue = $result->getDataValue();
399
-			if ( $dataValue !== null ) {
400
-				$value = $this->constraintParameterRenderer->formatValue( $dataValue );
398
+			if ($dataValue !== null) {
399
+				$value = $this->constraintParameterRenderer->formatValue($dataValue);
401 400
 			}
402
-		} elseif ( $snakType !== null ) {
403
-			$value = htmlspecialchars( $snakType );
401
+		} elseif ($snakType !== null) {
402
+			$value = htmlspecialchars($snakType);
404 403
 		}
405
-		if ( $value === null ) {
404
+		if ($value === null) {
406 405
 			// incomplete CheckResult – this should never happen
407
-			$value = $this->msg( 'unknown-error' )->escaped();
406
+			$value = $this->msg('unknown-error')->escaped();
408 407
 		}
409 408
 
410 409
 		$claimColumn = $this->getClaimLink(
411 410
 			$entityId,
412
-			new PropertyId( $result->getContextCursor()->getSnakPropertyId() ),
413
-			$property . ': ' . $value
411
+			new PropertyId($result->getContextCursor()->getSnakPropertyId()),
412
+			$property.': '.$value
414 413
 		);
415 414
 
416 415
 		// Constraint column
417 416
 		$constraintTypeItemId = $result->getConstraint()->getConstraintTypeItemId();
418 417
 		try {
419
-			$constraintTypeLabel = $this->entityIdLabelFormatter->formatEntityId( new ItemId( $constraintTypeItemId ) );
420
-		} catch ( InvalidArgumentException $e ) {
421
-			$constraintTypeLabel = htmlspecialchars( $constraintTypeItemId );
418
+			$constraintTypeLabel = $this->entityIdLabelFormatter->formatEntityId(new ItemId($constraintTypeItemId));
419
+		} catch (InvalidArgumentException $e) {
420
+			$constraintTypeLabel = htmlspecialchars($constraintTypeItemId);
422 421
 		}
423 422
 		$constraintLink = $this->getClaimLink(
424
-			new PropertyId( $result->getContextCursor()->getSnakPropertyId() ),
425
-			new PropertyId( $this->config->get( 'WBQualityConstraintsPropertyConstraintId' ) ),
423
+			new PropertyId($result->getContextCursor()->getSnakPropertyId()),
424
+			new PropertyId($this->config->get('WBQualityConstraintsPropertyConstraintId')),
426 425
 			$constraintTypeLabel
427 426
 		);
428 427
 		$constraintColumn = $this->buildExpandableElement(
429 428
 			$constraintLink,
430
-			$this->constraintParameterRenderer->formatParameters( $result->getParameters() ),
429
+			$this->constraintParameterRenderer->formatParameters($result->getParameters()),
431 430
 			'[...]'
432 431
 		);
433 432
 
@@ -462,15 +461,15 @@  discard block
 block discarded – undo
462 461
 	 *
463 462
 	 * @return string HTML
464 463
 	 */
465
-	protected function buildResultHeader( EntityId $entityId ) {
466
-		$entityLink = sprintf( '%s (%s)',
467
-							   $this->entityIdLinkFormatter->formatEntityId( $entityId ),
468
-							   htmlspecialchars( $entityId->getSerialization() ) );
464
+	protected function buildResultHeader(EntityId $entityId) {
465
+		$entityLink = sprintf('%s (%s)',
466
+							   $this->entityIdLinkFormatter->formatEntityId($entityId),
467
+							   htmlspecialchars($entityId->getSerialization()));
469 468
 
470 469
 		return Html::rawElement(
471 470
 			'h3',
472 471
 			[],
473
-			sprintf( '%s %s', $this->msg( 'wbqc-constraintreport-result-headline' )->escaped(), $entityLink )
472
+			sprintf('%s %s', $this->msg('wbqc-constraintreport-result-headline')->escaped(), $entityLink)
474 473
 		);
475 474
 	}
476 475
 
@@ -481,24 +480,24 @@  discard block
 block discarded – undo
481 480
 	 *
482 481
 	 * @return string HTML
483 482
 	 */
484
-	protected function buildSummary( array $results ) {
483
+	protected function buildSummary(array $results) {
485 484
 		$statuses = [];
486
-		foreach ( $results as $result ) {
487
-			$status = strtolower( $result->getStatus() );
488
-			$statuses[$status] = isset( $statuses[$status] ) ? $statuses[$status] + 1 : 1;
485
+		foreach ($results as $result) {
486
+			$status = strtolower($result->getStatus());
487
+			$statuses[$status] = isset($statuses[$status]) ? $statuses[$status] + 1 : 1;
489 488
 		}
490 489
 
491 490
 		$statusElements = [];
492
-		foreach ( $statuses as $status => $count ) {
493
-			if ( $count > 0 ) {
491
+		foreach ($statuses as $status => $count) {
492
+			if ($count > 0) {
494 493
 				$statusElements[] =
495
-					$this->formatStatus( $status )
494
+					$this->formatStatus($status)
496 495
 					. ': '
497 496
 					. $count;
498 497
 			}
499 498
 		}
500 499
 
501
-		return Html::rawElement( 'p', [], implode( ', ', $statusElements ) );
500
+		return Html::rawElement('p', [], implode(', ', $statusElements));
502 501
 	}
503 502
 
504 503
 	/**
@@ -513,15 +512,15 @@  discard block
 block discarded – undo
513 512
 	 *
514 513
 	 * @return string HTML
515 514
 	 */
516
-	protected function buildTooltipElement( $content, $tooltipContent, $indicator ) {
517
-		if ( !is_string( $content ) ) {
518
-			throw new InvalidArgumentException( '$content has to be string.' );
515
+	protected function buildTooltipElement($content, $tooltipContent, $indicator) {
516
+		if (!is_string($content)) {
517
+			throw new InvalidArgumentException('$content has to be string.');
519 518
 		}
520
-		if ( $tooltipContent && ( !is_string( $tooltipContent ) ) ) {
521
-			throw new InvalidArgumentException( '$tooltipContent, if provided, has to be string.' );
519
+		if ($tooltipContent && (!is_string($tooltipContent))) {
520
+			throw new InvalidArgumentException('$tooltipContent, if provided, has to be string.');
522 521
 		}
523 522
 
524
-		if ( empty( $tooltipContent ) ) {
523
+		if (empty($tooltipContent)) {
525 524
 			return $content;
526 525
 		}
527 526
 
@@ -538,13 +537,13 @@  discard block
 block discarded – undo
538 537
 			[
539 538
 				'class' => 'wbqc-indicator'
540 539
 			],
541
-			htmlspecialchars( $indicator ) . $tooltip
540
+			htmlspecialchars($indicator).$tooltip
542 541
 		);
543 542
 
544 543
 		return Html::rawElement(
545 544
 			'span',
546 545
 			[],
547
-			sprintf( '%s %s', $content, $tooltipIndicator )
546
+			sprintf('%s %s', $content, $tooltipIndicator)
548 547
 		);
549 548
 	}
550 549
 
@@ -560,15 +559,15 @@  discard block
 block discarded – undo
560 559
 	 *
561 560
 	 * @return string HTML
562 561
 	 */
563
-	protected function buildExpandableElement( $content, $expandableContent, $indicator ) {
564
-		if ( !is_string( $content ) ) {
565
-			throw new InvalidArgumentException( '$content has to be string.' );
562
+	protected function buildExpandableElement($content, $expandableContent, $indicator) {
563
+		if (!is_string($content)) {
564
+			throw new InvalidArgumentException('$content has to be string.');
566 565
 		}
567
-		if ( $expandableContent && ( !is_string( $expandableContent ) ) ) {
568
-			throw new InvalidArgumentException( '$tooltipContent, if provided, has to be string.' );
566
+		if ($expandableContent && (!is_string($expandableContent))) {
567
+			throw new InvalidArgumentException('$tooltipContent, if provided, has to be string.');
569 568
 		}
570 569
 
571
-		if ( empty( $expandableContent ) ) {
570
+		if (empty($expandableContent)) {
572 571
 			return $content;
573 572
 		}
574 573
 
@@ -588,7 +587,7 @@  discard block
 block discarded – undo
588 587
 			$expandableContent
589 588
 		);
590 589
 
591
-		return sprintf( '%s %s %s', $content, $tooltipIndicator, $expandableContent );
590
+		return sprintf('%s %s %s', $content, $tooltipIndicator, $expandableContent);
592 591
 	}
593 592
 
594 593
 	/**
@@ -600,16 +599,16 @@  discard block
 block discarded – undo
600 599
 	 *
601 600
 	 * @return string HTML
602 601
 	 */
603
-	private function formatStatus( $status ) {
604
-		$messageName = "wbqc-constraintreport-status-" . strtolower( $status );
602
+	private function formatStatus($status) {
603
+		$messageName = "wbqc-constraintreport-status-".strtolower($status);
605 604
 
606 605
 		$formattedStatus =
607 606
 			Html::element(
608 607
 				'span',
609 608
 				[
610
-					'class' => 'wbqc-status wbqc-status-' . $status
609
+					'class' => 'wbqc-status wbqc-status-'.$status
611 610
 				],
612
-				$this->msg( $messageName )->text()
611
+				$this->msg($messageName)->text()
613 612
 			);
614 613
 
615 614
 		return $formattedStatus;
@@ -625,26 +624,26 @@  discard block
 block discarded – undo
625 624
 	 *
626 625
 	 * @return string HTML
627 626
 	 */
628
-	protected function formatDataValues( $dataValues, $separator = ', ' ) {
629
-		if ( $dataValues instanceof DataValue ) {
630
-			$dataValues = [ $dataValues ];
631
-		} elseif ( !is_array( $dataValues ) ) {
632
-			throw new InvalidArgumentException( '$dataValues has to be instance of DataValue or an array of DataValues.' );
627
+	protected function formatDataValues($dataValues, $separator = ', ') {
628
+		if ($dataValues instanceof DataValue) {
629
+			$dataValues = [$dataValues];
630
+		} elseif (!is_array($dataValues)) {
631
+			throw new InvalidArgumentException('$dataValues has to be instance of DataValue or an array of DataValues.');
633 632
 		}
634 633
 
635 634
 		$formattedDataValues = [];
636
-		foreach ( $dataValues as $dataValue ) {
637
-			if ( !( $dataValue instanceof DataValue ) ) {
638
-				throw new InvalidArgumentException( '$dataValues has to be instance of DataValue or an array of DataValues.' );
635
+		foreach ($dataValues as $dataValue) {
636
+			if (!($dataValue instanceof DataValue)) {
637
+				throw new InvalidArgumentException('$dataValues has to be instance of DataValue or an array of DataValues.');
639 638
 			}
640
-			if ( $dataValue instanceof EntityIdValue ) {
641
-				$formattedDataValues[ ] = $this->entityIdLabelFormatter->formatEntityId( $dataValue->getEntityId() );
639
+			if ($dataValue instanceof EntityIdValue) {
640
+				$formattedDataValues[] = $this->entityIdLabelFormatter->formatEntityId($dataValue->getEntityId());
642 641
 			} else {
643
-				$formattedDataValues[ ] = $this->dataValueFormatter->format( $dataValue );
642
+				$formattedDataValues[] = $this->dataValueFormatter->format($dataValue);
644 643
 			}
645 644
 		}
646 645
 
647
-		return implode( $separator, $formattedDataValues );
646
+		return implode($separator, $formattedDataValues);
648 647
 	}
649 648
 
650 649
 	/**
@@ -656,11 +655,11 @@  discard block
 block discarded – undo
656 655
 	 *
657 656
 	 * @return string HTML
658 657
 	 */
659
-	private function getClaimLink( EntityId $entityId, PropertyId $propertyId, $text ) {
658
+	private function getClaimLink(EntityId $entityId, PropertyId $propertyId, $text) {
660 659
 		return Html::rawElement(
661 660
 			'a',
662 661
 			[
663
-				'href' => $this->getClaimUrl( $entityId, $propertyId ),
662
+				'href' => $this->getClaimUrl($entityId, $propertyId),
664 663
 				'target' => '_blank'
665 664
 			],
666 665
 			$text
@@ -675,9 +674,9 @@  discard block
 block discarded – undo
675 674
 	 *
676 675
 	 * @return string
677 676
 	 */
678
-	private function getClaimUrl( EntityId $entityId, PropertyId $propertyId ) {
679
-		$title = $this->entityTitleLookup->getTitleForId( $entityId );
680
-		$entityUrl = sprintf( '%s#%s', $title->getLocalURL(), $propertyId->getSerialization() );
677
+	private function getClaimUrl(EntityId $entityId, PropertyId $propertyId) {
678
+		$title = $this->entityTitleLookup->getTitleForId($entityId);
679
+		$entityUrl = sprintf('%s#%s', $title->getLocalURL(), $propertyId->getSerialization());
681 680
 
682 681
 		return $entityUrl;
683 682
 	}
Please login to merge, or discard this patch.
src/ConstraintCheck/Context/QualifierContext.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 		Statement $statement,
24 24
 		Snak $snak
25 25
 	) {
26
-		parent::__construct( $entity, $snak );
26
+		parent::__construct($entity, $snak);
27 27
 		$this->statement = $statement;
28 28
 	}
29 29
 
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 
34 34
 	public function getSnakGroup() {
35 35
 		$snaks = $this->statement->getQualifiers();
36
-		return array_values( $snaks->getArrayCopy() );
36
+		return array_values($snaks->getArrayCopy());
37 37
 	}
38 38
 
39 39
 	public function getCursor() {
Please login to merge, or discard this patch.
src/ConstraintCheck/Context/MainSnakContext.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -20,9 +20,9 @@  discard block
 block discarded – undo
20 20
 	 */
21 21
 	private $statement;
22 22
 
23
-	public function __construct( EntityDocument $entity, Statement $statement ) {
24
-		Assert::parameterType( StatementListProvider::class, $entity, '$entity' );
25
-		parent::__construct( $entity, $statement->getMainSnak() );
23
+	public function __construct(EntityDocument $entity, Statement $statement) {
24
+		Assert::parameterType(StatementListProvider::class, $entity, '$entity');
25
+		parent::__construct($entity, $statement->getMainSnak());
26 26
 
27 27
 		$this->statement = $statement;
28 28
 	}
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 		/** @var StatementList $statements */
44 44
 		$statements = $this->entity->getStatements();
45 45
 		return $statements
46
-			->getByRank( [ Statement::RANK_NORMAL, Statement::RANK_PREFERRED ] )
46
+			->getByRank([Statement::RANK_NORMAL, Statement::RANK_PREFERRED])
47 47
 			->getMainSnaks();
48 48
 	}
49 49
 
Please login to merge, or discard this patch.
src/ConstraintCheck/Context/ReferenceContext.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 		Reference $reference,
31 31
 		Snak $snak
32 32
 	) {
33
-		parent::__construct( $entity, $snak );
33
+		parent::__construct($entity, $snak);
34 34
 		$this->statement = $statement;
35 35
 		$this->reference = $reference;
36 36
 	}
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 
42 42
 	public function getSnakGroup() {
43 43
 		$snaks = $this->reference->getSnaks();
44
-		return array_values( $snaks->getArrayCopy() );
44
+		return array_values($snaks->getArrayCopy());
45 45
 	}
46 46
 
47 47
 	public function getCursor() {
Please login to merge, or discard this patch.