Completed
Push — master ( 1a2329...d460d9 )
by
unknown
02:14
created
src/ConstraintCheck/Result/NullResult.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -25,22 +25,22 @@
 block discarded – undo
25 25
 	 */
26 26
 	const NULL_PROPERTY_ID = 'P2147483647';
27 27
 
28
-	public function __construct( Context $context ) {
28
+	public function __construct(Context $context) {
29 29
 		$constraint = new Constraint(
30 30
 			'null',
31
-			new PropertyId( self::NULL_PROPERTY_ID ),
31
+			new PropertyId(self::NULL_PROPERTY_ID),
32 32
 			'none',
33 33
 			[]
34 34
 		);
35
-		parent::__construct( $context, $constraint );
35
+		parent::__construct($context, $constraint);
36 36
 	}
37 37
 
38 38
 	public function getConstraint() {
39
-		throw new DomainException( 'NullResult holds no constraint' );
39
+		throw new DomainException('NullResult holds no constraint');
40 40
 	}
41 41
 
42 42
 	public function getConstraintId() {
43
-		throw new DomainException( 'NullResult holds no constraint' );
43
+		throw new DomainException('NullResult holds no constraint');
44 44
 	}
45 45
 
46 46
 }
Please login to merge, or discard this patch.
src/ConstraintCheck/ConstraintChecker.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 	 * @throws ConstraintParameterException if the constraint parameters are invalid
23 23
 	 * @throws SparqlHelperException if the checker uses SPARQL and the query times out or some other error occurs
24 24
 	 */
25
-	public function checkConstraint( Context $context, Constraint $constraint );
25
+	public function checkConstraint(Context $context, Constraint $constraint);
26 26
 
27 27
 	/**
28 28
 	 * Check if the constraint parameters of $constraint are valid.
@@ -33,6 +33,6 @@  discard block
 block discarded – undo
33 33
 	 *
34 34
 	 * @return ConstraintParameterException[]
35 35
 	 */
36
-	public function checkConstraintParameters( Constraint $constraint );
36
+	public function checkConstraintParameters(Constraint $constraint);
37 37
 
38 38
 }
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/MandatoryQualifiersChecker.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -52,46 +52,46 @@
 block discarded – undo
52 52
 	 *
53 53
 	 * @return CheckResult
54 54
 	 */
55
-	public function checkConstraint( Context $context, Constraint $constraint ) {
56
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
57
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
55
+	public function checkConstraint(Context $context, Constraint $constraint) {
56
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
57
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
58 58
 		}
59
-		if ( $context->getType() !== Context::TYPE_STATEMENT ) {
60
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_NOT_MAIN_SNAK );
59
+		if ($context->getType() !== Context::TYPE_STATEMENT) {
60
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_NOT_MAIN_SNAK);
61 61
 		}
62 62
 
63 63
 		$parameters = [];
64 64
 		$constraintParameters = $constraint->getConstraintParameters();
65 65
 
66
-		$propertyId = $this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
67
-		$parameters['property'] = [ $propertyId ];
66
+		$propertyId = $this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId());
67
+		$parameters['property'] = [$propertyId];
68 68
 
69
-		$message = wfMessage( "wbqc-violation-message-mandatory-qualifier" )
69
+		$message = wfMessage("wbqc-violation-message-mandatory-qualifier")
70 70
 				 ->rawParams(
71
-					 $this->constraintParameterRenderer->formatEntityId( $context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY ),
72
-					 $this->constraintParameterRenderer->formatEntityId( $propertyId, Role::QUALIFIER_PREDICATE )
71
+					 $this->constraintParameterRenderer->formatEntityId($context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY),
72
+					 $this->constraintParameterRenderer->formatEntityId($propertyId, Role::QUALIFIER_PREDICATE)
73 73
 				 )
74 74
 				 ->escaped();
75 75
 		$status = CheckResult::STATUS_VIOLATION;
76 76
 
77 77
 		/** @var Snak $qualifier */
