Completed
Push — master ( c5411a...4acbd7 )
by
unknown
02:00 queued 11s
created
src/ServiceWiring-ConstraintCheckers.php 1 patch
Spacing   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -37,197 +37,197 @@
 block discarded – undo
37 37
 use WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\ValueTypeChecker;
38 38
 
39 39
 return [
40
-	ConstraintCheckerServices::CONFLICTS_WITH_CHECKER => static function ( MediaWikiServices $services ) {
40
+	ConstraintCheckerServices::CONFLICTS_WITH_CHECKER => static function(MediaWikiServices $services) {
41 41
 		return new ConflictsWithChecker(
42
-			ConstraintsServices::getConstraintParameterParser( $services ),
43
-			ConstraintsServices::getConnectionCheckerHelper( $services )
42
+			ConstraintsServices::getConstraintParameterParser($services),
43
+			ConstraintsServices::getConnectionCheckerHelper($services)
44 44
 		);
45 45
 	},
46 46
 
47
-	ConstraintCheckerServices::ITEM_CHECKER => static function ( MediaWikiServices $services ) {
47
+	ConstraintCheckerServices::ITEM_CHECKER => static function(MediaWikiServices $services) {
48 48
 		return new ItemChecker(
49
-			ConstraintsServices::getConstraintParameterParser( $services ),
50
-			ConstraintsServices::getConnectionCheckerHelper( $services )
49
+			ConstraintsServices::getConstraintParameterParser($services),
50
+			ConstraintsServices::getConnectionCheckerHelper($services)
51 51
 		);
52 52
 	},
53 53
 
54
-	ConstraintCheckerServices::TARGET_REQUIRED_CLAIM_CHECKER => static function ( MediaWikiServices $services ) {
54
+	ConstraintCheckerServices::TARGET_REQUIRED_CLAIM_CHECKER => static function(MediaWikiServices $services) {
55 55
 		return new TargetRequiredClaimChecker(
56
-			WikibaseServices::getEntityLookup( $services ),
57
-			ConstraintsServices::getConstraintParameterParser( $services ),
58
-			ConstraintsServices::getConnectionCheckerHelper( $services )
56
+			WikibaseServices::getEntityLookup($services),
57
+			ConstraintsServices::getConstraintParameterParser($services),
58
+			ConstraintsServices::getConnectionCheckerHelper($services)
59 59
 		);
60 60
 	},
61 61
 
62
-	ConstraintCheckerServices::SYMMETRIC_CHECKER => static function ( MediaWikiServices $services ) {
62
+	ConstraintCheckerServices::SYMMETRIC_CHECKER => static function(MediaWikiServices $services) {
63 63
 		return new SymmetricChecker(
64
-			WikibaseServices::getEntityLookupWithoutCache( $services ),
65
-			ConstraintsServices::getConnectionCheckerHelper( $services )
64
+			WikibaseServices::getEntityLookupWithoutCache($services),
65
+			ConstraintsServices::getConnectionCheckerHelper($services)
66 66
 		);
67 67
 	},
68 68
 
69
-	ConstraintCheckerServices::INVERSE_CHECKER => static function ( MediaWikiServices $services ) {
69
+	ConstraintCheckerServices::INVERSE_CHECKER => static function(MediaWikiServices $services) {
70 70
 		return new InverseChecker(
71
-			WikibaseServices::getEntityLookup( $services ),
72
-			ConstraintsServices::getConstraintParameterParser( $services ),
73
-			ConstraintsServices::getConnectionCheckerHelper( $services )
71
+			WikibaseServices::getEntityLookup($services),
72
+			ConstraintsServices::getConstraintParameterParser($services),
73
+			ConstraintsServices::getConnectionCheckerHelper($services)
74 74
 		);
75 75
 	},
76 76
 
77
-	ConstraintCheckerServices::QUALIFIER_CHECKER => static function ( MediaWikiServices $services ) {
77
+	ConstraintCheckerServices::QUALIFIER_CHECKER => static function(MediaWikiServices $services) {
78 78
 		return new QualifierChecker();
79 79
 	},
80 80
 
81
-	ConstraintCheckerServices::QUALIFIERS_CHECKER => static function ( MediaWikiServices $services ) {
81
+	ConstraintCheckerServices::QUALIFIERS_CHECKER => static function(MediaWikiServices $services) {
82 82
 		return new QualifiersChecker(
83
-			ConstraintsServices::getConstraintParameterParser( $services )
83
+			ConstraintsServices::getConstraintParameterParser($services)
84 84
 		);
85 85
 	},
86 86
 
87
-	ConstraintCheckerServices::MANDATORY_QUALIFIERS_CHECKER => static function ( MediaWikiServices $services ) {
87
+	ConstraintCheckerServices::MANDATORY_QUALIFIERS_CHECKER => static function(MediaWikiServices $services) {
88 88
 		return new MandatoryQualifiersChecker(
89
-			ConstraintsServices::getConstraintParameterParser( $services )
89
+			ConstraintsServices::getConstraintParameterParser($services)
90 90
 		);
91 91
 	},
92 92
 
93
-	ConstraintCheckerServices::RANGE_CHECKER => static function ( MediaWikiServices $services ) {
93
+	ConstraintCheckerServices::RANGE_CHECKER => static function(MediaWikiServices $services) {
94 94
 		return new RangeChecker(
95
-			WikibaseServices::getPropertyDataTypeLookup( $services ),
96
-			ConstraintsServices::getConstraintParameterParser( $services ),
97
-			ConstraintsServices::getRangeCheckerHelper( $services )
95
+			WikibaseServices::getPropertyDataTypeLookup($services),
96
+			ConstraintsServices::getConstraintParameterParser($services),
97
+			ConstraintsServices::getRangeCheckerHelper($services)
98 98
 		);
99 99
 	},
100 100
 
101
-	ConstraintCheckerServices::DIFF_WITHIN_RANGE_CHECKER => static function ( MediaWikiServices $services ) {
101
+	ConstraintCheckerServices::DIFF_WITHIN_RANGE_CHECKER => static function(MediaWikiServices $services) {
102 102
 		return new DiffWithinRangeChecker(
103
-			ConstraintsServices::getConstraintParameterParser( $services ),
104
-			ConstraintsServices::getRangeCheckerHelper( $services ),
103
+			ConstraintsServices::getConstraintParameterParser($services),
104
+			ConstraintsServices::getRangeCheckerHelper($services),
105 105
 			$services->getMainConfig()
106 106
 		);
107 107
 	},
108 108
 
109
-	ConstraintCheckerServices::TYPE_CHECKER => static function ( MediaWikiServices $services ) {
109
+	ConstraintCheckerServices::TYPE_CHECKER => static function(MediaWikiServices $services) {
110 110
 		return new TypeChecker(
111
-			ConstraintsServices::getConstraintParameterParser( $services ),
112
-			ConstraintsServices::getTypeCheckerHelper( $services ),
111
+			ConstraintsServices::getConstraintParameterParser($services),
112
+			ConstraintsServices::getTypeCheckerHelper($services),
113 113
 			$services->getMainConfig()
114 114
 		);
115 115
 	},
116 116
 
117
-	ConstraintCheckerServices::VALUE_TYPE_CHECKER => static function ( MediaWikiServices $services ) {
117
+	ConstraintCheckerServices::VALUE_TYPE_CHECKER => static function(MediaWikiServices $services) {
118 118
 		return new ValueTypeChecker(
119
-			WikibaseServices::getEntityLookup( $services ),
120
-			ConstraintsServices::getConstraintParameterParser( $services ),
121
-			ConstraintsServices::getTypeCheckerHelper( $services ),
119
+			WikibaseServices::getEntityLookup($services),
120
+			ConstraintsServices::getConstraintParameterParser($services),
121
+			ConstraintsServices::getTypeCheckerHelper($services),
122 122
 			$services->getMainConfig()
123 123
 		);
124 124
 	},
125 125
 
126
-	ConstraintCheckerServices::SINGLE_VALUE_CHECKER => static function ( MediaWikiServices $services ) {
126
+	ConstraintCheckerServices::SINGLE_VALUE_CHECKER => static function(MediaWikiServices $services) {
127 127
 		return new SingleValueChecker(
128
-			ConstraintsServices::getConstraintParameterParser( $services )
128
+			ConstraintsServices::getConstraintParameterParser($services)
129 129
 		);
130 130
 	},
131 131
 
132
-	ConstraintCheckerServices::MULTI_VALUE_CHECKER => static function ( MediaWikiServices $services ) {
132
+	ConstraintCheckerServices::MULTI_VALUE_CHECKER => static function(MediaWikiServices $services) {
133 133
 		return new MultiValueChecker(
134
-			ConstraintsServices::getConstraintParameterParser( $services )
134
+			ConstraintsServices::getConstraintParameterParser($services)
135 135
 		);
136 136
 	},
137 137
 
138
-	ConstraintCheckerServices::UNIQUE_VALUE_CHECKER => static function ( MediaWikiServices $services ) {
138
+	ConstraintCheckerServices::UNIQUE_VALUE_CHECKER => static function(MediaWikiServices $services) {
139 139
 		// TODO return a different, dummy implementation if SPARQL is not available
140 140
 		return new UniqueValueChecker(
141
-			ConstraintsServices::getSparqlHelper( $services )
141
+			ConstraintsServices::getSparqlHelper($services)
142 142
 		);
143 143
 	},
144 144
 
145
-	ConstraintCheckerServices::FORMAT_CHECKER => static function ( MediaWikiServices $services ) {
145
+	ConstraintCheckerServices::FORMAT_CHECKER => static function(MediaWikiServices $services) {
146 146
 		// TODO return a different, dummy implementation if SPARQL is not available
147 147
 		return new FormatChecker(
148
-			ConstraintsServices::getConstraintParameterParser( $services ),
148
+			ConstraintsServices::getConstraintParameterParser($services),
149 149
 			$services->getMainConfig(),
150
-			ConstraintsServices::getSparqlHelper( $services )
150
+			ConstraintsServices::getSparqlHelper($services)
151 151
 		);
152 152
 	},
153 153
 
154
-	ConstraintCheckerServices::COMMONS_LINK_CHECKER => static function ( MediaWikiServices $services ) {
154
+	ConstraintCheckerServices::COMMONS_LINK_CHECKER => static function(MediaWikiServices $services) {
155 155
 		$pageNameNormalizer = new MediaWikiPageNameNormalizer();
156 156
 		return new CommonsLinkChecker(
157
-			ConstraintsServices::getConstraintParameterParser( $services ),
157
+			ConstraintsServices::getConstraintParameterParser($services),
158 158
 			$pageNameNormalizer
159 159
 		);
160 160
 	},
161 161
 
162
-	ConstraintCheckerServices::ONE_OF_CHECKER => static function ( MediaWikiServices $services ) {
162
+	ConstraintCheckerServices::ONE_OF_CHECKER => static function(MediaWikiServices $services) {
163 163
 		return new OneOfChecker(
164
-			ConstraintsServices::getConstraintParameterParser( $services )
164
+			ConstraintsServices::getConstraintParameterParser($services)
165 165
 		);
166 166
 	},
167 167
 
168
-	ConstraintCheckerServices::VALUE_ONLY_CHECKER => static function ( MediaWikiServices $services ) {
168
+	ConstraintCheckerServices::VALUE_ONLY_CHECKER => static function(MediaWikiServices $services) {
169 169
 		return new ValueOnlyChecker();
170 170
 	},
171 171
 
172
-	ConstraintCheckerServices::REFERENCE_CHECKER => static function ( MediaWikiServices $services ) {
172
+	ConstraintCheckerServices::REFERENCE_CHECKER => static function(MediaWikiServices $services) {
173 173
 		return new ReferenceChecker();
174 174
 	},
175 175
 
176
-	ConstraintCheckerServices::NO_BOUNDS_CHECKER => static function ( MediaWikiServices $services ) {
176
+	ConstraintCheckerServices::NO_BOUNDS_CHECKER => static function(MediaWikiServices $services) {
177 177
 		return new NoBoundsChecker();
178 178
 	},
179 179
 
180
-	ConstraintCheckerServices::ALLOWED_UNITS_CHECKER => static function ( MediaWikiServices $services ) {
180
+	ConstraintCheckerServices::ALLOWED_UNITS_CHECKER => static function(MediaWikiServices $services) {
181 181
 		return new AllowedUnitsChecker(
182
-			ConstraintsServices::getConstraintParameterParser( $services ),
183
-			WikibaseRepo::getUnitConverter( $services )
182
+			ConstraintsServices::getConstraintParameterParser($services),
183
+			WikibaseRepo::getUnitConverter($services)
184 184
 		);
185 185
 	},
186 186
 
187
-	ConstraintCheckerServices::SINGLE_BEST_VALUE_CHECKER => static function ( MediaWikiServices $services ) {
187
+	ConstraintCheckerServices::SINGLE_BEST_VALUE_CHECKER => static function(MediaWikiServices $services) {
188 188
 		return new SingleBestValueChecker(
189
-			ConstraintsServices::getConstraintParameterParser( $services )
189
+			ConstraintsServices::getConstraintParameterParser($services)
190 190
 		);
191 191
 	},
192 192
 
193
-	ConstraintCheckerServices::ENTITY_TYPE_CHECKER => static function ( MediaWikiServices $services ) {
193
+	ConstraintCheckerServices::ENTITY_TYPE_CHECKER => static function(MediaWikiServices $services) {
194 194
 		return new EntityTypeChecker(
195
-			ConstraintsServices::getConstraintParameterParser( $services )
195
+			ConstraintsServices::getConstraintParameterParser($services)
196 196
 		);
197 197
 	},
198 198
 
199
-	ConstraintCheckerServices::NONE_OF_CHECKER => static function ( MediaWikiServices $services ) {
199
+	ConstraintCheckerServices::NONE_OF_CHECKER => static function(MediaWikiServices $services) {
200 200
 		return new NoneOfChecker(
201
-			ConstraintsServices::getConstraintParameterParser( $services )
201
+			ConstraintsServices::getConstraintParameterParser($services)
202 202
 		);
203 203
 	},
204 204
 
205
-	ConstraintCheckerServices::INTEGER_CHECKER => static function ( MediaWikiServices $services ) {
205
+	ConstraintCheckerServices::INTEGER_CHECKER => static function(MediaWikiServices $services) {
206 206
 		return new IntegerChecker();
207 207
 	},
208 208
 
209
-	ConstraintCheckerServices::CITATION_NEEDED_CHECKER => static function ( MediaWikiServices $services ) {
209
+	ConstraintCheckerServices::CITATION_NEEDED_CHECKER => static function(MediaWikiServices $services) {
210 210
 		return new CitationNeededChecker();
211 211
 	},
212 212
 
213
-	ConstraintCheckerServices::PROPERTY_SCOPE_CHECKER => static function ( MediaWikiServices $services ) {
213
+	ConstraintCheckerServices::PROPERTY_SCOPE_CHECKER => static function(MediaWikiServices $services) {
214 214
 		return new PropertyScopeChecker(
215
-			ConstraintsServices::getConstraintParameterParser( $services )
215
+			ConstraintsServices::getConstraintParameterParser($services)
216 216
 		);
217 217
 	},
218 218
 
219
-	ConstraintCheckerServices::CONTEMPORARY_CHECKER => static function ( MediaWikiServices $services ) {
219
+	ConstraintCheckerServices::CONTEMPORARY_CHECKER => static function(MediaWikiServices $services) {
220 220
 		return new ContemporaryChecker(
221
-			WikibaseServices::getEntityLookup( $services ),
222
-			ConstraintsServices::getRangeCheckerHelper( $services ),
221
+			WikibaseServices::getEntityLookup($services),
222
+			ConstraintsServices::getRangeCheckerHelper($services),
223 223
 			$services->getMainConfig()
224 224
 		);
225 225
 	},
226 226
 
227
-	ConstraintCheckerServices::LEXEME_LANGUAGE_CHECKER => static function ( MediaWikiServices $services ) {
227
+	ConstraintCheckerServices::LEXEME_LANGUAGE_CHECKER => static function(MediaWikiServices $services) {
228 228
 		return new LanguageChecker(
229
-			ConstraintsServices::getConstraintParameterParser( $services ),
230
-			WikibaseServices::getEntityLookup( $services )
229
+			ConstraintsServices::getConstraintParameterParser($services),
230
+			WikibaseServices::getEntityLookup($services)
231 231
 		);
232 232
 	},
233 233
 ];
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/Lexeme/LanguageChecker.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -73,16 +73,16 @@  discard block
 block discarded – undo
73 73
 	 * @throws ConstraintParameterException
74 74
 	 * @return CheckResult
75 75
 	 */
76
-	public function checkConstraint( Context $context, Constraint $constraint ) {
77
-		if ( !ExtensionRegistry::getInstance()->isLoaded( 'WikibaseLexeme' ) ) {
78
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_NOT_IN_SCOPE );
76
+	public function checkConstraint(Context $context, Constraint $constraint) {
77
+		if (!ExtensionRegistry::getInstance()->isLoaded('WikibaseLexeme')) {
78
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_NOT_IN_SCOPE);
79 79
 		}
80 80
 		$entityType = $context->getEntity()->getType();
81
-		if ( !in_array( $entityType, [ Lexeme::ENTITY_TYPE, Sense::ENTITY_TYPE, Form::ENTITY_TYPE ] ) ) {
82
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_NOT_IN_SCOPE );
81
+		if (!in_array($entityType, [Lexeme::ENTITY_TYPE, Sense::ENTITY_TYPE, Form::ENTITY_TYPE])) {
82
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_NOT_IN_SCOPE);
83 83
 		}
84
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
85
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
84
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
85
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
86 86
 		}
87 87
 
88 88
 		$parameters = [];
@@ -96,50 +96,50 @@  discard block
 block discarded – undo
96 96
 		);
97 97
 		$parameters['languages'] = $languages;
98 98
 
99
-		$message = ( new ViolationMessage( 'wbqc-violation-message-language' ) )
100
-			->withEntityId( $context->getSnak()->getPropertyId(), Role::PREDICATE )
101
-			->withItemIdSnakValueList( $languages, Role::OBJECT );
99
+		$message = (new ViolationMessage('wbqc-violation-message-language'))
100
+			->withEntityId($context->getSnak()->getPropertyId(), Role::PREDICATE)
101
+			->withItemIdSnakValueList($languages, Role::OBJECT);
102 102
 		$status = CheckResult::STATUS_VIOLATION;
103 103
 
104
-		$lexeme = $this->getLexeme( $context );
105
-		if ( !$lexeme ) {
104
+		$lexeme = $this->getLexeme($context);
105
+		if (!$lexeme) {
106 106
 			// Lexeme doesn't exist, let's not bother
107
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_NOT_IN_SCOPE );
107
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_NOT_IN_SCOPE);
108 108
 		}
109 109
 
110 110
 		/** @var Lexeme $lexeme */
111 111
 		'@phan-var Lexeme $lexeme';
112 112
 
113
-		foreach ( $languages as $language ) {
114
-			if ( $language->isNoValue() || $language->isSomeValue() ) {
113
+		foreach ($languages as $language) {
114
+			if ($language->isNoValue() || $language->isSomeValue()) {
115 115
 				continue;
116 116
 			}
117
-			if ( $lexeme->getLanguage()->equals( $language->getItemId() ) ) {
117
+			if ($lexeme->getLanguage()->equals($language->getItemId())) {
118 118
 				$message = null;
119 119
 				$status = CheckResult::STATUS_COMPLIANCE;
120 120
 				break;
121 121
 			}
122 122
 		}
123 123
 
124
-		return new CheckResult( $context, $constraint, $parameters, $status, $message );
124
+		return new CheckResult($context, $constraint, $parameters, $status, $message);
125 125
 	}
126 126
 
127
-	private function getLexeme( Context $context ): ?EntityDocument {
127
+	private function getLexeme(Context $context): ?EntityDocument {
128 128
 		$entityType = $context->getEntity()->getType();
129 129
 
130
-		if ( $entityType === Lexeme::ENTITY_TYPE ) {
130
+		if ($entityType === Lexeme::ENTITY_TYPE) {
131 131
 			return $context->getEntity();
132 132
 		}
133 133
 
134
-		if ( in_array( $entityType, [ Form::ENTITY_TYPE, Sense::ENTITY_TYPE ] ) ) {
134
+		if (in_array($entityType, [Form::ENTITY_TYPE, Sense::ENTITY_TYPE])) {
135 135
 			/** @var LexemeSubEntityId $id */
136 136
 			$id = $context->getEntity()->getId();
137 137
 			'@phan-var LexemeSubEntityId $id';
138
-			return $this->entityLookup->getEntity( $id->getLexemeId() );
138
+			return $this->entityLookup->getEntity($id->getLexemeId());
139 139
 		}
140 140
 	}
141 141
 
142
-	public function checkConstraintParameters( Constraint $constraint ): array {
142
+	public function checkConstraintParameters(Constraint $constraint): array {
143 143
 		$constraintParameters = $constraint->getConstraintParameters();
144 144
 		$constraintTypeItemId = $constraint->getConstraintTypeItemId();
145 145
 		$exceptions = [];
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 				$constraintTypeItemId,
150 150
 				true
151 151
 			);
152
-		} catch ( ConstraintParameterException $e ) {
152
+		} catch (ConstraintParameterException $e) {
153 153
 			$exceptions[] = $e;
154 154
 		}
155 155
 		return $exceptions;
Please login to merge, or discard this patch.