Completed
Pull Request — master (#82)
by
unknown
16s
created
src/ConstraintCheck/Checker/CitationNeededChecker.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	 * @codeCoverageIgnore This method is purely declarative.
31 31
 	 */
32 32
 	public function getDefaultContextTypes() {
33
-		return [ Context::TYPE_STATEMENT ];
33
+		return [Context::TYPE_STATEMENT];
34 34
 	}
35 35
 
36 36
 	/** @codeCoverageIgnore This method is purely declarative. */
@@ -38,12 +38,12 @@  discard block
 block discarded – undo
38 38
 		return self::ALL_ENTITY_TYPES_SUPPORTED;
39 39
 	}
40 40
 
41
-	public function checkConstraint( Context $context, Constraint $constraint ) {
41
+	public function checkConstraint(Context $context, Constraint $constraint) {
42 42
 		$referenceList = $context->getSnakStatement()->getReferences();
43 43
 
44
-		if ( $referenceList->isEmpty() ) {
45
-			$message = ( new ViolationMessage( 'wbqc-violation-message-citationNeeded' ) )
46
-				->withEntityId( $context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY );
44
+		if ($referenceList->isEmpty()) {
45
+			$message = (new ViolationMessage('wbqc-violation-message-citationNeeded'))
46
+				->withEntityId($context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY);
47 47
 			return new CheckResult(
48 48
 				$context,
49 49
 				$constraint,
@@ -52,10 +52,10 @@  discard block
 block discarded – undo
52 52
 			);
53 53
 		}
54 54
 
55
-		return new CheckResult( $context, $constraint, CheckResult::STATUS_COMPLIANCE );
55
+		return new CheckResult($context, $constraint, CheckResult::STATUS_COMPLIANCE);
56 56
 	}
57 57
 
58
-	public function checkConstraintParameters( Constraint $constraint ) {
58
+	public function checkConstraintParameters(Constraint $constraint) {
59 59
 		// no parameters
60 60
 		return [];
61 61
 	}
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/NoneOfChecker.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -57,9 +57,9 @@  discard block
 block discarded – undo
57 57
 	 * @throws ConstraintParameterException
58 58
 	 * @return CheckResult
59 59
 	 */
60
-	public function checkConstraint( Context $context, Constraint $constraint ) {
61
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
62
-			return new CheckResult( $context, $constraint, CheckResult::STATUS_DEPRECATED );
60
+	public function checkConstraint(Context $context, Constraint $constraint) {
61
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
62
+			return new CheckResult($context, $constraint, CheckResult::STATUS_DEPRECATED);
63 63
 		}
64 64
 
65 65
 		$constraintParameters = $constraint->getConstraintParameters();
@@ -76,20 +76,20 @@  discard block
 block discarded – undo
76 76
 		$message = null;
77 77
 		$status = CheckResult::STATUS_COMPLIANCE;
78 78
 
79
-		foreach ( $items as $item ) {
80
-			if ( $item->matchesSnak( $snak ) ) {
81
-				$message = ( new ViolationMessage( 'wbqc-violation-message-none-of' ) )
82
-					->withEntityId( $context->getSnak()->getPropertyId(), Role::PREDICATE )
83
-					->withItemIdSnakValueList( $items, Role::OBJECT );
79
+		foreach ($items as $item) {
80
+			if ($item->matchesSnak($snak)) {
81
+				$message = (new ViolationMessage('wbqc-violation-message-none-of'))
82
+					->withEntityId($context->getSnak()->getPropertyId(), Role::PREDICATE)
83
+					->withItemIdSnakValueList($items, Role::OBJECT);
84 84
 				$status = CheckResult::STATUS_VIOLATION;
85 85
 				break;
86 86
 			}
87 87
 		}
88 88
 
89
-		return new CheckResult( $context, $constraint, $status, $message );
89
+		return new CheckResult($context, $constraint, $status, $message);
90 90
 	}
91 91
 
92
-	public function checkConstraintParameters( Constraint $constraint ) {
92
+	public function checkConstraintParameters(Constraint $constraint) {
93 93
 		$constraintParameters = $constraint->getConstraintParameters();
94 94
 		$constraintTypeItemId = $constraint->getConstraintTypeItemId();
95 95
 		$exceptions = [];
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 				$constraintTypeItemId,
100 100
 				true
101 101
 			);
102
-		} catch ( ConstraintParameterException $e ) {
102
+		} catch (ConstraintParameterException $e) {
103 103
 			$exceptions[] = $e;
104 104
 		}
105 105
 		return $exceptions;
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/OneOfChecker.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -57,9 +57,9 @@  discard block
 block discarded – undo
57 57
 	 * @throws ConstraintParameterException
58 58
 	 * @return CheckResult
59 59
 	 */
60
-	public function checkConstraint( Context $context, Constraint $constraint ) {
61
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
62
-			return new CheckResult( $context, $constraint, CheckResult::STATUS_DEPRECATED );
60
+	public function checkConstraint(Context $context, Constraint $constraint) {
61
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
62
+			return new CheckResult($context, $constraint, CheckResult::STATUS_DEPRECATED);
63 63
 		}
64 64
 
65 65
 		$constraintParameters = $constraint->getConstraintParameters();
@@ -73,23 +73,23 @@  discard block
 block discarded – undo
73 73
 
74 74
 		$snak = $context->getSnak();
75 75
 
76
-		$message = ( new ViolationMessage( 'wbqc-violation-message-one-of' ) )
77
-			->withEntityId( $context->getSnak()->getPropertyId(), Role::PREDICATE )
78
-			->withItemIdSnakValueList( $items, Role::OBJECT );
76
+		$message = (new ViolationMessage('wbqc-violation-message-one-of'))
77
+			->withEntityId($context->getSnak()->getPropertyId(), Role::PREDICATE)
78
+			->withItemIdSnakValueList($items, Role::OBJECT);
79 79
 		$status = CheckResult::STATUS_VIOLATION;
80 80
 
81
-		foreach ( $items as $item ) {
82
-			if ( $item->matchesSnak( $snak ) ) {
81
+		foreach ($items as $item) {
82
+			if ($item->matchesSnak($snak)) {
83 83
 				$message = null;
84 84
 				$status = CheckResult::STATUS_COMPLIANCE;
85 85
 				break;
86 86
 			}
87 87
 		}
88 88
 
89
-		return new CheckResult( $context, $constraint, $status, $message );
89
+		return new CheckResult($context, $constraint, $status, $message);
90 90
 	}
91 91
 
92
-	public function checkConstraintParameters( Constraint $constraint ) {
92
+	public function checkConstraintParameters(Constraint $constraint) {
93 93
 		$constraintParameters = $constraint->getConstraintParameters();
94 94
 		$constraintTypeItemId = $constraint->getConstraintTypeItemId();
95 95
 		$exceptions = [];
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 				$constraintTypeItemId,
100 100
 				true
101 101
 			);
102
-		} catch ( ConstraintParameterException $e ) {
102
+		} catch (ConstraintParameterException $e) {
103 103
 			$exceptions[] = $e;
104 104
 		}
105 105
 		return $exceptions;
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/DiffWithinRangeChecker.php 1 patch
Spacing   +36 added lines, -37 removed lines patch added patch discarded remove patch
@@ -73,8 +73,8 @@  discard block
 block discarded – undo
73 73
 	 * @throws ConstraintParameterException
74 74
 	 * @return array [ DataValue|null $min, DataValue|null $max, NumericPropertyId $property ]
75 75
 	 */
76
-	private function parseConstraintParameters( Constraint $constraint ) {
77
-		list( $min, $max ) = $this->constraintParameterParser->parseQuantityRangeParameter(
76
+	private function parseConstraintParameters(Constraint $constraint) {
77
+		list($min, $max) = $this->constraintParameterParser->parseQuantityRangeParameter(
78 78
 			$constraint->getConstraintParameters(),
79 79
 			$constraint->getConstraintTypeItemId()
80 80
 		);
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 			$constraint->getConstraintTypeItemId()
84 84
 		);
85 85
 
86
-		return [ $min, $max, $property ];
86
+		return [$min, $max, $property];
87 87
 	}
88 88
 
89 89
 	/**
@@ -93,13 +93,13 @@  discard block
 block discarded – undo
93 93
 	 *
94 94
 	 * @return bool
95 95
 	 */
96
-	private function rangeInYears( $min, $max ) {
97
-		$yearUnit = $this->config->get( 'WBQualityConstraintsYearUnit' );
96
+	private function rangeInYears($min, $max) {
97
+		$yearUnit = $this->config->get('WBQualityConstraintsYearUnit');
98 98
 
99
-		if ( $min !== null && $min->getUnit() === $yearUnit ) {
99
+		if ($min !== null && $min->getUnit() === $yearUnit) {
100 100
 			return true;
101 101
 		}
102
-		if ( $max !== null && $max->getUnit() === $yearUnit ) {
102
+		if ($max !== null && $max->getUnit() === $yearUnit) {
103 103
 			return true;
104 104
 		}
105 105
 
@@ -115,28 +115,28 @@  discard block
 block discarded – undo
115 115
 	 * @throws ConstraintParameterException
116 116
 	 * @return CheckResult
117 117
 	 */
118
-	public function checkConstraint( Context $context, Constraint $constraint ) {
119
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
120
-			return new CheckResult( $context, $constraint, CheckResult::STATUS_DEPRECATED );
118
+	public function checkConstraint(Context $context, Constraint $constraint) {
119
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
120
+			return new CheckResult($context, $constraint, CheckResult::STATUS_DEPRECATED);
121 121
 		}
122 122
 
123 123
 		$snak = $context->getSnak();
124 124
 
125
-		if ( !$snak instanceof PropertyValueSnak ) {
125
+		if (!$snak instanceof PropertyValueSnak) {
126 126
 			// nothing to check
127
-			return new CheckResult( $context, $constraint, CheckResult::STATUS_COMPLIANCE );
127
+			return new CheckResult($context, $constraint, CheckResult::STATUS_COMPLIANCE);
128 128
 		}
129 129
 
130 130
 		$minuend = $snak->getDataValue();
131 131
 		'@phan-var \DataValues\TimeValue|\DataValues\QuantityValue|\DataValues\UnboundedQuantityValue $minuend';
132 132
 
133 133
 		/** @var NumericPropertyId $property */
134
-		list( $min, $max, $property ) = $this->parseConstraintParameters( $constraint );
134
+		list($min, $max, $property) = $this->parseConstraintParameters($constraint);
135 135
 
136 136
 		// checks only the first occurrence of the referenced property
137
-		foreach ( $context->getSnakGroup( Context::GROUP_NON_DEPRECATED ) as $otherSnak ) {
137
+		foreach ($context->getSnakGroup(Context::GROUP_NON_DEPRECATED) as $otherSnak) {
138 138
 			if (
139
-				!$property->equals( $otherSnak->getPropertyId() ) ||
139
+				!$property->equals($otherSnak->getPropertyId()) ||
140 140
 				!$otherSnak instanceof PropertyValueSnak
141 141
 			) {
142 142
 				continue;
@@ -144,30 +144,29 @@  discard block
 block discarded – undo
144 144
 
145 145
 			$subtrahend = $otherSnak->getDataValue();
146 146
 			'@phan-var \DataValues\TimeValue|\DataValues\QuantityValue|\DataValues\UnboundedQuantityValue $subtrahend';
147
-			if ( $subtrahend->getType() === $minuend->getType() ) {
148
-				$diff = $this->rangeInYears( $min, $max ) && $minuend->getType() === 'time' ?
149
-					$this->rangeCheckerHelper->getDifferenceInYears( $minuend, $subtrahend ) :
150
-					$this->rangeCheckerHelper->getDifference( $minuend, $subtrahend );
147
+			if ($subtrahend->getType() === $minuend->getType()) {
148
+				$diff = $this->rangeInYears($min, $max) && $minuend->getType() === 'time' ?
149
+					$this->rangeCheckerHelper->getDifferenceInYears($minuend, $subtrahend) : $this->rangeCheckerHelper->getDifference($minuend, $subtrahend);
151 150
 
152
-				if ( $this->rangeCheckerHelper->getComparison( $min, $diff ) > 0 ||
153
-					$this->rangeCheckerHelper->getComparison( $diff, $max ) > 0
151
+				if ($this->rangeCheckerHelper->getComparison($min, $diff) > 0 ||
152
+					$this->rangeCheckerHelper->getComparison($diff, $max) > 0
154 153
 				) {
155 154
 					// at least one of $min, $max is set at this point, otherwise there could be no violation
156
-					$openness = $min !== null ? ( $max !== null ? '' : '-rightopen' ) : '-leftopen';
155
+					$openness = $min !== null ? ($max !== null ? '' : '-rightopen') : '-leftopen';
157 156
 					// possible message keys:
158 157
 					// wbqc-violation-message-diff-within-range
159 158
 					// wbqc-violation-message-diff-within-range-leftopen
160 159
 					// wbqc-violation-message-diff-within-range-rightopen
161
-					$message = ( new ViolationMessage( "wbqc-violation-message-diff-within-range$openness" ) )
162
-						->withEntityId( $context->getSnak()->getPropertyId(), Role::PREDICATE )
163
-						->withDataValue( $minuend, Role::OBJECT )
164
-						->withEntityId( $otherSnak->getPropertyId(), Role::PREDICATE )
165
-						->withDataValue( $subtrahend, Role::OBJECT );
166
-					if ( $min !== null ) {
167
-						$message = $message->withDataValue( $min, Role::OBJECT );
160
+					$message = (new ViolationMessage("wbqc-violation-message-diff-within-range$openness"))
161
+						->withEntityId($context->getSnak()->getPropertyId(), Role::PREDICATE)
162
+						->withDataValue($minuend, Role::OBJECT)
163
+						->withEntityId($otherSnak->getPropertyId(), Role::PREDICATE)
164
+						->withDataValue($subtrahend, Role::OBJECT);
165
+					if ($min !== null) {
166
+						$message = $message->withDataValue($min, Role::OBJECT);
168 167
 					}
169
-					if ( $max !== null ) {
170
-						$message = $message->withDataValue( $max, Role::OBJECT );
168
+					if ($max !== null) {
169
+						$message = $message->withDataValue($max, Role::OBJECT);
171 170
 					}
172 171
 					$status = CheckResult::STATUS_VIOLATION;
173 172
 				} else {
@@ -175,17 +174,17 @@  discard block
 block discarded – undo
175 174
 					$status = CheckResult::STATUS_COMPLIANCE;
176 175
 				}
177 176
 			} else {
178
-				$message = new ViolationMessage( 'wbqc-violation-message-diff-within-range-must-have-equal-types' );
177
+				$message = new ViolationMessage('wbqc-violation-message-diff-within-range-must-have-equal-types');
179 178
 				$status = CheckResult::STATUS_VIOLATION;
180 179
 			}
181 180
 
182
-			return new CheckResult( $context, $constraint, $status, $message );
181
+			return new CheckResult($context, $constraint, $status, $message);
183 182
 		}
184 183
 
185
-		return new CheckResult( $context, $constraint, CheckResult::STATUS_COMPLIANCE );
184
+		return new CheckResult($context, $constraint, CheckResult::STATUS_COMPLIANCE);
186 185
 	}
187 186
 
188
-	public function checkConstraintParameters( Constraint $constraint ) {
187
+	public function checkConstraintParameters(Constraint $constraint) {
189 188
 		$constraintParameters = $constraint->getConstraintParameters();
190 189
 		$constraintTypeItemId = $constraint->getConstraintTypeItemId();
191 190
 		$exceptions = [];
@@ -194,7 +193,7 @@  discard block
 block discarded – undo
194 193
 				$constraintParameters,
195 194
 				$constraintTypeItemId
196 195
 			);
197
-		} catch ( ConstraintParameterException $e ) {
196
+		} catch (ConstraintParameterException $e) {
198 197
 			$exceptions[] = $e;
199 198
 		}
200 199
 		try {
@@ -202,7 +201,7 @@  discard block
 block discarded – undo
202 201
 				$constraintParameters,
203 202
 				$constraintTypeItemId
204 203
 			);
205
-		} catch ( ConstraintParameterException $e ) {
204
+		} catch (ConstraintParameterException $e) {
206 205
 			$exceptions[] = $e;
207 206
 		}
208 207
 		return $exceptions;
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/SingleBestValueChecker.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -63,9 +63,9 @@  discard block
 block discarded – undo
63 63
 	 *
64 64
 	 * @return CheckResult
65 65
 	 */
66
-	public function checkConstraint( Context $context, Constraint $constraint ) {
67
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
68
-			return new CheckResult( $context, $constraint, CheckResult::STATUS_DEPRECATED );
66
+	public function checkConstraint(Context $context, Constraint $constraint) {
67
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
68
+			return new CheckResult($context, $constraint, CheckResult::STATUS_DEPRECATED);
69 69
 		}
70 70
 
71 71
 		$separators = $this->constraintParameterParser->parseSeparatorsParameter(
@@ -74,13 +74,13 @@  discard block
 block discarded – undo
74 74
 
75 75
 		$propertyId = $context->getSnak()->getPropertyId();
76 76
 		$bestRankCount = $this->valueCountCheckerHelper->getPropertyCount(
77
-			$context->getSnakGroup( Context::GROUP_BEST_RANK, $separators ),
77
+			$context->getSnakGroup(Context::GROUP_BEST_RANK, $separators),
78 78
 			$propertyId
79 79
 		);
80 80
 
81
-		if ( $bestRankCount > 1 ) {
81
+		if ($bestRankCount > 1) {
82 82
 			$nonDeprecatedCount = $this->valueCountCheckerHelper->getPropertyCount(
83
-				$context->getSnakGroup( Context::GROUP_NON_DEPRECATED ),
83
+				$context->getSnakGroup(Context::GROUP_NON_DEPRECATED),
84 84
 				$propertyId
85 85
 			);
86 86
 			$message = $this->getViolationMessage(
@@ -95,15 +95,15 @@  discard block
 block discarded – undo
95 95
 			$status = CheckResult::STATUS_COMPLIANCE;
96 96
 		}
97 97
 
98
-		return new CheckResult( $context, $constraint, $status, $message );
98
+		return new CheckResult($context, $constraint, $status, $message);
99 99
 	}
100 100
 
101
-	public function checkConstraintParameters( Constraint $constraint ) {
101
+	public function checkConstraintParameters(Constraint $constraint) {
102 102
 		$constraintParameters = $constraint->getConstraintParameters();
103 103
 		$exceptions = [];
104 104
 		try {
105
-			$this->constraintParameterParser->parseSeparatorsParameter( $constraintParameters );
106
-		} catch ( ConstraintParameterException $e ) {
105
+			$this->constraintParameterParser->parseSeparatorsParameter($constraintParameters);
106
+		} catch (ConstraintParameterException $e) {
107 107
 			$exceptions[] = $e;
108 108
 		}
109 109
 		return $exceptions;
@@ -122,23 +122,23 @@  discard block
 block discarded – undo
122 122
 		$separators,
123 123
 		$propertyId
124 124
 	) {
125
-		if ( $bestRankCount === $nonDeprecatedCount ) {
126
-			if ( $separators === [] ) {
125
+		if ($bestRankCount === $nonDeprecatedCount) {
126
+			if ($separators === []) {
127 127
 				$messageKey = 'wbqc-violation-message-single-best-value-no-preferred';
128 128
 			} else {
129 129
 				$messageKey = 'wbqc-violation-message-single-best-value-no-preferred-separators';
130 130
 			}
131 131
 		} else {
132
-			if ( $separators === [] ) {
132
+			if ($separators === []) {
133 133
 				$messageKey = 'wbqc-violation-message-single-best-value-multi-preferred';
134 134
 			} else {
135 135
 				$messageKey = 'wbqc-violation-message-single-best-value-multi-preferred-separators';
136 136
 			}
137 137
 		}
138 138
 
139
-		return ( new ViolationMessage( $messageKey ) )
140
-			->withEntityId( $propertyId )
141
-			->withEntityIdList( $separators );
139
+		return (new ViolationMessage($messageKey))
140
+			->withEntityId($propertyId)
141
+			->withEntityIdList($separators);
142 142
 	}
143 143
 
144 144
 }
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/ValueTypeChecker.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -88,9 +88,9 @@  discard block
 block discarded – undo
88 88
 	 * @throws SparqlHelperException if the checker uses SPARQL and the query times out or some other error occurs
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
 		$constraintParameters = $constraint->getConstraintParameters();
@@ -106,18 +106,18 @@  discard block
 block discarded – undo
106 106
 			$constraintTypeItemId
107 107
 		);
108 108
 		$relationIds = [];
109
-		if ( $relation === 'instance' || $relation === 'instanceOrSubclass' ) {
110
-			$relationIds[] = $this->config->get( 'WBQualityConstraintsInstanceOfId' );
109
+		if ($relation === 'instance' || $relation === 'instanceOrSubclass') {
110
+			$relationIds[] = $this->config->get('WBQualityConstraintsInstanceOfId');
111 111
 		}
112
-		if ( $relation === 'subclass' || $relation === 'instanceOrSubclass' ) {
113
-			$relationIds[] = $this->config->get( 'WBQualityConstraintsSubclassOfId' );
112
+		if ($relation === 'subclass' || $relation === 'instanceOrSubclass') {
113
+			$relationIds[] = $this->config->get('WBQualityConstraintsSubclassOfId');
114 114
 		}
115 115
 
116 116
 		$snak = $context->getSnak();
117 117
 
118
-		if ( !$snak instanceof PropertyValueSnak ) {
118
+		if (!$snak instanceof PropertyValueSnak) {
119 119
 			// nothing to check
120
-			return new CheckResult( $context, $constraint, CheckResult::STATUS_COMPLIANCE );
120
+			return new CheckResult($context, $constraint, CheckResult::STATUS_COMPLIANCE);
121 121
 		}
122 122
 
123 123
 		$dataValue = $snak->getDataValue();
@@ -126,23 +126,23 @@  discard block
 block discarded – undo
126 126
 		 * error handling:
127 127
 		 *   type of $dataValue for properties with 'Value type' constraint has to be 'wikibase-entityid'
128 128
 		 */
129
-		if ( !$dataValue instanceof EntityIdValue ) {
130
-			$message = ( new ViolationMessage( 'wbqc-violation-message-value-needed-of-type' ) )
131
-				->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
132
-				->withDataValueType( 'wikibase-entityid' );
133
-			return new CheckResult( $context, $constraint, CheckResult::STATUS_VIOLATION, $message );
129
+		if (!$dataValue instanceof EntityIdValue) {
130
+			$message = (new ViolationMessage('wbqc-violation-message-value-needed-of-type'))
131
+				->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
132
+				->withDataValueType('wikibase-entityid');
133
+			return new CheckResult($context, $constraint, CheckResult::STATUS_VIOLATION, $message);
134 134
 		}
135 135
 
136 136
 		try {
137
-			$item = $this->entityLookup->getEntity( $dataValue->getEntityId() );
138
-		} catch ( UnresolvedEntityRedirectException $e ) {
137
+			$item = $this->entityLookup->getEntity($dataValue->getEntityId());
138
+		} catch (UnresolvedEntityRedirectException $e) {
139 139
 			// Edge case (double redirect): Pretend the entity doesn't exist
140 140
 			$item = null;
141 141
 		}
142 142
 
143
-		if ( !( $item instanceof StatementListProvidingEntity ) ) {
144
-			$message = new ViolationMessage( 'wbqc-violation-message-value-entity-must-exist' );
145
-			return new CheckResult( $context, $constraint, CheckResult::STATUS_VIOLATION, $message );
143
+		if (!($item instanceof StatementListProvidingEntity)) {
144
+			$message = new ViolationMessage('wbqc-violation-message-value-entity-must-exist');
145
+			return new CheckResult($context, $constraint, CheckResult::STATUS_VIOLATION, $message);
146 146
 		}
147 147
 
148 148
 		$statements = $item->getStatements();
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 			$classes
154 154
 		);
155 155
 
156
-		if ( $result->getBool() ) {
156
+		if ($result->getBool()) {
157 157
 			$message = null;
158 158
 			$status = CheckResult::STATUS_COMPLIANCE;
159 159
 		} else {
@@ -167,11 +167,11 @@  discard block
 block discarded – undo
167 167
 			$status = CheckResult::STATUS_VIOLATION;
168 168
 		}
169 169
 
170
-		return ( new CheckResult( $context, $constraint, $status, $message ) )
171
-			->withMetadata( $result->getMetadata() );
170
+		return (new CheckResult($context, $constraint, $status, $message))
171
+			->withMetadata($result->getMetadata());
172 172
 	}
173 173
 
174
-	public function checkConstraintParameters( Constraint $constraint ) {
174
+	public function checkConstraintParameters(Constraint $constraint) {
175 175
 		$constraintParameters = $constraint->getConstraintParameters();
176 176
 		$constraintTypeItemId = $constraint->getConstraintTypeItemId();
177 177
 		$exceptions = [];
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 				$constraintParameters,
181 181
 				$constraintTypeItemId
182 182
 			);
183
-		} catch ( ConstraintParameterException $e ) {
183
+		} catch (ConstraintParameterException $e) {
184 184
 			$exceptions[] = $e;
185 185
 		}
186 186
 		try {
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 				$constraintParameters,
189 189
 				$constraintTypeItemId
190 190
 			);
191
-		} catch ( ConstraintParameterException $e ) {
191
+		} catch (ConstraintParameterException $e) {
192 192
 			$exceptions[] = $e;
193 193
 		}
194 194
 		return $exceptions;
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/EntityTypeChecker.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -48,9 +48,9 @@  discard block
 block discarded – undo
48 48
 		return self::ALL_ENTITY_TYPES_SUPPORTED;
49 49
 	}
50 50
 
51
-	public function checkConstraint( Context $context, Constraint $constraint ) {
52
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
53
-			return new CheckResult( $context, $constraint, CheckResult::STATUS_DEPRECATED );
51
+	public function checkConstraint(Context $context, Constraint $constraint) {
52
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
53
+			return new CheckResult($context, $constraint, CheckResult::STATUS_DEPRECATED);
54 54
 		}
55 55
 
56 56
 		$constraintParameters = $constraint->getConstraintParameters();
@@ -59,10 +59,10 @@  discard block
 block discarded – undo
59 59
 			$constraint->getConstraintTypeItemId()
60 60
 		);
61 61
 
62
-		if ( !in_array( $context->getEntity()->getType(), $entityTypes->getEntityTypes() ) ) {
63
-			$message = ( new ViolationMessage( 'wbqc-violation-message-entityType' ) )
64
-				->withEntityId( $context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY )
65
-				->withEntityIdList( $entityTypes->getEntityTypeItemIds(), Role::CONSTRAINT_PARAMETER_VALUE );
62
+		if (!in_array($context->getEntity()->getType(), $entityTypes->getEntityTypes())) {
63
+			$message = (new ViolationMessage('wbqc-violation-message-entityType'))
64
+				->withEntityId($context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY)
65
+				->withEntityIdList($entityTypes->getEntityTypeItemIds(), Role::CONSTRAINT_PARAMETER_VALUE);
66 66
 
67 67
 			return new CheckResult(
68 68
 				$context,
@@ -72,10 +72,10 @@  discard block
 block discarded – undo
72 72
 			);
73 73
 		}
74 74
 
75
-		return new CheckResult( $context, $constraint, CheckResult::STATUS_COMPLIANCE );
75
+		return new CheckResult($context, $constraint, CheckResult::STATUS_COMPLIANCE);
76 76
 	}
77 77
 
78
-	public function checkConstraintParameters( Constraint $constraint ) {
78
+	public function checkConstraintParameters(Constraint $constraint) {
79 79
 		$constraintParameters = $constraint->getConstraintParameters();
80 80
 		$exceptions = [];
81 81
 		try {
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 				$constraintParameters,
84 84
 				$constraint->getConstraintTypeItemId()
85 85
 			);
86
-		} catch ( ConstraintParameterException $e ) {
86
+		} catch (ConstraintParameterException $e) {
87 87
 			$exceptions[] = $e;
88 88
 		}
89 89
 		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
@@ -62,9 +62,9 @@  discard block
 block discarded – undo
62 62
 	 *
63 63
 	 * @return CheckResult
64 64
 	 */
65
-	public function checkConstraint( Context $context, Constraint $constraint ) {
66
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
67
-			return new CheckResult( $context, $constraint, CheckResult::STATUS_DEPRECATED );
65
+	public function checkConstraint(Context $context, Constraint $constraint) {
66
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
67
+			return new CheckResult($context, $constraint, CheckResult::STATUS_DEPRECATED);
68 68
 		}
69 69
 
70 70
 		$separators = $this->constraintParameterParser->parseSeparatorsParameter(
@@ -73,33 +73,32 @@  discard block
 block discarded – undo
73 73
 
74 74
 		$propertyId = $context->getSnak()->getPropertyId();
75 75
 		$propertyCount = $this->valueCountCheckerHelper->getPropertyCount(
76
-			$context->getSnakGroup( Context::GROUP_NON_DEPRECATED, $separators ),
76
+			$context->getSnakGroup(Context::GROUP_NON_DEPRECATED, $separators),
77 77
 			$propertyId
78 78
 		);
79 79
 
80
-		if ( $propertyCount <= 1 ) {
81
-			$message = ( new ViolationMessage(
80
+		if ($propertyCount <= 1) {
81
+			$message = (new ViolationMessage(
82 82
 					$separators === [] ?
83
-						'wbqc-violation-message-multi-value' :
84
-						'wbqc-violation-message-multi-value-separators'
85
-				) )
86
-				->withEntityId( $propertyId )
87
-				->withEntityIdList( $separators );
83
+						'wbqc-violation-message-multi-value' : 'wbqc-violation-message-multi-value-separators'
84
+				))
85
+				->withEntityId($propertyId)
86
+				->withEntityIdList($separators);
88 87
 			$status = CheckResult::STATUS_VIOLATION;
89 88
 		} else {
90 89
 			$message = null;
91 90
 			$status = CheckResult::STATUS_COMPLIANCE;
92 91
 		}
93 92
 
94
-		return new CheckResult( $context, $constraint, $status, $message );
93
+		return new CheckResult($context, $constraint, $status, $message);
95 94
 	}
96 95
 
97
-	public function checkConstraintParameters( Constraint $constraint ) {
96
+	public function checkConstraintParameters(Constraint $constraint) {
98 97
 		$constraintParameters = $constraint->getConstraintParameters();
99 98
 		$exceptions = [];
100 99
 		try {
101
-			$this->constraintParameterParser->parseSeparatorsParameter( $constraintParameters );
102
-		} catch ( ConstraintParameterException $e ) {
100
+			$this->constraintParameterParser->parseSeparatorsParameter($constraintParameters);
101
+		} catch (ConstraintParameterException $e) {
103 102
 			$exceptions[] = $e;
104 103
 		}
105 104
 		return $exceptions;
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/Lexeme/LanguageChecker.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -76,9 +76,9 @@  discard block
 block discarded – undo
76 76
 	 * @throws ConstraintParameterException
77 77
 	 * @return CheckResult
78 78
 	 */
79
-	public function checkConstraint( Context $context, Constraint $constraint ) {
80
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
81
-			return new CheckResult( $context, $constraint, CheckResult::STATUS_DEPRECATED );
79
+	public function checkConstraint(Context $context, Constraint $constraint) {
80
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
81
+			return new CheckResult($context, $constraint, CheckResult::STATUS_DEPRECATED);
82 82
 		}
83 83
 
84 84
 		$constraintParameters = $constraint->getConstraintParameters();
@@ -90,50 +90,50 @@  discard block
 block discarded – undo
90 90
 			true
91 91
 		);
92 92
 
93
-		$message = ( new ViolationMessage( 'wbqc-violation-message-language' ) )
94
-			->withEntityId( $context->getSnak()->getPropertyId(), Role::PREDICATE )
95
-			->withItemIdSnakValueList( $languages, Role::OBJECT );
93
+		$message = (new ViolationMessage('wbqc-violation-message-language'))
94
+			->withEntityId($context->getSnak()->getPropertyId(), Role::PREDICATE)
95
+			->withItemIdSnakValueList($languages, Role::OBJECT);
96 96
 		$status = CheckResult::STATUS_VIOLATION;
97 97
 
98
-		$lexeme = $this->getLexeme( $context );
99
-		if ( !$lexeme ) {
98
+		$lexeme = $this->getLexeme($context);
99
+		if (!$lexeme) {
100 100
 			// Lexeme doesn't exist, let's not bother
101
-			return new CheckResult( $context, $constraint, CheckResult::STATUS_NOT_IN_SCOPE );
101
+			return new CheckResult($context, $constraint, CheckResult::STATUS_NOT_IN_SCOPE);
102 102
 		}
103 103
 
104 104
 		/** @var Lexeme $lexeme */
105 105
 		'@phan-var Lexeme $lexeme';
106 106
 
107
-		foreach ( $languages as $language ) {
108
-			if ( $language->isNoValue() || $language->isSomeValue() ) {
107
+		foreach ($languages as $language) {
108
+			if ($language->isNoValue() || $language->isSomeValue()) {
109 109
 				continue;
110 110
 			}
111
-			if ( $lexeme->getLanguage()->equals( $language->getItemId() ) ) {
111
+			if ($lexeme->getLanguage()->equals($language->getItemId())) {
112 112
 				$message = null;
113 113
 				$status = CheckResult::STATUS_COMPLIANCE;
114 114
 				break;
115 115
 			}
116 116
 		}
117 117
 
118
-		return new CheckResult( $context, $constraint, $status, $message );
118
+		return new CheckResult($context, $constraint, $status, $message);
119 119
 	}
120 120
 
121
-	private function getLexeme( Context $context ): ?EntityDocument {
121
+	private function getLexeme(Context $context): ?EntityDocument {
122 122
 		$entityType = $context->getEntity()->getType();
123 123
 
124
-		if ( $entityType === Lexeme::ENTITY_TYPE ) {
124
+		if ($entityType === Lexeme::ENTITY_TYPE) {
125 125
 			return $context->getEntity();
126 126
 		}
127 127
 
128
-		if ( in_array( $entityType, [ Form::ENTITY_TYPE, Sense::ENTITY_TYPE ] ) ) {
128
+		if (in_array($entityType, [Form::ENTITY_TYPE, Sense::ENTITY_TYPE])) {
129 129
 			/** @var LexemeSubEntityId $id */
130 130
 			$id = $context->getEntity()->getId();
131 131
 			'@phan-var LexemeSubEntityId $id';
132
-			return $this->entityLookup->getEntity( $id->getLexemeId() );
132
+			return $this->entityLookup->getEntity($id->getLexemeId());
133 133
 		}
134 134
 	}
135 135
 
136
-	public function checkConstraintParameters( Constraint $constraint ): array {
136
+	public function checkConstraintParameters(Constraint $constraint): array {
137 137
 		$constraintParameters = $constraint->getConstraintParameters();
138 138
 		$constraintTypeItemId = $constraint->getConstraintTypeItemId();
139 139
 		$exceptions = [];
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 				$constraintTypeItemId,
144 144
 				true
145 145
 			);
146
-		} catch ( ConstraintParameterException $e ) {
146
+		} catch (ConstraintParameterException $e) {
147 147
 			$exceptions[] = $e;
148 148
 		}
149 149
 		return $exceptions;
Please login to merge, or discard this patch.