Completed
Push — master ( f6a477...97f202 )
by
unknown
04:20
created
src/ConstraintCheck/Helper/TypeCheckerHelper.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -89,23 +89,23 @@  discard block
 block discarded – undo
89 89
 	 * @return bool
90 90
 	 * @throws OverflowException if $entitiesChecked exceeds the configured limit
91 91
 	 */
92
-	private function isSubclassOf( EntityId $comparativeClass, array $classesToCheck, &$entitiesChecked = 0 ) {
93
-		$maxEntities = $this->config->get( 'WBQualityConstraintsTypeCheckMaxEntities' );
92
+	private function isSubclassOf(EntityId $comparativeClass, array $classesToCheck, &$entitiesChecked = 0) {
93
+		$maxEntities = $this->config->get('WBQualityConstraintsTypeCheckMaxEntities');
94 94
 		if ( ++$entitiesChecked > $maxEntities ) {
95
-			throw new OverflowException( 'Too many entities to check' );
95
+			throw new OverflowException('Too many entities to check');
96 96
 		}
97 97
 
98
-		$item = $this->entityLookup->getEntity( $comparativeClass );
99
-		if ( !( $item instanceof StatementListProvider ) ) {
98
+		$item = $this->entityLookup->getEntity($comparativeClass);
99
+		if (!($item instanceof StatementListProvider)) {
100 100
 			return false; // lookup failed, probably because item doesn't exist
101 101
 		}
102 102
 
103
-		$subclassId = $this->config->get( 'WBQualityConstraintsSubclassOfId' );
103
+		$subclassId = $this->config->get('WBQualityConstraintsSubclassOfId');
104 104
 		/** @var Statement $statement */
105
-		foreach ( $item->getStatements()->getByPropertyId( new PropertyId( $subclassId ) ) as $statement ) {
105
+		foreach ($item->getStatements()->getByPropertyId(new PropertyId($subclassId)) as $statement) {
106 106
 			$mainSnak = $statement->getMainSnak();
107 107
 
108
-			if ( !( $this->hasCorrectType( $mainSnak ) ) ) {
108
+			if (!($this->hasCorrectType($mainSnak))) {
109 109
 				continue;
110 110
 			}
111 111
 			/** @var PropertyValueSnak $mainSnak */
@@ -114,11 +114,11 @@  discard block
 block discarded – undo
114 114
 			$dataValue = $mainSnak->getDataValue();
115 115
 			$comparativeClass = $dataValue->getEntityId();
116 116
 
117
-			if ( in_array( $comparativeClass->getSerialization(), $classesToCheck ) ) {
117
+			if (in_array($comparativeClass->getSerialization(), $classesToCheck)) {
118 118
 				return true;
119 119
 			}
120 120
 
121
-			if ( $this->isSubclassOf( $comparativeClass, $classesToCheck, $entitiesChecked ) ) {
121
+			if ($this->isSubclassOf($comparativeClass, $classesToCheck, $entitiesChecked)) {
122 122
 				return true;
123 123
 			}
124 124
 		}
@@ -139,14 +139,14 @@  discard block
 block discarded – undo
139 139
 	 * @return CachedBool
140 140
 	 * @throws SparqlHelperException if SPARQL is used and the query times out or some other error occurs
141 141
 	 */
142
-	public function isSubclassOfWithSparqlFallback( EntityId $comparativeClass, array $classesToCheck ) {
142
+	public function isSubclassOfWithSparqlFallback(EntityId $comparativeClass, array $classesToCheck) {
143 143
 		try {
144 144
 			return new CachedBool(
145
-				$this->isSubclassOf( $comparativeClass, $classesToCheck ),
145
+				$this->isSubclassOf($comparativeClass, $classesToCheck),
146 146
 				Metadata::blank()
147 147
 			);
148
-		} catch ( OverflowException $e ) {
149
-			if ( $this->sparqlHelper !== null ) {
148
+		} catch (OverflowException $e) {
149
+			if ($this->sparqlHelper !== null) {
150 150
 				$this->dataFactory->increment(
151 151
 					'wikibase.quality.constraints.sparql.typeFallback'
152 152
 				);
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 					/* withInstance = */ false
157 157
 				);
158 158
 			} else {
159
-				return new CachedBool( false, Metadata::blank() );
159
+				return new CachedBool(false, Metadata::blank());
160 160
 			}
161 161
 		}
162 162
 	}
@@ -174,13 +174,13 @@  discard block
 block discarded – undo
174 174
 	 * @return CachedBool
175 175
 	 * @throws SparqlHelperException if SPARQL is used and the query times out or some other error occurs
176 176
 	 */
177
-	public function hasClassInRelation( StatementList $statements, array $relationIds, array $classesToCheck ) {
177
+	public function hasClassInRelation(StatementList $statements, array $relationIds, array $classesToCheck) {
178 178
 		$metadatas = [];
179 179
 
180
-		foreach ( $this->getStatementsByPropertyIds( $statements, $relationIds ) as $statement ) {
180
+		foreach ($this->getStatementsByPropertyIds($statements, $relationIds) as $statement) {
181 181
 			$mainSnak = $statement->getMainSnak();
182 182
 
183
-			if ( !$this->hasCorrectType( $mainSnak ) ) {
183
+			if (!$this->hasCorrectType($mainSnak)) {
184 184
 				continue;
185 185
 			}
186 186
 			/** @var PropertyValueSnak $mainSnak */
@@ -189,28 +189,28 @@  discard block
 block discarded – undo
189 189
 			$dataValue = $mainSnak->getDataValue();
190 190
 			$comparativeClass = $dataValue->getEntityId();
191 191
 
192
-			if ( in_array( $comparativeClass->getSerialization(), $classesToCheck ) ) {
192
+			if (in_array($comparativeClass->getSerialization(), $classesToCheck)) {
193 193
 				// discard $metadatas, we know this is fresh
194
-				return new CachedBool( true, Metadata::blank() );
194
+				return new CachedBool(true, Metadata::blank());
195 195
 			}
196 196
 
197
-			$result = $this->isSubclassOfWithSparqlFallback( $comparativeClass, $classesToCheck );
197
+			$result = $this->isSubclassOfWithSparqlFallback($comparativeClass, $classesToCheck);
198 198
 			$metadatas[] = $result->getMetadata();
199
-			if ( $result->getBool() ) {
199
+			if ($result->getBool()) {
200 200
 				return new CachedBool(
201 201
 					true,
202
-					Metadata::merge( $metadatas )
202
+					Metadata::merge($metadatas)
203 203
 				);
204 204
 			}
205 205
 		}
206 206
 
207 207
 		return new CachedBool(
208 208
 			false,
209
-			Metadata::merge( $metadatas )
209
+			Metadata::merge($metadatas)
210 210
 		);
211 211
 	}
212 212
 
213
-	private function hasCorrectType( Snak $mainSnak ) {
213
+	private function hasCorrectType(Snak $mainSnak) {
214 214
 		return $mainSnak instanceof PropertyValueSnak
215 215
 			&& $mainSnak->getDataValue()->getType() === 'wikibase-entityid';
216 216
 	}
@@ -227,12 +227,12 @@  discard block
 block discarded – undo
227 227
 	) {
228 228
 		$statementArrays = [];
229 229
 
230
-		foreach ( $propertyIdSerializations as $propertyIdSerialization ) {
231
-			$propertyId = new PropertyId( $propertyIdSerialization );
232
-			$statementArrays[] = $statements->getByPropertyId( $propertyId )->toArray();
230
+		foreach ($propertyIdSerializations as $propertyIdSerialization) {
231
+			$propertyId = new PropertyId($propertyIdSerialization);
232
+			$statementArrays[] = $statements->getByPropertyId($propertyId)->toArray();
233 233
 		}
234 234
 
235
-		return call_user_func_array( 'array_merge', $statementArrays );
235
+		return call_user_func_array('array_merge', $statementArrays);
236 236
 	}
237 237
 
238 238
 	/**
@@ -244,10 +244,10 @@  discard block
 block discarded – undo
244 244
 	 *
245 245
 	 * @return ViolationMessage
246 246
 	 */
247
-	public function getViolationMessage( PropertyId $propertyId, EntityId $entityId, array $classes, $checker, $relation ) {
247
+	public function getViolationMessage(PropertyId $propertyId, EntityId $entityId, array $classes, $checker, $relation) {
248 248
 		$classes = array_map(
249
-			function( $itemIdSerialization ) {
250
-				return new ItemId( $itemIdSerialization );
249
+			function($itemIdSerialization) {
250
+				return new ItemId($itemIdSerialization);
251 251
 			},
252 252
 			$classes
253 253
 		);
@@ -259,10 +259,10 @@  discard block
 block discarded – undo
259 259
 		// wbqc-violation-message-valueType-instance
260 260
 		// wbqc-violation-message-valueType-subclass
261 261
 		// wbqc-violation-message-valueType-instanceOrSubclass
262
-		return ( new ViolationMessage( 'wbqc-violation-message-' . $checker . '-' . $relation ) )
263
-			->withEntityId( $propertyId, Role::CONSTRAINT_PROPERTY )
264
-			->withEntityId( $entityId, Role::SUBJECT )
265
-			->withEntityIdList( $classes, Role::OBJECT );
262
+		return (new ViolationMessage('wbqc-violation-message-'.$checker.'-'.$relation))
263
+			->withEntityId($propertyId, Role::CONSTRAINT_PROPERTY)
264
+			->withEntityId($entityId, Role::SUBJECT)
265
+			->withEntityIdList($classes, Role::OBJECT);
266 266
 	}
267 267
 
268 268
 }
Please login to merge, or discard this patch.
src/Api/CheckConstraints.php 1 patch
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -77,21 +77,21 @@  discard block
 block discarded – undo
77 77
 	 *
78 78
 	 * @return self
79 79
 	 */
80
-	public static function newFromGlobalState( ApiMain $main, $name, $prefix = '' ) {
80
+	public static function newFromGlobalState(ApiMain $main, $name, $prefix = '') {
81 81
 		$repo = WikibaseRepo::getDefaultInstance();
82 82
 
83 83
 		$language = $repo->getUserLanguage();
84 84
 		$formatterOptions = new FormatterOptions();
85
-		$formatterOptions->setOption( SnakFormatter::OPT_LANG, $language->getCode() );
85
+		$formatterOptions->setOption(SnakFormatter::OPT_LANG, $language->getCode());
86 86
 		$valueFormatterFactory = $repo->getValueFormatterFactory();
87
-		$valueFormatter = $valueFormatterFactory->getValueFormatter( SnakFormatter::FORMAT_HTML, $formatterOptions );
87
+		$valueFormatter = $valueFormatterFactory->getValueFormatter(SnakFormatter::FORMAT_HTML, $formatterOptions);
88 88
 
89 89
 		$languageFallbackLabelDescriptionLookupFactory = $repo->getLanguageFallbackLabelDescriptionLookupFactory();
90
-		$labelDescriptionLookup = $languageFallbackLabelDescriptionLookupFactory->newLabelDescriptionLookup( $language );
90
+		$labelDescriptionLookup = $languageFallbackLabelDescriptionLookupFactory->newLabelDescriptionLookup($language);
91 91
 		$entityIdHtmlLinkFormatterFactory = $repo->getEntityIdHtmlLinkFormatterFactory();
92
-		$entityIdHtmlLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter( $labelDescriptionLookup );
92
+		$entityIdHtmlLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter($labelDescriptionLookup);
93 93
 		$entityIdLabelFormatterFactory = new EntityIdLabelFormatterFactory();
94
-		$entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter( $labelDescriptionLookup );
94
+		$entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter($labelDescriptionLookup);
95 95
 		$config = MediaWikiServices::getInstance()->getMainConfig();
96 96
 		$titleParser = MediaWikiServices::getInstance()->getTitleParser();
97 97
 		$unitConverter = $repo->getUnitConverter();
@@ -124,10 +124,10 @@  discard block
 block discarded – undo
124 124
 			$repo->getEntityTitleLookup(),
125 125
 			$entityIdLabelFormatter,
126 126
 			$constraintParameterRenderer,
127
-			new ViolationMessageRenderer( $entityIdHtmlLinkFormatter, $valueFormatter, $config ),
127
+			new ViolationMessageRenderer($entityIdHtmlLinkFormatter, $valueFormatter, $config),
128 128
 			$config
129 129
 		);
130
-		if ( $config->get( 'WBQualityConstraintsCacheCheckConstraintsResults' ) ) {
130
+		if ($config->get('WBQualityConstraintsCacheCheckConstraintsResults')) {
131 131
 			$wikiPageEntityMetaDataAccessor = new WikiPageEntityMetaDataLookup(
132 132
 				$repo->getEntityNamespaceLookup()
133 133
 			);
@@ -138,12 +138,12 @@  discard block
 block discarded – undo
138 138
 				ResultsCache::getDefaultInstance(),
139 139
 				$wikiPageEntityMetaDataAccessor,
140 140
 				$entityIdParser,
141
-				$config->get( 'WBQualityConstraintsCacheCheckConstraintsTTLSeconds' ),
141
+				$config->get('WBQualityConstraintsCacheCheckConstraintsTTLSeconds'),
142 142
 				[
143
-					$config->get( 'WBQualityConstraintsCommonsLinkConstraintId' ),
144
-					$config->get( 'WBQualityConstraintsTypeConstraintId' ),
145
-					$config->get( 'WBQualityConstraintsValueTypeConstraintId' ),
146
-					$config->get( 'WBQualityConstraintsDistinctValuesConstraintId' ),
143
+					$config->get('WBQualityConstraintsCommonsLinkConstraintId'),
144
+					$config->get('WBQualityConstraintsTypeConstraintId'),
145
+					$config->get('WBQualityConstraintsValueTypeConstraintId'),
146
+					$config->get('WBQualityConstraintsDistinctValuesConstraintId'),
147 147
 				],
148 148
 				$dataFactory
149 149
 			);
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 			$prefix,
156 156
 			$repo->getEntityIdParser(),
157 157
 			$repo->getStatementGuidValidator(),
158
-			$repo->getApiHelperFactory( RequestContext::getMain() ),
158
+			$repo->getApiHelperFactory(RequestContext::getMain()),
159 159
 			$resultsBuilder,
160 160
 			$dataFactory
161 161
 		);
@@ -181,11 +181,11 @@  discard block
 block discarded – undo
181 181
 		ResultsBuilder $resultsBuilder,
182 182
 		IBufferingStatsdDataFactory $dataFactory
183 183
 	) {
184
-		parent::__construct( $main, $name, $prefix );
184
+		parent::__construct($main, $name, $prefix);
185 185
 		$this->entityIdParser = $entityIdParser;
186 186
 		$this->statementGuidValidator = $statementGuidValidator;
187
-		$this->resultBuilder = $apiHelperFactory->getResultBuilder( $this );
188
-		$this->errorReporter = $apiHelperFactory->getErrorReporter( $this );
187
+		$this->resultBuilder = $apiHelperFactory->getResultBuilder($this);
188
+		$this->errorReporter = $apiHelperFactory->getErrorReporter($this);
189 189
 		$this->resultsBuilder = $resultsBuilder;
190 190
 		$this->dataFactory = $dataFactory;
191 191
 	}
@@ -200,9 +200,9 @@  discard block
 block discarded – undo
200 200
 
201 201
 		$params = $this->extractRequestParams();
202 202
 
203
-		$this->validateParameters( $params );
204
-		$entityIds = $this->parseEntityIds( $params );
205
-		$claimIds = $this->parseClaimIds( $params );
203
+		$this->validateParameters($params);
204
+		$entityIds = $this->parseEntityIds($params);
205
+		$claimIds = $this->parseClaimIds($params);
206 206
 		$constraintIDs = $params[self::PARAM_CONSTRAINT_ID];
207 207
 		$statuses = $params[self::PARAM_STATUS];
208 208
 
@@ -217,13 +217,13 @@  discard block
 block discarded – undo
217 217
 			)->getArray()
218 218
 		);
219 219
 		// ensure that result contains the given entity IDs even if they have no statements
220
-		foreach ( $entityIds as $entityId ) {
220
+		foreach ($entityIds as $entityId) {
221 221
 			$this->getResult()->addArrayType(
222
-				[ $this->getModuleName(), $entityId->getSerialization() ],
222
+				[$this->getModuleName(), $entityId->getSerialization()],
223 223
 				'assoc'
224 224
 			);
225 225
 		}
226
-		$this->resultBuilder->markSuccess( 1 );
226
+		$this->resultBuilder->markSuccess(1);
227 227
 	}
228 228
 
229 229
 	/**
@@ -231,24 +231,24 @@  discard block
 block discarded – undo
231 231
 	 *
232 232
 	 * @return EntityId[]
233 233
 	 */
234
-	private function parseEntityIds( array $params ) {
234
+	private function parseEntityIds(array $params) {
235 235
 		$ids = $params[self::PARAM_ID];
236 236
 
237
-		if ( $ids === null ) {
237
+		if ($ids === null) {
238 238
 			return [];
239
-		} elseif ( $ids === [] ) {
239
+		} elseif ($ids === []) {
240 240
 			$this->errorReporter->dieError(
241
-				'If ' . self::PARAM_ID . ' is specified, it must be nonempty.', 'no-data' );
241
+				'If '.self::PARAM_ID.' is specified, it must be nonempty.', 'no-data' );
242 242
 		}
243 243
 
244
-		return array_map( function ( $id ) {
244
+		return array_map(function($id) {
245 245
 			try {
246
-				return $this->entityIdParser->parse( $id );
247
-			} catch ( EntityIdParsingException $e ) {
246
+				return $this->entityIdParser->parse($id);
247
+			} catch (EntityIdParsingException $e) {
248 248
 				$this->errorReporter->dieError(
249
-					"Invalid id: $id", 'invalid-entity-id', 0, [ self::PARAM_ID => $id ] );
249
+					"Invalid id: $id", 'invalid-entity-id', 0, [self::PARAM_ID => $id] );
250 250
 			}
251
-		}, $ids );
251
+		}, $ids);
252 252
 	}
253 253
 
254 254
 	/**
@@ -256,35 +256,35 @@  discard block
 block discarded – undo
256 256
 	 *
257 257
 	 * @return string[]
258 258
 	 */
259
-	private function parseClaimIds( array $params ) {
259
+	private function parseClaimIds(array $params) {
260 260
 		$ids = $params[self::PARAM_CLAIM_ID];
261 261
 
262
-		if ( $ids === null ) {
262
+		if ($ids === null) {
263 263
 			return [];
264
-		} elseif ( $ids === [] ) {
264
+		} elseif ($ids === []) {
265 265
 			$this->errorReporter->dieError(
266
-				'If ' . self::PARAM_CLAIM_ID . ' is specified, it must be nonempty.', 'no-data' );
266
+				'If '.self::PARAM_CLAIM_ID.' is specified, it must be nonempty.', 'no-data' );
267 267
 		}
268 268
 
269
-		foreach ( $ids as $id ) {
270
-			if ( !$this->statementGuidValidator->validate( $id ) ) {
269
+		foreach ($ids as $id) {
270
+			if (!$this->statementGuidValidator->validate($id)) {
271 271
 				$this->errorReporter->dieError(
272
-					"Invalid claim id: $id", 'invalid-guid', 0, [ self::PARAM_CLAIM_ID => $id ] );
272
+					"Invalid claim id: $id", 'invalid-guid', 0, [self::PARAM_CLAIM_ID => $id] );
273 273
 			}
274 274
 		}
275 275
 
276 276
 		return $ids;
277 277
 	}
278 278
 
279
-	private function validateParameters( array $params ) {
280
-		if ( $params[self::PARAM_CONSTRAINT_ID] !== null
281
-			 && empty( $params[self::PARAM_CONSTRAINT_ID] )
279
+	private function validateParameters(array $params) {
280
+		if ($params[self::PARAM_CONSTRAINT_ID] !== null
281
+			 && empty($params[self::PARAM_CONSTRAINT_ID])
282 282
 		) {
283 283
 			$paramConstraintId = self::PARAM_CONSTRAINT_ID;
284 284
 			$this->errorReporter->dieError(
285 285
 				"If $paramConstraintId is specified, it must be nonempty.", 'no-data' );
286 286
 		}
287
-		if ( $params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null ) {
287
+		if ($params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null) {
288 288
 			$paramId = self::PARAM_ID;
289 289
 			$paramClaimId = self::PARAM_CLAIM_ID;
290 290
 			$this->errorReporter->dieError(
Please login to merge, or discard this patch.
src/ConstraintCheck/Message/ViolationMessageRenderer.php 1 patch
Spacing   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -66,31 +66,31 @@  discard block
 block discarded – undo
66 66
 	 * (temporarily, pre-rendered strings are allowed and returned without changes)
67 67
 	 * @return string
68 68
 	 */
69
-	public function render( $violationMessage ) {
70
-		if ( is_string( $violationMessage ) ) {
69
+	public function render($violationMessage) {
70
+		if (is_string($violationMessage)) {
71 71
 			// TODO remove this once all checkers produce ViolationMessage objects
72 72
 			return $violationMessage;
73 73
 		}
74 74
 
75 75
 		$messageKey = $violationMessage->getMessageKey();
76
-		$paramsLists = [ [] ];
77
-		foreach ( $violationMessage->getArguments() as $argument ) {
78
-			$params = $this->renderArgument( $argument );
76
+		$paramsLists = [[]];
77
+		foreach ($violationMessage->getArguments() as $argument) {
78
+			$params = $this->renderArgument($argument);
79 79
 			$paramsLists[] = $params;
80 80
 		}
81
-		$allParams = call_user_func_array( 'array_merge', $paramsLists );
82
-		return ( new Message( $messageKey ) )
83
-			->params( $allParams )
81
+		$allParams = call_user_func_array('array_merge', $paramsLists);
82
+		return (new Message($messageKey))
83
+			->params($allParams)
84 84
 			->escaped();
85 85
 	}
86 86
 
87
-	private function addRole( $value, $role ) {
88
-		if ( $role === null ) {
87
+	private function addRole($value, $role) {
88
+		if ($role === null) {
89 89
 			return $value;
90 90
 		}
91 91
 
92
-		return '<span class="wbqc-role wbqc-role-' . htmlspecialchars( $role ) . '">' .
93
-			$value .
92
+		return '<span class="wbqc-role wbqc-role-'.htmlspecialchars($role).'">'.
93
+			$value.
94 94
 			'</span>';
95 95
 	}
96 96
 
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 	 * @param array $argument
99 99
 	 * @return array params (for Message::params)
100 100
 	 */
101
-	private function renderArgument( array $argument ) {
101
+	private function renderArgument(array $argument) {
102 102
 		$methods = [
103 103
 			ViolationMessage::TYPE_ENTITY_ID => 'renderEntityId',
104 104
 			ViolationMessage::TYPE_ENTITY_ID_LIST => 'renderEntityIdList',
@@ -116,55 +116,55 @@  discard block
 block discarded – undo
116 116
 		$value = $argument['value'];
117 117
 		$role = $argument['role'];
118 118
 
119
-		if ( array_key_exists( $type, $methods ) ) {
119
+		if (array_key_exists($type, $methods)) {
120 120
 			$method = $methods[$type];
121
-			$params = $this->$method( $value, $role );
121
+			$params = $this->$method($value, $role);
122 122
 		} else {
123 123
 			throw new InvalidArgumentException(
124
-				'Unknown ViolationMessage argument type ' . $type . '!'
124
+				'Unknown ViolationMessage argument type '.$type.'!'
125 125
 			);
126 126
 		}
127 127
 
128
-		if ( !array_key_exists( 0, $params ) ) {
129
-			$params = [ $params ];
128
+		if (!array_key_exists(0, $params)) {
129
+			$params = [$params];
130 130
 		}
131 131
 		return $params;
132 132
 	}
133 133
 
134
-	private function renderList( array $list, $role, callable $render ) {
135
-		if ( $list === [] ) {
134
+	private function renderList(array $list, $role, callable $render) {
135
+		if ($list === []) {
136 136
 			return [
137
-				Message::numParam( 0 ),
138
-				Message::rawParam( '<ul></ul>' ),
137
+				Message::numParam(0),
138
+				Message::rawParam('<ul></ul>'),
139 139
 			];
140 140
 		}
141 141
 
142
-		if ( count( $list ) > $this->maxListLength ) {
143
-			$list = array_slice( $list, 0, $this->maxListLength );
142
+		if (count($list) > $this->maxListLength) {
143
+			$list = array_slice($list, 0, $this->maxListLength);
144 144
 			$truncated = true;
145 145
 		}
146 146
 
147 147
 		$renderedParams = array_map(
148 148
 			$render,
149 149
 			$list,
150
-			array_fill( 0, count( $list ), $role )
150
+			array_fill(0, count($list), $role)
151 151
 		);
152 152
 		$renderedElements = array_map(
153
-			function ( $param ) {
153
+			function($param) {
154 154
 				return $param['raw'];
155 155
 			},
156 156
 			$renderedParams
157 157
 		);
158
-		if ( isset( $truncated ) ) {
159
-			$renderedElements[] = wfMessage( 'ellipsis' )->escaped();
158
+		if (isset($truncated)) {
159
+			$renderedElements[] = wfMessage('ellipsis')->escaped();
160 160
 		}
161 161
 
162 162
 		return array_merge(
163 163
 			[
164
-				Message::numParam( count( $list ) ),
164
+				Message::numParam(count($list)),
165 165
 				Message::rawParam(
166
-					'<ul><li>' .
167
-					implode( '</li><li>', $renderedElements ) .
166
+					'<ul><li>'.
167
+					implode('</li><li>', $renderedElements).
168 168
 					'</li></ul>'
169 169
 				),
170 170
 			],
@@ -172,35 +172,35 @@  discard block
 block discarded – undo
172 172
 		);
173 173
 	}
174 174
 
175
-	private function renderEntityId( EntityId $entityId, $role ) {
176
-		return Message::rawParam( $this->addRole(
177
-			$this->entityIdFormatter->formatEntityId( $entityId ),
175
+	private function renderEntityId(EntityId $entityId, $role) {
176
+		return Message::rawParam($this->addRole(
177
+			$this->entityIdFormatter->formatEntityId($entityId),
178 178
 			$role
179
-		) );
179
+		));
180 180
 	}
181 181
 
182
-	private function renderEntityIdList( array $entityIdList, $role ) {
183
-		return $this->renderList( $entityIdList, $role, [ $this, 'renderEntityId' ] );
182
+	private function renderEntityIdList(array $entityIdList, $role) {
183
+		return $this->renderList($entityIdList, $role, [$this, 'renderEntityId']);
184 184
 	}
185 185
 
186
-	private function renderItemIdSnakValue( ItemIdSnakValue $value, $role ) {
187
-		switch ( true ) {
186
+	private function renderItemIdSnakValue(ItemIdSnakValue $value, $role) {
187
+		switch (true) {
188 188
 			case $value->isValue():
189
-				return $this->renderEntityId( $value->getItemId(), $role );
189
+				return $this->renderEntityId($value->getItemId(), $role);
190 190
 			case $value->isSomeValue():
191
-				return Message::rawParam( $this->addRole(
192
-					'<span class="wikibase-snakview-variation-somevaluesnak">' .
193
-						wfMessage( 'wikibase-snakview-snaktypeselector-somevalue' )->escaped() .
191
+				return Message::rawParam($this->addRole(
192
+					'<span class="wikibase-snakview-variation-somevaluesnak">'.
193
+						wfMessage('wikibase-snakview-snaktypeselector-somevalue')->escaped().
194 194
 						'</span>',
195 195
 					$role
196
-				) );
196
+				));
197 197
 			case $value->isNoValue():
198
-				return Message::rawParam( $this->addRole(
199
-					'<span class="wikibase-snakview-variation-novaluesnak">' .
200
-						wfMessage( 'wikibase-snakview-snaktypeselector-novalue' )->escaped() .
198
+				return Message::rawParam($this->addRole(
199
+					'<span class="wikibase-snakview-variation-novaluesnak">'.
200
+						wfMessage('wikibase-snakview-snaktypeselector-novalue')->escaped().
201 201
 						'</span>',
202 202
 					$role
203
-				) );
203
+				));
204 204
 			default:
205 205
 				// @codeCoverageIgnoreStart
206 206
 				throw new LogicException(
@@ -210,47 +210,47 @@  discard block
 block discarded – undo
210 210
 		}
211 211
 	}
212 212
 
213
-	private function renderItemIdSnakValueList( array $valueList, $role ) {
214
-		return $this->renderList( $valueList, $role, [ $this, 'renderItemIdSnakValue' ] );
213
+	private function renderItemIdSnakValueList(array $valueList, $role) {
214
+		return $this->renderList($valueList, $role, [$this, 'renderItemIdSnakValue']);
215 215
 	}
216 216
 
217
-	private function renderDataValue( DataValue $dataValue, $role ) {
218
-		return Message::rawParam( $this->addRole(
219
-			$this->dataValueFormatter->format( $dataValue ),
217
+	private function renderDataValue(DataValue $dataValue, $role) {
218
+		return Message::rawParam($this->addRole(
219
+			$this->dataValueFormatter->format($dataValue),
220 220
 			$role
221
-		) );
221
+		));
222 222
 	}
223 223
 
224
-	private function renderDataValueType( $dataValueType, $role ) {
224
+	private function renderDataValueType($dataValueType, $role) {
225 225
 		$messageKeys = [
226 226
 			'string' => 'datatypes-type-string',
227 227
 			'monolingualtext' => 'datatypes-monolingualtext',
228 228
 			'wikibase-entityid' => 'wbqc-dataValueType-wikibase-entityid',
229 229
 		];
230 230
 
231
-		if ( array_key_exists( $dataValueType, $messageKeys ) ) {
232
-			return Message::rawParam( $this->addRole(
233
-				wfMessage( $messageKeys[$dataValueType] )->escaped(),
231
+		if (array_key_exists($dataValueType, $messageKeys)) {
232
+			return Message::rawParam($this->addRole(
233
+				wfMessage($messageKeys[$dataValueType])->escaped(),
234 234
 				$role
235
-			) );
235
+			));
236 236
 		} else {
237 237
 			// @codeCoverageIgnoreStart
238 238
 			throw new LogicException(
239
-				'Unknown data value type ' . $dataValueType
239
+				'Unknown data value type '.$dataValueType
240 240
 			);
241 241
 			// @codeCoverageIgnoreEnd
242 242
 		}
243 243
 	}
244 244
 
245
-	private function renderInlineCode( $code, $role ) {
246
-		return Message::rawParam( $this->addRole(
247
-			'<code>' . htmlspecialchars( $code ) . '</code>',
245
+	private function renderInlineCode($code, $role) {
246
+		return Message::rawParam($this->addRole(
247
+			'<code>'.htmlspecialchars($code).'</code>',
248 248
 			$role
249
-		) );
249
+		));
250 250
 	}
251 251
 
252
-	private function renderConstraintScope( $scope, $role ) {
253
-		switch ( $scope ) {
252
+	private function renderConstraintScope($scope, $role) {
253
+		switch ($scope) {
254 254
 			case Context::TYPE_STATEMENT:
255 255
 				$itemId = $this->config->get(
256 256
 					'WBQualityConstraintsConstraintCheckedOnMainValueId'
@@ -270,20 +270,20 @@  discard block
 block discarded – undo
270 270
 				// callers should never let this happen, but if it does happen,
271 271
 				// showing “unknown value” seems reasonable
272 272
 				// @codeCoverageIgnoreStart
273
-				return $this->renderItemIdSnakValue( ItemIdSnakValue::someValue(), $role );
273
+				return $this->renderItemIdSnakValue(ItemIdSnakValue::someValue(), $role);
274 274
 				// @codeCoverageIgnoreEnd
275 275
 		}
276
-		return $this->renderEntityId( new ItemId( $itemId ), $role );
276
+		return $this->renderEntityId(new ItemId($itemId), $role);
277 277
 	}
278 278
 
279
-	private function renderConstraintScopeList( array $scopeList, $role ) {
280
-		return $this->renderList( $scopeList, $role, [ $this, 'renderConstraintScope' ] );
279
+	private function renderConstraintScopeList(array $scopeList, $role) {
280
+		return $this->renderList($scopeList, $role, [$this, 'renderConstraintScope']);
281 281
 	}
282 282
 
283
-	private function renderLanguage( $languageCode, $role ) {
283
+	private function renderLanguage($languageCode, $role) {
284 284
 		return [
285
-			Message::plaintextParam( Language::fetchLanguageName( $languageCode ) ),
286
-			Message::plaintextParam( $languageCode ),
285
+			Message::plaintextParam(Language::fetchLanguageName($languageCode)),
286
+			Message::plaintextParam($languageCode),
287 287
 		];
288 288
 	}
289 289
 
Please login to merge, or discard this patch.
src/ConstraintCheck/Message/ViolationMessage.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -103,17 +103,17 @@  discard block
 block discarded – undo
103 103
 	public function __construct(
104 104
 		$messageKey
105 105
 	) {
106
-		if ( strpos( $messageKey, self::MESSAGE_KEY_PREFIX ) !== 0 ) {
106
+		if (strpos($messageKey, self::MESSAGE_KEY_PREFIX) !== 0) {
107 107
 			throw new InvalidArgumentException(
108
-				'ViolationMessage key ⧼' .
109
-				$messageKey .
110
-				'⧽ should start with "' .
111
-				self::MESSAGE_KEY_PREFIX .
108
+				'ViolationMessage key ⧼'.
109
+				$messageKey.
110
+				'⧽ should start with "'.
111
+				self::MESSAGE_KEY_PREFIX.
112 112
 				'".'
113 113
 			);
114 114
 		}
115 115
 
116
-		$this->messageKeySuffix = substr( $messageKey, strlen( self::MESSAGE_KEY_PREFIX ) );
116
+		$this->messageKeySuffix = substr($messageKey, strlen(self::MESSAGE_KEY_PREFIX));
117 117
 		$this->arguments = [];
118 118
 	}
119 119
 
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 	 * @return string
123 123
 	 */
124 124
 	public function getMessageKey() {
125
-		return self::MESSAGE_KEY_PREFIX . $this->messageKeySuffix;
125
+		return self::MESSAGE_KEY_PREFIX.$this->messageKeySuffix;
126 126
 	}
127 127
 
128 128
 	/**
@@ -140,9 +140,9 @@  discard block
 block discarded – undo
140 140
 	 * @param mixed $value the value, which should match the $type
141 141
 	 * @return ViolationMessage
142 142
 	 */
143
-	private function withArgument( $type, $role, $value ) {
143
+	private function withArgument($type, $role, $value) {
144 144
 		$ret = clone $this;
145
-		$ret->arguments[] = [ 'type' => $type, 'role' => $role, 'value' => $value ];
145
+		$ret->arguments[] = ['type' => $type, 'role' => $role, 'value' => $value];
146 146
 		return $ret;
147 147
 	}
148 148
 
@@ -154,8 +154,8 @@  discard block
 block discarded – undo
154 154
 	 * @param string|null $role one of the Role::* constants
155 155
 	 * @return ViolationMessage
156 156
 	 */
157
-	public function withEntityId( EntityId $entityId, $role = null ) {
158
-		return $this->withArgument( self::TYPE_ENTITY_ID, $role, $entityId );
157
+	public function withEntityId(EntityId $entityId, $role = null) {
158
+		return $this->withArgument(self::TYPE_ENTITY_ID, $role, $entityId);
159 159
 	}
160 160
 
161 161
 	/**
@@ -172,8 +172,8 @@  discard block
 block discarded – undo
172 172
 	 * @param string|null $role one of the Role::* constants
173 173
 	 * @return ViolationMessage
174 174
 	 */
175
-	public function withEntityIdList( array $entityIdList, $role = null ) {
176
-		return $this->withArgument( self::TYPE_ENTITY_ID_LIST, $role, $entityIdList );
175
+	public function withEntityIdList(array $entityIdList, $role = null) {
176
+		return $this->withArgument(self::TYPE_ENTITY_ID_LIST, $role, $entityIdList);
177 177
 	}
178 178
 
179 179
 	/**
@@ -184,8 +184,8 @@  discard block
 block discarded – undo
184 184
 	 * @param string|null $role one of the Role::* constants
185 185
 	 * @return ViolationMessage
186 186
 	 */
187
-	public function withItemIdSnakValue( ItemIdSnakValue $value, $role = null ) {
188
-		return $this->withArgument( self::TYPE_ITEM_ID_SNAK_VALUE, $role, $value );
187
+	public function withItemIdSnakValue(ItemIdSnakValue $value, $role = null) {
188
+		return $this->withArgument(self::TYPE_ITEM_ID_SNAK_VALUE, $role, $value);
189 189
 	}
190 190
 
191 191
 	/**
@@ -202,8 +202,8 @@  discard block
 block discarded – undo
202 202
 	 * @param string|null $role one of the Role::* constants
203 203
 	 * @return ViolationMessage
204 204
 	 */
205
-	public function withItemIdSnakValueList( array $valueList, $role = null ) {
206
-		return $this->withArgument( self::TYPE_ITEM_ID_SNAK_VALUE_LIST, $role, $valueList );
205
+	public function withItemIdSnakValueList(array $valueList, $role = null) {
206
+		return $this->withArgument(self::TYPE_ITEM_ID_SNAK_VALUE_LIST, $role, $valueList);
207 207
 	}
208 208
 
209 209
 	/**
@@ -214,8 +214,8 @@  discard block
 block discarded – undo
214 214
 	 * @param string|null $role one of the Role::* constants
215 215
 	 * @return ViolationMessage
216 216
 	 */
217
-	public function withDataValue( DataValue $dataValue, $role = null ) {
218
-		return $this->withArgument( self::TYPE_DATA_VALUE, $role, $dataValue );
217
+	public function withDataValue(DataValue $dataValue, $role = null) {
218
+		return $this->withArgument(self::TYPE_DATA_VALUE, $role, $dataValue);
219 219
 	}
220 220
 
221 221
 	/**
@@ -230,8 +230,8 @@  discard block
 block discarded – undo
230 230
 	 * @param string|null $role one of the Role::* constants
231 231
 	 * @return ViolationMessage
232 232
 	 */
233
-	public function withDataValueType( $dataValueType, $role = null ) {
234
-		return $this->withArgument( self::TYPE_DATA_VALUE_TYPE, $role, $dataValueType );
233
+	public function withDataValueType($dataValueType, $role = null) {
234
+		return $this->withArgument(self::TYPE_DATA_VALUE_TYPE, $role, $dataValueType);
235 235
 	}
236 236
 
237 237
 	/**
@@ -242,8 +242,8 @@  discard block
 block discarded – undo
242 242
 	 * @param string|null $role one of the Role::* constants
243 243
 	 * @return ViolationMessage
244 244
 	 */
245
-	public function withInlineCode( $code, $role = null ) {
246
-		return $this->withArgument( self::TYPE_INLINE_CODE, $role, $code );
245
+	public function withInlineCode($code, $role = null) {
246
+		return $this->withArgument(self::TYPE_INLINE_CODE, $role, $code);
247 247
 	}
248 248
 
249 249
 	/**
@@ -254,8 +254,8 @@  discard block
 block discarded – undo
254 254
 	 * @param string|null $role one of the Role::* constants
255 255
 	 * @return ViolationMessage
256 256
 	 */
257
-	public function withConstraintScope( $scope, $role = null ) {
258
-		return $this->withArgument( self::TYPE_CONSTRAINT_SCOPE, $role, $scope );
257
+	public function withConstraintScope($scope, $role = null) {
258
+		return $this->withArgument(self::TYPE_CONSTRAINT_SCOPE, $role, $scope);
259 259
 	}
260 260
 
261 261
 	/**
@@ -266,8 +266,8 @@  discard block
 block discarded – undo
266 266
 	 * @param string|null $role one of the Role::* constants
267 267
 	 * @return ViolationMessage
268 268
 	 */
269
-	public function withConstraintScopeList( array $scopeList, $role = null ) {
270
-		return $this->withArgument( self::TYPE_CONSTRAINT_SCOPE_LIST, $role, $scopeList );
269
+	public function withConstraintScopeList(array $scopeList, $role = null) {
270
+		return $this->withArgument(self::TYPE_CONSTRAINT_SCOPE_LIST, $role, $scopeList);
271 271
 	}
272 272
 
273 273
 	/**
@@ -282,8 +282,8 @@  discard block
 block discarded – undo
282 282
 	 * @param string $languageCode
283 283
 	 * @return ViolationMessage
284 284
 	 */
285
-	public function withLanguage( $languageCode ) {
286
-		return $this->withArgument( self::TYPE_LANGUAGE, null, $languageCode );
285
+	public function withLanguage($languageCode) {
286
+		return $this->withArgument(self::TYPE_LANGUAGE, null, $languageCode);
287 287
 	}
288 288
 
289 289
 }
Please login to merge, or discard this patch.