Completed
Push — master ( f2dcc0...aae13f )
by
unknown
02:14
created
src/ServiceWiring-ConstraintCheckers.php 1 patch
Spacing   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -36,196 +36,196 @@
 block discarded – undo
36 36
 use WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\ValueTypeChecker;
37 37
 
38 38
 return [
39
-	ConstraintCheckerServices::CONFLICTS_WITH_CHECKER => function( MediaWikiServices $services ) {
39
+	ConstraintCheckerServices::CONFLICTS_WITH_CHECKER => function(MediaWikiServices $services) {
40 40
 		return new ConflictsWithChecker(
41
-			WikibaseServices::getEntityLookup( $services ),
42
-			ConstraintsServices::getConstraintParameterParser( $services ),
43
-			ConstraintsServices::getConnectionCheckerHelper( $services )
41
+			WikibaseServices::getEntityLookup($services),
42
+			ConstraintsServices::getConstraintParameterParser($services),
43
+			ConstraintsServices::getConnectionCheckerHelper($services)
44 44
 		);
45 45
 	},
46 46
 
47
-	ConstraintCheckerServices::ITEM_CHECKER => function( MediaWikiServices $services ) {
47
+	ConstraintCheckerServices::ITEM_CHECKER => function(MediaWikiServices $services) {
48 48
 		return new ItemChecker(
49
-			WikibaseServices::getEntityLookup( $services ),
50
-			ConstraintsServices::getConstraintParameterParser( $services ),
51
-			ConstraintsServices::getConnectionCheckerHelper( $services )
49
+			WikibaseServices::getEntityLookup($services),
50
+			ConstraintsServices::getConstraintParameterParser($services),
51
+			ConstraintsServices::getConnectionCheckerHelper($services)
52 52
 		);
53 53
 	},
54 54
 
55
-	ConstraintCheckerServices::TARGET_REQUIRED_CLAIM_CHECKER => function( MediaWikiServices $services ) {
55
+	ConstraintCheckerServices::TARGET_REQUIRED_CLAIM_CHECKER => function(MediaWikiServices $services) {
56 56
 		return new TargetRequiredClaimChecker(
57
-			WikibaseServices::getEntityLookup( $services ),
58
-			ConstraintsServices::getConstraintParameterParser( $services ),
59
-			ConstraintsServices::getConnectionCheckerHelper( $services )
57
+			WikibaseServices::getEntityLookup($services),
58
+			ConstraintsServices::getConstraintParameterParser($services),
59
+			ConstraintsServices::getConnectionCheckerHelper($services)
60 60
 		);
61 61
 	},
62 62
 
63
-	ConstraintCheckerServices::SYMMETRIC_CHECKER => function( MediaWikiServices $services ) {
63
+	ConstraintCheckerServices::SYMMETRIC_CHECKER => function(MediaWikiServices $services) {
64 64
 		return new SymmetricChecker(
65
-			WikibaseServices::getEntityLookup( $services ),
66
-			ConstraintsServices::getConnectionCheckerHelper( $services )
65
+			WikibaseServices::getEntityLookup($services),
66
+			ConstraintsServices::getConnectionCheckerHelper($services)
67 67
 		);
68 68
 	},
69 69
 
70
-	ConstraintCheckerServices::INVERSE_CHECKER => function( MediaWikiServices $services ) {
70
+	ConstraintCheckerServices::INVERSE_CHECKER => function(MediaWikiServices $services) {
71 71
 		return new InverseChecker(
72
-			WikibaseServices::getEntityLookup( $services ),
73
-			ConstraintsServices::getConstraintParameterParser( $services ),
74
-			ConstraintsServices::getConnectionCheckerHelper( $services )
72
+			WikibaseServices::getEntityLookup($services),
73
+			ConstraintsServices::getConstraintParameterParser($services),
74
+			ConstraintsServices::getConnectionCheckerHelper($services)
75 75
 		);
76 76
 	},
77 77
 
78
-	ConstraintCheckerServices::QUALIFIER_CHECKER => function( MediaWikiServices $services ) {
78
+	ConstraintCheckerServices::QUALIFIER_CHECKER => function(MediaWikiServices $services) {
79 79
 		return new QualifierChecker();
80 80
 	},
81 81
 
82
-	ConstraintCheckerServices::QUALIFIERS_CHECKER => function( MediaWikiServices $services ) {
82
+	ConstraintCheckerServices::QUALIFIERS_CHECKER => function(MediaWikiServices $services) {
83 83
 		return new QualifiersChecker(
84
-			ConstraintsServices::getConstraintParameterParser( $services )
84
+			ConstraintsServices::getConstraintParameterParser($services)
85 85
 		);
86 86
 	},
87 87
 
88
-	ConstraintCheckerServices::MANDATORY_QUALIFIERS_CHECKER => function( MediaWikiServices $services ) {
88
+	ConstraintCheckerServices::MANDATORY_QUALIFIERS_CHECKER => function(MediaWikiServices $services) {
89 89
 		return new MandatoryQualifiersChecker(
90
-			ConstraintsServices::getConstraintParameterParser( $services )
90
+			ConstraintsServices::getConstraintParameterParser($services)
91 91
 		);
92 92
 	},
93 93
 
94
-	ConstraintCheckerServices::RANGE_CHECKER => function( MediaWikiServices $services ) {
94
+	ConstraintCheckerServices::RANGE_CHECKER => function(MediaWikiServices $services) {
95 95
 		return new RangeChecker(
96
-			WikibaseServices::getPropertyDataTypeLookup( $services ),
97
-			ConstraintsServices::getConstraintParameterParser( $services ),
98
-			ConstraintsServices::getRangeCheckerHelper( $services )
96
+			WikibaseServices::getPropertyDataTypeLookup($services),
97
+			ConstraintsServices::getConstraintParameterParser($services),
98
+			ConstraintsServices::getRangeCheckerHelper($services)
99 99
 		);
100 100
 	},
101 101
 
102
-	ConstraintCheckerServices::DIFF_WITHIN_RANGE_CHECKER => function( MediaWikiServices $services ) {
102
+	ConstraintCheckerServices::DIFF_WITHIN_RANGE_CHECKER => function(MediaWikiServices $services) {
103 103
 		return new DiffWithinRangeChecker(
104
-			ConstraintsServices::getConstraintParameterParser( $services ),
105
-			ConstraintsServices::getRangeCheckerHelper( $services ),
104
+			ConstraintsServices::getConstraintParameterParser($services),
105
+			ConstraintsServices::getRangeCheckerHelper($services),
106 106
 			$services->getMainConfig()
107 107
 		);
108 108
 	},
109 109
 
110
-	ConstraintCheckerServices::TYPE_CHECKER => function( MediaWikiServices $services ) {
110
+	ConstraintCheckerServices::TYPE_CHECKER => function(MediaWikiServices $services) {
111 111
 		return new TypeChecker(
112
-			WikibaseServices::getEntityLookup( $services ),
113
-			ConstraintsServices::getConstraintParameterParser( $services ),
114
-			ConstraintsServices::getTypeCheckerHelper( $services ),
112
+			WikibaseServices::getEntityLookup($services),
113
+			ConstraintsServices::getConstraintParameterParser($services),
114
+			ConstraintsServices::getTypeCheckerHelper($services),
115 115
 			$services->getMainConfig()
116 116
 		);
117 117
 	},
118 118
 
119
-	ConstraintCheckerServices::VALUE_TYPE_CHECKER => function( MediaWikiServices $services ) {
119
+	ConstraintCheckerServices::VALUE_TYPE_CHECKER => function(MediaWikiServices $services) {
120 120
 		return new ValueTypeChecker(
121
-			WikibaseServices::getEntityLookup( $services ),
122
-			ConstraintsServices::getConstraintParameterParser( $services ),
123
-			ConstraintsServices::getTypeCheckerHelper( $services ),
121
+			WikibaseServices::getEntityLookup($services),
122
+			ConstraintsServices::getConstraintParameterParser($services),
123
+			ConstraintsServices::getTypeCheckerHelper($services),
124 124
 			$services->getMainConfig()
125 125
 		);
126 126
 	},
127 127
 
128
-	ConstraintCheckerServices::SINGLE_VALUE_CHECKER => function( MediaWikiServices $services ) {
128
+	ConstraintCheckerServices::SINGLE_VALUE_CHECKER => function(MediaWikiServices $services) {
129 129
 		return new SingleValueChecker(
130
-			ConstraintsServices::getConstraintParameterParser( $services )
130
+			ConstraintsServices::getConstraintParameterParser($services)
131 131
 		);
132 132
 	},
133 133
 
134
-	ConstraintCheckerServices::MULTI_VALUE_CHECKER => function( MediaWikiServices $services ) {
134
+	ConstraintCheckerServices::MULTI_VALUE_CHECKER => function(MediaWikiServices $services) {
135 135
 		return new MultiValueChecker(
136
-			ConstraintsServices::getConstraintParameterParser( $services )
136
+			ConstraintsServices::getConstraintParameterParser($services)
137 137
 		);
138 138
 	},
139 139
 
140
-	ConstraintCheckerServices::UNIQUE_VALUE_CHECKER => function( MediaWikiServices $services ) {
140
+	ConstraintCheckerServices::UNIQUE_VALUE_CHECKER => function(MediaWikiServices $services) {
141 141
 		// TODO return a different, dummy implementation if SPARQL is not available
142 142
 		return new UniqueValueChecker(
143
-			ConstraintsServices::getSparqlHelper( $services )
143
+			ConstraintsServices::getSparqlHelper($services)
144 144
 		);
145 145
 	},
146 146
 
147
-	ConstraintCheckerServices::FORMAT_CHECKER => function( MediaWikiServices $services ) {
147
+	ConstraintCheckerServices::FORMAT_CHECKER => function(MediaWikiServices $services) {
148 148
 		// TODO return a different, dummy implementation if SPARQL is not available
149 149
 		return new FormatChecker(
150
-			ConstraintsServices::getConstraintParameterParser( $services ),
150
+			ConstraintsServices::getConstraintParameterParser($services),
151 151
 			$services->getMainConfig(),
152
-			ConstraintsServices::getSparqlHelper( $services )
152
+			ConstraintsServices::getSparqlHelper($services)
153 153
 		);
154 154
 	},
155 155
 
156
-	ConstraintCheckerServices::COMMONS_LINK_CHECKER => function( MediaWikiServices $services ) {
156
+	ConstraintCheckerServices::COMMONS_LINK_CHECKER => function(MediaWikiServices $services) {
157 157
 		$pageNameNormalizer = new MediaWikiPageNameNormalizer();
158 158
 		return new CommonsLinkChecker(
159
-			ConstraintsServices::getConstraintParameterParser( $services ),
159
+			ConstraintsServices::getConstraintParameterParser($services),
160 160
 			$pageNameNormalizer
161 161
 		);
162 162
 	},
163 163
 
164
-	ConstraintCheckerServices::ONE_OF_CHECKER => function( MediaWikiServices $services ) {
164
+	ConstraintCheckerServices::ONE_OF_CHECKER => function(MediaWikiServices $services) {
165 165
 		return new OneOfChecker(
166
-			ConstraintsServices::getConstraintParameterParser( $services )
166
+			ConstraintsServices::getConstraintParameterParser($services)
167 167
 		);
168 168
 	},
169 169
 
170
-	ConstraintCheckerServices::VALUE_ONLY_CHECKER => function( MediaWikiServices $services ) {
170
+	ConstraintCheckerServices::VALUE_ONLY_CHECKER => function(MediaWikiServices $services) {
171 171
 		return new ValueOnlyChecker();
172 172
 	},
173 173
 
174
-	ConstraintCheckerServices::REFERENCE_CHECKER => function( MediaWikiServices $services ) {
174
+	ConstraintCheckerServices::REFERENCE_CHECKER => function(MediaWikiServices $services) {
175 175
 		return new ReferenceChecker();
176 176
 	},
177 177
 
178
-	ConstraintCheckerServices::NO_BOUNDS_CHECKER => function( MediaWikiServices $services ) {
178
+	ConstraintCheckerServices::NO_BOUNDS_CHECKER => function(MediaWikiServices $services) {
179 179
 		return new NoBoundsChecker();
180 180
 	},
181 181
 
182
-	ConstraintCheckerServices::ALLOWED_UNITS_CHECKER => function( MediaWikiServices $services ) {
182
+	ConstraintCheckerServices::ALLOWED_UNITS_CHECKER => function(MediaWikiServices $services) {
183 183
 		// TODO in the future, get UnitConverter from $services?
184 184
 		$repo = WikibaseRepo::getDefaultInstance();
185 185
 		$unitConverter = $repo->getUnitConverter();
186 186
 
187 187
 		return new AllowedUnitsChecker(
188
-			ConstraintsServices::getConstraintParameterParser( $services ),
188
+			ConstraintsServices::getConstraintParameterParser($services),
189 189
 			$unitConverter
190 190
 		);
191 191
 	},
192 192
 
193
-	ConstraintCheckerServices::SINGLE_BEST_VALUE_CHECKER => function( MediaWikiServices $services ) {
193
+	ConstraintCheckerServices::SINGLE_BEST_VALUE_CHECKER => function(MediaWikiServices $services) {
194 194
 		return new SingleBestValueChecker(
195
-			ConstraintsServices::getConstraintParameterParser( $services )
195
+			ConstraintsServices::getConstraintParameterParser($services)
196 196
 		);
197 197
 	},
198 198
 
199
-	ConstraintCheckerServices::ENTITY_TYPE_CHECKER => function( MediaWikiServices $services ) {
199
+	ConstraintCheckerServices::ENTITY_TYPE_CHECKER => function(MediaWikiServices $services) {
200 200
 		return new EntityTypeChecker(
201
-			ConstraintsServices::getConstraintParameterParser( $services )
201
+			ConstraintsServices::getConstraintParameterParser($services)
202 202
 		);
203 203
 	},
204 204
 
205
-	ConstraintCheckerServices::NONE_OF_CHECKER => function( MediaWikiServices $services ) {
205
+	ConstraintCheckerServices::NONE_OF_CHECKER => function(MediaWikiServices $services) {
206 206
 		return new NoneOfChecker(
207
-			ConstraintsServices::getConstraintParameterParser( $services )
207
+			ConstraintsServices::getConstraintParameterParser($services)
208 208
 		);
209 209
 	},
210 210
 
211
-	ConstraintCheckerServices::INTEGER_CHECKER => function( MediaWikiServices $services ) {
211
+	ConstraintCheckerServices::INTEGER_CHECKER => function(MediaWikiServices $services) {
212 212
 		return new IntegerChecker();
213 213
 	},
214 214
 
215
-	ConstraintCheckerServices::CITATION_NEEDED_CHECKER => function( MediaWikiServices $services ) {
215
+	ConstraintCheckerServices::CITATION_NEEDED_CHECKER => function(MediaWikiServices $services) {
216 216
 		return new CitationNeededChecker();
217 217
 	},
218 218
 
219
-	ConstraintCheckerServices::PROPERTY_SCOPE_CHECKER => function( MediaWikiServices $services ) {
219
+	ConstraintCheckerServices::PROPERTY_SCOPE_CHECKER => function(MediaWikiServices $services) {
220 220
 		return new PropertyScopeChecker(
221
-			ConstraintsServices::getConstraintParameterParser( $services )
221
+			ConstraintsServices::getConstraintParameterParser($services)
222 222
 		);
223 223
 	},
224 224
 
225
-	ConstraintCheckerServices::CONTEMPORARY_CHECKER => function( MediaWikiServices $services ) {
225
+	ConstraintCheckerServices::CONTEMPORARY_CHECKER => function(MediaWikiServices $services) {
226 226
 		return new ContemporaryChecker(
227
-			WikibaseServices::getEntityLookup( $services ),
228
-			ConstraintsServices::getRangeCheckerHelper( $services ),
227
+			WikibaseServices::getEntityLookup($services),
228
+			ConstraintsServices::getRangeCheckerHelper($services),
229 229
 			$services->getMainConfig()
230 230
 		);
231 231
 	},
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/CommonsLinkChecker.php 1 patch
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -70,26 +70,26 @@  discard block
 block discarded – undo
70 70
 	 * @return array first element is the namespace number (default namespace for TitleParser),
71 71
 	 * second element is a string to prepend to the title before giving it to the TitleParser
72 72
 	 */
73
-	private function getCommonsNamespace( $namespace ) {
74
-		switch ( $namespace ) {
73
+	private function getCommonsNamespace($namespace) {
74
+		switch ($namespace) {
75 75
 			case '':
76
-				return [ NS_MAIN, '' ];
76
+				return [NS_MAIN, ''];
77 77
 			// extra namespaces, see operations/mediawiki-config.git,
78 78
 			// wmf-config/InitialiseSettings.php, 'wgExtraNamespaces' key, 'commonswiki' subkey
79 79
 			case 'Creator':
80
-				return [ 100, '' ];
80
+				return [100, ''];
81 81
 			case 'TimedText':
82
-				return [ 102, '' ];
82
+				return [102, ''];
83 83
 			case 'Sequence':
84
-				return [ 104, '' ];
84
+				return [104, ''];
85 85
 			case 'Institution':
86
-				return [ 106, '' ];
86
+				return [106, ''];
87 87
 			// extension namespace, see mediawiki/extensions/JsonConfig.git,
88 88
 			// extension.json, 'namespaces' key, third element
89 89
 			case 'Data':
90
-				return [ 486, '' ];
90
+				return [486, ''];
91 91
 			default:
92
-				return [ NS_MAIN, $namespace . ':' ];
92
+				return [NS_MAIN, $namespace.':'];
93 93
 		}
94 94
 	}
95 95
 
@@ -102,17 +102,17 @@  discard block
 block discarded – undo
102 102
 	 * @throws ConstraintParameterException
103 103
 	 * @return CheckResult
104 104
 	 */
105
-	public function checkConstraint( Context $context, Constraint $constraint ) {
105
+	public function checkConstraint(Context $context, Constraint $constraint) {
106 106
 		$parameters = [];
107 107
 		$constraintParameters = $constraint->getConstraintParameters();
108
-		$namespace = $this->constraintParameterParser->parseNamespaceParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
109
-		$parameters['namespace'] = [ $namespace ];
108
+		$namespace = $this->constraintParameterParser->parseNamespaceParameter($constraintParameters, $constraint->getConstraintTypeItemId());
109
+		$parameters['namespace'] = [$namespace];
110 110
 
111 111
 		$snak = $context->getSnak();
112 112
 
113
-		if ( !$snak instanceof PropertyValueSnak ) {
113
+		if (!$snak instanceof PropertyValueSnak) {
114 114
 			// nothing to check
115
-			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE );
115
+			return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE);
116 116
 		}
117 117
 
118 118
 		$dataValue = $snak->getDataValue();
@@ -122,51 +122,51 @@  discard block
 block discarded – undo
122 122
 		 *   type of $dataValue for properties with 'Commons link' constraint has to be 'string'
123 123
 		 *   parameter $namespace can be null, works for commons galleries
124 124
 		 */
125
-		if ( $dataValue->getType() !== 'string' ) {
126
-			$message = ( new ViolationMessage( 'wbqc-violation-message-value-needed-of-type' ) )
127
-				->withEntityId( new ItemId( $constraint->getConstraintTypeItemId() ), Role::CONSTRAINT_TYPE_ITEM )
128
-				->withDataValueType( 'string' );
129
-			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message );
125
+		if ($dataValue->getType() !== 'string') {
126
+			$message = (new ViolationMessage('wbqc-violation-message-value-needed-of-type'))
127
+				->withEntityId(new ItemId($constraint->getConstraintTypeItemId()), Role::CONSTRAINT_TYPE_ITEM)
128
+				->withDataValueType('string');
129
+			return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message);
130 130
 		}
131 131
 
132 132
 		$commonsLink = $dataValue->getValue();
133 133
 
134 134
 		try {
135
-			if ( !$this->commonsLinkIsWellFormed( $commonsLink ) ) {
136
-				throw new MalformedTitleException( 'wbqc-violation-message-commons-link-not-well-formed', $commonsLink ); // caught below
135
+			if (!$this->commonsLinkIsWellFormed($commonsLink)) {
136
+				throw new MalformedTitleException('wbqc-violation-message-commons-link-not-well-formed', $commonsLink); // caught below
137 137
 			}
138 138
 
139
-			$prefix = $this->getCommonsNamespace( $namespace )[1];
139
+			$prefix = $this->getCommonsNamespace($namespace)[1];
140 140
 			$normalizedTitle = $this->pageNameNormalizer->normalizePageName(
141
-				$prefix . $commonsLink,
141
+				$prefix.$commonsLink,
142 142
 				'https://commons.wikimedia.org/w/api.php'
143 143
 			);
144 144
 
145
-			if ( $normalizedTitle === false ) {
146
-				if ( $this->valueIncludesNamespace( $commonsLink, $namespace ) ) {
147
-					throw new MalformedTitleException( 'wbqc-violation-message-commons-link-not-well-formed', $commonsLink ); // caught below
145
+			if ($normalizedTitle === false) {
146
+				if ($this->valueIncludesNamespace($commonsLink, $namespace)) {
147
+					throw new MalformedTitleException('wbqc-violation-message-commons-link-not-well-formed', $commonsLink); // caught below
148 148
 				} else {
149
-					$message = new ViolationMessage( 'wbqc-violation-message-commons-link-no-existent' );
149
+					$message = new ViolationMessage('wbqc-violation-message-commons-link-no-existent');
150 150
 					$status = CheckResult::STATUS_VIOLATION;
151 151
 				}
152 152
 			} else {
153 153
 				$message = null;
154 154
 				$status = CheckResult::STATUS_COMPLIANCE;
155 155
 			}
156
-		} catch ( MalformedTitleException $e ) {
157
-			$message = new ViolationMessage( 'wbqc-violation-message-commons-link-not-well-formed' );
156
+		} catch (MalformedTitleException $e) {
157
+			$message = new ViolationMessage('wbqc-violation-message-commons-link-not-well-formed');
158 158
 			$status = CheckResult::STATUS_VIOLATION;
159 159
 		}
160 160
 
161
-		return new CheckResult( $context, $constraint, $parameters, $status, $message );
161
+		return new CheckResult($context, $constraint, $parameters, $status, $message);
162 162
 	}
163 163
 
164
-	public function checkConstraintParameters( Constraint $constraint ) {
164
+	public function checkConstraintParameters(Constraint $constraint) {
165 165
 		$constraintParameters = $constraint->getConstraintParameters();
166 166
 		$exceptions = [];
167 167
 		try {
168
-			$this->constraintParameterParser->parseNamespaceParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
169
-		} catch ( ConstraintParameterException $e ) {
168
+			$this->constraintParameterParser->parseNamespaceParameter($constraintParameters, $constraint->getConstraintTypeItemId());
169
+		} catch (ConstraintParameterException $e) {
170 170
 			$exceptions[] = $e;
171 171
 		}
172 172
 		return $exceptions;
@@ -177,9 +177,9 @@  discard block
 block discarded – undo
177 177
 	 *
178 178
 	 * @return bool
179 179
 	 */
180
-	private function commonsLinkIsWellFormed( $commonsLink ) {
181
-		$toReplace = [ "_", "%20" ];
182
-		$compareString = trim( str_replace( $toReplace, '', $commonsLink ) );
180
+	private function commonsLinkIsWellFormed($commonsLink) {
181
+		$toReplace = ["_", "%20"];
182
+		$compareString = trim(str_replace($toReplace, '', $commonsLink));
183 183
 
184 184
 		return $commonsLink === $compareString;
185 185
 	}
@@ -193,9 +193,9 @@  discard block
 block discarded – undo
193 193
 	 *
194 194
 	 * @return bool
195 195
 	 */
196
-	private function valueIncludesNamespace( $value, $namespace ) {
196
+	private function valueIncludesNamespace($value, $namespace) {
197 197
 		return $namespace !== '' &&
198
-			strncasecmp( $value, $namespace . ':', strlen( $namespace ) + 1 ) === 0;
198
+			strncasecmp($value, $namespace.':', strlen($namespace) + 1) === 0;
199 199
 	}
200 200
 
201 201
 }
Please login to merge, or discard this patch.
src/Api/CheckConstraints.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -79,19 +79,19 @@  discard block
 block discarded – undo
79 79
 	 *
80 80
 	 * @return self
81 81
 	 */
82
-	public static function newFromGlobalState( ApiMain $main, $name, $prefix = '' ) {
82
+	public static function newFromGlobalState(ApiMain $main, $name, $prefix = '') {
83 83
 		$repo = WikibaseRepo::getDefaultInstance();
84 84
 
85 85
 		$language = $repo->getUserLanguage();
86 86
 		$formatterOptions = new FormatterOptions();
87
-		$formatterOptions->setOption( SnakFormatter::OPT_LANG, $language->getCode() );
87
+		$formatterOptions->setOption(SnakFormatter::OPT_LANG, $language->getCode());
88 88
 		$valueFormatterFactory = $repo->getValueFormatterFactory();
89
-		$valueFormatter = $valueFormatterFactory->getValueFormatter( SnakFormatter::FORMAT_HTML, $formatterOptions );
89
+		$valueFormatter = $valueFormatterFactory->getValueFormatter(SnakFormatter::FORMAT_HTML, $formatterOptions);
90 90
 
91 91
 		$entityIdHtmlLinkFormatterFactory = $repo->getEntityIdHtmlLinkFormatterFactory();
92
-		$entityIdHtmlLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter( $language );
92
+		$entityIdHtmlLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter($language);
93 93
 		$entityIdLabelFormatterFactory = new EntityIdLabelFormatterFactory();
94
-		$entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter( $language );
94
+		$entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter($language);
95 95
 		$config = MediaWikiServices::getInstance()->getMainConfig();
96 96
 		$dataFactory = MediaWikiServices::getInstance()->getStatsdDataFactory();
97 97
 
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 			$prefix,
114 114
 			$repo->getEntityIdParser(),
115 115
 			$repo->getStatementGuidValidator(),
116
-			$repo->getApiHelperFactory( RequestContext::getMain() ),
116
+			$repo->getApiHelperFactory(RequestContext::getMain()),
117 117
 			$resultsSource,
118 118
 			$checkResultsRenderer,
119 119
 			$dataFactory
@@ -142,11 +142,11 @@  discard block
 block discarded – undo
142 142
 		CheckResultsRenderer $checkResultsRenderer,
143 143
 		IBufferingStatsdDataFactory $dataFactory
144 144
 	) {
145
-		parent::__construct( $main, $name, $prefix );
145
+		parent::__construct($main, $name, $prefix);
146 146
 		$this->entityIdParser = $entityIdParser;
147 147
 		$this->statementGuidValidator = $statementGuidValidator;
148
-		$this->resultBuilder = $apiHelperFactory->getResultBuilder( $this );
149
-		$this->errorReporter = $apiHelperFactory->getErrorReporter( $this );
148
+		$this->resultBuilder = $apiHelperFactory->getResultBuilder($this);
149
+		$this->errorReporter = $apiHelperFactory->getErrorReporter($this);
150 150
 		$this->resultsSource = $resultsSource;
151 151
 		$this->checkResultsRenderer = $checkResultsRenderer;
152 152
 		$this->dataFactory = $dataFactory;
@@ -162,9 +162,9 @@  discard block
 block discarded – undo
162 162
 
163 163
 		$params = $this->extractRequestParams();
164 164
 
165
-		$this->validateParameters( $params );
166
-		$entityIds = $this->parseEntityIds( $params );
167
-		$claimIds = $this->parseClaimIds( $params );
165
+		$this->validateParameters($params);
166
+		$entityIds = $this->parseEntityIds($params);
167
+		$claimIds = $this->parseClaimIds($params);
168 168
 		$constraintIDs = $params[self::PARAM_CONSTRAINT_ID];
169 169
 		$statuses = $params[self::PARAM_STATUS];
170 170
 
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 				)
181 181
 			)->getArray()
182 182
 		);
183
-		$this->resultBuilder->markSuccess( 1 );
183
+		$this->resultBuilder->markSuccess(1);
184 184
 	}
185 185
 
186 186
 	/**
@@ -188,24 +188,24 @@  discard block
 block discarded – undo
188 188
 	 *
189 189
 	 * @return EntityId[]
190 190
 	 */
191
-	private function parseEntityIds( array $params ) {
191
+	private function parseEntityIds(array $params) {
192 192
 		$ids = $params[self::PARAM_ID];
193 193
 
194
-		if ( $ids === null ) {
194
+		if ($ids === null) {
195 195
 			return [];
196
-		} elseif ( $ids === [] ) {
196
+		} elseif ($ids === []) {
197 197
 			$this->errorReporter->dieError(
198
-				'If ' . self::PARAM_ID . ' is specified, it must be nonempty.', 'no-data' );
198
+				'If '.self::PARAM_ID.' is specified, it must be nonempty.', 'no-data' );
199 199
 		}
200 200
 
201
-		return array_map( function ( $id ) {
201
+		return array_map(function($id) {
202 202
 			try {
203
-				return $this->entityIdParser->parse( $id );
204
-			} catch ( EntityIdParsingException $e ) {
203
+				return $this->entityIdParser->parse($id);
204
+			} catch (EntityIdParsingException $e) {
205 205
 				$this->errorReporter->dieError(
206
-					"Invalid id: $id", 'invalid-entity-id', 0, [ self::PARAM_ID => $id ] );
206
+					"Invalid id: $id", 'invalid-entity-id', 0, [self::PARAM_ID => $id] );
207 207
 			}
208
-		}, $ids );
208
+		}, $ids);
209 209
 	}
210 210
 
211 211
 	/**
@@ -213,35 +213,35 @@  discard block
 block discarded – undo
213 213
 	 *
214 214
 	 * @return string[]
215 215
 	 */
216
-	private function parseClaimIds( array $params ) {
216
+	private function parseClaimIds(array $params) {
217 217
 		$ids = $params[self::PARAM_CLAIM_ID];
218 218
 
219
-		if ( $ids === null ) {
219
+		if ($ids === null) {
220 220
 			return [];
221
-		} elseif ( $ids === [] ) {
221
+		} elseif ($ids === []) {
222 222
 			$this->errorReporter->dieError(
223
-				'If ' . self::PARAM_CLAIM_ID . ' is specified, it must be nonempty.', 'no-data' );
223
+				'If '.self::PARAM_CLAIM_ID.' is specified, it must be nonempty.', 'no-data' );
224 224
 		}
225 225
 
226
-		foreach ( $ids as $id ) {
227
-			if ( !$this->statementGuidValidator->validate( $id ) ) {
226
+		foreach ($ids as $id) {
227
+			if (!$this->statementGuidValidator->validate($id)) {
228 228
 				$this->errorReporter->dieError(
229
-					"Invalid claim id: $id", 'invalid-guid', 0, [ self::PARAM_CLAIM_ID => $id ] );
229
+					"Invalid claim id: $id", 'invalid-guid', 0, [self::PARAM_CLAIM_ID => $id] );
230 230
 			}
231 231
 		}
232 232
 
233 233
 		return $ids;
234 234
 	}
235 235
 
236
-	private function validateParameters( array $params ) {
237
-		if ( $params[self::PARAM_CONSTRAINT_ID] !== null
238
-			 && empty( $params[self::PARAM_CONSTRAINT_ID] )
236
+	private function validateParameters(array $params) {
237
+		if ($params[self::PARAM_CONSTRAINT_ID] !== null
238
+			 && empty($params[self::PARAM_CONSTRAINT_ID])
239 239
 		) {
240 240
 			$paramConstraintId = self::PARAM_CONSTRAINT_ID;
241 241
 			$this->errorReporter->dieError(
242 242
 				"If $paramConstraintId is specified, it must be nonempty.", 'no-data' );
243 243
 		}
244
-		if ( $params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null ) {
244
+		if ($params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null) {
245 245
 			$paramId = self::PARAM_ID;
246 246
 			$paramClaimId = self::PARAM_CLAIM_ID;
247 247
 			$this->errorReporter->dieError(
@@ -282,12 +282,12 @@  discard block
 block discarded – undo
282 282
 				],
283 283
 				ApiBase::PARAM_ISMULTI => true,
284 284
 				ApiBase::PARAM_ALL => true,
285
-				ApiBase::PARAM_DFLT => implode( '|', [
285
+				ApiBase::PARAM_DFLT => implode('|', [
286 286
 					CheckResult::STATUS_VIOLATION,
287 287
 					CheckResult::STATUS_WARNING,
288 288
 					CheckResult::STATUS_SUGGESTION,
289 289
 					CheckResult::STATUS_BAD_PARAMETERS,
290
-				] ),
290
+				]),
291 291
 				ApiBase::PARAM_HELP_MSG_PER_VALUE => [],
292 292
 			],
293 293
 		];
Please login to merge, or discard this patch.
src/Specials/SpecialConstraintReport.php 1 patch
Spacing   +104 added lines, -104 removed lines patch added patch discarded remove patch
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 		Config $config,
137 137
 		IBufferingStatsdDataFactory $dataFactory
138 138
 	) {
139
-		parent::__construct( 'ConstraintReport' );
139
+		parent::__construct('ConstraintReport');
140 140
 
141 141
 		$this->entityLookup = $entityLookup;
142 142
 		$this->entityTitleLookup = $entityTitleLookup;
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 		$language = $this->getLanguage();
146 146
 
147 147
 		$formatterOptions = new FormatterOptions();
148
-		$formatterOptions->setOption( SnakFormatter::OPT_LANG, $language->getCode() );
148
+		$formatterOptions->setOption(SnakFormatter::OPT_LANG, $language->getCode());
149 149
 		$this->dataValueFormatter = $valueFormatterFactory->getValueFormatter(
150 150
 			SnakFormatter::FORMAT_HTML,
151 151
 			$formatterOptions
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 	 * @return string
206 206
 	 */
207 207
 	public function getDescription() {
208
-		return $this->msg( 'wbqc-constraintreport' )->escaped();
208
+		return $this->msg('wbqc-constraintreport')->escaped();
209 209
 	}
210 210
 
211 211
 	/**
@@ -217,43 +217,43 @@  discard block
 block discarded – undo
217 217
 	 * @throws EntityIdParsingException
218 218
 	 * @throws UnexpectedValueException
219 219
 	 */
220
-	public function execute( $subPage ) {
220
+	public function execute($subPage) {
221 221
 		$out = $this->getOutput();
222 222
 
223
-		$postRequest = $this->getContext()->getRequest()->getVal( 'entityid' );
224
-		if ( $postRequest ) {
225
-			$out->redirect( $this->getPageTitle( strtoupper( $postRequest ) )->getLocalURL() );
223
+		$postRequest = $this->getContext()->getRequest()->getVal('entityid');
224
+		if ($postRequest) {
225
+			$out->redirect($this->getPageTitle(strtoupper($postRequest))->getLocalURL());
226 226
 			return;
227 227
 		}
228 228
 
229 229
 		$out->enableOOUI();
230
-		$out->addModules( $this->getModules() );
230
+		$out->addModules($this->getModules());
231 231
 
232 232
 		$this->setHeaders();
233 233
 
234
-		$out->addHTML( $this->getExplanationText() );
234
+		$out->addHTML($this->getExplanationText());
235 235
 		$this->buildEntityIdForm();
236 236
 
237
-		if ( !$subPage ) {
237
+		if (!$subPage) {
238 238
 			return;
239 239
 		}
240 240
 
241
-		if ( !is_string( $subPage ) ) {
242
-			throw new InvalidArgumentException( '$subPage must be string.' );
241
+		if (!is_string($subPage)) {
242
+			throw new InvalidArgumentException('$subPage must be string.');
243 243
 		}
244 244
 
245 245
 		try {
246
-			$entityId = $this->entityIdParser->parse( $subPage );
247
-		} catch ( EntityIdParsingException $e ) {
246
+			$entityId = $this->entityIdParser->parse($subPage);
247
+		} catch (EntityIdParsingException $e) {
248 248
 			$out->addHTML(
249
-				$this->buildNotice( 'wbqc-constraintreport-invalid-entity-id', true )
249
+				$this->buildNotice('wbqc-constraintreport-invalid-entity-id', true)
250 250
 			);
251 251
 			return;
252 252
 		}
253 253
 
254
-		if ( !$this->entityLookup->hasEntity( $entityId ) ) {
254
+		if (!$this->entityLookup->hasEntity($entityId)) {
255 255
 			$out->addHTML(
256
-				$this->buildNotice( 'wbqc-constraintreport-not-existent-entity', true )
256
+				$this->buildNotice('wbqc-constraintreport-not-existent-entity', true)
257 257
 			);
258 258
 			return;
259 259
 		}
@@ -261,18 +261,18 @@  discard block
 block discarded – undo
261 261
 		$this->dataFactory->increment(
262 262
 			'wikibase.quality.constraints.specials.specialConstraintReport.executeCheck'
263 263
 		);
264
-		$results = $this->constraintChecker->checkAgainstConstraintsOnEntityId( $entityId );
264
+		$results = $this->constraintChecker->checkAgainstConstraintsOnEntityId($entityId);
265 265
 
266
-		if ( $results !== [] ) {
266
+		if ($results !== []) {
267 267
 			$out->addHTML(
268
-				$this->buildResultHeader( $entityId )
269
-				. $this->buildSummary( $results )
270
-				. $this->buildResultTable( $entityId, $results )
268
+				$this->buildResultHeader($entityId)
269
+				. $this->buildSummary($results)
270
+				. $this->buildResultTable($entityId, $results)
271 271
 			);
272 272
 		} else {
273 273
 			$out->addHTML(
274
-				$this->buildResultHeader( $entityId )
275
-				. $this->buildNotice( 'wbqc-constraintreport-empty-result' )
274
+				$this->buildResultHeader($entityId)
275
+				. $this->buildNotice('wbqc-constraintreport-empty-result')
276 276
 			);
277 277
 		}
278 278
 	}
@@ -288,15 +288,15 @@  discard block
 block discarded – undo
288 288
 				'name' => 'entityid',
289 289
 				'label-message' => 'wbqc-constraintreport-form-entityid-label',
290 290
 				'cssclass' => 'wbqc-constraintreport-form-entity-id',
291
-				'placeholder' => $this->msg( 'wbqc-constraintreport-form-entityid-placeholder' )->escaped()
291
+				'placeholder' => $this->msg('wbqc-constraintreport-form-entityid-placeholder')->escaped()
292 292
 			]
293 293
 		];
294
-		$htmlForm = HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext(), 'wbqc-constraintreport-form' );
295
-		$htmlForm->setSubmitText( $this->msg( 'wbqc-constraintreport-form-submit-label' )->escaped() );
296
-		$htmlForm->setSubmitCallback( function() {
294
+		$htmlForm = HTMLForm::factory('ooui', $formDescriptor, $this->getContext(), 'wbqc-constraintreport-form');
295
+		$htmlForm->setSubmitText($this->msg('wbqc-constraintreport-form-submit-label')->escaped());
296
+		$htmlForm->setSubmitCallback(function() {
297 297
 			return false;
298 298
 		} );
299
-		$htmlForm->setMethod( 'post' );
299
+		$htmlForm->setMethod('post');
300 300
 		$htmlForm->show();
301 301
 	}
302 302
 
@@ -310,16 +310,16 @@  discard block
 block discarded – undo
310 310
 	 *
311 311
 	 * @return string HTML
312 312
 	 */
313
-	private function buildNotice( $messageKey, $error = false ) {
314
-		if ( !is_string( $messageKey ) ) {
315
-			throw new InvalidArgumentException( '$message must be string.' );
313
+	private function buildNotice($messageKey, $error = false) {
314
+		if (!is_string($messageKey)) {
315
+			throw new InvalidArgumentException('$message must be string.');
316 316
 		}
317
-		if ( !is_bool( $error ) ) {
318
-			throw new InvalidArgumentException( '$error must be bool.' );
317
+		if (!is_bool($error)) {
318
+			throw new InvalidArgumentException('$error must be bool.');
319 319
 		}
320 320
 
321 321
 		$cssClasses = 'wbqc-constraintreport-notice';
322
-		if ( $error ) {
322
+		if ($error) {
323 323
 			$cssClasses .= ' wbqc-constraintreport-notice-error';
324 324
 		}
325 325
 
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 				[
329 329
 					'class' => $cssClasses
330 330
 				],
331
-				$this->msg( $messageKey )->escaped()
331
+				$this->msg($messageKey)->escaped()
332 332
 			);
333 333
 	}
334 334
 
@@ -338,16 +338,16 @@  discard block
 block discarded – undo
338 338
 	private function getExplanationText() {
339 339
 		return Html::rawElement(
340 340
 			'div',
341
-			[ 'class' => 'wbqc-explanation' ],
341
+			['class' => 'wbqc-explanation'],
342 342
 			Html::rawElement(
343 343
 				'p',
344 344
 				[],
345
-				$this->msg( 'wbqc-constraintreport-explanation-part-one' )->escaped()
345
+				$this->msg('wbqc-constraintreport-explanation-part-one')->escaped()
346 346
 			)
347 347
 			. Html::rawElement(
348 348
 				'p',
349 349
 				[],
350
-				$this->msg( 'wbqc-constraintreport-explanation-part-two' )->escaped()
350
+				$this->msg('wbqc-constraintreport-explanation-part-two')->escaped()
351 351
 			)
352 352
 		);
353 353
 	}
@@ -358,72 +358,72 @@  discard block
 block discarded – undo
358 358
 	 *
359 359
 	 * @return string HTML
360 360
 	 */
361
-	private function buildResultTable( EntityId $entityId, array $results ) {
361
+	private function buildResultTable(EntityId $entityId, array $results) {
362 362
 		// Set table headers
363 363
 		$table = new HtmlTableBuilder(
364 364
 			[
365 365
 				new HtmlTableHeaderBuilder(
366
-					$this->msg( 'wbqc-constraintreport-result-table-header-status' )->escaped(),
366
+					$this->msg('wbqc-constraintreport-result-table-header-status')->escaped(),
367 367
 					true
368 368
 				),
369 369
 				new HtmlTableHeaderBuilder(
370
-					$this->msg( 'wbqc-constraintreport-result-table-header-property' )->escaped(),
370
+					$this->msg('wbqc-constraintreport-result-table-header-property')->escaped(),
371 371
 					true
372 372
 				),
373 373
 				new HtmlTableHeaderBuilder(
374
-					$this->msg( 'wbqc-constraintreport-result-table-header-message' )->escaped(),
374
+					$this->msg('wbqc-constraintreport-result-table-header-message')->escaped(),
375 375
 					true
376 376
 				),
377 377
 				new HtmlTableHeaderBuilder(
378
-					$this->msg( 'wbqc-constraintreport-result-table-header-constraint' )->escaped(),
378
+					$this->msg('wbqc-constraintreport-result-table-header-constraint')->escaped(),
379 379
 					true
380 380
 				)
381 381
 			]
382 382
 		);
383 383
 
384
-		foreach ( $results as $result ) {
385
-			$table = $this->appendToResultTable( $table, $entityId, $result );
384
+		foreach ($results as $result) {
385
+			$table = $this->appendToResultTable($table, $entityId, $result);
386 386
 		}
387 387
 
388 388
 		return $table->toHtml();
389 389
 	}
390 390
 
391
-	private function appendToResultTable( HtmlTableBuilder $table, EntityId $entityId, CheckResult $result ) {
391
+	private function appendToResultTable(HtmlTableBuilder $table, EntityId $entityId, CheckResult $result) {
392 392
 		$message = $result->getMessage();
393
-		if ( $message === null ) {
393
+		if ($message === null) {
394 394
 			// no row for this result
395 395
 			return $table;
396 396
 		}
397 397
 
398 398
 		// Status column
399
-		$statusColumn = $this->formatStatus( $result->getStatus() );
399
+		$statusColumn = $this->formatStatus($result->getStatus());
400 400
 
401 401
 		// Property column
402
-		$propertyId = new PropertyId( $result->getContextCursor()->getSnakPropertyId() );
402
+		$propertyId = new PropertyId($result->getContextCursor()->getSnakPropertyId());
403 403
 		$propertyColumn = $this->getClaimLink(
404 404
 			$entityId,
405 405
 			$propertyId,
406
-			$this->entityIdLabelFormatter->formatEntityId( $propertyId )
406
+			$this->entityIdLabelFormatter->formatEntityId($propertyId)
407 407
 		);
408 408
 
409 409
 		// Message column
410
-		$messageColumn = $this->violationMessageRenderer->render( $message );
410
+		$messageColumn = $this->violationMessageRenderer->render($message);
411 411
 
412 412
 		// Constraint column
413 413
 		$constraintTypeItemId = $result->getConstraint()->getConstraintTypeItemId();
414 414
 		try {
415
-			$constraintTypeLabel = $this->entityIdLabelFormatter->formatEntityId( new ItemId( $constraintTypeItemId ) );
416
-		} catch ( InvalidArgumentException $e ) {
417
-			$constraintTypeLabel = htmlspecialchars( $constraintTypeItemId );
415
+			$constraintTypeLabel = $this->entityIdLabelFormatter->formatEntityId(new ItemId($constraintTypeItemId));
416
+		} catch (InvalidArgumentException $e) {
417
+			$constraintTypeLabel = htmlspecialchars($constraintTypeItemId);
418 418
 		}
419 419
 		$constraintLink = $this->getClaimLink(
420 420
 			$propertyId,
421
-			new PropertyId( $this->config->get( 'WBQualityConstraintsPropertyConstraintId' ) ),
421
+			new PropertyId($this->config->get('WBQualityConstraintsPropertyConstraintId')),
422 422
 			$constraintTypeLabel
423 423
 		);
424 424
 		$constraintColumn = $this->buildExpandableElement(
425 425
 			$constraintLink,
426
-			$this->constraintParameterRenderer->formatParameters( $result->getParameters() ),
426
+			$this->constraintParameterRenderer->formatParameters($result->getParameters()),
427 427
 			'[...]'
428 428
 		);
429 429
 
@@ -463,15 +463,15 @@  discard block
 block discarded – undo
463 463
 	 *
464 464
 	 * @return string HTML
465 465
 	 */
466
-	protected function buildResultHeader( EntityId $entityId ) {
467
-		$entityLink = sprintf( '%s (%s)',
468
-							   $this->entityIdLinkFormatter->formatEntityId( $entityId ),
469
-							   htmlspecialchars( $entityId->getSerialization() ) );
466
+	protected function buildResultHeader(EntityId $entityId) {
467
+		$entityLink = sprintf('%s (%s)',
468
+							   $this->entityIdLinkFormatter->formatEntityId($entityId),
469
+							   htmlspecialchars($entityId->getSerialization()));
470 470
 
471 471
 		return Html::rawElement(
472 472
 			'h3',
473 473
 			[],
474
-			sprintf( '%s %s', $this->msg( 'wbqc-constraintreport-result-headline' )->escaped(), $entityLink )
474
+			sprintf('%s %s', $this->msg('wbqc-constraintreport-result-headline')->escaped(), $entityLink)
475 475
 		);
476 476
 	}
477 477
 
@@ -482,24 +482,24 @@  discard block
 block discarded – undo
482 482
 	 *
483 483
 	 * @return string HTML
484 484
 	 */
485
-	protected function buildSummary( array $results ) {
485
+	protected function buildSummary(array $results) {
486 486
 		$statuses = [];
487
-		foreach ( $results as $result ) {
488
-			$status = strtolower( $result->getStatus() );
489
-			$statuses[$status] = isset( $statuses[$status] ) ? $statuses[$status] + 1 : 1;
487
+		foreach ($results as $result) {
488
+			$status = strtolower($result->getStatus());
489
+			$statuses[$status] = isset($statuses[$status]) ? $statuses[$status] + 1 : 1;
490 490
 		}
491 491
 
492 492
 		$statusElements = [];
493
-		foreach ( $statuses as $status => $count ) {
494
-			if ( $count > 0 ) {
493
+		foreach ($statuses as $status => $count) {
494
+			if ($count > 0) {
495 495
 				$statusElements[] =
496
-					$this->formatStatus( $status )
496
+					$this->formatStatus($status)
497 497
 					. ': '
498 498
 					. $count;
499 499
 			}
500 500
 		}
501 501
 
502
-		return Html::rawElement( 'p', [], implode( ', ', $statusElements ) );
502
+		return Html::rawElement('p', [], implode(', ', $statusElements));
503 503
 	}
504 504
 
505 505
 	/**
@@ -514,15 +514,15 @@  discard block
 block discarded – undo
514 514
 	 *
515 515
 	 * @return string HTML
516 516
 	 */
517
-	protected function buildExpandableElement( $content, $expandableContent, $indicator ) {
518
-		if ( !is_string( $content ) ) {
519
-			throw new InvalidArgumentException( '$content has to be string.' );
517
+	protected function buildExpandableElement($content, $expandableContent, $indicator) {
518
+		if (!is_string($content)) {
519
+			throw new InvalidArgumentException('$content has to be string.');
520 520
 		}
521
-		if ( $expandableContent && ( !is_string( $expandableContent ) ) ) {
522
-			throw new InvalidArgumentException( '$tooltipContent, if provided, has to be string.' );
521
+		if ($expandableContent && (!is_string($expandableContent))) {
522
+			throw new InvalidArgumentException('$tooltipContent, if provided, has to be string.');
523 523
 		}
524 524
 
525
-		if ( empty( $expandableContent ) ) {
525
+		if (empty($expandableContent)) {
526 526
 			return $content;
527 527
 		}
528 528
 
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
 			$expandableContent
543 543
 		);
544 544
 
545
-		return sprintf( '%s %s %s', $content, $tooltipIndicator, $expandableContent );
545
+		return sprintf('%s %s %s', $content, $tooltipIndicator, $expandableContent);
546 546
 	}
547 547
 
548 548
 	/**
@@ -554,8 +554,8 @@  discard block
 block discarded – undo
554 554
 	 *
555 555
 	 * @return string HTML
556 556
 	 */
557
-	private function formatStatus( $status ) {
558
-		$messageName = "wbqc-constraintreport-status-" . strtolower( $status );
557
+	private function formatStatus($status) {
558
+		$messageName = "wbqc-constraintreport-status-".strtolower($status);
559 559
 		$statusIcons = [
560 560
 			CheckResult::STATUS_SUGGESTION => [
561 561
 				'icon' => 'suggestion-constraint-violation',
@@ -572,25 +572,25 @@  discard block
 block discarded – undo
572 572
 			],
573 573
 		];
574 574
 
575
-		if ( array_key_exists( $status, $statusIcons ) ) {
576
-			$iconWidget = new IconWidget( $statusIcons[$status] );
577
-			$iconHtml = $iconWidget->toString() . ' ';
575
+		if (array_key_exists($status, $statusIcons)) {
576
+			$iconWidget = new IconWidget($statusIcons[$status]);
577
+			$iconHtml = $iconWidget->toString().' ';
578 578
 		} else {
579 579
 			$iconHtml = '';
580 580
 		}
581 581
 
582
-		$labelWidget = new LabelWidget( [
583
-			'label' => $this->msg( $messageName )->text(),
584
-		] );
582
+		$labelWidget = new LabelWidget([
583
+			'label' => $this->msg($messageName)->text(),
584
+		]);
585 585
 		$labelHtml = $labelWidget->toString();
586 586
 
587 587
 		$formattedStatus =
588 588
 			Html::rawElement(
589 589
 				'span',
590 590
 				[
591
-					'class' => 'wbqc-status wbqc-status-' . $status
591
+					'class' => 'wbqc-status wbqc-status-'.$status
592 592
 				],
593
-				$iconHtml . $labelHtml
593
+				$iconHtml.$labelHtml
594 594
 			);
595 595
 
596 596
 		return $formattedStatus;
@@ -606,26 +606,26 @@  discard block
 block discarded – undo
606 606
 	 *
607 607
 	 * @return string HTML
608 608
 	 */
609
-	protected function formatDataValues( $dataValues, $separator = ', ' ) {
610
-		if ( $dataValues instanceof DataValue ) {
611
-			$dataValues = [ $dataValues ];
612
-		} elseif ( !is_array( $dataValues ) ) {
613
-			throw new InvalidArgumentException( '$dataValues has to be instance of DataValue or an array of DataValues.' );
609
+	protected function formatDataValues($dataValues, $separator = ', ') {
610
+		if ($dataValues instanceof DataValue) {
611
+			$dataValues = [$dataValues];
612
+		} elseif (!is_array($dataValues)) {
613
+			throw new InvalidArgumentException('$dataValues has to be instance of DataValue or an array of DataValues.');
614 614
 		}
615 615
 
616 616
 		$formattedDataValues = [];
617
-		foreach ( $dataValues as $dataValue ) {
618
-			if ( !( $dataValue instanceof DataValue ) ) {
619
-				throw new InvalidArgumentException( '$dataValues has to be instance of DataValue or an array of DataValues.' );
617
+		foreach ($dataValues as $dataValue) {
618
+			if (!($dataValue instanceof DataValue)) {
619
+				throw new InvalidArgumentException('$dataValues has to be instance of DataValue or an array of DataValues.');
620 620
 			}
621
-			if ( $dataValue instanceof EntityIdValue ) {
622
-				$formattedDataValues[ ] = $this->entityIdLabelFormatter->formatEntityId( $dataValue->getEntityId() );
621
+			if ($dataValue instanceof EntityIdValue) {
622
+				$formattedDataValues[] = $this->entityIdLabelFormatter->formatEntityId($dataValue->getEntityId());
623 623
 			} else {
624
-				$formattedDataValues[ ] = $this->dataValueFormatter->format( $dataValue );
624
+				$formattedDataValues[] = $this->dataValueFormatter->format($dataValue);
625 625
 			}
626 626
 		}
627 627
 
628
-		return implode( $separator, $formattedDataValues );
628
+		return implode($separator, $formattedDataValues);
629 629
 	}
630 630
 
631 631
 	/**
@@ -637,11 +637,11 @@  discard block
 block discarded – undo
637 637
 	 *
638 638
 	 * @return string HTML
639 639
 	 */
640
-	private function getClaimLink( EntityId $entityId, PropertyId $propertyId, $text ) {
640
+	private function getClaimLink(EntityId $entityId, PropertyId $propertyId, $text) {
641 641
 		return Html::rawElement(
642 642
 			'a',
643 643
 			[
644
-				'href' => $this->getClaimUrl( $entityId, $propertyId ),
644
+				'href' => $this->getClaimUrl($entityId, $propertyId),
645 645
 				'target' => '_blank'
646 646
 			],
647 647
 			$text
@@ -656,9 +656,9 @@  discard block
 block discarded – undo
656 656
 	 *
657 657
 	 * @return string
658 658
 	 */
659
-	private function getClaimUrl( EntityId $entityId, PropertyId $propertyId ) {
660
-		$title = $this->entityTitleLookup->getTitleForId( $entityId );
661
-		$entityUrl = sprintf( '%s#%s', $title->getLocalURL(), $propertyId->getSerialization() );
659
+	private function getClaimUrl(EntityId $entityId, PropertyId $propertyId) {
660
+		$title = $this->entityTitleLookup->getTitleForId($entityId);
661
+		$entityUrl = sprintf('%s#%s', $title->getLocalURL(), $propertyId->getSerialization());
662 662
 
663 663
 		return $entityUrl;
664 664
 	}
Please login to merge, or discard this patch.
src/ConstraintCheck/Helper/ConstraintParameterParser.php 1 patch
Spacing   +286 added lines, -286 removed lines patch added patch discarded remove patch
@@ -78,15 +78,15 @@  discard block
 block discarded – undo
78 78
 	 * @param array $parameters
79 79
 	 * @throws ConstraintParameterException
80 80
 	 */
81
-	public function checkError( array $parameters ) {
82
-		if ( array_key_exists( '@error', $parameters ) ) {
81
+	public function checkError(array $parameters) {
82
+		if (array_key_exists('@error', $parameters)) {
83 83
 			$error = $parameters['@error'];
84
-			if ( array_key_exists( 'toolong', $error ) && $error['toolong'] ) {
84
+			if (array_key_exists('toolong', $error) && $error['toolong']) {
85 85
 				$msg = 'wbqc-violation-message-parameters-error-toolong';
86 86
 			} else {
87 87
 				$msg = 'wbqc-violation-message-parameters-error-unknown';
88 88
 			}
89
-			throw new ConstraintParameterException( new ViolationMessage( $msg ) );
89
+			throw new ConstraintParameterException(new ViolationMessage($msg));
90 90
 		}
91 91
 	}
92 92
 
@@ -96,11 +96,11 @@  discard block
 block discarded – undo
96 96
 	 * @param string $parameterId
97 97
 	 * @throws ConstraintParameterException
98 98
 	 */
99
-	private function requireSingleParameter( array $parameters, $parameterId ) {
100
-		if ( count( $parameters[$parameterId] ) !== 1 ) {
99
+	private function requireSingleParameter(array $parameters, $parameterId) {
100
+		if (count($parameters[$parameterId]) !== 1) {
101 101
 			throw new ConstraintParameterException(
102
-				( new ViolationMessage( 'wbqc-violation-message-parameter-single' ) )
103
-					->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
102
+				(new ViolationMessage('wbqc-violation-message-parameter-single'))
103
+					->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
104 104
 			);
105 105
 		}
106 106
 	}
@@ -112,11 +112,11 @@  discard block
 block discarded – undo
112 112
 	 * @return void
113 113
 	 * @throws ConstraintParameterException
114 114
 	 */
115
-	private function requireValueParameter( Snak $snak, $parameterId ) {
116
-		if ( !( $snak instanceof PropertyValueSnak ) ) {
115
+	private function requireValueParameter(Snak $snak, $parameterId) {
116
+		if (!($snak instanceof PropertyValueSnak)) {
117 117
 			throw new ConstraintParameterException(
118
-				( new ViolationMessage( 'wbqc-violation-message-parameter-value' ) )
119
-					->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
118
+				(new ViolationMessage('wbqc-violation-message-parameter-value'))
119
+					->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
120 120
 			);
121 121
 		}
122 122
 	}
@@ -128,17 +128,17 @@  discard block
 block discarded – undo
128 128
 	 * @throws ConstraintParameterException
129 129
 	 * @return EntityId
130 130
 	 */
131
-	private function parseEntityIdParameter( array $snakSerialization, $parameterId ) {
132
-		$snak = $this->snakDeserializer->deserialize( $snakSerialization );
133
-		$this->requireValueParameter( $snak, $parameterId );
131
+	private function parseEntityIdParameter(array $snakSerialization, $parameterId) {
132
+		$snak = $this->snakDeserializer->deserialize($snakSerialization);
133
+		$this->requireValueParameter($snak, $parameterId);
134 134
 		$value = $snak->getDataValue();
135
-		if ( $value instanceof EntityIdValue ) {
135
+		if ($value instanceof EntityIdValue) {
136 136
 			return $value->getEntityId();
137 137
 		} else {
138 138
 			throw new ConstraintParameterException(
139
-				( new ViolationMessage( 'wbqc-violation-message-parameter-entity' ) )
140
-					->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
141
-					->withDataValue( $value, Role::CONSTRAINT_PARAMETER_VALUE )
139
+				(new ViolationMessage('wbqc-violation-message-parameter-entity'))
140
+					->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
141
+					->withDataValue($value, Role::CONSTRAINT_PARAMETER_VALUE)
142 142
 			);
143 143
 		}
144 144
 	}
@@ -149,20 +149,20 @@  discard block
 block discarded – undo
149 149
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
150 150
 	 * @return string[] class entity ID serializations
151 151
 	 */
152
-	public function parseClassParameter( array $constraintParameters, $constraintTypeItemId ) {
153
-		$this->checkError( $constraintParameters );
154
-		$classId = $this->config->get( 'WBQualityConstraintsClassId' );
155
-		if ( !array_key_exists( $classId, $constraintParameters ) ) {
152
+	public function parseClassParameter(array $constraintParameters, $constraintTypeItemId) {
153
+		$this->checkError($constraintParameters);
154
+		$classId = $this->config->get('WBQualityConstraintsClassId');
155
+		if (!array_key_exists($classId, $constraintParameters)) {
156 156
 			throw new ConstraintParameterException(
157
-				( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
158
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
159
-					->withEntityId( new PropertyId( $classId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
157
+				(new ViolationMessage('wbqc-violation-message-parameter-needed'))
158
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
159
+					->withEntityId(new PropertyId($classId), Role::CONSTRAINT_PARAMETER_PROPERTY)
160 160
 			);
161 161
 		}
162 162
 
163 163
 		$classes = [];
164
-		foreach ( $constraintParameters[$classId] as $class ) {
165
-			$classes[] = $this->parseEntityIdParameter( $class, $classId )->getSerialization();
164
+		foreach ($constraintParameters[$classId] as $class) {
165
+			$classes[] = $this->parseEntityIdParameter($class, $classId)->getSerialization();
166 166
 		}
167 167
 		return $classes;
168 168
 	}
@@ -173,23 +173,23 @@  discard block
 block discarded – undo
173 173
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
174 174
 	 * @return string 'instance', 'subclass', or 'instanceOrSubclass'
175 175
 	 */
176
-	public function parseRelationParameter( array $constraintParameters, $constraintTypeItemId ) {
177
-		$this->checkError( $constraintParameters );
178
-		$relationId = $this->config->get( 'WBQualityConstraintsRelationId' );
179
-		if ( !array_key_exists( $relationId, $constraintParameters ) ) {
176
+	public function parseRelationParameter(array $constraintParameters, $constraintTypeItemId) {
177
+		$this->checkError($constraintParameters);
178
+		$relationId = $this->config->get('WBQualityConstraintsRelationId');
179
+		if (!array_key_exists($relationId, $constraintParameters)) {
180 180
 			throw new ConstraintParameterException(
181
-				( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
182
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
183
-					->withEntityId( new PropertyId( $relationId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
181
+				(new ViolationMessage('wbqc-violation-message-parameter-needed'))
182
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
183
+					->withEntityId(new PropertyId($relationId), Role::CONSTRAINT_PARAMETER_PROPERTY)
184 184
 			);
185 185
 		}
186 186
 
187
-		$this->requireSingleParameter( $constraintParameters, $relationId );
188
-		$relationEntityId = $this->parseEntityIdParameter( $constraintParameters[$relationId][0], $relationId );
189
-		$instanceId = $this->config->get( 'WBQualityConstraintsInstanceOfRelationId' );
190
-		$subclassId = $this->config->get( 'WBQualityConstraintsSubclassOfRelationId' );
191
-		$instanceOrSubclassId = $this->config->get( 'WBQualityConstraintsInstanceOrSubclassOfRelationId' );
192
-		switch ( $relationEntityId ) {
187
+		$this->requireSingleParameter($constraintParameters, $relationId);
188
+		$relationEntityId = $this->parseEntityIdParameter($constraintParameters[$relationId][0], $relationId);
189
+		$instanceId = $this->config->get('WBQualityConstraintsInstanceOfRelationId');
190
+		$subclassId = $this->config->get('WBQualityConstraintsSubclassOfRelationId');
191
+		$instanceOrSubclassId = $this->config->get('WBQualityConstraintsInstanceOrSubclassOfRelationId');
192
+		switch ($relationEntityId) {
193 193
 			case $instanceId:
194 194
 				return 'instance';
195 195
 			case $subclassId:
@@ -198,13 +198,13 @@  discard block
 block discarded – undo
198 198
 				return 'instanceOrSubclass';
199 199
 			default:
200 200
 				throw new ConstraintParameterException(
201
-					( new ViolationMessage( 'wbqc-violation-message-parameter-oneof' ) )
202
-						->withEntityId( new PropertyId( $relationId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
201
+					(new ViolationMessage('wbqc-violation-message-parameter-oneof'))
202
+						->withEntityId(new PropertyId($relationId), Role::CONSTRAINT_PARAMETER_PROPERTY)
203 203
 						->withEntityIdList(
204 204
 							[
205
-								new ItemId( $instanceId ),
206
-								new ItemId( $subclassId ),
207
-								new ItemId( $instanceOrSubclassId ),
205
+								new ItemId($instanceId),
206
+								new ItemId($subclassId),
207
+								new ItemId($instanceOrSubclassId),
208 208
 							],
209 209
 							Role::CONSTRAINT_PARAMETER_VALUE
210 210
 						)
@@ -219,20 +219,20 @@  discard block
 block discarded – undo
219 219
 	 * @throws ConstraintParameterException
220 220
 	 * @return PropertyId
221 221
 	 */
222
-	private function parsePropertyIdParameter( array $snakSerialization, $parameterId ) {
223
-		$snak = $this->snakDeserializer->deserialize( $snakSerialization );
224
-		$this->requireValueParameter( $snak, $parameterId );
222
+	private function parsePropertyIdParameter(array $snakSerialization, $parameterId) {
223
+		$snak = $this->snakDeserializer->deserialize($snakSerialization);
224
+		$this->requireValueParameter($snak, $parameterId);
225 225
 		$value = $snak->getDataValue();
226
-		if ( $value instanceof EntityIdValue ) {
226
+		if ($value instanceof EntityIdValue) {
227 227
 			$id = $value->getEntityId();
228
-			if ( $id instanceof PropertyId ) {
228
+			if ($id instanceof PropertyId) {
229 229
 				return $id;
230 230
 			}
231 231
 		}
232 232
 		throw new ConstraintParameterException(
233
-			( new ViolationMessage( 'wbqc-violation-message-parameter-property' ) )
234
-				->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
235
-				->withDataValue( $value, Role::CONSTRAINT_PARAMETER_VALUE )
233
+			(new ViolationMessage('wbqc-violation-message-parameter-property'))
234
+				->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
235
+				->withDataValue($value, Role::CONSTRAINT_PARAMETER_VALUE)
236 236
 		);
237 237
 	}
238 238
 
@@ -243,32 +243,32 @@  discard block
 block discarded – undo
243 243
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
244 244
 	 * @return PropertyId
245 245
 	 */
246
-	public function parsePropertyParameter( array $constraintParameters, $constraintTypeItemId ) {
247
-		$this->checkError( $constraintParameters );
248
-		$propertyId = $this->config->get( 'WBQualityConstraintsPropertyId' );
249
-		if ( !array_key_exists( $propertyId, $constraintParameters ) ) {
246
+	public function parsePropertyParameter(array $constraintParameters, $constraintTypeItemId) {
247
+		$this->checkError($constraintParameters);
248
+		$propertyId = $this->config->get('WBQualityConstraintsPropertyId');
249
+		if (!array_key_exists($propertyId, $constraintParameters)) {
250 250
 			throw new ConstraintParameterException(
251
-				( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
252
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
253
-					->withEntityId( new PropertyId( $propertyId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
251
+				(new ViolationMessage('wbqc-violation-message-parameter-needed'))
252
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
253
+					->withEntityId(new PropertyId($propertyId), Role::CONSTRAINT_PARAMETER_PROPERTY)
254 254
 			);
255 255
 		}
256 256
 
257
-		$this->requireSingleParameter( $constraintParameters, $propertyId );
258
-		return $this->parsePropertyIdParameter( $constraintParameters[$propertyId][0], $propertyId );
257
+		$this->requireSingleParameter($constraintParameters, $propertyId);
258
+		return $this->parsePropertyIdParameter($constraintParameters[$propertyId][0], $propertyId);
259 259
 	}
260 260
 
261
-	private function parseItemIdParameter( PropertyValueSnak $snak, $parameterId ) {
261
+	private function parseItemIdParameter(PropertyValueSnak $snak, $parameterId) {
262 262
 		$dataValue = $snak->getDataValue();
263
-		if ( $dataValue instanceof EntityIdValue &&
263
+		if ($dataValue instanceof EntityIdValue &&
264 264
 			$dataValue->getEntityId() instanceof ItemId
265 265
 		) {
266
-			return ItemIdSnakValue::fromItemId( $dataValue->getEntityId() );
266
+			return ItemIdSnakValue::fromItemId($dataValue->getEntityId());
267 267
 		} else {
268 268
 			throw new ConstraintParameterException(
269
-				( new ViolationMessage( 'wbqc-violation-message-parameter-item' ) )
270
-					->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
271
-					->withDataValue( $dataValue, Role::CONSTRAINT_PARAMETER_VALUE )
269
+				(new ViolationMessage('wbqc-violation-message-parameter-item'))
270
+					->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
271
+					->withDataValue($dataValue, Role::CONSTRAINT_PARAMETER_VALUE)
272 272
 			);
273 273
 		}
274 274
 	}
@@ -287,16 +287,16 @@  discard block
 block discarded – undo
287 287
 		$required,
288 288
 		$parameterId = null
289 289
 	) {
290
-		$this->checkError( $constraintParameters );
291
-		if ( $parameterId === null ) {
292
-			$parameterId = $this->config->get( 'WBQualityConstraintsQualifierOfPropertyConstraintId' );
290
+		$this->checkError($constraintParameters);
291
+		if ($parameterId === null) {
292
+			$parameterId = $this->config->get('WBQualityConstraintsQualifierOfPropertyConstraintId');
293 293
 		}
294
-		if ( !array_key_exists( $parameterId, $constraintParameters ) ) {
295
-			if ( $required ) {
294
+		if (!array_key_exists($parameterId, $constraintParameters)) {
295
+			if ($required) {
296 296
 				throw new ConstraintParameterException(
297
-					( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
298
-						->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
299
-						->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
297
+					(new ViolationMessage('wbqc-violation-message-parameter-needed'))
298
+						->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
299
+						->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
300 300
 				);
301 301
 			} else {
302 302
 				return [];
@@ -304,11 +304,11 @@  discard block
 block discarded – undo
304 304
 		}
305 305
 
306 306
 		$values = [];
307
-		foreach ( $constraintParameters[$parameterId] as $parameter ) {
308
-			$snak = $this->snakDeserializer->deserialize( $parameter );
309
-			switch ( true ) {
307
+		foreach ($constraintParameters[$parameterId] as $parameter) {
308
+			$snak = $this->snakDeserializer->deserialize($parameter);
309
+			switch (true) {
310 310
 				case $snak instanceof PropertyValueSnak:
311
-					$values[] = $this->parseItemIdParameter( $snak, $parameterId );
311
+					$values[] = $this->parseItemIdParameter($snak, $parameterId);
312 312
 					break;
313 313
 				case $snak instanceof PropertySomeValueSnak:
314 314
 					$values[] = ItemIdSnakValue::someValue();
@@ -327,27 +327,27 @@  discard block
 block discarded – undo
327 327
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
328 328
 	 * @return PropertyId[]
329 329
 	 */
330
-	public function parsePropertiesParameter( array $constraintParameters, $constraintTypeItemId ) {
331
-		$this->checkError( $constraintParameters );
332
-		$propertyId = $this->config->get( 'WBQualityConstraintsPropertyId' );
333
-		if ( !array_key_exists( $propertyId, $constraintParameters ) ) {
330
+	public function parsePropertiesParameter(array $constraintParameters, $constraintTypeItemId) {
331
+		$this->checkError($constraintParameters);
332
+		$propertyId = $this->config->get('WBQualityConstraintsPropertyId');
333
+		if (!array_key_exists($propertyId, $constraintParameters)) {
334 334
 			throw new ConstraintParameterException(
335
-				( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
336
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
337
-					->withEntityId( new PropertyId( $propertyId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
335
+				(new ViolationMessage('wbqc-violation-message-parameter-needed'))
336
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
337
+					->withEntityId(new PropertyId($propertyId), Role::CONSTRAINT_PARAMETER_PROPERTY)
338 338
 			);
339 339
 		}
340 340
 
341 341
 		$parameters = $constraintParameters[$propertyId];
342
-		if ( count( $parameters ) === 1 &&
343
-			$this->snakDeserializer->deserialize( $parameters[0] ) instanceof PropertyNoValueSnak
342
+		if (count($parameters) === 1 &&
343
+			$this->snakDeserializer->deserialize($parameters[0]) instanceof PropertyNoValueSnak
344 344
 		) {
345 345
 			return [];
346 346
 		}
347 347
 
348 348
 		$properties = [];
349
-		foreach ( $parameters as $parameter ) {
350
-			$properties[] = $this->parsePropertyIdParameter( $parameter, $propertyId );
349
+		foreach ($parameters as $parameter) {
350
+			$properties[] = $this->parsePropertyIdParameter($parameter, $propertyId);
351 351
 		}
352 352
 		return $properties;
353 353
 	}
@@ -358,16 +358,16 @@  discard block
 block discarded – undo
358 358
 	 * @throws ConstraintParameterException
359 359
 	 * @return DataValue|null
360 360
 	 */
361
-	private function parseValueOrNoValueParameter( array $snakSerialization, $parameterId ) {
362
-		$snak = $this->snakDeserializer->deserialize( $snakSerialization );
363
-		if ( $snak instanceof PropertyValueSnak ) {
361
+	private function parseValueOrNoValueParameter(array $snakSerialization, $parameterId) {
362
+		$snak = $this->snakDeserializer->deserialize($snakSerialization);
363
+		if ($snak instanceof PropertyValueSnak) {
364 364
 			return $snak->getDataValue();
365
-		} elseif ( $snak instanceof PropertyNoValueSnak ) {
365
+		} elseif ($snak instanceof PropertyNoValueSnak) {
366 366
 			return null;
367 367
 		} else {
368 368
 			throw new ConstraintParameterException(
369
-				( new ViolationMessage( 'wbqc-violation-message-parameter-value-or-novalue' ) )
370
-					->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
369
+				(new ViolationMessage('wbqc-violation-message-parameter-value-or-novalue'))
370
+					->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
371 371
 			);
372 372
 		}
373 373
 	}
@@ -377,10 +377,10 @@  discard block
 block discarded – undo
377 377
 	 * @param string $parameterId
378 378
 	 * @return DataValue|null
379 379
 	 */
380
-	private function parseValueOrNoValueOrNowParameter( array $snakSerialization, $parameterId ) {
380
+	private function parseValueOrNoValueOrNowParameter(array $snakSerialization, $parameterId) {
381 381
 		try {
382
-			return $this->parseValueOrNoValueParameter( $snakSerialization, $parameterId );
383
-		} catch ( ConstraintParameterException $e ) {
382
+			return $this->parseValueOrNoValueParameter($snakSerialization, $parameterId);
383
+		} catch (ConstraintParameterException $e) {
384 384
 			// unknown value means “now”
385 385
 			return new NowValue();
386 386
 		}
@@ -393,14 +393,14 @@  discard block
 block discarded – undo
393 393
 	 * @param string $unit
394 394
 	 * @return bool
395 395
 	 */
396
-	private function exactlyOneQuantityWithUnit( DataValue $min = null, DataValue $max = null, $unit ) {
397
-		if ( !( $min instanceof UnboundedQuantityValue ) ||
398
-			!( $max instanceof UnboundedQuantityValue )
396
+	private function exactlyOneQuantityWithUnit(DataValue $min = null, DataValue $max = null, $unit) {
397
+		if (!($min instanceof UnboundedQuantityValue) ||
398
+			!($max instanceof UnboundedQuantityValue)
399 399
 		) {
400 400
 			return false;
401 401
 		}
402 402
 
403
-		return ( $min->getUnit() === $unit ) !== ( $max->getUnit() === $unit );
403
+		return ($min->getUnit() === $unit) !== ($max->getUnit() === $unit);
404 404
 	}
405 405
 
406 406
 	/**
@@ -413,42 +413,42 @@  discard block
 block discarded – undo
413 413
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
414 414
 	 * @return DataValue[] if the parameter is invalid or missing
415 415
 	 */
416
-	private function parseRangeParameter( array $constraintParameters, $minimumId, $maximumId, $constraintTypeItemId, $type ) {
417
-		$this->checkError( $constraintParameters );
418
-		if ( !array_key_exists( $minimumId, $constraintParameters ) ||
419
-			!array_key_exists( $maximumId, $constraintParameters )
416
+	private function parseRangeParameter(array $constraintParameters, $minimumId, $maximumId, $constraintTypeItemId, $type) {
417
+		$this->checkError($constraintParameters);
418
+		if (!array_key_exists($minimumId, $constraintParameters) ||
419
+			!array_key_exists($maximumId, $constraintParameters)
420 420
 		) {
421 421
 			throw new ConstraintParameterException(
422
-				( new ViolationMessage( 'wbqc-violation-message-range-parameters-needed' ) )
423
-					->withDataValueType( $type )
424
-					->withEntityId( new PropertyId( $minimumId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
425
-					->withEntityId( new PropertyId( $maximumId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
426
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
422
+				(new ViolationMessage('wbqc-violation-message-range-parameters-needed'))
423
+					->withDataValueType($type)
424
+					->withEntityId(new PropertyId($minimumId), Role::CONSTRAINT_PARAMETER_PROPERTY)
425
+					->withEntityId(new PropertyId($maximumId), Role::CONSTRAINT_PARAMETER_PROPERTY)
426
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
427 427
 			);
428 428
 		}
429 429
 
430
-		$this->requireSingleParameter( $constraintParameters, $minimumId );
431
-		$this->requireSingleParameter( $constraintParameters, $maximumId );
430
+		$this->requireSingleParameter($constraintParameters, $minimumId);
431
+		$this->requireSingleParameter($constraintParameters, $maximumId);
432 432
 		$parseFunction = $type === 'time' ? 'parseValueOrNoValueOrNowParameter' : 'parseValueOrNoValueParameter';
433
-		$min = $this->$parseFunction( $constraintParameters[$minimumId][0], $minimumId );
434
-		$max = $this->$parseFunction( $constraintParameters[$maximumId][0], $maximumId );
433
+		$min = $this->$parseFunction($constraintParameters[$minimumId][0], $minimumId);
434
+		$max = $this->$parseFunction($constraintParameters[$maximumId][0], $maximumId);
435 435
 
436
-		$yearUnit = $this->config->get( 'WBQualityConstraintsYearUnit' );
437
-		if ( $this->exactlyOneQuantityWithUnit( $min, $max, $yearUnit ) ) {
436
+		$yearUnit = $this->config->get('WBQualityConstraintsYearUnit');
437
+		if ($this->exactlyOneQuantityWithUnit($min, $max, $yearUnit)) {
438 438
 			throw new ConstraintParameterException(
439
-				new ViolationMessage( 'wbqc-violation-message-range-parameters-one-year' )
439
+				new ViolationMessage('wbqc-violation-message-range-parameters-one-year')
440 440
 			);
441 441
 		}
442
-		if ( $min === null && $max === null ||
443
-			$min !== null && $max !== null && $min->equals( $max ) ) {
442
+		if ($min === null && $max === null ||
443
+			$min !== null && $max !== null && $min->equals($max)) {
444 444
 			throw new ConstraintParameterException(
445
-				( new ViolationMessage( 'wbqc-violation-message-range-parameters-same' ) )
446
-					->withEntityId( new PropertyId( $minimumId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
447
-					->withEntityId( new PropertyId( $maximumId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
445
+				(new ViolationMessage('wbqc-violation-message-range-parameters-same'))
446
+					->withEntityId(new PropertyId($minimumId), Role::CONSTRAINT_PARAMETER_PROPERTY)
447
+					->withEntityId(new PropertyId($maximumId), Role::CONSTRAINT_PARAMETER_PROPERTY)
448 448
 			);
449 449
 		}
450 450
 
451
-		return [ $min, $max ];
451
+		return [$min, $max];
452 452
 	}
453 453
 
454 454
 	/**
@@ -458,11 +458,11 @@  discard block
 block discarded – undo
458 458
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
459 459
 	 * @return DataValue[] a pair of two data values, either of which may be null to signify an open range
460 460
 	 */
461
-	public function parseQuantityRangeParameter( array $constraintParameters, $constraintTypeItemId ) {
461
+	public function parseQuantityRangeParameter(array $constraintParameters, $constraintTypeItemId) {
462 462
 		return $this->parseRangeParameter(
463 463
 			$constraintParameters,
464
-			$this->config->get( 'WBQualityConstraintsMinimumQuantityId' ),
465
-			$this->config->get( 'WBQualityConstraintsMaximumQuantityId' ),
464
+			$this->config->get('WBQualityConstraintsMinimumQuantityId'),
465
+			$this->config->get('WBQualityConstraintsMaximumQuantityId'),
466 466
 			$constraintTypeItemId,
467 467
 			'quantity'
468 468
 		);
@@ -475,11 +475,11 @@  discard block
 block discarded – undo
475 475
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
476 476
 	 * @return DataValue[] a pair of two data values, either of which may be null to signify an open range
477 477
 	 */
478
-	public function parseTimeRangeParameter( array $constraintParameters, $constraintTypeItemId ) {
478
+	public function parseTimeRangeParameter(array $constraintParameters, $constraintTypeItemId) {
479 479
 		return $this->parseRangeParameter(
480 480
 			$constraintParameters,
481
-			$this->config->get( 'WBQualityConstraintsMinimumDateId' ),
482
-			$this->config->get( 'WBQualityConstraintsMaximumDateId' ),
481
+			$this->config->get('WBQualityConstraintsMinimumDateId'),
482
+			$this->config->get('WBQualityConstraintsMaximumDateId'),
483 483
 			$constraintTypeItemId,
484 484
 			'time'
485 485
 		);
@@ -492,17 +492,17 @@  discard block
 block discarded – undo
492 492
 	 * @throws ConstraintParameterException
493 493
 	 * @return string
494 494
 	 */
495
-	private function parseStringParameter( array $snakSerialization, $parameterId ) {
496
-		$snak = $this->snakDeserializer->deserialize( $snakSerialization );
497
-		$this->requireValueParameter( $snak, $parameterId );
495
+	private function parseStringParameter(array $snakSerialization, $parameterId) {
496
+		$snak = $this->snakDeserializer->deserialize($snakSerialization);
497
+		$this->requireValueParameter($snak, $parameterId);
498 498
 		$value = $snak->getDataValue();
499
-		if ( $value instanceof StringValue ) {
499
+		if ($value instanceof StringValue) {
500 500
 			return $value->getValue();
501 501
 		} else {
502 502
 			throw new ConstraintParameterException(
503
-				( new ViolationMessage( 'wbqc-violation-message-parameter-string' ) )
504
-					->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
505
-					->withDataValue( $value, Role::CONSTRAINT_PARAMETER_VALUE )
503
+				(new ViolationMessage('wbqc-violation-message-parameter-string'))
504
+					->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
505
+					->withDataValue($value, Role::CONSTRAINT_PARAMETER_VALUE)
506 506
 			);
507 507
 		}
508 508
 	}
@@ -513,15 +513,15 @@  discard block
 block discarded – undo
513 513
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
514 514
 	 * @return string
515 515
 	 */
516
-	public function parseNamespaceParameter( array $constraintParameters, $constraintTypeItemId ) {
517
-		$this->checkError( $constraintParameters );
518
-		$namespaceId = $this->config->get( 'WBQualityConstraintsNamespaceId' );
519
-		if ( !array_key_exists( $namespaceId, $constraintParameters ) ) {
516
+	public function parseNamespaceParameter(array $constraintParameters, $constraintTypeItemId) {
517
+		$this->checkError($constraintParameters);
518
+		$namespaceId = $this->config->get('WBQualityConstraintsNamespaceId');
519
+		if (!array_key_exists($namespaceId, $constraintParameters)) {
520 520
 			return '';
521 521
 		}
522 522
 
523
-		$this->requireSingleParameter( $constraintParameters, $namespaceId );
524
-		return $this->parseStringParameter( $constraintParameters[$namespaceId][0], $namespaceId );
523
+		$this->requireSingleParameter($constraintParameters, $namespaceId);
524
+		return $this->parseStringParameter($constraintParameters[$namespaceId][0], $namespaceId);
525 525
 	}
526 526
 
527 527
 	/**
@@ -530,19 +530,19 @@  discard block
 block discarded – undo
530 530
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
531 531
 	 * @return string
532 532
 	 */
533
-	public function parseFormatParameter( array $constraintParameters, $constraintTypeItemId ) {
534
-		$this->checkError( $constraintParameters );
535
-		$formatId = $this->config->get( 'WBQualityConstraintsFormatAsARegularExpressionId' );
536
-		if ( !array_key_exists( $formatId, $constraintParameters ) ) {
533
+	public function parseFormatParameter(array $constraintParameters, $constraintTypeItemId) {
534
+		$this->checkError($constraintParameters);
535
+		$formatId = $this->config->get('WBQualityConstraintsFormatAsARegularExpressionId');
536
+		if (!array_key_exists($formatId, $constraintParameters)) {
537 537
 			throw new ConstraintParameterException(
538
-				( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
539
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
540
-					->withEntityId( new PropertyId( $formatId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
538
+				(new ViolationMessage('wbqc-violation-message-parameter-needed'))
539
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
540
+					->withEntityId(new PropertyId($formatId), Role::CONSTRAINT_PARAMETER_PROPERTY)
541 541
 			);
542 542
 		}
543 543
 
544
-		$this->requireSingleParameter( $constraintParameters, $formatId );
545
-		return $this->parseStringParameter( $constraintParameters[$formatId][0], $formatId );
544
+		$this->requireSingleParameter($constraintParameters, $formatId);
545
+		return $this->parseStringParameter($constraintParameters[$formatId][0], $formatId);
546 546
 	}
547 547
 
548 548
 	/**
@@ -550,16 +550,16 @@  discard block
 block discarded – undo
550 550
 	 * @throws ConstraintParameterException if the parameter is invalid
551 551
 	 * @return EntityId[]
552 552
 	 */
553
-	public function parseExceptionParameter( array $constraintParameters ) {
554
-		$this->checkError( $constraintParameters );
555
-		$exceptionId = $this->config->get( 'WBQualityConstraintsExceptionToConstraintId' );
556
-		if ( !array_key_exists( $exceptionId, $constraintParameters ) ) {
553
+	public function parseExceptionParameter(array $constraintParameters) {
554
+		$this->checkError($constraintParameters);
555
+		$exceptionId = $this->config->get('WBQualityConstraintsExceptionToConstraintId');
556
+		if (!array_key_exists($exceptionId, $constraintParameters)) {
557 557
 			return [];
558 558
 		}
559 559
 
560 560
 		return array_map(
561
-			function( $snakSerialization ) use ( $exceptionId ) {
562
-				return $this->parseEntityIdParameter( $snakSerialization, $exceptionId );
561
+			function($snakSerialization) use ($exceptionId) {
562
+				return $this->parseEntityIdParameter($snakSerialization, $exceptionId);
563 563
 			},
564 564
 			$constraintParameters[$exceptionId]
565 565
 		);
@@ -570,35 +570,35 @@  discard block
 block discarded – undo
570 570
 	 * @throws ConstraintParameterException if the parameter is invalid
571 571
 	 * @return string|null 'mandatory', 'suggestion' or null
572 572
 	 */
573
-	public function parseConstraintStatusParameter( array $constraintParameters ) {
574
-		$this->checkError( $constraintParameters );
575
-		$constraintStatusId = $this->config->get( 'WBQualityConstraintsConstraintStatusId' );
576
-		if ( !array_key_exists( $constraintStatusId, $constraintParameters ) ) {
573
+	public function parseConstraintStatusParameter(array $constraintParameters) {
574
+		$this->checkError($constraintParameters);
575
+		$constraintStatusId = $this->config->get('WBQualityConstraintsConstraintStatusId');
576
+		if (!array_key_exists($constraintStatusId, $constraintParameters)) {
577 577
 			return null;
578 578
 		}
579 579
 
580
-		$mandatoryId = $this->config->get( 'WBQualityConstraintsMandatoryConstraintId' );
581
-		$supportedStatuses = [ new ItemId( $mandatoryId ) ];
582
-		if ( $this->config->get( 'WBQualityConstraintsEnableSuggestionConstraintStatus' ) ) {
583
-			$suggestionId = $this->config->get( 'WBQualityConstraintsSuggestionConstraintId' );
584
-			$supportedStatuses[] = new ItemId( $suggestionId );
580
+		$mandatoryId = $this->config->get('WBQualityConstraintsMandatoryConstraintId');
581
+		$supportedStatuses = [new ItemId($mandatoryId)];
582
+		if ($this->config->get('WBQualityConstraintsEnableSuggestionConstraintStatus')) {
583
+			$suggestionId = $this->config->get('WBQualityConstraintsSuggestionConstraintId');
584
+			$supportedStatuses[] = new ItemId($suggestionId);
585 585
 		} else {
586 586
 			$suggestionId = null;
587 587
 		}
588 588
 
589
-		$this->requireSingleParameter( $constraintParameters, $constraintStatusId );
590
-		$snak = $this->snakDeserializer->deserialize( $constraintParameters[$constraintStatusId][0] );
591
-		$this->requireValueParameter( $snak, $constraintStatusId );
589
+		$this->requireSingleParameter($constraintParameters, $constraintStatusId);
590
+		$snak = $this->snakDeserializer->deserialize($constraintParameters[$constraintStatusId][0]);
591
+		$this->requireValueParameter($snak, $constraintStatusId);
592 592
 		$statusId = $snak->getDataValue()->getEntityId()->getSerialization();
593 593
 
594
-		if ( $statusId === $mandatoryId ) {
594
+		if ($statusId === $mandatoryId) {
595 595
 			return 'mandatory';
596
-		} elseif ( $statusId === $suggestionId ) {
596
+		} elseif ($statusId === $suggestionId) {
597 597
 			return 'suggestion';
598 598
 		} else {
599 599
 			throw new ConstraintParameterException(
600
-				( new ViolationMessage( 'wbqc-violation-message-parameter-oneof' ) )
601
-					->withEntityId( new PropertyId( $constraintStatusId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
600
+				(new ViolationMessage('wbqc-violation-message-parameter-oneof'))
601
+					->withEntityId(new PropertyId($constraintStatusId), Role::CONSTRAINT_PARAMETER_PROPERTY)
602 602
 					->withEntityIdList(
603 603
 						$supportedStatuses,
604 604
 						Role::CONSTRAINT_PARAMETER_VALUE
@@ -614,12 +614,12 @@  discard block
 block discarded – undo
614 614
 	 * @return void
615 615
 	 * @throws ConstraintParameterException
616 616
 	 */
617
-	private function requireMonolingualTextParameter( DataValue $dataValue, $parameterId ) {
618
-		if ( !( $dataValue instanceof MonolingualTextValue ) ) {
617
+	private function requireMonolingualTextParameter(DataValue $dataValue, $parameterId) {
618
+		if (!($dataValue instanceof MonolingualTextValue)) {
619 619
 			throw new ConstraintParameterException(
620
-				( new ViolationMessage( 'wbqc-violation-message-parameter-monolingualtext' ) )
621
-					->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
622
-					->withDataValue( $dataValue, Role::CONSTRAINT_PARAMETER_VALUE )
620
+				(new ViolationMessage('wbqc-violation-message-parameter-monolingualtext'))
621
+					->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
622
+					->withDataValue($dataValue, Role::CONSTRAINT_PARAMETER_VALUE)
623 623
 			);
624 624
 		}
625 625
 	}
@@ -632,30 +632,30 @@  discard block
 block discarded – undo
632 632
 	 * @throws ConstraintParameterException if invalid snaks are found or a language has multiple texts
633 633
 	 * @return MultilingualTextValue
634 634
 	 */
635
-	private function parseMultilingualTextParameter( array $snakSerializations, $parameterId ) {
635
+	private function parseMultilingualTextParameter(array $snakSerializations, $parameterId) {
636 636
 		$result = [];
637 637
 
638
-		foreach ( $snakSerializations as $snakSerialization ) {
639
-			$snak = $this->snakDeserializer->deserialize( $snakSerialization );
640
-			$this->requireValueParameter( $snak, $parameterId );
638
+		foreach ($snakSerializations as $snakSerialization) {
639
+			$snak = $this->snakDeserializer->deserialize($snakSerialization);
640
+			$this->requireValueParameter($snak, $parameterId);
641 641
 
642 642
 			$value = $snak->getDataValue();
643
-			$this->requireMonolingualTextParameter( $value, $parameterId );
643
+			$this->requireMonolingualTextParameter($value, $parameterId);
644 644
 			/** @var MonolingualTextValue $value */
645 645
 
646 646
 			$code = $value->getLanguageCode();
647
-			if ( array_key_exists( $code, $result ) ) {
647
+			if (array_key_exists($code, $result)) {
648 648
 				throw new ConstraintParameterException(
649
-					( new ViolationMessage( 'wbqc-violation-message-parameter-single-per-language' ) )
650
-						->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
651
-						->withLanguage( $code )
649
+					(new ViolationMessage('wbqc-violation-message-parameter-single-per-language'))
650
+						->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
651
+						->withLanguage($code)
652 652
 				);
653 653
 			}
654 654
 
655 655
 			$result[$code] = $value;
656 656
 		}
657 657
 
658
-		return new MultilingualTextValue( $result );
658
+		return new MultilingualTextValue($result);
659 659
 	}
660 660
 
661 661
 	/**
@@ -663,11 +663,11 @@  discard block
 block discarded – undo
663 663
 	 * @throws ConstraintParameterException if the parameter is invalid
664 664
 	 * @return MultilingualTextValue
665 665
 	 */
666
-	public function parseSyntaxClarificationParameter( array $constraintParameters ) {
667
-		$syntaxClarificationId = $this->config->get( 'WBQualityConstraintsSyntaxClarificationId' );
666
+	public function parseSyntaxClarificationParameter(array $constraintParameters) {
667
+		$syntaxClarificationId = $this->config->get('WBQualityConstraintsSyntaxClarificationId');
668 668
 
669
-		if ( !array_key_exists( $syntaxClarificationId, $constraintParameters ) ) {
670
-			return new MultilingualTextValue( [] );
669
+		if (!array_key_exists($syntaxClarificationId, $constraintParameters)) {
670
+			return new MultilingualTextValue([]);
671 671
 		}
672 672
 
673 673
 		$syntaxClarifications = $this->parseMultilingualTextParameter(
@@ -686,9 +686,9 @@  discard block
 block discarded – undo
686 686
 	 * @throws ConstraintParameterException if the parameter is invalid
687 687
 	 * @return string[]|null Context::TYPE_* constants
688 688
 	 */
689
-	public function parseConstraintScopeParameter( array $constraintParameters, $constraintTypeItemId, array $validScopes = null ) {
689
+	public function parseConstraintScopeParameter(array $constraintParameters, $constraintTypeItemId, array $validScopes = null) {
690 690
 		$contextTypes = [];
691
-		$parameterId = $this->config->get( 'WBQualityConstraintsConstraintScopeId' );
691
+		$parameterId = $this->config->get('WBQualityConstraintsConstraintScopeId');
692 692
 		$items = $this->parseItemsParameter(
693 693
 			$constraintParameters,
694 694
 			$constraintTypeItemId,
@@ -696,23 +696,23 @@  discard block
 block discarded – undo
696 696
 			$parameterId
697 697
 		);
698 698
 
699
-		if ( $items === [] ) {
699
+		if ($items === []) {
700 700
 			return null;
701 701
 		}
702 702
 
703
-		foreach ( $items as $item ) {
704
-			$contextTypes[] = $this->parseContextTypeItem( $item, 'constraint scope', $parameterId );
703
+		foreach ($items as $item) {
704
+			$contextTypes[] = $this->parseContextTypeItem($item, 'constraint scope', $parameterId);
705 705
 		}
706 706
 
707
-		if ( $validScopes !== null ) {
708
-			$invalidScopes = array_diff( $contextTypes, $validScopes );
709
-			if ( $invalidScopes !== [] ) {
710
-				$invalidScope = array_pop( $invalidScopes );
707
+		if ($validScopes !== null) {
708
+			$invalidScopes = array_diff($contextTypes, $validScopes);
709
+			if ($invalidScopes !== []) {
710
+				$invalidScope = array_pop($invalidScopes);
711 711
 				throw new ConstraintParameterException(
712
-					( new ViolationMessage( 'wbqc-violation-message-invalid-scope' ) )
713
-						->withConstraintScope( $invalidScope, Role::CONSTRAINT_PARAMETER_VALUE )
714
-						->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
715
-						->withConstraintScopeList( $validScopes, Role::CONSTRAINT_PARAMETER_VALUE )
712
+					(new ViolationMessage('wbqc-violation-message-invalid-scope'))
713
+						->withConstraintScope($invalidScope, Role::CONSTRAINT_PARAMETER_VALUE)
714
+						->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
715
+						->withConstraintScopeList($validScopes, Role::CONSTRAINT_PARAMETER_VALUE)
716 716
 				);
717 717
 			}
718 718
 		}
@@ -726,15 +726,15 @@  discard block
 block discarded – undo
726 726
 	 * @param ItemId $unitId
727 727
 	 * @return string unit
728 728
 	 */
729
-	private function parseUnitParameter( ItemId $unitId ) {
729
+	private function parseUnitParameter(ItemId $unitId) {
730 730
 		$unitRepositoryName = $unitId->getRepositoryName();
731
-		if ( !array_key_exists( $unitRepositoryName, $this->conceptBaseUris ) ) {
731
+		if (!array_key_exists($unitRepositoryName, $this->conceptBaseUris)) {
732 732
 			throw new LogicException(
733
-				'No base URI for concept URI for repository: ' . $unitRepositoryName
733
+				'No base URI for concept URI for repository: '.$unitRepositoryName
734 734
 			);
735 735
 		}
736 736
 		$baseUri = $this->conceptBaseUris[$unitRepositoryName];
737
-		return $baseUri . $unitId->getSerialization();
737
+		return $baseUri.$unitId->getSerialization();
738 738
 	}
739 739
 
740 740
 	/**
@@ -744,23 +744,23 @@  discard block
 block discarded – undo
744 744
 	 * @return UnitsParameter
745 745
 	 * @throws ConstraintParameterException
746 746
 	 */
747
-	private function parseUnitItem( ItemIdSnakValue $item ) {
748
-		switch ( true ) {
747
+	private function parseUnitItem(ItemIdSnakValue $item) {
748
+		switch (true) {
749 749
 			case $item->isValue():
750
-				$unit = $this->parseUnitParameter( $item->getItemId() );
750
+				$unit = $this->parseUnitParameter($item->getItemId());
751 751
 				return new UnitsParameter(
752
-					[ $item->getItemId() ],
753
-					[ UnboundedQuantityValue::newFromNumber( 1, $unit ) ],
752
+					[$item->getItemId()],
753
+					[UnboundedQuantityValue::newFromNumber(1, $unit)],
754 754
 					false
755 755
 				);
756 756
 			case $item->isSomeValue():
757
-				$qualifierId = $this->config->get( 'WBQualityConstraintsQualifierOfPropertyConstraintId' );
757
+				$qualifierId = $this->config->get('WBQualityConstraintsQualifierOfPropertyConstraintId');
758 758
 				throw new ConstraintParameterException(
759
-					( new ViolationMessage( 'wbqc-violation-message-parameter-value-or-novalue' ) )
760
-						->withEntityId( new PropertyId( $qualifierId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
759
+					(new ViolationMessage('wbqc-violation-message-parameter-value-or-novalue'))
760
+						->withEntityId(new PropertyId($qualifierId), Role::CONSTRAINT_PARAMETER_PROPERTY)
761 761
 				);
762 762
 			case $item->isNoValue():
763
-				return new UnitsParameter( [], [], true );
763
+				return new UnitsParameter([], [], true);
764 764
 		}
765 765
 	}
766 766
 
@@ -770,26 +770,26 @@  discard block
 block discarded – undo
770 770
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
771 771
 	 * @return UnitsParameter
772 772
 	 */
773
-	public function parseUnitsParameter( array $constraintParameters, $constraintTypeItemId ) {
774
-		$items = $this->parseItemsParameter( $constraintParameters, $constraintTypeItemId, true );
773
+	public function parseUnitsParameter(array $constraintParameters, $constraintTypeItemId) {
774
+		$items = $this->parseItemsParameter($constraintParameters, $constraintTypeItemId, true);
775 775
 		$unitItems = [];
776 776
 		$unitQuantities = [];
777 777
 		$unitlessAllowed = false;
778 778
 
779
-		foreach ( $items as $item ) {
780
-			$unit = $this->parseUnitItem( $item );
781
-			$unitItems = array_merge( $unitItems, $unit->getUnitItemIds() );
782
-			$unitQuantities = array_merge( $unitQuantities, $unit->getUnitQuantities() );
779
+		foreach ($items as $item) {
780
+			$unit = $this->parseUnitItem($item);
781
+			$unitItems = array_merge($unitItems, $unit->getUnitItemIds());
782
+			$unitQuantities = array_merge($unitQuantities, $unit->getUnitQuantities());
783 783
 			$unitlessAllowed = $unitlessAllowed || $unit->getUnitlessAllowed();
784 784
 		}
785 785
 
786
-		if ( $unitQuantities === [] && !$unitlessAllowed ) {
786
+		if ($unitQuantities === [] && !$unitlessAllowed) {
787 787
 			throw new LogicException(
788 788
 				'The "units" parameter is required, and yet we seem to be missing any allowed unit'
789 789
 			);
790 790
 		}
791 791
 
792
-		return new UnitsParameter( $unitItems, $unitQuantities, $unitlessAllowed );
792
+		return new UnitsParameter($unitItems, $unitQuantities, $unitlessAllowed);
793 793
 	}
794 794
 
795 795
 	/**
@@ -799,49 +799,49 @@  discard block
 block discarded – undo
799 799
 	 * @return EntityTypesParameter
800 800
 	 * @throws ConstraintParameterException
801 801
 	 */
802
-	private function parseEntityTypeItem( ItemIdSnakValue $item ) {
803
-		$parameterId = $this->config->get( 'WBQualityConstraintsQualifierOfPropertyConstraintId' );
802
+	private function parseEntityTypeItem(ItemIdSnakValue $item) {
803
+		$parameterId = $this->config->get('WBQualityConstraintsQualifierOfPropertyConstraintId');
804 804
 
805
-		if ( !$item->isValue() ) {
805
+		if (!$item->isValue()) {
806 806
 			throw new ConstraintParameterException(
807
-				( new ViolationMessage( 'wbqc-violation-message-parameter-value' ) )
808
-					->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
807
+				(new ViolationMessage('wbqc-violation-message-parameter-value'))
808
+					->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
809 809
 			);
810 810
 		}
811 811
 
812 812
 		$itemId = $item->getItemId();
813
-		switch ( $itemId->getSerialization() ) {
814
-			case $this->config->get( 'WBQualityConstraintsWikibaseItemId' ):
813
+		switch ($itemId->getSerialization()) {
814
+			case $this->config->get('WBQualityConstraintsWikibaseItemId'):
815 815
 				$entityType = 'item';
816 816
 				break;
817
-			case $this->config->get( 'WBQualityConstraintsWikibasePropertyId' ):
817
+			case $this->config->get('WBQualityConstraintsWikibasePropertyId'):
818 818
 				$entityType = 'property';
819 819
 				break;
820
-			case $this->config->get( 'WBQualityConstraintsWikibaseLexemeId' ):
820
+			case $this->config->get('WBQualityConstraintsWikibaseLexemeId'):
821 821
 				$entityType = 'lexeme';
822 822
 				break;
823
-			case $this->config->get( 'WBQualityConstraintsWikibaseFormId' ):
823
+			case $this->config->get('WBQualityConstraintsWikibaseFormId'):
824 824
 				$entityType = 'form';
825 825
 				break;
826
-			case $this->config->get( 'WBQualityConstraintsWikibaseSenseId' ):
826
+			case $this->config->get('WBQualityConstraintsWikibaseSenseId'):
827 827
 				$entityType = 'sense';
828 828
 				break;
829 829
 			default:
830 830
 				$allowed = [
831
-					new ItemId( $this->config->get( 'WBQualityConstraintsWikibaseItemId' ) ),
832
-					new ItemId( $this->config->get( 'WBQualityConstraintsWikibasePropertyId' ) ),
833
-					new ItemId( $this->config->get( 'WBQualityConstraintsWikibaseLexemeId' ) ),
834
-					new ItemId( $this->config->get( 'WBQualityConstraintsWikibaseFormId' ) ),
835
-					new ItemId( $this->config->get( 'WBQualityConstraintsWikibaseSenseId' ) ),
831
+					new ItemId($this->config->get('WBQualityConstraintsWikibaseItemId')),
832
+					new ItemId($this->config->get('WBQualityConstraintsWikibasePropertyId')),
833
+					new ItemId($this->config->get('WBQualityConstraintsWikibaseLexemeId')),
834
+					new ItemId($this->config->get('WBQualityConstraintsWikibaseFormId')),
835
+					new ItemId($this->config->get('WBQualityConstraintsWikibaseSenseId')),
836 836
 				];
837 837
 				throw new ConstraintParameterException(
838
-					( new ViolationMessage( 'wbqc-violation-message-parameter-oneof' ) )
839
-						->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
840
-						->withEntityIdList( $allowed, Role::CONSTRAINT_PARAMETER_VALUE )
838
+					(new ViolationMessage('wbqc-violation-message-parameter-oneof'))
839
+						->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
840
+						->withEntityIdList($allowed, Role::CONSTRAINT_PARAMETER_VALUE)
841 841
 				);
842 842
 		}
843 843
 
844
-		return new EntityTypesParameter( [ $entityType ], [ $itemId ] );
844
+		return new EntityTypesParameter([$entityType], [$itemId]);
845 845
 	}
846 846
 
847 847
 	/**
@@ -850,27 +850,27 @@  discard block
 block discarded – undo
850 850
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
851 851
 	 * @return EntityTypesParameter
852 852
 	 */
853
-	public function parseEntityTypesParameter( array $constraintParameters, $constraintTypeItemId ) {
853
+	public function parseEntityTypesParameter(array $constraintParameters, $constraintTypeItemId) {
854 854
 		$entityTypes = [];
855 855
 		$entityTypeItemIds = [];
856
-		$items = $this->parseItemsParameter( $constraintParameters, $constraintTypeItemId, true );
856
+		$items = $this->parseItemsParameter($constraintParameters, $constraintTypeItemId, true);
857 857
 
858
-		foreach ( $items as $item ) {
859
-			$entityType = $this->parseEntityTypeItem( $item );
860
-			$entityTypes = array_merge( $entityTypes, $entityType->getEntityTypes() );
861
-			$entityTypeItemIds = array_merge( $entityTypeItemIds, $entityType->getEntityTypeItemIds() );
858
+		foreach ($items as $item) {
859
+			$entityType = $this->parseEntityTypeItem($item);
860
+			$entityTypes = array_merge($entityTypes, $entityType->getEntityTypes());
861
+			$entityTypeItemIds = array_merge($entityTypeItemIds, $entityType->getEntityTypeItemIds());
862 862
 		}
863 863
 
864
-		if ( empty( $entityTypes ) ) {
864
+		if (empty($entityTypes)) {
865 865
 			// @codeCoverageIgnoreStart
866 866
 			throw new LogicException(
867
-				'The "entity types" parameter is required, ' .
867
+				'The "entity types" parameter is required, '.
868 868
 				'and yet we seem to be missing any allowed entity type'
869 869
 			);
870 870
 			// @codeCoverageIgnoreEnd
871 871
 		}
872 872
 
873
-		return new EntityTypesParameter( $entityTypes, $entityTypeItemIds );
873
+		return new EntityTypesParameter($entityTypes, $entityTypeItemIds);
874 874
 	}
875 875
 
876 876
 	/**
@@ -878,18 +878,18 @@  discard block
 block discarded – undo
878 878
 	 * @throws ConstraintParameterException if the parameter is invalid
879 879
 	 * @return PropertyId[]
880 880
 	 */
881
-	public function parseSeparatorsParameter( array $constraintParameters ) {
882
-		$separatorId = $this->config->get( 'WBQualityConstraintsSeparatorId' );
881
+	public function parseSeparatorsParameter(array $constraintParameters) {
882
+		$separatorId = $this->config->get('WBQualityConstraintsSeparatorId');
883 883
 
884
-		if ( !array_key_exists( $separatorId, $constraintParameters ) ) {
884
+		if (!array_key_exists($separatorId, $constraintParameters)) {
885 885
 			return [];
886 886
 		}
887 887
 
888 888
 		$parameters = $constraintParameters[$separatorId];
889 889
 		$separators = [];
890 890
 
891
-		foreach ( $parameters as $parameter ) {
892
-			$separators[] = $this->parsePropertyIdParameter( $parameter, $separatorId );
891
+		foreach ($parameters as $parameter) {
892
+			$separators[] = $this->parsePropertyIdParameter($parameter, $separatorId);
893 893
 		}
894 894
 
895 895
 		return $separators;
@@ -904,26 +904,26 @@  discard block
 block discarded – undo
904 904
 	 * @return string one of the Context::TYPE_* constants
905 905
 	 * @throws ConstraintParameterException
906 906
 	 */
907
-	private function parseContextTypeItem( ItemIdSnakValue $item, $use, $parameterId ) {
908
-		if ( !$item->isValue() ) {
907
+	private function parseContextTypeItem(ItemIdSnakValue $item, $use, $parameterId) {
908
+		if (!$item->isValue()) {
909 909
 			throw new ConstraintParameterException(
910
-				( new ViolationMessage( 'wbqc-violation-message-parameter-value' ) )
911
-					->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
910
+				(new ViolationMessage('wbqc-violation-message-parameter-value'))
911
+					->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
912 912
 			);
913 913
 		}
914 914
 
915
-		if ( $use === 'constraint scope' ) {
916
-			$mainSnakId = $this->config->get( 'WBQualityConstraintsConstraintCheckedOnMainValueId' );
917
-			$qualifiersId = $this->config->get( 'WBQualityConstraintsConstraintCheckedOnQualifiersId' );
918
-			$referencesId = $this->config->get( 'WBQualityConstraintsConstraintCheckedOnReferencesId' );
915
+		if ($use === 'constraint scope') {
916
+			$mainSnakId = $this->config->get('WBQualityConstraintsConstraintCheckedOnMainValueId');
917
+			$qualifiersId = $this->config->get('WBQualityConstraintsConstraintCheckedOnQualifiersId');
918
+			$referencesId = $this->config->get('WBQualityConstraintsConstraintCheckedOnReferencesId');
919 919
 		} else {
920
-			$mainSnakId = $this->config->get( 'WBQualityConstraintsAsMainValueId' );
921
-			$qualifiersId = $this->config->get( 'WBQualityConstraintsAsQualifiersId' );
922
-			$referencesId = $this->config->get( 'WBQualityConstraintsAsReferencesId' );
920
+			$mainSnakId = $this->config->get('WBQualityConstraintsAsMainValueId');
921
+			$qualifiersId = $this->config->get('WBQualityConstraintsAsQualifiersId');
922
+			$referencesId = $this->config->get('WBQualityConstraintsAsReferencesId');
923 923
 		}
924 924
 
925 925
 		$itemId = $item->getItemId();
926
-		switch ( $itemId->getSerialization() ) {
926
+		switch ($itemId->getSerialization()) {
927 927
 			case $mainSnakId:
928 928
 				return Context::TYPE_STATEMENT;
929 929
 			case $qualifiersId:
@@ -931,11 +931,11 @@  discard block
 block discarded – undo
931 931
 			case $referencesId:
932 932
 				return Context::TYPE_REFERENCE;
933 933
 			default:
934
-				$allowed = [ $mainSnakId, $qualifiersId, $referencesId ];
934
+				$allowed = [$mainSnakId, $qualifiersId, $referencesId];
935 935
 				throw new ConstraintParameterException(
936
-					( new ViolationMessage( 'wbqc-violation-message-parameter-oneof' ) )
937
-						->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
938
-						->withEntityIdList( $allowed, Role::CONSTRAINT_PARAMETER_VALUE )
936
+					(new ViolationMessage('wbqc-violation-message-parameter-oneof'))
937
+						->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
938
+						->withEntityIdList($allowed, Role::CONSTRAINT_PARAMETER_VALUE)
939 939
 				);
940 940
 		}
941 941
 	}
@@ -946,9 +946,9 @@  discard block
 block discarded – undo
946 946
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
947 947
 	 * @return string[] list of Context::TYPE_* constants
948 948
 	 */
949
-	public function parsePropertyScopeParameter( array $constraintParameters, $constraintTypeItemId ) {
949
+	public function parsePropertyScopeParameter(array $constraintParameters, $constraintTypeItemId) {
950 950
 		$contextTypes = [];
951
-		$parameterId = $this->config->get( 'WBQualityConstraintsPropertyScopeId' );
951
+		$parameterId = $this->config->get('WBQualityConstraintsPropertyScopeId');
952 952
 		$items = $this->parseItemsParameter(
953 953
 			$constraintParameters,
954 954
 			$constraintTypeItemId,
@@ -956,14 +956,14 @@  discard block
 block discarded – undo
956 956
 			$parameterId
957 957
 		);
958 958
 
959
-		foreach ( $items as $item ) {
960
-			$contextTypes[] = $this->parseContextTypeItem( $item, 'property scope', $parameterId );
959
+		foreach ($items as $item) {
960
+			$contextTypes[] = $this->parseContextTypeItem($item, 'property scope', $parameterId);
961 961
 		}
962 962
 
963
-		if ( empty( $contextTypes ) ) {
963
+		if (empty($contextTypes)) {
964 964
 			// @codeCoverageIgnoreStart
965 965
 			throw new LogicException(
966
-				'The "property scope" parameter is required, ' .
966
+				'The "property scope" parameter is required, '.
967 967
 				'and yet we seem to be missing any allowed scope'
968 968
 			);
969 969
 			// @codeCoverageIgnoreEnd
Please login to merge, or discard this patch.