Completed
Push — master ( 94f1fa...bbc60f )
by
unknown
02:56
created
src/ConstraintCheck/Checker/SingleBestValueChecker.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -66,9 +66,9 @@  discard block
 block discarded – undo
66 66
 	 *
67 67
 	 * @return CheckResult
68 68
 	 */
69
-	public function checkConstraint( Context $context, Constraint $constraint ) {
70
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
71
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
69
+	public function checkConstraint(Context $context, Constraint $constraint) {
70
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
71
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
72 72
 		}
73 73
 
74 74
 		$parameters = [];
@@ -80,13 +80,13 @@  discard block
 block discarded – undo
80 80
 
81 81
 		$propertyId = $context->getSnak()->getPropertyId();
82 82
 		$bestRankCount = $this->valueCountCheckerHelper->getPropertyCount(
83
-			$context->getSnakGroup( Context::GROUP_BEST_RANK, $separators ),
83
+			$context->getSnakGroup(Context::GROUP_BEST_RANK, $separators),
84 84
 			$propertyId
85 85
 		);
86 86
 
87
-		if ( $bestRankCount > 1 ) {
87
+		if ($bestRankCount > 1) {
88 88
 			$nonDeprecatedCount = $this->valueCountCheckerHelper->getPropertyCount(
89
-				$context->getSnakGroup( Context::GROUP_NON_DEPRECATED ),
89
+				$context->getSnakGroup(Context::GROUP_NON_DEPRECATED),
90 90
 				$propertyId
91 91
 			);
92 92
 			$message = $this->getViolationMessage(
@@ -101,15 +101,15 @@  discard block
 block discarded – undo
101 101
 			$status = CheckResult::STATUS_COMPLIANCE;
102 102
 		}
103 103
 
104
-		return new CheckResult( $context, $constraint, $parameters, $status, $message );
104
+		return new CheckResult($context, $constraint, $parameters, $status, $message);
105 105
 	}
106 106
 
107
-	public function checkConstraintParameters( Constraint $constraint ) {
107
+	public function checkConstraintParameters(Constraint $constraint) {
108 108
 		$constraintParameters = $constraint->getConstraintParameters();
109 109
 		$exceptions = [];
110 110
 		try {
111
-			$this->constraintParameterParser->parseSeparatorsParameter( $constraintParameters );
112
-		} catch ( ConstraintParameterException $e ) {
111
+			$this->constraintParameterParser->parseSeparatorsParameter($constraintParameters);
112
+		} catch (ConstraintParameterException $e) {
113 113
 			$exceptions[] = $e;
114 114
 		}
115 115
 		return $exceptions;
@@ -128,23 +128,23 @@  discard block
 block discarded – undo
128 128
 		$separators,
129 129
 		$propertyId
130 130
 	) {
131
-		if ( $bestRankCount === $nonDeprecatedCount ) {
132
-			if ( $separators === [] ) {
131
+		if ($bestRankCount === $nonDeprecatedCount) {
132
+			if ($separators === []) {
133 133
 				$messageKey = 'wbqc-violation-message-single-best-value-no-preferred';
134 134
 			} else {
135 135
 				$messageKey = 'wbqc-violation-message-single-best-value-no-preferred-separators';
136 136
 			}
137 137
 		} else {
138
-			if ( $separators === [] ) {
138
+			if ($separators === []) {
139 139
 				$messageKey = 'wbqc-violation-message-single-best-value-multi-preferred';
140 140
 			} else {
141 141
 				$messageKey = 'wbqc-violation-message-single-best-value-multi-preferred-separators';
142 142
 			}
143 143
 		}
144 144
 
145
-		return ( new ViolationMessage( $messageKey ) )
146
-			->withEntityId( $propertyId )
147
-			->withEntityIdList( $separators );
145
+		return (new ViolationMessage($messageKey))
146
+			->withEntityId($propertyId)
147
+			->withEntityIdList($separators);
148 148
 	}
149 149
 
150 150
 }
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/SingleValueChecker.php 1 patch
Spacing   +15 added lines, -16 removed lines patch added patch discarded remove patch
@@ -67,9 +67,9 @@  discard block
 block discarded – undo
67 67
 	 * @throws ConstraintParameterException
68 68
 	 * @return CheckResult
69 69
 	 */
70
-	public function checkConstraint( Context $context, Constraint $constraint ) {
71
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
72
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
70
+	public function checkConstraint(Context $context, Constraint $constraint) {
71
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
72
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
73 73
 		}
74 74
 
75 75
 		$parameters = [];
@@ -81,19 +81,19 @@  discard block
 block discarded – undo
81 81
 
82 82
 		$propertyId = $context->getSnak()->getPropertyId();
83 83
 		$propertyCount = $this->valueCountCheckerHelper->getPropertyCount(
84
-			$context->getSnakGroup( Context::GROUP_NON_DEPRECATED, $separators ),
84
+			$context->getSnakGroup(Context::GROUP_NON_DEPRECATED, $separators),
85 85
 			$propertyId
86 86
 		);
87 87
 
88
-		if ( $propertyCount > 1 ) {
89
-			$message = $this->getViolationMessage( $separators, $propertyId );
88
+		if ($propertyCount > 1) {
89
+			$message = $this->getViolationMessage($separators, $propertyId);
90 90
 			$status = CheckResult::STATUS_VIOLATION;
91 91
 		} else {
92 92
 			$message = null;
93 93
 			$status = CheckResult::STATUS_COMPLIANCE;
94 94
 		}
95 95
 
96
-		return new CheckResult( $context, $constraint, $parameters, $status, $message );
96
+		return new CheckResult($context, $constraint, $parameters, $status, $message);
97 97
 	}
98 98
 
99 99
 	/**
@@ -101,22 +101,21 @@  discard block
 block discarded – undo
101 101
 	 * @param PropertyId $propertyId
102 102
 	 * @return ViolationMessage
103 103
 	 */
104
-	private function getViolationMessage( array $separators, PropertyId $propertyId ) {
104
+	private function getViolationMessage(array $separators, PropertyId $propertyId) {
105 105
 		$messageKey = $separators === [] ?
106
-			'wbqc-violation-message-single-value' :
107
-			'wbqc-violation-message-single-value-separators';
106
+			'wbqc-violation-message-single-value' : 'wbqc-violation-message-single-value-separators';
108 107
 
109
-		return ( new ViolationMessage( $messageKey ) )
110
-			->withEntityId( $propertyId )
111
-			->withEntityIdList( $separators );
108
+		return (new ViolationMessage($messageKey))
109
+			->withEntityId($propertyId)
110
+			->withEntityIdList($separators);
112 111
 	}
113 112
 
114
-	public function checkConstraintParameters( Constraint $constraint ) {
113
+	public function checkConstraintParameters(Constraint $constraint) {
115 114
 		$constraintParameters = $constraint->getConstraintParameters();
116 115
 		$exceptions = [];
117 116
 		try {
118
-			$this->constraintParameterParser->parseSeparatorsParameter( $constraintParameters );
119
-		} catch ( ConstraintParameterException $e ) {
117
+			$this->constraintParameterParser->parseSeparatorsParameter($constraintParameters);
118
+		} catch (ConstraintParameterException $e) {
120 119
 			$exceptions[] = $e;
121 120
 		}
122 121
 		return $exceptions;
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/MultiValueChecker.php 1 patch
Spacing   +14 added lines, -15 removed lines patch added patch discarded remove patch
@@ -65,9 +65,9 @@  discard block
 block discarded – undo
65 65
 	 *
66 66
 	 * @return CheckResult
67 67
 	 */
68
-	public function checkConstraint( Context $context, Constraint $constraint ) {
69
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
70
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
68
+	public function checkConstraint(Context $context, Constraint $constraint) {
69
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
70
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
71 71
 		}
72 72
 
73 73
 		$parameters = [];
@@ -79,33 +79,32 @@  discard block
 block discarded – undo
79 79
 
80 80
 		$propertyId = $context->getSnak()->getPropertyId();
81 81
 		$propertyCount = $this->valueCountCheckerHelper->getPropertyCount(
82
-			$context->getSnakGroup( Context::GROUP_NON_DEPRECATED, $separators ),
82
+			$context->getSnakGroup(Context::GROUP_NON_DEPRECATED, $separators),
83 83
 			$propertyId
84 84
 		);
85 85
 
86
-		if ( $propertyCount <= 1 ) {
87
-			$message = ( new ViolationMessage(
86
+		if ($propertyCount <= 1) {
87
+			$message = (new ViolationMessage(
88 88
 					$separators === [] ?
89
-						'wbqc-violation-message-multi-value' :
90
-						'wbqc-violation-message-multi-value-separators'
91
-				) )
92
-				->withEntityId( $propertyId )
93
-				->withEntityIdList( $separators );
89
+						'wbqc-violation-message-multi-value' : 'wbqc-violation-message-multi-value-separators'
90
+				))
91
+				->withEntityId($propertyId)
92
+				->withEntityIdList($separators);
94 93
 			$status = CheckResult::STATUS_VIOLATION;
95 94
 		} else {
96 95
 			$message = null;
97 96
 			$status = CheckResult::STATUS_COMPLIANCE;
98 97
 		}
99 98
 
100
-		return new CheckResult( $context, $constraint, $parameters, $status, $message );
99
+		return new CheckResult($context, $constraint, $parameters, $status, $message);
101 100
 	}
102 101
 
103
-	public function checkConstraintParameters( Constraint $constraint ) {
102
+	public function checkConstraintParameters(Constraint $constraint) {
104 103
 		$constraintParameters = $constraint->getConstraintParameters();
105 104
 		$exceptions = [];
106 105
 		try {
107
-			$this->constraintParameterParser->parseSeparatorsParameter( $constraintParameters );
108
-		} catch ( ConstraintParameterException $e ) {
106
+			$this->constraintParameterParser->parseSeparatorsParameter($constraintParameters);
107
+		} catch (ConstraintParameterException $e) {
109 108
 			$exceptions[] = $e;
110 109
 		}
111 110
 		return $exceptions;
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/ConflictsWithChecker.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -88,39 +88,39 @@  discard block
 block discarded – undo
88 88
 	 * @throws ConstraintParameterException
89 89
 	 * @return CheckResult
90 90
 	 */
91
-	public function checkConstraint( Context $context, Constraint $constraint ) {
92
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
93
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
91
+	public function checkConstraint(Context $context, Constraint $constraint) {
92
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
93
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
94 94
 		}
95 95
 
96 96
 		$parameters = [];
97 97
 		$constraintParameters = $constraint->getConstraintParameters();
98 98
 
99
-		$propertyId = $this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
100
-		$parameters['property'] = [ $propertyId ];
99
+		$propertyId = $this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId());
100
+		$parameters['property'] = [$propertyId];
101 101
 
102
-		$items = $this->constraintParameterParser->parseItemsParameter( $constraintParameters, $constraint->getConstraintTypeItemId(), false );
102
+		$items = $this->constraintParameterParser->parseItemsParameter($constraintParameters, $constraint->getConstraintTypeItemId(), false);
103 103
 		$parameters['items'] = $items;
104 104
 
105 105
 		/** @var StatementList $statementList */
106 106
 		$statementList = $context->getEntity()
107 107
 			->getStatements()
108
-			->getByRank( [ Statement::RANK_PREFERRED, Statement::RANK_NORMAL ] );
108
+			->getByRank([Statement::RANK_PREFERRED, Statement::RANK_NORMAL]);
109 109
 
110 110
 		/*
111 111
 		 * 'Conflicts with' can be defined with
112 112
 		 *   a) a property only
113 113
 		 *   b) a property and a number of items (each combination of property and item forming an individual claim)
114 114
 		 */
115
-		if ( $items === [] ) {
115
+		if ($items === []) {
116 116
 			$offendingStatement = $this->connectionCheckerHelper->findStatementWithProperty(
117 117
 				$statementList,
118 118
 				$propertyId
119 119
 			);
120
-			if ( $offendingStatement !== null ) {
121
-				$message = ( new ViolationMessage( 'wbqc-violation-message-conflicts-with-property' ) )
122
-					->withEntityId( $context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY )
123
-					->withEntityId( $propertyId, Role::PREDICATE );
120
+			if ($offendingStatement !== null) {
121
+				$message = (new ViolationMessage('wbqc-violation-message-conflicts-with-property'))
122
+					->withEntityId($context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY)
123
+					->withEntityId($propertyId, Role::PREDICATE);
124 124
 				$status = CheckResult::STATUS_VIOLATION;
125 125
 			} else {
126 126
 				$message = null;
@@ -132,12 +132,12 @@  discard block
 block discarded – undo
132 132
 				$propertyId,
133 133
 				$items
134 134
 			);
135
-			if ( $offendingStatement !== null ) {
136
-				$offendingValue = ItemIdSnakValue::fromSnak( $offendingStatement->getMainSnak() );
137
-				$message = ( new ViolationMessage( 'wbqc-violation-message-conflicts-with-claim' ) )
138
-					->withEntityId( $context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY )
139
-					->withEntityId( $propertyId, Role::PREDICATE )
140
-					->withItemIdSnakValue( $offendingValue, Role::OBJECT );
135
+			if ($offendingStatement !== null) {
136
+				$offendingValue = ItemIdSnakValue::fromSnak($offendingStatement->getMainSnak());
137
+				$message = (new ViolationMessage('wbqc-violation-message-conflicts-with-claim'))
138
+					->withEntityId($context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY)
139
+					->withEntityId($propertyId, Role::PREDICATE)
140
+					->withItemIdSnakValue($offendingValue, Role::OBJECT);
141 141
 				$status = CheckResult::STATUS_VIOLATION;
142 142
 			} else {
143 143
 				$message = null;
@@ -145,20 +145,20 @@  discard block
 block discarded – undo
145 145
 			}
146 146
 		}
147 147
 
148
-		return new CheckResult( $context, $constraint, $parameters, $status, $message );
148
+		return new CheckResult($context, $constraint, $parameters, $status, $message);
149 149
 	}
150 150
 
151
-	public function checkConstraintParameters( Constraint $constraint ) {
151
+	public function checkConstraintParameters(Constraint $constraint) {
152 152
 		$constraintParameters = $constraint->getConstraintParameters();
153 153
 		$exceptions = [];
154 154
 		try {
155
-			$this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
156
-		} catch ( ConstraintParameterException $e ) {
155
+			$this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId());
156
+		} catch (ConstraintParameterException $e) {
157 157
 			$exceptions[] = $e;
158 158
 		}
159 159
 		try {
160
-			$this->constraintParameterParser->parseItemsParameter( $constraintParameters, $constraint->getConstraintTypeItemId(), false );
161
-		} catch ( ConstraintParameterException $e ) {
160
+			$this->constraintParameterParser->parseItemsParameter($constraintParameters, $constraint->getConstraintTypeItemId(), false);
161
+		} catch (ConstraintParameterException $e) {
162 162
 			$exceptions[] = $e;
163 163
 		}
164 164
 		return $exceptions;
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/IntegerChecker.php 1 patch
Spacing   +21 added lines, -22 removed lines patch added patch discarded remove patch
@@ -41,22 +41,21 @@  discard block
 block discarded – undo
41 41
 		];
42 42
 	}
43 43
 
44
-	public function checkConstraint( Context $context, Constraint $constraint ) {
44
+	public function checkConstraint(Context $context, Constraint $constraint) {
45 45
 		$snak = $context->getSnak();
46 46
 
47
-		if ( $context->getSnak()->getType() !== 'value' ) {
48
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_COMPLIANCE );
47
+		if ($context->getSnak()->getType() !== 'value') {
48
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_COMPLIANCE);
49 49
 		}
50 50
 
51
-		$violationMessage = $this->checkSnak( $snak );
51
+		$violationMessage = $this->checkSnak($snak);
52 52
 
53 53
 		return new CheckResult(
54 54
 			$context,
55 55
 			$constraint,
56 56
 			[],
57 57
 			$violationMessage === null ?
58
-				CheckResult::STATUS_COMPLIANCE :
59
-				CheckResult::STATUS_VIOLATION,
58
+				CheckResult::STATUS_COMPLIANCE : CheckResult::STATUS_VIOLATION,
60 59
 			$violationMessage
61 60
 		);
62 61
 	}
@@ -65,23 +64,23 @@  discard block
 block discarded – undo
65 64
 	 * @param PropertyValueSnak $snak
66 65
 	 * @return ViolationMessage|null
67 66
 	 */
68
-	public function checkSnak( PropertyValueSnak $snak ) {
67
+	public function checkSnak(PropertyValueSnak $snak) {
69 68
 		$dataValue = $snak->getDataValue();
70 69
 
71
-		if ( $dataValue instanceof DecimalValue ) {
72
-			if ( !$this->isInteger( $dataValue ) ) {
73
-				return $this->getViolationMessage( 'wbqc-violation-message-integer', $snak );
70
+		if ($dataValue instanceof DecimalValue) {
71
+			if (!$this->isInteger($dataValue)) {
72
+				return $this->getViolationMessage('wbqc-violation-message-integer', $snak);
74 73
 			}
75
-		} elseif ( $dataValue instanceof UnboundedQuantityValue ) {
76
-			if ( !$this->isInteger( $dataValue->getAmount() ) ) {
77
-				return $this->getViolationMessage( 'wbqc-violation-message-integer', $snak );
74
+		} elseif ($dataValue instanceof UnboundedQuantityValue) {
75
+			if (!$this->isInteger($dataValue->getAmount())) {
76
+				return $this->getViolationMessage('wbqc-violation-message-integer', $snak);
78 77
 			} elseif (
79 78
 				$dataValue instanceof QuantityValue && (
80
-					!$this->isInteger( $dataValue->getLowerBound() ) ||
81
-					!$this->isInteger( $dataValue->getUpperBound() )
79
+					!$this->isInteger($dataValue->getLowerBound()) ||
80
+					!$this->isInteger($dataValue->getUpperBound())
82 81
 				)
83 82
 			) {
84
-				return $this->getViolationMessage( 'wbqc-violation-message-integer-bounds', $snak );
83
+				return $this->getViolationMessage('wbqc-violation-message-integer-bounds', $snak);
85 84
 			}
86 85
 		}
87 86
 
@@ -92,7 +91,7 @@  discard block
 block discarded – undo
92 91
 	 * @param DecimalValue $decimalValue
93 92
 	 * @return bool
94 93
 	 */
95
-	private function isInteger( DecimalValue $decimalValue ) {
94
+	private function isInteger(DecimalValue $decimalValue) {
96 95
 		return $decimalValue->getTrimmed()->getFractionalPart() === '';
97 96
 	}
98 97
 
@@ -101,13 +100,13 @@  discard block
 block discarded – undo
101 100
 	 * @param PropertyValueSnak $snak
102 101
 	 * @return ViolationMessage
103 102
 	 */
104
-	private function getViolationMessage( $messageKey, PropertyValueSnak $snak ) {
105
-		return ( new ViolationMessage( $messageKey ) )
106
-			->withEntityId( $snak->getPropertyId(), Role::CONSTRAINT_PROPERTY )
107
-			->withDataValue( $snak->getDataValue() );
103
+	private function getViolationMessage($messageKey, PropertyValueSnak $snak) {
104
+		return (new ViolationMessage($messageKey))
105
+			->withEntityId($snak->getPropertyId(), Role::CONSTRAINT_PROPERTY)
106
+			->withDataValue($snak->getDataValue());
108 107
 	}
109 108
 
110
-	public function checkConstraintParameters( Constraint $constraint ) {
109
+	public function checkConstraintParameters(Constraint $constraint) {
111 110
 		// no parameters
112 111
 		return [];
113 112
 	}
Please login to merge, or discard this patch.
src/ConstraintReportFactory.php 1 patch
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 	public static function getDefaultInstance() {
144 144
 		static $instance = null;
145 145
 
146
-		if ( $instance === null ) {
146
+		if ($instance === null) {
147 147
 			$wikibaseRepo = WikibaseRepo::getDefaultInstance();
148 148
 			$config = MediaWikiServices::getInstance()->getMainConfig();
149 149
 			$titleParser = MediaWikiServices::getInstance()->getTitleParser();
@@ -206,21 +206,21 @@  discard block
 block discarded – undo
206 206
 	 * @return DelegatingConstraintChecker
207 207
 	 */
208 208
 	public function getConstraintChecker() {
209
-		if ( $this->delegatingConstraintChecker === null ) {
209
+		if ($this->delegatingConstraintChecker === null) {
210 210
 			$this->delegatingConstraintChecker = new DelegatingConstraintChecker(
211 211
 				$this->lookup,
212 212
 				$this->getConstraintCheckerMap(),
213
-				new CachingConstraintLookup( $this->getConstraintRepository() ),
213
+				new CachingConstraintLookup($this->getConstraintRepository()),
214 214
 				$this->constraintParameterParser,
215 215
 				$this->statementGuidParser,
216 216
 				new LoggingHelper(
217 217
 					$this->dataFactory,
218
-					LoggerFactory::getInstance( 'WikibaseQualityConstraints' ),
218
+					LoggerFactory::getInstance('WikibaseQualityConstraints'),
219 219
 					$this->config
220 220
 				),
221
-				$this->config->get( 'WBQualityConstraintsCheckQualifiers' ),
222
-				$this->config->get( 'WBQualityConstraintsCheckReferences' ),
223
-				$this->config->get( 'WBQualityConstraintsPropertiesWithViolatingQualifiers' )
221
+				$this->config->get('WBQualityConstraintsCheckQualifiers'),
222
+				$this->config->get('WBQualityConstraintsCheckReferences'),
223
+				$this->config->get('WBQualityConstraintsPropertiesWithViolatingQualifiers')
224 224
 			);
225 225
 		}
226 226
 
@@ -231,10 +231,10 @@  discard block
 block discarded – undo
231 231
 	 * @return ConstraintChecker[]
232 232
 	 */
233 233
 	private function getConstraintCheckerMap() {
234
-		if ( $this->constraintCheckerMap === null ) {
234
+		if ($this->constraintCheckerMap === null) {
235 235
 			$connectionCheckerHelper = new ConnectionCheckerHelper();
236
-			$rangeCheckerHelper = new RangeCheckerHelper( $this->config, $this->unitConverter );
237
-			if ( $this->config->get( 'WBQualityConstraintsSparqlEndpoint' ) !== '' ) {
236
+			$rangeCheckerHelper = new RangeCheckerHelper($this->config, $this->unitConverter);
237
+			if ($this->config->get('WBQualityConstraintsSparqlEndpoint') !== '') {
238 238
 				$sparqlHelper = new SparqlHelper(
239 239
 					$this->config,
240 240
 					$this->rdfVocabulary,
@@ -256,116 +256,116 @@  discard block
 block discarded – undo
256 256
 			);
257 257
 
258 258
 			$this->constraintCheckerMap = [
259
-				$this->config->get( 'WBQualityConstraintsConflictsWithConstraintId' )
259
+				$this->config->get('WBQualityConstraintsConflictsWithConstraintId')
260 260
 					=> new ConflictsWithChecker(
261 261
 						$this->lookup,
262 262
 						$this->constraintParameterParser,
263 263
 						$connectionCheckerHelper
264 264
 					),
265
-				$this->config->get( 'WBQualityConstraintsItemRequiresClaimConstraintId' )
265
+				$this->config->get('WBQualityConstraintsItemRequiresClaimConstraintId')
266 266
 					=> new ItemChecker(
267 267
 						$this->lookup,
268 268
 						$this->constraintParameterParser,
269 269
 						$connectionCheckerHelper
270 270
 					),
271
-				$this->config->get( 'WBQualityConstraintsValueRequiresClaimConstraintId' )
271
+				$this->config->get('WBQualityConstraintsValueRequiresClaimConstraintId')
272 272
 					=> new TargetRequiredClaimChecker(
273 273
 						$this->lookup,
274 274
 						$this->constraintParameterParser,
275 275
 						$connectionCheckerHelper
276 276
 					),
277
-				$this->config->get( 'WBQualityConstraintsSymmetricConstraintId' )
277
+				$this->config->get('WBQualityConstraintsSymmetricConstraintId')
278 278
 					=> new SymmetricChecker(
279 279
 						$this->lookup,
280 280
 						$connectionCheckerHelper
281 281
 					),
282
-				$this->config->get( 'WBQualityConstraintsInverseConstraintId' )
282
+				$this->config->get('WBQualityConstraintsInverseConstraintId')
283 283
 					=> new InverseChecker(
284 284
 						$this->lookup,
285 285
 						$this->constraintParameterParser,
286 286
 						$connectionCheckerHelper
287 287
 					),
288
-				$this->config->get( 'WBQualityConstraintsUsedAsQualifierConstraintId' )
288
+				$this->config->get('WBQualityConstraintsUsedAsQualifierConstraintId')
289 289
 					=> new QualifierChecker(),
290
-				$this->config->get( 'WBQualityConstraintsAllowedQualifiersConstraintId' )
290
+				$this->config->get('WBQualityConstraintsAllowedQualifiersConstraintId')
291 291
 					=> new QualifiersChecker(
292 292
 						$this->constraintParameterParser
293 293
 					),
294
-				$this->config->get( 'WBQualityConstraintsMandatoryQualifierConstraintId' )
294
+				$this->config->get('WBQualityConstraintsMandatoryQualifierConstraintId')
295 295
 					=> new MandatoryQualifiersChecker(
296 296
 						$this->constraintParameterParser
297 297
 					),
298
-				$this->config->get( 'WBQualityConstraintsRangeConstraintId' )
298
+				$this->config->get('WBQualityConstraintsRangeConstraintId')
299 299
 					=> new RangeChecker(
300 300
 						$this->propertyDataTypeLookup,
301 301
 						$this->constraintParameterParser,
302 302
 						$rangeCheckerHelper
303 303
 					),
304
-				$this->config->get( 'WBQualityConstraintsDifferenceWithinRangeConstraintId' )
304
+				$this->config->get('WBQualityConstraintsDifferenceWithinRangeConstraintId')
305 305
 					=> new DiffWithinRangeChecker(
306 306
 						$this->constraintParameterParser,
307 307
 						$rangeCheckerHelper,
308 308
 						$this->config
309 309
 					),
310
-				$this->config->get( 'WBQualityConstraintsTypeConstraintId' )
310
+				$this->config->get('WBQualityConstraintsTypeConstraintId')
311 311
 					=> new TypeChecker(
312 312
 						$this->lookup,
313 313
 						$this->constraintParameterParser,
314 314
 						$typeCheckerHelper,
315 315
 						$this->config
316 316
 					),
317
-				$this->config->get( 'WBQualityConstraintsValueTypeConstraintId' )
317
+				$this->config->get('WBQualityConstraintsValueTypeConstraintId')
318 318
 					=> new ValueTypeChecker(
319 319
 						$this->lookup,
320 320
 						$this->constraintParameterParser,
321 321
 						$typeCheckerHelper,
322 322
 						$this->config
323 323
 					),
324
-				$this->config->get( 'WBQualityConstraintsSingleValueConstraintId' )
325
-					=> new SingleValueChecker( $this->constraintParameterParser ),
326
-				$this->config->get( 'WBQualityConstraintsMultiValueConstraintId' )
327
-					=> new MultiValueChecker( $this->constraintParameterParser ),
328
-				$this->config->get( 'WBQualityConstraintsDistinctValuesConstraintId' )
324
+				$this->config->get('WBQualityConstraintsSingleValueConstraintId')
325
+					=> new SingleValueChecker($this->constraintParameterParser),
326
+				$this->config->get('WBQualityConstraintsMultiValueConstraintId')
327
+					=> new MultiValueChecker($this->constraintParameterParser),
328
+				$this->config->get('WBQualityConstraintsDistinctValuesConstraintId')
329 329
 					=> new UniqueValueChecker(
330 330
 						$sparqlHelper
331 331
 					),
332
-				$this->config->get( 'WBQualityConstraintsFormatConstraintId' )
332
+				$this->config->get('WBQualityConstraintsFormatConstraintId')
333 333
 					=> new FormatChecker(
334 334
 						$this->constraintParameterParser,
335 335
 						$this->config,
336 336
 						$sparqlHelper
337 337
 					),
338
-				$this->config->get( 'WBQualityConstraintsCommonsLinkConstraintId' )
338
+				$this->config->get('WBQualityConstraintsCommonsLinkConstraintId')
339 339
 					=> new CommonsLinkChecker(
340 340
 						$this->constraintParameterParser,
341 341
 						$this->titleParser
342 342
 					),
343
-				$this->config->get( 'WBQualityConstraintsOneOfConstraintId' )
343
+				$this->config->get('WBQualityConstraintsOneOfConstraintId')
344 344
 					=> new OneOfChecker(
345 345
 						$this->constraintParameterParser
346 346
 					),
347
-				$this->config->get( 'WBQualityConstraintsUsedForValuesOnlyConstraintId' )
347
+				$this->config->get('WBQualityConstraintsUsedForValuesOnlyConstraintId')
348 348
 					=> new ValueOnlyChecker(),
349
-				$this->config->get( 'WBQualityConstraintsUsedAsReferenceConstraintId' )
349
+				$this->config->get('WBQualityConstraintsUsedAsReferenceConstraintId')
350 350
 					=> new ReferenceChecker(),
351
-				$this->config->get( 'WBQualityConstraintsNoBoundsConstraintId' )
351
+				$this->config->get('WBQualityConstraintsNoBoundsConstraintId')
352 352
 					=> new NoBoundsChecker(),
353
-				$this->config->get( 'WBQualityConstraintsAllowedUnitsConstraintId' )
353
+				$this->config->get('WBQualityConstraintsAllowedUnitsConstraintId')
354 354
 					=> new AllowedUnitsChecker(
355 355
 						$this->constraintParameterParser,
356 356
 						$this->unitConverter
357 357
 					),
358
-				$this->config->get( 'WBQualityConstraintsSingleBestValueConstraintId' )
359
-					=> new SingleBestValueChecker( $this->constraintParameterParser ),
360
-				$this->config->get( 'WBQualityConstraintsAllowedEntityTypesConstraintId' )
358
+				$this->config->get('WBQualityConstraintsSingleBestValueConstraintId')
359
+					=> new SingleBestValueChecker($this->constraintParameterParser),
360
+				$this->config->get('WBQualityConstraintsAllowedEntityTypesConstraintId')
361 361
 					=> new EntityTypeChecker(
362 362
 						$this->constraintParameterParser
363 363
 					),
364
-				$this->config->get( 'WBQualityConstraintsNoneOfConstraintId' )
364
+				$this->config->get('WBQualityConstraintsNoneOfConstraintId')
365 365
 					=> new NoneOfChecker(
366 366
 						$this->constraintParameterParser
367 367
 					),
368
-				$this->config->get( 'WBQualityConstraintsIntegerConstraintId' )
368
+				$this->config->get('WBQualityConstraintsIntegerConstraintId')
369 369
 					=> new IntegerChecker(),
370 370
 			];
371 371
 		}
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
 	 * @return ConstraintRepository
378 378
 	 */
379 379
 	public function getConstraintRepository() {
380
-		if ( $this->constraintRepository === null ) {
380
+		if ($this->constraintRepository === null) {
381 381
 			$this->constraintRepository = new ConstraintRepository();
382 382
 		}
383 383
 
Please login to merge, or discard this patch.
src/Api/CheckConstraints.php 1 patch
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -90,26 +90,26 @@  discard block
 block discarded – undo
90 90
 	 *
91 91
 	 * @return self
92 92
 	 */
93
-	public static function newFromGlobalState( ApiMain $main, $name, $prefix = '' ) {
93
+	public static function newFromGlobalState(ApiMain $main, $name, $prefix = '') {
94 94
 		$repo = WikibaseRepo::getDefaultInstance();
95 95
 
96 96
 		$language = $repo->getUserLanguage();
97 97
 		$formatterOptions = new FormatterOptions();
98
-		$formatterOptions->setOption( SnakFormatter::OPT_LANG, $language->getCode() );
98
+		$formatterOptions->setOption(SnakFormatter::OPT_LANG, $language->getCode());
99 99
 		$valueFormatterFactory = $repo->getValueFormatterFactory();
100
-		$valueFormatter = $valueFormatterFactory->getValueFormatter( SnakFormatter::FORMAT_HTML, $formatterOptions );
100
+		$valueFormatter = $valueFormatterFactory->getValueFormatter(SnakFormatter::FORMAT_HTML, $formatterOptions);
101 101
 
102 102
 		$languageFallbackLabelDescriptionLookupFactory = $repo->getLanguageFallbackLabelDescriptionLookupFactory();
103
-		$labelDescriptionLookup = $languageFallbackLabelDescriptionLookupFactory->newLabelDescriptionLookup( $language );
103
+		$labelDescriptionLookup = $languageFallbackLabelDescriptionLookupFactory->newLabelDescriptionLookup($language);
104 104
 		$entityIdHtmlLinkFormatterFactory = $repo->getEntityIdHtmlLinkFormatterFactory();
105
-		$entityIdHtmlLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter( $labelDescriptionLookup );
105
+		$entityIdHtmlLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter($labelDescriptionLookup);
106 106
 		$entityIdLabelFormatterFactory = new EntityIdLabelFormatterFactory();
107
-		$entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter( $labelDescriptionLookup );
107
+		$entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter($labelDescriptionLookup);
108 108
 		$config = MediaWikiServices::getInstance()->getMainConfig();
109 109
 		$dataFactory = MediaWikiServices::getInstance()->getStatsdDataFactory();
110 110
 		$loggingHelper = new LoggingHelper(
111 111
 			$dataFactory,
112
-			LoggerFactory::getInstance( 'WikibaseQualityConstraints' ),
112
+			LoggerFactory::getInstance('WikibaseQualityConstraints'),
113 113
 			$config
114 114
 		);
115 115
 		$constraintReportFactory = ConstraintReportFactory::getDefaultInstance();
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 		$resultsSource = new CheckingResultsSource(
129 129
 			$constraintReportFactory->getConstraintChecker()
130 130
 		);
131
-		if ( $config->get( 'WBQualityConstraintsCacheCheckConstraintsResults' ) ) {
131
+		if ($config->get('WBQualityConstraintsCacheCheckConstraintsResults')) {
132 132
 			$wikiPageEntityMetaDataAccessor = new WikiPageEntityMetaDataLookup(
133 133
 				$repo->getEntityNamespaceLookup()
134 134
 			);
@@ -157,14 +157,14 @@  discard block
 block discarded – undo
157 157
 				$checkResultDeserializer,
158 158
 				$wikiPageEntityMetaDataAccessor,
159 159
 				$entityIdParser,
160
-				$config->get( 'WBQualityConstraintsCacheCheckConstraintsTTLSeconds' ),
160
+				$config->get('WBQualityConstraintsCacheCheckConstraintsTTLSeconds'),
161 161
 				[
162
-					$config->get( 'WBQualityConstraintsCommonsLinkConstraintId' ),
163
-					$config->get( 'WBQualityConstraintsTypeConstraintId' ),
164
-					$config->get( 'WBQualityConstraintsValueTypeConstraintId' ),
165
-					$config->get( 'WBQualityConstraintsDistinctValuesConstraintId' ),
162
+					$config->get('WBQualityConstraintsCommonsLinkConstraintId'),
163
+					$config->get('WBQualityConstraintsTypeConstraintId'),
164
+					$config->get('WBQualityConstraintsValueTypeConstraintId'),
165
+					$config->get('WBQualityConstraintsDistinctValuesConstraintId'),
166 166
 				],
167
-				$config->get( 'WBQualityConstraintsCacheCheckConstraintsMaximumRevisionIds' ),
167
+				$config->get('WBQualityConstraintsCacheCheckConstraintsMaximumRevisionIds'),
168 168
 				$loggingHelper
169 169
 			);
170 170
 		}
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 			$prefix,
176 176
 			$repo->getEntityIdParser(),
177 177
 			$repo->getStatementGuidValidator(),
178
-			$repo->getApiHelperFactory( RequestContext::getMain() ),
178
+			$repo->getApiHelperFactory(RequestContext::getMain()),
179 179
 			$resultsSource,
180 180
 			$checkResultsRenderer,
181 181
 			$dataFactory
@@ -204,11 +204,11 @@  discard block
 block discarded – undo
204 204
 		CheckResultsRenderer $checkResultsRenderer,
205 205
 		IBufferingStatsdDataFactory $dataFactory
206 206
 	) {
207
-		parent::__construct( $main, $name, $prefix );
207
+		parent::__construct($main, $name, $prefix);
208 208
 		$this->entityIdParser = $entityIdParser;
209 209
 		$this->statementGuidValidator = $statementGuidValidator;
210
-		$this->resultBuilder = $apiHelperFactory->getResultBuilder( $this );
211
-		$this->errorReporter = $apiHelperFactory->getErrorReporter( $this );
210
+		$this->resultBuilder = $apiHelperFactory->getResultBuilder($this);
211
+		$this->errorReporter = $apiHelperFactory->getErrorReporter($this);
212 212
 		$this->resultsSource = $resultsSource;
213 213
 		$this->checkResultsRenderer = $checkResultsRenderer;
214 214
 		$this->dataFactory = $dataFactory;
@@ -224,9 +224,9 @@  discard block
 block discarded – undo
224 224
 
225 225
 		$params = $this->extractRequestParams();
226 226
 
227
-		$this->validateParameters( $params );
228
-		$entityIds = $this->parseEntityIds( $params );
229
-		$claimIds = $this->parseClaimIds( $params );
227
+		$this->validateParameters($params);
228
+		$entityIds = $this->parseEntityIds($params);
229
+		$claimIds = $this->parseClaimIds($params);
230 230
 		$constraintIDs = $params[self::PARAM_CONSTRAINT_ID];
231 231
 		$statuses = $params[self::PARAM_STATUS];
232 232
 
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 				)
243 243
 			)->getArray()
244 244
 		);
245
-		$this->resultBuilder->markSuccess( 1 );
245
+		$this->resultBuilder->markSuccess(1);
246 246
 	}
247 247
 
248 248
 	/**
@@ -250,24 +250,24 @@  discard block
 block discarded – undo
250 250
 	 *
251 251
 	 * @return EntityId[]
252 252
 	 */
253
-	private function parseEntityIds( array $params ) {
253
+	private function parseEntityIds(array $params) {
254 254
 		$ids = $params[self::PARAM_ID];
255 255
 
256
-		if ( $ids === null ) {
256
+		if ($ids === null) {
257 257
 			return [];
258
-		} elseif ( $ids === [] ) {
258
+		} elseif ($ids === []) {
259 259
 			$this->errorReporter->dieError(
260
-				'If ' . self::PARAM_ID . ' is specified, it must be nonempty.', 'no-data' );
260
+				'If '.self::PARAM_ID.' is specified, it must be nonempty.', 'no-data' );
261 261
 		}
262 262
 
263
-		return array_map( function ( $id ) {
263
+		return array_map(function($id) {
264 264
 			try {
265
-				return $this->entityIdParser->parse( $id );
266
-			} catch ( EntityIdParsingException $e ) {
265
+				return $this->entityIdParser->parse($id);
266
+			} catch (EntityIdParsingException $e) {
267 267
 				$this->errorReporter->dieError(
268
-					"Invalid id: $id", 'invalid-entity-id', 0, [ self::PARAM_ID => $id ] );
268
+					"Invalid id: $id", 'invalid-entity-id', 0, [self::PARAM_ID => $id] );
269 269
 			}
270
-		}, $ids );
270
+		}, $ids);
271 271
 	}
272 272
 
273 273
 	/**
@@ -275,35 +275,35 @@  discard block
 block discarded – undo
275 275
 	 *
276 276
 	 * @return string[]
277 277
 	 */
278
-	private function parseClaimIds( array $params ) {
278
+	private function parseClaimIds(array $params) {
279 279
 		$ids = $params[self::PARAM_CLAIM_ID];
280 280
 
281
-		if ( $ids === null ) {
281
+		if ($ids === null) {
282 282
 			return [];
283
-		} elseif ( $ids === [] ) {
283
+		} elseif ($ids === []) {
284 284
 			$this->errorReporter->dieError(
285
-				'If ' . self::PARAM_CLAIM_ID . ' is specified, it must be nonempty.', 'no-data' );
285
+				'If '.self::PARAM_CLAIM_ID.' is specified, it must be nonempty.', 'no-data' );
286 286
 		}
287 287
 
288
-		foreach ( $ids as $id ) {
289
-			if ( !$this->statementGuidValidator->validate( $id ) ) {
288
+		foreach ($ids as $id) {
289
+			if (!$this->statementGuidValidator->validate($id)) {
290 290
 				$this->errorReporter->dieError(
291
-					"Invalid claim id: $id", 'invalid-guid', 0, [ self::PARAM_CLAIM_ID => $id ] );
291
+					"Invalid claim id: $id", 'invalid-guid', 0, [self::PARAM_CLAIM_ID => $id] );
292 292
 			}
293 293
 		}
294 294
 
295 295
 		return $ids;
296 296
 	}
297 297
 
298
-	private function validateParameters( array $params ) {
299
-		if ( $params[self::PARAM_CONSTRAINT_ID] !== null
300
-			 && empty( $params[self::PARAM_CONSTRAINT_ID] )
298
+	private function validateParameters(array $params) {
299
+		if ($params[self::PARAM_CONSTRAINT_ID] !== null
300
+			 && empty($params[self::PARAM_CONSTRAINT_ID])
301 301
 		) {
302 302
 			$paramConstraintId = self::PARAM_CONSTRAINT_ID;
303 303
 			$this->errorReporter->dieError(
304 304
 				"If $paramConstraintId is specified, it must be nonempty.", 'no-data' );
305 305
 		}
306
-		if ( $params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null ) {
306
+		if ($params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null) {
307 307
 			$paramId = self::PARAM_ID;
308 308
 			$paramClaimId = self::PARAM_CLAIM_ID;
309 309
 			$this->errorReporter->dieError(
@@ -343,11 +343,11 @@  discard block
 block discarded – undo
343 343
 				],
344 344
 				ApiBase::PARAM_ISMULTI => true,
345 345
 				ApiBase::PARAM_ALL => true,
346
-				ApiBase::PARAM_DFLT => implode( '|', [
346
+				ApiBase::PARAM_DFLT => implode('|', [
347 347
 					CheckResult::STATUS_VIOLATION,
348 348
 					CheckResult::STATUS_WARNING,
349 349
 					CheckResult::STATUS_BAD_PARAMETERS,
350
-				] ),
350
+				]),
351 351
 				ApiBase::PARAM_HELP_MSG_PER_VALUE => [],
352 352
 			],
353 353
 		];
Please login to merge, or discard this patch.