Completed
Push — master ( 5ee1ae...54a748 )
by
unknown
12:01
created
src/ConstraintCheck/Context/QualifierContext.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 		Statement $statement,
24 24
 		Snak $snak
25 25
 	) {
26
-		parent::__construct( $entity, $snak );
26
+		parent::__construct($entity, $snak);
27 27
 		$this->statement = $statement;
28 28
 	}
29 29
 
@@ -31,9 +31,9 @@  discard block
 block discarded – undo
31 31
 		return self::TYPE_QUALIFIER;
32 32
 	}
33 33
 
34
-	public function getSnakGroup( $groupingMode ) {
34
+	public function getSnakGroup($groupingMode) {
35 35
 		$snaks = $this->statement->getQualifiers();
36
-		return array_values( $snaks->getArrayCopy() );
36
+		return array_values($snaks->getArrayCopy());
37 37
 	}
38 38
 
39 39
 	public function getCursor() {
Please login to merge, or discard this patch.
src/ConstraintCheck/Context/ReferenceContext.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 		Reference $reference,
31 31
 		Snak $snak
32 32
 	) {
33
-		parent::__construct( $entity, $snak );
33
+		parent::__construct($entity, $snak);
34 34
 		$this->statement = $statement;
35 35
 		$this->reference = $reference;
36 36
 	}
@@ -39,9 +39,9 @@  discard block
 block discarded – undo
39 39
 		return self::TYPE_REFERENCE;
40 40
 	}
41 41
 
