Completed
Push — master ( 32936a...86defd )
by
unknown
02:03
created
includes/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.
includes/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.
includes/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.
includes/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.
includes/ConstraintCheck/Checker/QualifiersChecker.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -52,46 +52,46 @@  discard block
 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
-		$properties = $this->constraintParameterParser->parsePropertiesParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
66
+		$properties = $this->constraintParameterParser->parsePropertiesParameter($constraintParameters, $constraint->getConstraintTypeItemId());
67 67
 		$parameters['property'] = $properties;
68 68
 
69 69
 		$message = '';
70 70
 		$status = CheckResult::STATUS_COMPLIANCE;
71 71
 
72 72
 		/** @var Snak $qualifier */
73
-		foreach ( $context->getSnakStatement()->getQualifiers() as $qualifier ) {
73
+		foreach ($context->getSnakStatement()->getQualifiers() as $qualifier) {
74 74
 			$allowedQualifier = false;
75
-			foreach ( $properties as $property ) {
76
-				if ( $qualifier->getPropertyId()->equals( $property ) ) {
75
+			foreach ($properties as $property) {
76
+				if ($qualifier->getPropertyId()->equals($property)) {
77 77
 					$allowedQualifier = true;
78 78
 					break;
79 79
 				}
80 80
 			}
81
-			if ( !$allowedQualifier ) {
82
-				if ( empty( $properties ) || $properties === [ '' ] ) {
83
-					$message = wfMessage( 'wbqc-violation-message-no-qualifiers' );
81
+			if (!$allowedQualifier) {
82
+				if (empty($properties) || $properties === ['']) {
83
+					$message = wfMessage('wbqc-violation-message-no-qualifiers');
84 84
 					$message->rawParams(
85
-						$this->constraintParameterRenderer->formatEntityId( $context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY )
85
+						$this->constraintParameterRenderer->formatEntityId($context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY)
86 86
 					);
87 87
 				} else {
88
-					$message = wfMessage( "wbqc-violation-message-qualifiers" );
88
+					$message = wfMessage("wbqc-violation-message-qualifiers");
89 89
 					$message->rawParams(
90
-						$this->constraintParameterRenderer->formatEntityId( $context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY ),
91
-						$this->constraintParameterRenderer->formatEntityId( $qualifier->getPropertyId(), Role::QUALIFIER_PREDICATE )
90
+						$this->constraintParameterRenderer->formatEntityId($context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY),
91
+						$this->constraintParameterRenderer->formatEntityId($qualifier->getPropertyId(), Role::QUALIFIER_PREDICATE)
92 92
 					);
93
-					$message->numParams( count( $properties ) );
94
-					$message->rawParams( $this->constraintParameterRenderer->formatPropertyIdList( $properties, Role::QUALIFIER_PREDICATE ) );
93
+					$message->numParams(count($properties));
94
+					$message->rawParams($this->constraintParameterRenderer->formatPropertyIdList($properties, Role::QUALIFIER_PREDICATE));
95 95
 				}
96 96
 				$message = $message->escaped();
97 97
 				$status = CheckResult::STATUS_VIOLATION;
@@ -99,15 +99,15 @@  discard block
 block discarded – undo
99 99
 			}
100 100
 		}
101 101
 
102
-		return new CheckResult( $context, $constraint, $parameters, $status, $message );
102
+		return new CheckResult($context, $constraint, $parameters, $status, $message);
103 103
 	}
104 104
 
105
-	public function checkConstraintParameters( Constraint $constraint ) {
105
+	public function checkConstraintParameters(Constraint $constraint) {
106 106
 		$constraintParameters = $constraint->getConstraintParameters();
107 107
 		$exceptions = [];
108 108
 		try {
109
-			$this->constraintParameterParser->parsePropertiesParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
110
-		} catch ( ConstraintParameterException $e ) {
109
+			$this->constraintParameterParser->parsePropertiesParameter($constraintParameters, $constraint->getConstraintTypeItemId());
110
+		} catch (ConstraintParameterException $e) {
111 111
 			$exceptions[] = $e;
112 112
 		}
113 113
 		return $exceptions;
Please login to merge, or discard this patch.
includes/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.
includes/ConstraintCheck/Checker/ValueOnlyChecker.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -14,16 +14,16 @@
 block discarded – undo
14 14
  */
15 15
 class ValueOnlyChecker implements ConstraintChecker {
16 16
 
17
-	public function checkConstraint( Context $context, Constraint $constraint ) {
18
-		if ( $context->getType() === Context::TYPE_STATEMENT ) {
19
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_COMPLIANCE, '' );
17
+	public function checkConstraint(Context $context, Constraint $constraint) {
18
+		if ($context->getType() === Context::TYPE_STATEMENT) {
19
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_COMPLIANCE, '');
20 20
 		} else {
21
-			$message = wfMessage( 'wbqc-violation-message-valueOnly' )->escaped();
22
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_VIOLATION, $message );
21
+			$message = wfMessage('wbqc-violation-message-valueOnly')->escaped();
22
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_VIOLATION, $message);
23 23
 		}
24 24
 	}
25 25
 
26
-	public function checkConstraintParameters( Constraint $constraint ) {
26
+	public function checkConstraintParameters(Constraint $constraint) {
27 27
 		// no parameters
28 28
 		return [];
29 29
 	}
Please login to merge, or discard this patch.
includes/ConstraintCheck/Checker/ReferenceChecker.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -14,16 +14,16 @@
 block discarded – undo
14 14
  */
15 15
 class ReferenceChecker implements ConstraintChecker {
16 16
 
17
-	public function checkConstraint( Context $context, Constraint $constraint ) {
18
-		if ( $context->getType() === Context::TYPE_REFERENCE ) {
19
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_COMPLIANCE, '' );
17
+	public function checkConstraint(Context $context, Constraint $constraint) {
18
+		if ($context->getType() === Context::TYPE_REFERENCE) {
19
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_COMPLIANCE, '');
20 20
 		} else {
21
-			$message = wfMessage( 'wbqc-violation-message-reference' )->escaped();
22
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_VIOLATION, $message );
21
+			$message = wfMessage('wbqc-violation-message-reference')->escaped();
22
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_VIOLATION, $message);
23 23
 		}
24 24
 	}
25 25
 
26
-	public function checkConstraintParameters( Constraint $constraint ) {
26
+	public function checkConstraintParameters(Constraint $constraint) {
27 27
 		// no parameters
28 28
 		return [];
29 29
 	}
Please login to merge, or discard this patch.
includes/ConstraintCheck/Helper/RangeCheckerHelper.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -119,8 +119,8 @@
 block discarded – undo
119 119
 	 * for quantity values, the difference is the numerical difference between the quantities,
120 120
 	 * after attempting normalization of each side.
121 121
 	 *
122
-	 * @param TimeValue|QuantityValue|UnboundedQuantityValue $minuend
123
-	 * @param TimeValue|QuantityValue|UnboundedQuantityValue $subtrahend
122
+	 * @param DataValue $minuend
123
+	 * @param DataValue $subtrahend
124 124
 	 *
125 125
 	 * @throws InvalidArgumentException if the values do not both have the same, supported data value type
126 126
 	 * @return UnboundedQuantityValue
Please login to merge, or discard this patch.
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 		UnitConverter $unitConverter = null
48 48
 	) {
49 49
 		$this->config = $config;
50
-		$this->timeParser = ( new TimeParserFactory() )->getTimeParser();
50
+		$this->timeParser = (new TimeParserFactory())->getTimeParser();
51 51
 		$this->timeCalculator = new TimeValueCalculator();
52 52
 		$this->unitConverter = $unitConverter;
53 53
 	}
@@ -56,10 +56,10 @@  discard block
 block discarded – undo
56 56
 	 * @param UnboundedQuantityValue $value
57 57
 	 * @return UnboundedQuantityValue $value converted to standard units if possible, otherwise unchanged $value.
58 58
 	 */
59
-	private function standardize( UnboundedQuantityValue $value ) {
60
-		if ( $this->unitConverter !== null ) {
61
-			$standard = $this->unitConverter->toStandardUnits( $value );
62
-			if ( $standard !== null ) {
59
+	private function standardize(UnboundedQuantityValue $value) {
60
+		if ($this->unitConverter !== null) {
61
+			$standard = $this->unitConverter->toStandardUnits($value);
62
+			if ($standard !== null) {
63 63
 				return $standard;
64 64
 			} else {
65 65
 				return $value;
@@ -81,23 +81,23 @@  discard block
 block discarded – undo
81 81
 	 *                 when $lhs is respectively less than, equal to, or greater than $rhs.
82 82
 	 *                 (In other words, just like the “spaceship” operator <=>.)
83 83
 	 */
84
-	public function getComparison( DataValue $lhs = null, DataValue $rhs = null ) {
85
-		if ( $lhs === null || $rhs === null ) {
84
+	public function getComparison(DataValue $lhs = null, DataValue $rhs = null) {
85
+		if ($lhs === null || $rhs === null) {
86 86
 			return 0;
87 87
 		}
88 88
 
89
-		if ( $lhs->getType() !== $rhs->getType() ) {
90
-			throw new InvalidArgumentException( 'Different data value types' );
89
+		if ($lhs->getType() !== $rhs->getType()) {
90
+			throw new InvalidArgumentException('Different data value types');
91 91
 		}
92 92
 
93
-		switch ( $lhs->getType() ) {
93
+		switch ($lhs->getType()) {
94 94
 			case 'time':
95 95
 				/** @var TimeValue $lhs */
96 96
 				/** @var TimeValue $rhs */
97
-				$lhsTimestamp = $this->timeCalculator->getTimestamp( $lhs );
98
-				$rhsTimestamp = $this->timeCalculator->getTimestamp( $rhs );
97
+				$lhsTimestamp = $this->timeCalculator->getTimestamp($lhs);
98
+				$rhsTimestamp = $this->timeCalculator->getTimestamp($rhs);
99 99
 
100
-				if ( $lhsTimestamp === $rhsTimestamp ) {
100
+				if ($lhsTimestamp === $rhsTimestamp) {
101 101
 					return 0;
102 102
 				}
103 103
 
@@ -105,12 +105,12 @@  discard block
 block discarded – undo
105 105
 			case 'quantity':
106 106
 				/** @var QuantityValue|UnboundedQuantityValue $lhs */
107 107
 				/** @var QuantityValue|UnboundedQuantityValue $rhs */
108
-				$lhsStandard = $this->standardize( $lhs );
109
-				$rhsStandard = $this->standardize( $rhs );
110
-				return $lhsStandard->getAmount()->compare( $rhsStandard->getAmount() );
108
+				$lhsStandard = $this->standardize($lhs);
109
+				$rhsStandard = $this->standardize($rhs);
110
+				return $lhsStandard->getAmount()->compare($rhsStandard->getAmount());
111 111
 		}
112 112
 
113
-		throw new InvalidArgumentException( 'Unsupported data value type' );
113
+		throw new InvalidArgumentException('Unsupported data value type');
114 114
 	}
115 115
 
116 116
 	/**
@@ -125,83 +125,83 @@  discard block
 block discarded – undo
125 125
 	 * @throws InvalidArgumentException if the values do not both have the same, supported data value type
126 126
 	 * @return UnboundedQuantityValue
127 127
 	 */
128
-	public function getDifference( DataValue $minuend, DataValue $subtrahend ) {
129
-		if ( $minuend->getType() === 'time' && $subtrahend->getType() === 'time' ) {
130
-			$minuendSeconds = $this->timeCalculator->getTimestamp( $minuend );
131
-			$subtrahendSeconds = $this->timeCalculator->getTimestamp( $subtrahend );
128
+	public function getDifference(DataValue $minuend, DataValue $subtrahend) {
129
+		if ($minuend->getType() === 'time' && $subtrahend->getType() === 'time') {
130
+			$minuendSeconds = $this->timeCalculator->getTimestamp($minuend);
131
+			$subtrahendSeconds = $this->timeCalculator->getTimestamp($subtrahend);
132 132
 			return UnboundedQuantityValue::newFromNumber(
133 133
 				$minuendSeconds - $subtrahendSeconds,
134
-				$this->config->get( 'WBQualityConstraintsSecondUnit' )
134
+				$this->config->get('WBQualityConstraintsSecondUnit')
135 135
 			);
136 136
 		}
137
-		if ( $minuend->getType() === 'quantity' && $subtrahend->getType() === 'quantity' ) {
138
-			$minuendStandard = $this->standardize( $minuend );
139
-			$subtrahendStandard = $this->standardize( $subtrahend );
137
+		if ($minuend->getType() === 'quantity' && $subtrahend->getType() === 'quantity') {
138
+			$minuendStandard = $this->standardize($minuend);
139
+			$subtrahendStandard = $this->standardize($subtrahend);
140 140
 			$minuendValue = $minuendStandard->getAmount()->getValueFloat();
141 141
 			$subtrahendValue = $subtrahendStandard->getAmount()->getValueFloat();
142 142
 			$diff = $minuendValue - $subtrahendValue;
143 143
 			// we don’t check whether both quantities have the same standard unit –
144 144
 			// that’s the job of a different constraint type, Units (T164372)
145
-			return UnboundedQuantityValue::newFromNumber( $diff, $minuendStandard->getUnit() );
145
+			return UnboundedQuantityValue::newFromNumber($diff, $minuendStandard->getUnit());
146 146
 		}
147 147
 
148
-		throw new InvalidArgumentException( 'Unsupported or different data value types' );
148
+		throw new InvalidArgumentException('Unsupported or different data value types');
149 149
 	}
150 150
 
151
-	public function getDifferenceInYears( TimeValue $minuend, TimeValue $subtrahend ) {
152
-		if ( !preg_match( '/^([-+]\d{1,16})-(.*)$/', $minuend->getTime(), $minuendMatches ) ||
153
-			!preg_match( '/^([-+]\d{1,16})-(.*)$/', $subtrahend->getTime(), $subtrahendMatches )
151
+	public function getDifferenceInYears(TimeValue $minuend, TimeValue $subtrahend) {
152
+		if (!preg_match('/^([-+]\d{1,16})-(.*)$/', $minuend->getTime(), $minuendMatches) ||
153
+			!preg_match('/^([-+]\d{1,16})-(.*)$/', $subtrahend->getTime(), $subtrahendMatches)
154 154
 		) {
155
-			throw new InvalidArgumentException( 'TimeValue::getTime() did not match expected format' );
155
+			throw new InvalidArgumentException('TimeValue::getTime() did not match expected format');
156 156
 		}
157
-		$minuendYear = (float)$minuendMatches[1];
158
-		$subtrahendYear = (float)$subtrahendMatches[1];
157
+		$minuendYear = (float) $minuendMatches[1];
158
+		$subtrahendYear = (float) $subtrahendMatches[1];
159 159
 		$minuendRest = $minuendMatches[2];
160 160
 		$subtrahendRest = $subtrahendMatches[2];
161 161
 
162 162
 		// calculate difference of years
163 163
 		$diff = $minuendYear - $subtrahendYear;
164
-		if ( $minuendYear > 0.0 && $subtrahendYear < 0.0 ) {
164
+		if ($minuendYear > 0.0 && $subtrahendYear < 0.0) {
165 165
 			$diff -= 1.0; // there is no year 0, remove it from difference
166
-		} elseif ( $minuendYear < 0.0 && $subtrahendYear > 0.0 ) {
166
+		} elseif ($minuendYear < 0.0 && $subtrahendYear > 0.0) {
167 167
 			$diff -= -1.0; // there is no year 0, remove it from negative difference
168 168
 		}
169 169
 
170 170
 		// adjust for date within year by parsing the month-day part within the same year
171
-		$minuendDateValue = $this->timeParser->parse( '+0000000000001970-' . $minuendRest );
172
-		$subtrahendDateValue = $this->timeParser->parse( '+0000000000001970-' . $subtrahendRest );
173
-		$minuendDateSeconds = $this->timeCalculator->getTimestamp( $minuendDateValue );
174
-		$subtrahendDateSeconds = $this->timeCalculator->getTimestamp( $subtrahendDateValue );
175
-		if ( $minuendDateSeconds < $subtrahendDateSeconds ) {
171
+		$minuendDateValue = $this->timeParser->parse('+0000000000001970-'.$minuendRest);
172
+		$subtrahendDateValue = $this->timeParser->parse('+0000000000001970-'.$subtrahendRest);
173
+		$minuendDateSeconds = $this->timeCalculator->getTimestamp($minuendDateValue);
174
+		$subtrahendDateSeconds = $this->timeCalculator->getTimestamp($subtrahendDateValue);
175
+		if ($minuendDateSeconds < $subtrahendDateSeconds) {
176 176
 			// difference in the last year is actually less than one full year
177 177
 			// e. g. 1975-03-01 - 1974-09-01 is just six months
178 178
 			// (we don’t need sub-year precision in the difference, adjusting by 0.5 is enough)
179 179
 			$diff -= 0.5;
180
-		} elseif ( $minuendDateSeconds > $subtrahendDateSeconds ) {
180
+		} elseif ($minuendDateSeconds > $subtrahendDateSeconds) {
181 181
 			// difference in the last year is actually more than one full year
182 182
 			// e. g. 1975-09-01 - 1974-03-01 is 18 months
183 183
 			// (we don’t need sub-year precision in the difference, adjusting by 0.5 is enough)
184 184
 			$diff += 0.5;
185 185
 		}
186 186
 
187
-		$unit = $this->config->get( 'WBQualityConstraintsYearUnit' );
188
-		return UnboundedQuantityValue::newFromNumber( $diff, $unit );
187
+		$unit = $this->config->get('WBQualityConstraintsYearUnit');
188
+		return UnboundedQuantityValue::newFromNumber($diff, $unit);
189 189
 	}
190 190
 
191 191
 	/**
192 192
 	 * @param string $timeString
193 193
 	 * @return TimeValue
194 194
 	 */
195
-	public function parseTime( $timeString ) {
196
-		return $this->timeParser->parse( $timeString );
195
+	public function parseTime($timeString) {
196
+		return $this->timeParser->parse($timeString);
197 197
 	}
198 198
 
199 199
 	/**
200 200
 	 * @param string $quantityString
201 201
 	 * @return QuantityValue|UnboundedQuantityValue
202 202
 	 */
203
-	public function parseQuantity( $quantityString ) {
204
-		return UnboundedQuantityValue::newFromNumber( $quantityString );
203
+	public function parseQuantity($quantityString) {
204
+		return UnboundedQuantityValue::newFromNumber($quantityString);
205 205
 	}
206 206
 
207 207
 }
Please login to merge, or discard this patch.