78
-		foreach ( $context->getSnakStatement()->getQualifiers() as $qualifier ) {
79
-			if ( $propertyId->equals( $qualifier->getPropertyId() ) ) {
78
+		foreach ($context->getSnakStatement()->getQualifiers() as $qualifier) {
79
+			if ($propertyId->equals($qualifier->getPropertyId())) {
80 80
 				$message = '';
81 81
 				$status = CheckResult::STATUS_COMPLIANCE;
82 82
 				break;
83 83
 			}
84 84
 		}
85 85
 
86
-		return new CheckResult( $context, $constraint, $parameters, $status, $message );
86
+		return new CheckResult($context, $constraint, $parameters, $status, $message);
87 87
 	}
88 88
 
89
-	public function checkConstraintParameters( Constraint $constraint ) {
89
+	public function checkConstraintParameters(Constraint $constraint) {
90 90
 		$constraintParameters = $constraint->getConstraintParameters();
91 91
 		$exceptions = [];
92 92
 		try {
93
-			$this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
94
-		} catch ( ConstraintParameterException $e ) {
93
+			$this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId());
94
+		} catch (ConstraintParameterException $e) {
95 95
 			$exceptions[] = $e;
96 96
 		}
97 97
 		return $exceptions;
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/ConflictsWithChecker.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -70,22 +70,22 @@  discard block
 block discarded – undo
70 70
 	 *
71 71
 	 * @return CheckResult
72 72
 	 */
73
-	public function checkConstraint( Context $context, Constraint $constraint ) {
74
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
75
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
73
+	public function checkConstraint(Context $context, Constraint $constraint) {
74
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
75
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
76 76
 		}
77
-		if ( $context->getType() !== Context::TYPE_STATEMENT ) {
77
+		if ($context->getType() !== Context::TYPE_STATEMENT) {
78 78
 			// TODO T175562
79
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_NOT_MAIN_SNAK );
79
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_NOT_MAIN_SNAK);
80 80
 		}
81 81
 
82 82
 		$parameters = [];
83 83
 		$constraintParameters = $constraint->getConstraintParameters();
84 84
 
85
-		$propertyId = $this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
86
-		$parameters['property'] = [ $propertyId ];
85
+		$propertyId = $this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId());
86
+		$parameters['property'] = [$propertyId];
87 87
 
88
-		$items = $this->constraintParameterParser->parseItemsParameter( $constraintParameters, $constraint->getConstraintTypeItemId(), false );
88
+		$items = $this->constraintParameterParser->parseItemsParameter($constraintParameters, $constraint->getConstraintTypeItemId(), false);
89 89
 		$parameters['items'] = $items;
90 90
 
91 91
 		/*
@@ -93,16 +93,16 @@  discard block
 block discarded – undo
93 93
 		 *   a) a property only
94 94
 		 *   b) a property and a number of items (each combination of property and item forming an individual claim)
95 95
 		 */
96
-		if ( $items === [] ) {
96
+		if ($items === []) {
97 97
 			$offendingStatement = $this->connectionCheckerHelper->findStatementWithProperty(
98 98
 				$context->getEntity()->getStatements(),
99 99
 				$propertyId
100 100
 			);
101
-			if ( $offendingStatement !== null ) {
102
-				$message = wfMessage( "wbqc-violation-message-conflicts-with-property" )
101
+			if ($offendingStatement !== null) {
102
+				$message = wfMessage("wbqc-violation-message-conflicts-with-property")
103 103
 						 ->rawParams(
104
-							 $this->constraintParameterRenderer->formatEntityId( $context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY ),
105
-							 $this->constraintParameterRenderer->formatEntityId( $propertyId, Role::PREDICATE )
104
+							 $this->constraintParameterRenderer->formatEntityId($context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY),
105
+							 $this->constraintParameterRenderer->formatEntityId($propertyId, Role::PREDICATE)
106 106
 						 )
107 107
 						 ->escaped();
108 108
 				$status = CheckResult::STATUS_VIOLATION;
@@ -116,13 +116,13 @@  discard block
 block discarded – undo
116 116
 				$propertyId,
117 117
 				$items
118 118
 			);
119
-			if ( $offendingStatement !== null ) {
120
-				$offendingValue = ItemIdSnakValue::fromSnak( $offendingStatement->getMainSnak() );
121
-				$message = wfMessage( "wbqc-violation-message-conflicts-with-claim" )
119
+			if ($offendingStatement !== null) {
120
+				$offendingValue = ItemIdSnakValue::fromSnak($offendingStatement->getMainSnak());
121
+				$message = wfMessage("wbqc-violation-message-conflicts-with-claim")
122 122
 						 ->rawParams(
123
-							 $this->constraintParameterRenderer->formatEntityId( $context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY ),
124
-							 $this->constraintParameterRenderer->formatEntityId( $propertyId, Role::PREDICATE ),
125
-							 $this->constraintParameterRenderer->formatItemIdSnakValue( $offendingValue, Role::OBJECT )
123
+							 $this->constraintParameterRenderer->formatEntityId($context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY),
124
+							 $this->constraintParameterRenderer->formatEntityId($propertyId, Role::PREDICATE),
125
+							 $this->constraintParameterRenderer->formatItemIdSnakValue($offendingValue, Role::OBJECT)
126 126
 						 )
127 127
 						 ->escaped();
128 128
 				$status = CheckResult::STATUS_VIOLATION;
@@ -132,20 +132,20 @@  discard block
 block discarded – undo
132 132
 			}
133 133
 		}
134 134
 
135
-		return new CheckResult( $context, $constraint, $parameters, $status, $message );
135
+		return new CheckResult($context, $constraint, $parameters, $status, $message);
136 136
 	}
137 137
 
138
-	public function checkConstraintParameters( Constraint $constraint ) {
138
+	public function checkConstraintParameters(Constraint $constraint) {
139 139
 		$constraintParameters = $constraint->getConstraintParameters();
140 140
 		$exceptions = [];
141 141
 		try {
142
-			$this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
143
-		} catch ( ConstraintParameterException $e ) {
142
+			$this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId());
143
+		} catch (ConstraintParameterException $e) {
144 144
 			$exceptions[] = $e;
145 145
 		}
146 146
 		try {
147
-			$this->constraintParameterParser->parseItemsParameter( $constraintParameters, $constraint->getConstraintTypeItemId(), false );
148
-		} catch ( ConstraintParameterException $e ) {
147
+			$this->constraintParameterParser->parseItemsParameter($constraintParameters, $constraint->getConstraintTypeItemId(), false);
148
+		} catch (ConstraintParameterException $e) {
149 149
 			$exceptions[] = $e;
150 150
 		}
151 151
 		return $exceptions;
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/SingleValueChecker.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -35,33 +35,33 @@
 block discarded – undo
35 35
 	 *
36 36
 	 * @return CheckResult
37 37
 	 */
38
-	public function checkConstraint( Context $context, Constraint $constraint ) {
39
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
40
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
38
+	public function checkConstraint(Context $context, Constraint $constraint) {
39
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
40
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
41 41
 		}
42
-		if ( $context->getType() !== Context::TYPE_STATEMENT ) {
42
+		if ($context->getType() !== Context::TYPE_STATEMENT) {
43 43
 			// TODO T175566
44
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_NOT_MAIN_SNAK );
44
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_NOT_MAIN_SNAK);
45 45
 		}
46 46
 
47 47
 		$propertyId = $context->getSnak()->getPropertyId();
48 48
 
49 49
 		$parameters = [];
50 50
 
51
-		$propertyCountArray = $this->valueCountCheckerHelper->getPropertyCount( $context->getEntity()->getStatements() );
51
+		$propertyCountArray = $this->valueCountCheckerHelper->getPropertyCount($context->getEntity()->getStatements());
52 52
 
53
-		if ( $propertyCountArray[$propertyId->getSerialization()] > 1 ) {
54
-			$message = wfMessage( "wbqc-violation-message-single-value" )->escaped();
53
+		if ($propertyCountArray[$propertyId->getSerialization()] > 1) {
54
+			$message = wfMessage("wbqc-violation-message-single-value")->escaped();
55 55
 			$status = CheckResult::STATUS_VIOLATION;
56 56
 		} else {
57 57
 			$message = '';
58 58
 			$status = CheckResult::STATUS_COMPLIANCE;
59 59
 		}
60 60
 
61
-		return new CheckResult( $context, $constraint, $parameters, $status, $message );
61
+		return new CheckResult($context, $constraint, $parameters, $status, $message);
62 62
 	}
63 63
 
64
-	public function checkConstraintParameters( Constraint $constraint ) {
64
+	public function checkConstraintParameters(Constraint $constraint) {
65 65
 		// no parameters
66 66
 		return [];
67 67
 	}
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/RangeChecker.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -70,9 +70,9 @@  discard block
 block discarded – undo
70 70
 	 *
71 71
 	 * @return CheckResult
72 72
 	 */
73
-	public function checkConstraint( Context $context, Constraint $constraint ) {
74
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
75
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
73
+	public function checkConstraint(Context $context, Constraint $constraint) {
74
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
75
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
76 76
 		}
77 77
 
78 78
 		$parameters = [];
@@ -80,42 +80,42 @@  discard block
 block discarded – undo
80 80
 
81 81
 		$snak = $context->getSnak();
82 82
 
83
-		if ( !$snak instanceof PropertyValueSnak ) {
83
+		if (!$snak instanceof PropertyValueSnak) {
84 84
 			// nothing to check
85
-			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE, '' );
85
+			return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE, '');
86 86
 		}
87 87
 
88 88
 		$dataValue = $snak->getDataValue();
89 89
 
90
-		list( $min, $max ) = $this->constraintParameterParser->parseRangeParameter(
90
+		list($min, $max) = $this->constraintParameterParser->parseRangeParameter(
91 91
 			$constraintParameters,
92 92
 			$constraint->getConstraintTypeItemId(),
93 93
 			$dataValue->getType()
94 94
 		);
95 95
 		$parameterKey = $dataValue->getType() === 'quantity' ? 'quantity' : 'date';
96
-		if ( $min !== null ) {
97
-			$parameters['minimum_' . $parameterKey] = [ $min ];
96
+		if ($min !== null) {
97
+			$parameters['minimum_'.$parameterKey] = [$min];
98 98
 		}
99
-		if ( $max !== null ) {
100
-			$parameters['maximum_' . $parameterKey] = [ $max ];
99
+		if ($max !== null) {
100
+			$parameters['maximum_'.$parameterKey] = [$max];
101 101
 		}
102 102
 
103
-		if ( $this->rangeCheckerHelper->getComparison( $min, $dataValue ) > 0 ||
104
-			 $this->rangeCheckerHelper->getComparison( $dataValue, $max ) > 0
103
+		if ($this->rangeCheckerHelper->getComparison($min, $dataValue) > 0 ||
104
+			 $this->rangeCheckerHelper->getComparison($dataValue, $max) > 0
105 105
 		) {
106 106
 			// at least one of $min, $max is set at this point, otherwise there could be no violation
107 107
 			$type = $dataValue->getType();
108
-			$openness = $min !== null ? ( $max !== null ? 'closed' : 'rightopen' ) : 'leftopen';
109
-			$message = wfMessage( "wbqc-violation-message-range-$type-$openness" );
108
+			$openness = $min !== null ? ($max !== null ? 'closed' : 'rightopen') : 'leftopen';
109
+			$message = wfMessage("wbqc-violation-message-range-$type-$openness");
110 110
 			$message->rawParams(
111
-				$this->constraintParameterRenderer->formatEntityId( $context->getSnak()->getPropertyId(), Role::PREDICATE ),
112
-				$this->constraintParameterRenderer->formatDataValue( $dataValue, Role::OBJECT )
111
+				$this->constraintParameterRenderer->formatEntityId($context->getSnak()->getPropertyId(), Role::PREDICATE),
112
+				$this->constraintParameterRenderer->formatDataValue($dataValue, Role::OBJECT)
113 113
 			);
114
-			if ( $min !== null ) {
115
-				$message->rawParams( $this->constraintParameterRenderer->formatDataValue( $min, Role::OBJECT ) );
114
+			if ($min !== null) {
115
+				$message->rawParams($this->constraintParameterRenderer->formatDataValue($min, Role::OBJECT));
116 116
 			}
117
-			if ( $max !== null ) {
118
-				$message->rawParams( $this->constraintParameterRenderer->formatDataValue( $max, Role::OBJECT ) );
117
+			if ($max !== null) {
118
+				$message->rawParams($this->constraintParameterRenderer->formatDataValue($max, Role::OBJECT));
119 119
 			}
120 120
 			$message = $message->escaped();
121 121
 			$status = CheckResult::STATUS_VIOLATION;
@@ -124,22 +124,22 @@  discard block
 block discarded – undo
124 124
 			$status = CheckResult::STATUS_COMPLIANCE;
125 125
 		}
126 126
 
127
-		return new CheckResult( $context, $constraint, $parameters, $status, $message );
127
+		return new CheckResult($context, $constraint, $parameters, $status, $message);
128 128
 	}
129 129
 
130
-	public function checkConstraintParameters( Constraint $constraint ) {
130
+	public function checkConstraintParameters(Constraint $constraint) {
131 131
 		$constraintParameters = $constraint->getConstraintParameters();
132 132
 		$exceptions = [];
133 133
 		try {
134 134
 			// we don’t have a data value here, so get the type from the property instead
135 135
 			// (the distinction between data type and data value type is irrelevant for 'quantity' and 'time')
136
-			$type = $this->propertyDataTypeLookup->getDataTypeIdForProperty( $constraint->getPropertyId() );
136
+			$type = $this->propertyDataTypeLookup->getDataTypeIdForProperty($constraint->getPropertyId());
137 137
 			$this->constraintParameterParser->parseRangeParameter(
138 138
 				$constraintParameters,
139 139
 				$constraint->getConstraintTypeItemId(),
140 140
 				$type
141 141
 			);
142
-		} catch ( ConstraintParameterException $e ) {
142
+		} catch (ConstraintParameterException $e) {
143 143
 			$exceptions[] = $e;
144 144
 		}
145 145
 		return $exceptions;
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/DiffWithinRangeChecker.php 1 patch
Spacing   +45 added lines, -46 removed lines patch added patch discarded remove patch
@@ -67,8 +67,8 @@  discard block
 block discarded – undo
67 67
 	 * @throws ConstraintParameterException
68 68
 	 * @return array [ DataValue|null $min, DataValue|null $max, PropertyId $property, array $parameters ]
69 69
 	 */
70
-	private function parseConstraintParameters( Constraint $constraint ) {
71
-		list( $min, $max ) = $this->constraintParameterParser->parseRangeParameter(
70
+	private function parseConstraintParameters(Constraint $constraint) {
71
+		list($min, $max) = $this->constraintParameterParser->parseRangeParameter(
72 72
 			$constraint->getConstraintParameters(),
73 73
 			$constraint->getConstraintTypeItemId(),
74 74
 			'quantity'
@@ -78,15 +78,15 @@  discard block
 block discarded – undo
78 78
 			$constraint->getConstraintTypeItemId()
79 79
 		);
80 80
 
81
-		if ( $min !== null ) {
82
-			$parameters['minimum_quantity'] = [ $min ];
81
+		if ($min !== null) {
82
+			$parameters['minimum_quantity'] = [$min];
83 83
 		}
84
-		if ( $max !== null ) {
85
-			$parameters['maximum_quantity'] = [ $max ];
84
+		if ($max !== null) {
85
+			$parameters['maximum_quantity'] = [$max];
86 86
 		}
87
-		$parameters['property'] = [ $property ];
87
+		$parameters['property'] = [$property];
88 88
 
89
-		return [ $min, $max, $property, $parameters ];
89
+		return [$min, $max, $property, $parameters];
90 90
 	}
91 91
 
92 92
 	/**
@@ -96,13 +96,13 @@  discard block
 block discarded – undo
96 96
 	 *
97 97
 	 * @return bool
98 98
 	 */
99
-	private function rangeInYears( $min, $max ) {
100
-		$yearUnit = $this->config->get( 'WBQualityConstraintsYearUnit' );
99
+	private function rangeInYears($min, $max) {
100
+		$yearUnit = $this->config->get('WBQualityConstraintsYearUnit');
101 101
 
102
-		if ( $min !== null && $min->getUnit() === $yearUnit ) {
102
+		if ($min !== null && $min->getUnit() === $yearUnit) {
103 103
 			return true;
104 104
 		}
105
-		if ( $max !== null && $max->getUnit() === $yearUnit ) {
105
+		if ($max !== null && $max->getUnit() === $yearUnit) {
106 106
 			return true;
107 107
 		}
108 108
 
@@ -117,36 +117,36 @@  discard block
 block discarded – undo
117 117
 	 *
118 118
 	 * @return CheckResult
119 119
 	 */
120
-	public function checkConstraint( Context $context, Constraint $constraint ) {
121
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
122
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
120
+	public function checkConstraint(Context $context, Constraint $constraint) {
121
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
122
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
123 123
 		}
124
-		if ( $context->getType() !== Context::TYPE_STATEMENT ) {
124
+		if ($context->getType() !== Context::TYPE_STATEMENT) {
125 125
 			// TODO T175565
126
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_NOT_MAIN_SNAK );
126
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_NOT_MAIN_SNAK);
127 127
 		}
128 128
 
129 129
 		$parameters = [];
130 130
 
131 131
 		$snak = $context->getSnak();
132 132
 
133
-		if ( !$snak instanceof PropertyValueSnak ) {
133
+		if (!$snak instanceof PropertyValueSnak) {
134 134
 			// nothing to check
135
-			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE, '' );
135
+			return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE, '');
136 136
 		}
137 137
 
138 138
 		$minuend = $snak->getDataValue();
139 139
 
140 140
 		/** @var PropertyId $property */
141
-		list ( $min, $max, $property, $parameters ) = $this->parseConstraintParameters( $constraint );
141
+		list ($min, $max, $property, $parameters) = $this->parseConstraintParameters($constraint);
142 142
 
143 143
 		// checks only the first occurrence of the referenced property (this constraint implies a single value constraint on that property)
144 144
 		/** @var Statement $otherStatement */
145
-		foreach ( $context->getEntity()->getStatements() as $otherStatement ) {
145
+		foreach ($context->getEntity()->getStatements() as $otherStatement) {
146 146
 			$otherMainSnak = $otherStatement->getMainSnak();
147 147
 
148 148
 			if (
149
-				!$property->equals( $otherStatement->getPropertyId() ) ||
149
+				!$property->equals($otherStatement->getPropertyId()) ||
150 150
 				$otherStatement->getRank() === Statement::RANK_DEPRECATED ||
151 151
 				!$otherMainSnak instanceof PropertyValueSnak
152 152
 			) {
@@ -154,28 +154,27 @@  discard block
 block discarded – undo
154 154
 			}
155 155
 
156 156
 			$subtrahend = $otherMainSnak->getDataValue();
157
-			if ( $subtrahend->getType() === $minuend->getType() ) {
158
-				$diff = $this->rangeInYears( $min, $max ) ?
159
-					$this->rangeCheckerHelper->getDifferenceInYears( $minuend, $subtrahend ) :
160
-					$this->rangeCheckerHelper->getDifference( $minuend, $subtrahend );
157
+			if ($subtrahend->getType() === $minuend->getType()) {
158
+				$diff = $this->rangeInYears($min, $max) ?
159
+					$this->rangeCheckerHelper->getDifferenceInYears($minuend, $subtrahend) : $this->rangeCheckerHelper->getDifference($minuend, $subtrahend);
161 160
 
162
-				if ( $this->rangeCheckerHelper->getComparison( $min, $diff ) > 0 ||
163
-					$this->rangeCheckerHelper->getComparison( $diff, $max ) > 0
161
+				if ($this->rangeCheckerHelper->getComparison($min, $diff) > 0 ||
162
+					$this->rangeCheckerHelper->getComparison($diff, $max) > 0
164 163
 				) {
165 164
 					// at least one of $min, $max is set at this point, otherwise there could be no violation
166
-					$openness = $min !== null ? ( $max !== null ? '' : '-rightopen' ) : '-leftopen';
167
-					$message = wfMessage( "wbqc-violation-message-diff-within-range$openness" );
165
+					$openness = $min !== null ? ($max !== null ? '' : '-rightopen') : '-leftopen';
166
+					$message = wfMessage("wbqc-violation-message-diff-within-range$openness");
168 167
 					$message->rawParams(
169
-						$this->constraintParameterRenderer->formatEntityId( $context->getSnak()->getPropertyId(), Role::PREDICATE ),
170
-						$this->constraintParameterRenderer->formatDataValue( $minuend, Role::OBJECT ),
171
-						$this->constraintParameterRenderer->formatEntityId( $otherStatement->getPropertyId(), Role::PREDICATE ),
172
-						$this->constraintParameterRenderer->formatDataValue( $subtrahend, Role::OBJECT )
168
+						$this->constraintParameterRenderer->formatEntityId($context->getSnak()->getPropertyId(), Role::PREDICATE),
169
+						$this->constraintParameterRenderer->formatDataValue($minuend, Role::OBJECT),
170
+						$this->constraintParameterRenderer->formatEntityId($otherStatement->getPropertyId(), Role::PREDICATE),
171
+						$this->constraintParameterRenderer->formatDataValue($subtrahend, Role::OBJECT)
173 172
 					);
174
-					if ( $min !== null ) {
175
-						$message->rawParams( $this->constraintParameterRenderer->formatDataValue( $min, Role::OBJECT ) );
173
+					if ($min !== null) {
174
+						$message->rawParams($this->constraintParameterRenderer->formatDataValue($min, Role::OBJECT));
176 175
 					}
177
-					if ( $max !== null ) {
178
-						$message->rawParams( $this->constraintParameterRenderer->formatDataValue( $max, Role::OBJECT ) );
176
+					if ($max !== null) {
177
+						$message->rawParams($this->constraintParameterRenderer->formatDataValue($max, Role::OBJECT));
179 178
 					}
180 179
 					$message = $message->escaped();
181 180
 					$status = CheckResult::STATUS_VIOLATION;
@@ -184,19 +183,19 @@  discard block
 block discarded – undo
184 183
 					$status = CheckResult::STATUS_COMPLIANCE;
185 184
 				}
186 185
 			} else {
187
-				$message = wfMessage( "wbqc-violation-message-diff-within-range-must-have-equal-types" )->escaped();
186
+				$message = wfMessage("wbqc-violation-message-diff-within-range-must-have-equal-types")->escaped();
188 187
 				$status = CheckResult::STATUS_VIOLATION;
189 188
 			}
190 189
 
191
-			return new CheckResult( $context, $constraint, $parameters, $status, $message );
190
+			return new CheckResult($context, $constraint, $parameters, $status, $message);
192 191
 		}
193 192
 
194
-		$message = wfMessage( "wbqc-violation-message-diff-within-range-property-must-exist" )->escaped();
193
+		$message = wfMessage("wbqc-violation-message-diff-within-range-property-must-exist")->escaped();
195 194
 		$status = CheckResult::STATUS_VIOLATION;
196
-		return new CheckResult( $context, $constraint, $parameters, $status, $message );
195
+		return new CheckResult($context, $constraint, $parameters, $status, $message);
197 196
 	}
198 197
 
199
-	public function checkConstraintParameters( Constraint $constraint ) {
198
+	public function checkConstraintParameters(Constraint $constraint) {
200 199
 		$constraintParameters = $constraint->getConstraintParameters();
201 200
 		$exceptions = [];
202 201
 		try {
@@ -205,12 +204,12 @@  discard block
 block discarded – undo
205 204
 				$constraint->getConstraintTypeItemId(),
206 205
 				'quantity'
207 206
 			);
208
-		} catch ( ConstraintParameterException $e ) {
207
+		} catch (ConstraintParameterException $e) {
209 208
 			$exceptions[] = $e;
210 209
 		}
211 210
 		try {
212
-			$this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
213
-		} catch ( ConstraintParameterException $e ) {
211
+			$this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId());
212
+		} catch (ConstraintParameterException $e) {
214 213
 			$exceptions[] = $e;
215 214
 		}
216 215
 		return $exceptions;
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/MultiValueChecker.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -35,33 +35,33 @@
 block discarded – undo
35 35
 	 *
36 36
 	 * @return CheckResult
37 37
 	 */
38
-	public function checkConstraint( Context $context, Constraint $constraint ) {
39
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
40
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
38
+	public function checkConstraint(Context $context, Constraint $constraint) {
39
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
40
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
41 41
 		}
42
-		if ( $context->getType() !== Context::TYPE_STATEMENT ) {
42
+		if ($context->getType() !== Context::TYPE_STATEMENT) {
43 43
 			// TODO T175566
44
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_NOT_MAIN_SNAK );
44
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_NOT_MAIN_SNAK);
45 45
 		}
46 46
 
47 47
 		$propertyId = $context->getSnak()->getPropertyId();
48 48
 
49 49
 		$parameters = [];
50 50
 
51
-		$propertyCountArray = $this->valueCountCheckerHelper->getPropertyCount( $context->getEntity()->getStatements() );
51
+		$propertyCountArray = $this->valueCountCheckerHelper->getPropertyCount($context->getEntity()->getStatements());
52 52
 
53
-		if ( $propertyCountArray[$propertyId->getSerialization()] <= 1 ) {
54
-			$message = wfMessage( "wbqc-violation-message-multi-value" )->escaped();
53
+		if ($propertyCountArray[$propertyId->getSerialization()] <= 1) {
54
+			$message = wfMessage("wbqc-violation-message-multi-value")->escaped();
55 55
 			$status = CheckResult::STATUS_VIOLATION;
56 56
 		} else {
57 57
 			$message = '';
58 58
 			$status = CheckResult::STATUS_COMPLIANCE;
59 59
 		}
60 60
 
61
-		return new CheckResult( $context, $constraint, $parameters, $status, $message );
61
+		return new CheckResult($context, $constraint, $parameters, $status, $message);
62 62
 	}
63 63
 
64
-	public function checkConstraintParameters( Constraint $constraint ) {
64
+	public function checkConstraintParameters(Constraint $constraint) {
65 65
 		// no parameters
66 66
 		return [];
67 67
 	}
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/ItemChecker.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -69,22 +69,22 @@  discard block
 block discarded – undo
69 69
 	 *
70 70
 	 * @return CheckResult
71 71
 	 */
72
-	public function checkConstraint( Context $context, Constraint $constraint ) {
73
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
74
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
72
+	public function checkConstraint(Context $context, Constraint $constraint) {
73
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
74
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
75 75
 		}
76
-		if ( $context->getType() !== Context::TYPE_STATEMENT ) {
76
+		if ($context->getType() !== Context::TYPE_STATEMENT) {
77 77
 			// TODO T175562
78
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_NOT_MAIN_SNAK );
78
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_NOT_MAIN_SNAK);
79 79
 		}
80 80
 
81 81
 		$parameters = [];
82 82
 		$constraintParameters = $constraint->getConstraintParameters();
83 83
 
84
-		$propertyId = $this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
85
-		$parameters['property'] = [ $propertyId ];
84
+		$propertyId = $this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId());
85
+		$parameters['property'] = [$propertyId];
86 86
 
87
-		$items = $this->constraintParameterParser->parseItemsParameter( $constraintParameters, $constraint->getConstraintTypeItemId(), false );
87
+		$items = $this->constraintParameterParser->parseItemsParameter($constraintParameters, $constraint->getConstraintTypeItemId(), false);
88 88
 		$parameters['items'] = $items;
89 89
 
90 90
 		/*
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 		 *   a) a property only
93 93
 		 *   b) a property and a number of items (each combination of property and item forming an individual claim)
94 94
 		 */
95
-		if ( $items === [] ) {
95
+		if ($items === []) {
96 96
 			$requiredStatement = $this->connectionCheckerHelper->findStatementWithProperty(
97 97
 				$context->getEntity()->getStatements(),
98 98
 				$propertyId
@@ -105,35 +105,35 @@  discard block
 block discarded – undo
105 105
 			);
106 106
 		}
107 107
 
108
-		if ( $requiredStatement !== null ) {
108
+		if ($requiredStatement !== null) {
109 109
 			$status = CheckResult::STATUS_COMPLIANCE;
110 110
 			$message = '';
111 111
 		} else {
112 112
 			$status = CheckResult::STATUS_VIOLATION;
113
-			$message = wfMessage( 'wbqc-violation-message-item' );
113
+			$message = wfMessage('wbqc-violation-message-item');
114 114
 			$message->rawParams(
115
-				$this->constraintParameterRenderer->formatEntityId( $context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY ),
116
-				$this->constraintParameterRenderer->formatEntityId( $propertyId, Role::PREDICATE )
115
+				$this->constraintParameterRenderer->formatEntityId($context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY),
116
+				$this->constraintParameterRenderer->formatEntityId($propertyId, Role::PREDICATE)
117 117
 			);
118
-			$message->numParams( count( $items ) );
119
-			$message->rawParams( $this->constraintParameterRenderer->formatItemIdSnakValueList( $items, Role::OBJECT ) );
118
+			$message->numParams(count($items));
119
+			$message->rawParams($this->constraintParameterRenderer->formatItemIdSnakValueList($items, Role::OBJECT));
120 120
 			$message = $message->escaped();
121 121
 		}
122 122
 
123
-		return new CheckResult( $context, $constraint, $parameters, $status, $message );
123
+		return new CheckResult($context, $constraint, $parameters, $status, $message);
124 124
 	}
125 125
 
126
-	public function checkConstraintParameters( Constraint $constraint ) {
126
+	public function checkConstraintParameters(Constraint $constraint) {
127 127
 		$constraintParameters = $constraint->getConstraintParameters();
128 128
 		$exceptions = [];
129 129
 		try {
130
-			$this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
131
-		} catch ( ConstraintParameterException $e ) {
130
+			$this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId());
131
+		} catch (ConstraintParameterException $e) {
132 132
 			$exceptions[] = $e;
133 133
 		}
134 134
 		try {
135
-			$this->constraintParameterParser->parseItemsParameter( $constraintParameters, $constraint->getConstraintTypeItemId(), false );
136
-		} catch ( ConstraintParameterException $e ) {
135
+			$this->constraintParameterParser->parseItemsParameter($constraintParameters, $constraint->getConstraintTypeItemId(), false);
136
+		} catch (ConstraintParameterException $e) {
137 137
 			$exceptions[] = $e;
138 138
 		}
139 139
 		return $exceptions;
Please login to merge, or discard this patch.