42
-	public function getSnakGroup( $groupingMode ) {
42
+	public function getSnakGroup($groupingMode) {
43 43
 		$snaks = $this->reference->getSnaks();
44
-		return array_values( $snaks->getArrayCopy() );
44
+		return array_values($snaks->getArrayCopy());
45 45
 	}
46 46
 
47 47
 	public function getCursor() {
Please login to merge, or discard this patch.
src/ConstraintCheck/Context/Context.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -105,7 +105,7 @@
 block discarded – undo
105 105
 	 * @return Snak[] not a SnakList because for a statement context,
106 106
 	 * the returned value might contain the same snak several times.
107 107
 	 */
108
-	public function getSnakGroup( $groupingMode );
108
+	public function getSnakGroup($groupingMode);
109 109
 
110 110
 	/**
111 111
 	 * Get the cursor that can be used to address check results for this context.
Please login to merge, or discard this patch.
src/ConstraintCheck/Context/MainSnakContext.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -21,9 +21,9 @@  discard block
 block discarded – undo
21 21
 	 */
22 22
 	private $statement;
23 23
 
24
-	public function __construct( EntityDocument $entity, Statement $statement ) {
25
-		Assert::parameterType( StatementListProvider::class, $entity, '$entity' );
26
-		parent::__construct( $entity, $statement->getMainSnak() );
24
+	public function __construct(EntityDocument $entity, Statement $statement) {
25
+		Assert::parameterType(StatementListProvider::class, $entity, '$entity');
26
+		parent::__construct($entity, $statement->getMainSnak());
27 27
 
28 28
 		$this->statement = $statement;
29 29
 	}
@@ -40,32 +40,32 @@  discard block
 block discarded – undo
40 40
 		return $this->statement;
41 41
 	}
42 42
 
43
-	public function getSnakGroup( $groupingMode ) {
43
+	public function getSnakGroup($groupingMode) {
44 44
 		/** @var StatementList $statements */
45 45
 		$statements = $this->entity->getStatements();
46
-		switch ( $groupingMode ) {
46
+		switch ($groupingMode) {
47 47
 			case Context::GROUP_NON_DEPRECATED:
48
-				$statements = $statements->getByRank( [
48
+				$statements = $statements->getByRank([
49 49
 					Statement::RANK_NORMAL,
50 50
 					Statement::RANK_PREFERRED,
51
-				] );
51
+				]);
52 52
 				break;
53 53
 			case Context::GROUP_BEST_RANK:
54
-				$statements = $this->getBestStatementsPerPropertyId( $statements );
54
+				$statements = $this->getBestStatementsPerPropertyId($statements);
55 55
 				break;
56 56
 			default:
57
-				throw new LogicException( 'Unknown $groupingMode ' . $groupingMode );
57
+				throw new LogicException('Unknown $groupingMode '.$groupingMode);
58 58
 		}
59 59
 		return $statements->getMainSnaks();
60 60
 	}
61 61
 
62
-	private function getBestStatementsPerPropertyId( StatementList $statements ) {
62
+	private function getBestStatementsPerPropertyId(StatementList $statements) {
63 63
 		$allBestStatements = new StatementList();
64
-		foreach ( $statements->getPropertyIds() as $propertyId ) {
65
-			$bestStatements = $statements->getByPropertyId( $propertyId )
64
+		foreach ($statements->getPropertyIds() as $propertyId) {
65
+			$bestStatements = $statements->getByPropertyId($propertyId)
66 66
 				->getBestStatements();
67
-			foreach ( $bestStatements as $bestStatement ) {
68
-				$allBestStatements->addStatement( $bestStatement );
67
+			foreach ($bestStatements as $bestStatement) {
68
+				$allBestStatements->addStatement($bestStatement);
69 69
 			}
70 70
 		}
71 71
 		return $allBestStatements;
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/SingleValueChecker.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -55,9 +55,9 @@  discard block
 block discarded – undo
55 55
 	 *
56 56
 	 * @return CheckResult
57 57
 	 */
58
-	public function checkConstraint( Context $context, Constraint $constraint ) {
59
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
60
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
58
+	public function checkConstraint(Context $context, Constraint $constraint) {
59
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
60
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
61 61
 		}
62 62
 
63 63
 		$propertyId = $context->getSnak()->getPropertyId();
@@ -65,22 +65,22 @@  discard block
 block discarded – undo
65 65
 		$parameters = [];
66 66
 
67 67
 		$propertyCount = $this->valueCountCheckerHelper->getPropertyCount(
68
-			$context->getSnakGroup( Context::GROUP_NON_DEPRECATED ),
68
+			$context->getSnakGroup(Context::GROUP_NON_DEPRECATED),
69 69
 			$propertyId
70 70
 		);
71 71
 
72
-		if ( $propertyCount > 1 ) {
73
-			$message = new ViolationMessage( 'wbqc-violation-message-single-value' );
72
+		if ($propertyCount > 1) {
73
+			$message = new ViolationMessage('wbqc-violation-message-single-value');
74 74
 			$status = CheckResult::STATUS_VIOLATION;
75 75
 		} else {
76 76
 			$message = null;
77 77
 			$status = CheckResult::STATUS_COMPLIANCE;
78 78
 		}
79 79
 
80
-		return new CheckResult( $context, $constraint, $parameters, $status, $message );
80
+		return new CheckResult($context, $constraint, $parameters, $status, $message);
81 81
 	}
82 82
 
83
-	public function checkConstraintParameters( Constraint $constraint ) {
83
+	public function checkConstraintParameters(Constraint $constraint) {
84 84
 		// no parameters
85 85
 		return [];
86 86
 	}
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/MultiValueChecker.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -55,9 +55,9 @@  discard block
 block discarded – undo
55 55
 	 *
56 56
 	 * @return CheckResult
57 57
 	 */
58
-	public function checkConstraint( Context $context, Constraint $constraint ) {
59
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
60
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
58
+	public function checkConstraint(Context $context, Constraint $constraint) {
59
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
60
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
61 61
 		}
62 62
 
63 63
 		$propertyId = $context->getSnak()->getPropertyId();
@@ -65,22 +65,22 @@  discard block
 block discarded – undo
65 65
 		$parameters = [];
66 66
 
67 67
 		$propertyCount = $this->valueCountCheckerHelper->getPropertyCount(
68
-			$context->getSnakGroup( Context::GROUP_NON_DEPRECATED ),
68
+			$context->getSnakGroup(Context::GROUP_NON_DEPRECATED),
69 69
 			$propertyId
70 70
 		);
71 71
 
72
-		if ( $propertyCount <= 1 ) {
73
-			$message = new ViolationMessage( 'wbqc-violation-message-multi-value' );
72
+		if ($propertyCount <= 1) {
73
+			$message = new ViolationMessage('wbqc-violation-message-multi-value');
74 74
 			$status = CheckResult::STATUS_VIOLATION;
75 75
 		} else {
76 76
 			$message = null;
77 77
 			$status = CheckResult::STATUS_COMPLIANCE;
78 78
 		}
79 79
 
80
-		return new CheckResult( $context, $constraint, $parameters, $status, $message );
80
+		return new CheckResult($context, $constraint, $parameters, $status, $message);
81 81
 	}
82 82
 
83
-	public function checkConstraintParameters( Constraint $constraint ) {
83
+	public function checkConstraintParameters(Constraint $constraint) {
84 84
 		// no parameters
85 85
 		return [];
86 86
 	}
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/DiffWithinRangeChecker.php 1 patch
Spacing   +42 added lines, -43 removed lines patch added patch discarded remove patch
@@ -84,8 +84,8 @@  discard block
 block discarded – undo
84 84
 	 * @throws ConstraintParameterException
85 85
 	 * @return array [ DataValue|null $min, DataValue|null $max, PropertyId $property, array $parameters ]
86 86
 	 */
87
-	private function parseConstraintParameters( Constraint $constraint ) {
88
-		list( $min, $max ) = $this->constraintParameterParser->parseQuantityRangeParameter(
87
+	private function parseConstraintParameters(Constraint $constraint) {
88
+		list($min, $max) = $this->constraintParameterParser->parseQuantityRangeParameter(
89 89
 			$constraint->getConstraintParameters(),
90 90
 			$constraint->getConstraintTypeItemId()
91 91
 		);
@@ -94,15 +94,15 @@  discard block
 block discarded – undo
94 94
 			$constraint->getConstraintTypeItemId()
95 95
 		);
96 96
 
97
-		if ( $min !== null ) {
98
-			$parameters['minimum_quantity'] = [ $min ];
97
+		if ($min !== null) {
98
+			$parameters['minimum_quantity'] = [$min];
99 99
 		}
100
-		if ( $max !== null ) {
101
-			$parameters['maximum_quantity'] = [ $max ];
100
+		if ($max !== null) {
101
+			$parameters['maximum_quantity'] = [$max];
102 102
 		}
103
-		$parameters['property'] = [ $property ];
103
+		$parameters['property'] = [$property];
104 104
 
105
-		return [ $min, $max, $property, $parameters ];
105
+		return [$min, $max, $property, $parameters];
106 106
 	}
107 107
 
108 108
 	/**
@@ -112,13 +112,13 @@  discard block
 block discarded – undo
112 112
 	 *
113 113
 	 * @return bool
114 114
 	 */
115
-	private function rangeInYears( $min, $max ) {
116
-		$yearUnit = $this->config->get( 'WBQualityConstraintsYearUnit' );
115
+	private function rangeInYears($min, $max) {
116
+		$yearUnit = $this->config->get('WBQualityConstraintsYearUnit');
117 117
 
118
-		if ( $min !== null && $min->getUnit() === $yearUnit ) {
118
+		if ($min !== null && $min->getUnit() === $yearUnit) {
119 119
 			return true;
120 120
 		}
121
-		if ( $max !== null && $max->getUnit() === $yearUnit ) {
121
+		if ($max !== null && $max->getUnit() === $yearUnit) {
122 122
 			return true;
123 123
 		}
124 124
 
@@ -134,59 +134,58 @@  discard block
 block discarded – undo
134 134
 	 * @throws ConstraintParameterException
135 135
 	 * @return CheckResult
136 136
 	 */
137
-	public function checkConstraint( Context $context, Constraint $constraint ) {
138
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
139
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
137
+	public function checkConstraint(Context $context, Constraint $constraint) {
138
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
139
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
140 140
 		}
141 141
 
142 142
 		$parameters = [];
143 143
 
144 144
 		$snak = $context->getSnak();
145 145
 
146
-		if ( !$snak instanceof PropertyValueSnak ) {
146
+		if (!$snak instanceof PropertyValueSnak) {
147 147
 			// nothing to check
148
-			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE );
148
+			return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE);
149 149
 		}
150 150
 
151 151
 		$minuend = $snak->getDataValue();
152 152
 
153 153
 		/** @var PropertyId $property */
154
-		list( $min, $max, $property, $parameters ) = $this->parseConstraintParameters( $constraint );
154
+		list($min, $max, $property, $parameters) = $this->parseConstraintParameters($constraint);
155 155
 
156 156
 		// checks only the first occurrence of the referenced property (this constraint implies a single value constraint on that property)
157
-		foreach ( $context->getSnakGroup( Context::GROUP_NON_DEPRECATED ) as $otherSnak ) {
157
+		foreach ($context->getSnakGroup(Context::GROUP_NON_DEPRECATED) as $otherSnak) {
158 158
 			if (
159
-				!$property->equals( $otherSnak->getPropertyId() ) ||
159
+				!$property->equals($otherSnak->getPropertyId()) ||
160 160
 				!$otherSnak instanceof PropertyValueSnak
161 161
 			) {
162 162
 				continue;
163 163
 			}
164 164
 
165 165
 			$subtrahend = $otherSnak->getDataValue();
166
-			if ( $subtrahend->getType() === $minuend->getType() ) {
167
-				$diff = $this->rangeInYears( $min, $max ) && $minuend->getType() === 'time' ?
168
-					$this->rangeCheckerHelper->getDifferenceInYears( $minuend, $subtrahend ) :
169
-					$this->rangeCheckerHelper->getDifference( $minuend, $subtrahend );
166
+			if ($subtrahend->getType() === $minuend->getType()) {
167
+				$diff = $this->rangeInYears($min, $max) && $minuend->getType() === 'time' ?
168
+					$this->rangeCheckerHelper->getDifferenceInYears($minuend, $subtrahend) : $this->rangeCheckerHelper->getDifference($minuend, $subtrahend);
170 169
 
171
-				if ( $this->rangeCheckerHelper->getComparison( $min, $diff ) > 0 ||
172
-					$this->rangeCheckerHelper->getComparison( $diff, $max ) > 0
170
+				if ($this->rangeCheckerHelper->getComparison($min, $diff) > 0 ||
171
+					$this->rangeCheckerHelper->getComparison($diff, $max) > 0
173 172
 				) {
174 173
 					// at least one of $min, $max is set at this point, otherwise there could be no violation
175
-					$openness = $min !== null ? ( $max !== null ? '' : '-rightopen' ) : '-leftopen';
174
+					$openness = $min !== null ? ($max !== null ? '' : '-rightopen') : '-leftopen';
176 175
 					// possible message keys:
177 176
 					// wbqc-violation-message-diff-within-range
178 177
 					// wbqc-violation-message-diff-within-range-leftopen
179 178
 					// wbqc-violation-message-diff-within-range-rightopen
180
-					$message = ( new ViolationMessage( "wbqc-violation-message-diff-within-range$openness" ) )
181
-						->withEntityId( $context->getSnak()->getPropertyId(), Role::PREDICATE )
182
-						->withDataValue( $minuend, Role::OBJECT )
183
-						->withEntityId( $otherSnak->getPropertyId(), Role::PREDICATE )
184
-						->withDataValue( $subtrahend, Role::OBJECT );
185
-					if ( $min !== null ) {
186
-						$message = $message->withDataValue( $min, Role::OBJECT );
179
+					$message = (new ViolationMessage("wbqc-violation-message-diff-within-range$openness"))
180
+						->withEntityId($context->getSnak()->getPropertyId(), Role::PREDICATE)
181
+						->withDataValue($minuend, Role::OBJECT)
182
+						->withEntityId($otherSnak->getPropertyId(), Role::PREDICATE)
183
+						->withDataValue($subtrahend, Role::OBJECT);
184
+					if ($min !== null) {
185
+						$message = $message->withDataValue($min, Role::OBJECT);
187 186
 					}
188
-					if ( $max !== null ) {
189
-						$message = $message->withDataValue( $max, Role::OBJECT );
187
+					if ($max !== null) {
188
+						$message = $message->withDataValue($max, Role::OBJECT);
190 189
 					}
191 190
 					$status = CheckResult::STATUS_VIOLATION;
192 191
 				} else {
@@ -194,17 +193,17 @@  discard block
 block discarded – undo
194 193
 					$status = CheckResult::STATUS_COMPLIANCE;
195 194
 				}
196 195
 			} else {
197
-				$message = new ViolationMessage( 'wbqc-violation-message-diff-within-range-must-have-equal-types' );
196
+				$message = new ViolationMessage('wbqc-violation-message-diff-within-range-must-have-equal-types');
198 197
 				$status = CheckResult::STATUS_VIOLATION;
199 198
 			}
200 199
 
201
-			return new CheckResult( $context, $constraint, $parameters, $status, $message );
200
+			return new CheckResult($context, $constraint, $parameters, $status, $message);
202 201
 		}
203 202
 
204
-		return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE );
203
+		return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE);
205 204
 	}
206 205
 
207
-	public function checkConstraintParameters( Constraint $constraint ) {
206
+	public function checkConstraintParameters(Constraint $constraint) {
208 207
 		$constraintParameters = $constraint->getConstraintParameters();
209 208
 		$exceptions = [];
210 209
 		try {
@@ -212,12 +211,12 @@  discard block
 block discarded – undo
212 211
 				$constraintParameters,
213 212
 				$constraint->getConstraintTypeItemId()
214 213
 			);
215
-		} catch ( ConstraintParameterException $e ) {
214
+		} catch (ConstraintParameterException $e) {
216 215
 			$exceptions[] = $e;
217 216
 		}
218 217
 		try {
219
-			$this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
220
-		} catch ( ConstraintParameterException $e ) {
218
+			$this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId());
219
+		} catch (ConstraintParameterException $e) {
221 220
 			$exceptions[] = $e;
222 221
 		}
223 222
 		return $exceptions;
Please login to merge, or discard this patch.