Completed
Push — master ( 1d7888...0497b4 )
by
unknown
03:57 queued 01:15
created
src/ConstraintCheck/Checker/InverseChecker.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -71,25 +71,25 @@  discard block
 block discarded – undo
71 71
 	 * @throws ConstraintParameterException
72 72
 	 * @return CheckResult
73 73
 	 */
74
-	public function checkConstraint( Context $context, Constraint $constraint ) {
75
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
76
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
74
+	public function checkConstraint(Context $context, Constraint $constraint) {
75
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
76
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
77 77
 		}
78
-		if ( $context->getType() !== Context::TYPE_STATEMENT ) {
79
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_NOT_MAIN_SNAK );
78
+		if ($context->getType() !== Context::TYPE_STATEMENT) {
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 88
 		$snak = $context->getSnak();
89 89
 
90
-		if ( !$snak instanceof PropertyValueSnak ) {
90
+		if (!$snak instanceof PropertyValueSnak) {
91 91
 			// nothing to check
92
-			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE, '' );
92
+			return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE, '');
93 93
 		}
94 94
 
95 95
 		$dataValue = $snak->getDataValue();
@@ -98,22 +98,22 @@  discard block
 block discarded – undo
98 98
 		 * error handling:
99 99
 		 *   type of $dataValue for properties with 'Inverse' constraint has to be 'wikibase-entityid'
100 100
 		 */
101
-		if ( $dataValue->getType() !== 'wikibase-entityid' ) {
102
-			$message = wfMessage( "wbqc-violation-message-value-needed-of-type" )
101
+		if ($dataValue->getType() !== 'wikibase-entityid') {
102
+			$message = wfMessage("wbqc-violation-message-value-needed-of-type")
103 103
 					 ->rawParams(
104
-						 $this->constraintParameterRenderer->formatItemId( $constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM ),
104
+						 $this->constraintParameterRenderer->formatItemId($constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM),
105 105
 						 'wikibase-entityid' // TODO is there a message for this type so we can localize it?
106 106
 					 )
107 107
 					 ->escaped();
108
-			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message );
108
+			return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message);
109 109
 		}
110 110
 		/** @var EntityIdValue $dataValue */
111 111
 
112 112
 		$targetEntityId = $dataValue->getEntityId();
113
-		$targetEntity = $this->entityLookup->getEntity( $targetEntityId );
114
-		if ( $targetEntity === null ) {
115
-			$message = wfMessage( "wbqc-violation-message-target-entity-must-exist" )->escaped();
116
-			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message );
113
+		$targetEntity = $this->entityLookup->getEntity($targetEntityId);
114
+		if ($targetEntity === null) {
115
+			$message = wfMessage("wbqc-violation-message-target-entity-must-exist")->escaped();
116
+			return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message);
117 117
 		}
118 118
 
119 119
 		$inverseStatement = $this->connectionCheckerHelper->findStatementWithPropertyAndEntityIdValue(
@@ -121,31 +121,31 @@  discard block
 block discarded – undo
121 121
 			$propertyId,
122 122
 			$context->getEntity()->getId()
123 123
 		);
124
-		if ( $inverseStatement !== null ) {
124
+		if ($inverseStatement !== null) {
125 125
 			$message = '';
126 126
 			$status = CheckResult::STATUS_COMPLIANCE;
127 127
 		} else {
128
-			$message = wfMessage( 'wbqc-violation-message-inverse' )
128
+			$message = wfMessage('wbqc-violation-message-inverse')
129 129
 					 ->rawParams(
130
-						 $this->constraintParameterRenderer->formatEntityId( $targetEntityId, Role::SUBJECT ),
131
-						 $this->constraintParameterRenderer->formatEntityId( $propertyId, Role::PREDICATE ),
132
-						 $this->constraintParameterRenderer->formatEntityId( $context->getEntity()->getId(), Role::OBJECT )
130
+						 $this->constraintParameterRenderer->formatEntityId($targetEntityId, Role::SUBJECT),
131
+						 $this->constraintParameterRenderer->formatEntityId($propertyId, Role::PREDICATE),
132
+						 $this->constraintParameterRenderer->formatEntityId($context->getEntity()->getId(), Role::OBJECT)
133 133
 					 )
134 134
 					 ->escaped();
135 135
 			$status = CheckResult::STATUS_VIOLATION;
136 136
 		}
137 137
 
138
-		return ( new CheckResult( $context, $constraint, $parameters, $status, $message ) )
139
-			->withMetadata( Metadata::ofDependencyMetadata(
140
-				DependencyMetadata::ofEntityId( $targetEntityId ) ) );
138
+		return (new CheckResult($context, $constraint, $parameters, $status, $message))
139
+			->withMetadata(Metadata::ofDependencyMetadata(
140
+				DependencyMetadata::ofEntityId($targetEntityId) ));
141 141
 	}
142 142
 
143
-	public function checkConstraintParameters( Constraint $constraint ) {
143
+	public function checkConstraintParameters(Constraint $constraint) {
144 144
 		$constraintParameters = $constraint->getConstraintParameters();
145 145
 		$exceptions = [];
146 146
 		try {
147
-			$this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
148
-		} catch ( ConstraintParameterException $e ) {
147
+			$this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId());
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/RangeChecker.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -68,9 +68,9 @@  discard block
 block discarded – undo
68 68
 	 * @throws ConstraintParameterException
69 69
 	 * @return CheckResult
70 70
 	 */
71
-	public function checkConstraint( Context $context, Constraint $constraint ) {
72
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
73
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
71
+	public function checkConstraint(Context $context, Constraint $constraint) {
72
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
73
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
74 74
 		}
75 75
 
76 76
 		$parameters = [];
@@ -78,42 +78,42 @@  discard block
 block discarded – undo
78 78
 
79 79
 		$snak = $context->getSnak();
80 80
 
81
-		if ( !$snak instanceof PropertyValueSnak ) {
81
+		if (!$snak instanceof PropertyValueSnak) {
82 82
 			// nothing to check
83
-			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE, '' );
83
+			return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE, '');
84 84
 		}
85 85
 
86 86
 		$dataValue = $snak->getDataValue();
87 87
 
88
-		list( $min, $max ) = $this->constraintParameterParser->parseRangeParameter(
88
+		list($min, $max) = $this->constraintParameterParser->parseRangeParameter(
89 89
 			$constraintParameters,
90 90
 			$constraint->getConstraintTypeItemId(),
91 91
 			$dataValue->getType()
92 92
 		);
93 93
 		$parameterKey = $dataValue->getType() === 'quantity' ? 'quantity' : 'date';
94
-		if ( $min !== null ) {
95
-			$parameters['minimum_' . $parameterKey] = [ $min ];
94
+		if ($min !== null) {
95
+			$parameters['minimum_'.$parameterKey] = [$min];
96 96
 		}
97
-		if ( $max !== null ) {
98
-			$parameters['maximum_' . $parameterKey] = [ $max ];
97
+		if ($max !== null) {
98
+			$parameters['maximum_'.$parameterKey] = [$max];
99 99
 		}
100 100
 
101
-		if ( $this->rangeCheckerHelper->getComparison( $min, $dataValue ) > 0 ||
102
-			 $this->rangeCheckerHelper->getComparison( $dataValue, $max ) > 0
101
+		if ($this->rangeCheckerHelper->getComparison($min, $dataValue) > 0 ||
102
+			 $this->rangeCheckerHelper->getComparison($dataValue, $max) > 0
103 103
 		) {
104 104
 			// at least one of $min, $max is set at this point, otherwise there could be no violation
105 105
 			$type = $dataValue->getType();
106
-			$openness = $min !== null ? ( $max !== null ? 'closed' : 'rightopen' ) : 'leftopen';
107
-			$message = wfMessage( "wbqc-violation-message-range-$type-$openness" );
106
+			$openness = $min !== null ? ($max !== null ? 'closed' : 'rightopen') : 'leftopen';
107
+			$message = wfMessage("wbqc-violation-message-range-$type-$openness");
108 108
 			$message->rawParams(
109
-				$this->constraintParameterRenderer->formatEntityId( $context->getSnak()->getPropertyId(), Role::PREDICATE ),
110
-				$this->constraintParameterRenderer->formatDataValue( $dataValue, Role::OBJECT )
109
+				$this->constraintParameterRenderer->formatEntityId($context->getSnak()->getPropertyId(), Role::PREDICATE),
110
+				$this->constraintParameterRenderer->formatDataValue($dataValue, Role::OBJECT)
111 111
 			);
112
-			if ( $min !== null ) {
113
-				$message->rawParams( $this->constraintParameterRenderer->formatDataValue( $min, Role::OBJECT ) );
112
+			if ($min !== null) {
113
+				$message->rawParams($this->constraintParameterRenderer->formatDataValue($min, Role::OBJECT));
114 114
 			}
115
-			if ( $max !== null ) {
116
-				$message->rawParams( $this->constraintParameterRenderer->formatDataValue( $max, Role::OBJECT ) );
115
+			if ($max !== null) {
116
+				$message->rawParams($this->constraintParameterRenderer->formatDataValue($max, Role::OBJECT));
117 117
 			}
118 118
 			$message = $message->escaped();
119 119
 			$status = CheckResult::STATUS_VIOLATION;
@@ -122,22 +122,22 @@  discard block
 block discarded – undo
122 122
 			$status = CheckResult::STATUS_COMPLIANCE;
123 123
 		}
124 124
 
125
-		return new CheckResult( $context, $constraint, $parameters, $status, $message );
125
+		return new CheckResult($context, $constraint, $parameters, $status, $message);
126 126
 	}
127 127
 
128
-	public function checkConstraintParameters( Constraint $constraint ) {
128
+	public function checkConstraintParameters(Constraint $constraint) {
129 129
 		$constraintParameters = $constraint->getConstraintParameters();
130 130
 		$exceptions = [];
131 131
 		try {
132 132
 			// we don’t have a data value here, so get the type from the property instead
133 133
 			// (the distinction between data type and data value type is irrelevant for 'quantity' and 'time')
134
-			$type = $this->propertyDataTypeLookup->getDataTypeIdForProperty( $constraint->getPropertyId() );
134
+			$type = $this->propertyDataTypeLookup->getDataTypeIdForProperty($constraint->getPropertyId());
135 135
 			$this->constraintParameterParser->parseRangeParameter(
136 136
 				$constraintParameters,
137 137
 				$constraint->getConstraintTypeItemId(),
138 138
 				$type
139 139
 			);
140
-		} catch ( ConstraintParameterException $e ) {
140
+		} catch (ConstraintParameterException $e) {
141 141
 			$exceptions[] = $e;
142 142
 		}
143 143
 		return $exceptions;
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/CommonsLinkChecker.php 1 patch
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -60,22 +60,22 @@  discard block
 block discarded – undo
60 60
 	 * @return array first element is the namespace number (default namespace for TitleParser),
61 61
 	 * second element is a string to prepend to the title before giving it to the TitleParser
62 62
 	 */
63
-	private function getCommonsNamespace( $namespace ) {
63
+	private function getCommonsNamespace($namespace) {
64 64
 		// for namespace numbers see mediawiki-config repo, wmf-config/InitialiseSettings.php,
65 65
 		// 'wgExtraNamespaces' key, 'commonswiki' subkey
66
-		switch ( $namespace ) {
66
+		switch ($namespace) {
67 67
 			case '':
68
-				return [ NS_MAIN, '' ];
68
+				return [NS_MAIN, ''];
69 69
 			case 'Creator':
70
-				return [ 100, '' ];
70
+				return [100, ''];
71 71
 			case 'TimedText':
72
-				return [ 102, '' ];
72
+				return [102, ''];
73 73
 			case 'Sequence':
74
-				return [ 104, '' ];
74
+				return [104, ''];
75 75
 			case 'Institution':
76
-				return [ 106, '' ];
76
+				return [106, ''];
77 77
 			default:
78
-				return [ NS_MAIN, $namespace . ':' ];
78
+				return [NS_MAIN, $namespace.':'];
79 79
 		}
80 80
 	}
81 81
 
@@ -88,17 +88,17 @@  discard block
 block discarded – undo
88 88
 	 * @throws ConstraintParameterException
89 89
 	 * @return CheckResult
90 90
 	 */
91
-	public function checkConstraint( Context $context, Constraint $constraint ) {
91
+	public function checkConstraint(Context $context, Constraint $constraint) {
92 92
 		$parameters = [];
93 93
 		$constraintParameters = $constraint->getConstraintParameters();
94
-		$namespace = $this->constraintParameterParser->parseNamespaceParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
95
-		$parameters['namespace'] = [ $namespace ];
94
+		$namespace = $this->constraintParameterParser->parseNamespaceParameter($constraintParameters, $constraint->getConstraintTypeItemId());
95
+		$parameters['namespace'] = [$namespace];
96 96
 
97 97
 		$snak = $context->getSnak();
98 98
 
99
-		if ( !$snak instanceof PropertyValueSnak ) {
99
+		if (!$snak instanceof PropertyValueSnak) {
100 100
 			// nothing to check
101
-			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE, '' );
101
+			return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE, '');
102 102
 		}
103 103
 
104 104
 		$dataValue = $snak->getDataValue();
@@ -108,49 +108,49 @@  discard block
 block discarded – undo
108 108
 		 *   type of $dataValue for properties with 'Commons link' constraint has to be 'string'
109 109
 		 *   parameter $namespace can be null, works for commons galleries
110 110
 		 */
111
-		if ( $dataValue->getType() !== 'string' ) {
112
-			$message = wfMessage( "wbqc-violation-message-value-needed-of-type" )
111
+		if ($dataValue->getType() !== 'string') {
112
+			$message = wfMessage("wbqc-violation-message-value-needed-of-type")
113 113
 					 ->rawParams(
114
-						 $this->constraintParameterRenderer->formatItemId( $constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM ),
115
-						 wfMessage( 'datatypes-type-string' )->escaped()
114
+						 $this->constraintParameterRenderer->formatItemId($constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM),
115
+						 wfMessage('datatypes-type-string')->escaped()
116 116
 					 )
117 117
 					 ->escaped();
118
-			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message );
118
+			return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message);
119 119
 		}
120 120
 
121 121
 		$commonsLink = $dataValue->getValue();
122 122
 
123 123
 		try {
124
-			if ( !$this->commonsLinkIsWellFormed( $commonsLink ) ) {
125
-				throw new MalformedTitleException( 'wbqc-violation-message-commons-link-not-well-formed', $commonsLink ); // caught below
124
+			if (!$this->commonsLinkIsWellFormed($commonsLink)) {
125
+				throw new MalformedTitleException('wbqc-violation-message-commons-link-not-well-formed', $commonsLink); // caught below
126 126
 			}
127
-			list ( $defaultNamespace, $prefix ) = $this->getCommonsNamespace( $namespace );
128
-			$title = $this->titleParser->parseTitle( $prefix . $commonsLink, $defaultNamespace );
129
-			if ( $this->pageExists( $title ) ) {
127
+			list ($defaultNamespace, $prefix) = $this->getCommonsNamespace($namespace);
128
+			$title = $this->titleParser->parseTitle($prefix.$commonsLink, $defaultNamespace);
129
+			if ($this->pageExists($title)) {
130 130
 				$message = '';
131 131
 				$status = CheckResult::STATUS_COMPLIANCE;
132 132
 			} else {
133
-				if ( $this->valueIncludesNamespace( $commonsLink, $namespace ) ) {
134
-					throw new MalformedTitleException( 'wbqc-violation-message-commons-link-not-well-formed', $commonsLink ); // caught below
133
+				if ($this->valueIncludesNamespace($commonsLink, $namespace)) {
134
+					throw new MalformedTitleException('wbqc-violation-message-commons-link-not-well-formed', $commonsLink); // caught below
135 135
 				} else {
136
-					$message = wfMessage( "wbqc-violation-message-commons-link-no-existent" )->escaped();
136
+					$message = wfMessage("wbqc-violation-message-commons-link-no-existent")->escaped();
137 137
 					$status = CheckResult::STATUS_VIOLATION;
138 138
 				}
139 139
 			}
140
-		} catch ( MalformedTitleException $e ) {
141
-			$message = wfMessage( "wbqc-violation-message-commons-link-not-well-formed" )->escaped();
140
+		} catch (MalformedTitleException $e) {
141
+			$message = wfMessage("wbqc-violation-message-commons-link-not-well-formed")->escaped();
142 142
 			$status = CheckResult::STATUS_VIOLATION;
143 143
 		}
144 144
 
145
-		return new CheckResult( $context, $constraint, $parameters, $status, $message );
145
+		return new CheckResult($context, $constraint, $parameters, $status, $message);
146 146
 	}
147 147
 
148
-	public function checkConstraintParameters( Constraint $constraint ) {
148
+	public function checkConstraintParameters(Constraint $constraint) {
149 149
 		$constraintParameters = $constraint->getConstraintParameters();
150 150
 		$exceptions = [];
151 151
 		try {
152
-			$this->constraintParameterParser->parseNamespaceParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
153
-		} catch ( ConstraintParameterException $e ) {
152
+			$this->constraintParameterParser->parseNamespaceParameter($constraintParameters, $constraint->getConstraintTypeItemId());
153
+		} catch (ConstraintParameterException $e) {
154 154
 			$exceptions[] = $e;
155 155
 		}
156 156
 		return $exceptions;
@@ -161,19 +161,19 @@  discard block
 block discarded – undo
161 161
 	 *
162 162
 	 * @return bool
163 163
 	 */
164
-	private function pageExists( TitleValue $title ) {
164
+	private function pageExists(TitleValue $title) {
165 165
 		$commonsWikiId = 'commonswiki';
166
-		if ( defined( 'MW_PHPUNIT_TEST' ) ) {
166
+		if (defined('MW_PHPUNIT_TEST')) {
167 167
 			$commonsWikiId = false;
168 168
 		}
169 169
 
170
-		$dbLoadBalancer = wfGetLB( $commonsWikiId );
170
+		$dbLoadBalancer = wfGetLB($commonsWikiId);
171 171
 		$dbConnection = $dbLoadBalancer->getConnection(
172 172
 			DB_REPLICA, false, $commonsWikiId );
173
-		$row = $dbConnection->selectRow( 'page', '*', [
173
+		$row = $dbConnection->selectRow('page', '*', [
174 174
 			'page_title' => $title->getDBkey(),
175 175
 			'page_namespace' => $title->getNamespace()
176
-		] );
176
+		]);
177 177
 
178 178
 		return $row !== false;
179 179
 	}
@@ -183,9 +183,9 @@  discard block
 block discarded – undo
183 183
 	 *
184 184
 	 * @return bool
185 185
 	 */
186
-	private function commonsLinkIsWellFormed( $commonsLink ) {
187
-		$toReplace = [ "_", "%20" ];
188
-		$compareString = trim( str_replace( $toReplace, '', $commonsLink ) );
186
+	private function commonsLinkIsWellFormed($commonsLink) {
187
+		$toReplace = ["_", "%20"];
188
+		$compareString = trim(str_replace($toReplace, '', $commonsLink));
189 189
 		return $commonsLink === $compareString;
190 190
 	}
191 191
 
@@ -198,9 +198,9 @@  discard block
 block discarded – undo
198 198
 	 *
199 199
 	 * @return bool
200 200
 	 */
201
-	private function valueIncludesNamespace( $value, $namespace ) {
201
+	private function valueIncludesNamespace($value, $namespace) {
202 202
 		return $namespace !== '' &&
203
-			strncasecmp( $value, $namespace . ':', strlen( $namespace ) + 1 ) === 0;
203
+			strncasecmp($value, $namespace.':', strlen($namespace) + 1) === 0;
204 204
 	}
205 205
 
206 206
 }
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
 
@@ -118,36 +118,36 @@  discard block
 block discarded – undo
118 118
 	 * @throws ConstraintParameterException
119 119
 	 * @return CheckResult
120 120
 	 */
121
-	public function checkConstraint( Context $context, Constraint $constraint ) {
122
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
123
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
121
+	public function checkConstraint(Context $context, Constraint $constraint) {
122
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
123
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
124 124
 		}
125
-		if ( $context->getType() !== Context::TYPE_STATEMENT ) {
125
+		if ($context->getType() !== Context::TYPE_STATEMENT) {
126 126
 			// TODO T175565
127
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_NOT_MAIN_SNAK );
127
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_NOT_MAIN_SNAK);
128 128
 		}
129 129
 
130 130
 		$parameters = [];
131 131
 
132 132
 		$snak = $context->getSnak();
133 133
 
134
-		if ( !$snak instanceof PropertyValueSnak ) {
134
+		if (!$snak instanceof PropertyValueSnak) {
135 135
 			// nothing to check
136
-			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE, '' );
136
+			return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE, '');
137 137
 		}
138 138
 
139 139
 		$minuend = $snak->getDataValue();
140 140
 
141 141
 		/** @var PropertyId $property */
142
-		list ( $min, $max, $property, $parameters ) = $this->parseConstraintParameters( $constraint );
142
+		list ($min, $max, $property, $parameters) = $this->parseConstraintParameters($constraint);
143 143
 
144 144
 		// checks only the first occurrence of the referenced property (this constraint implies a single value constraint on that property)
145 145
 		/** @var Statement $otherStatement */
146
-		foreach ( $context->getEntity()->getStatements() as $otherStatement ) {
146
+		foreach ($context->getEntity()->getStatements() as $otherStatement) {
147 147
 			$otherMainSnak = $otherStatement->getMainSnak();
148 148
 
149 149
 			if (
150
-				!$property->equals( $otherStatement->getPropertyId() ) ||
150
+				!$property->equals($otherStatement->getPropertyId()) ||
151 151
 				$otherStatement->getRank() === Statement::RANK_DEPRECATED ||
152 152
 				!$otherMainSnak instanceof PropertyValueSnak
153 153
 			) {
@@ -155,28 +155,27 @@  discard block
 block discarded – undo
155 155
 			}
156 156
 
157 157
 			$subtrahend = $otherMainSnak->getDataValue();
158
-			if ( $subtrahend->getType() === $minuend->getType() ) {
159
-				$diff = $this->rangeInYears( $min, $max ) ?
160
-					$this->rangeCheckerHelper->getDifferenceInYears( $minuend, $subtrahend ) :
161
-					$this->rangeCheckerHelper->getDifference( $minuend, $subtrahend );
158
+			if ($subtrahend->getType() === $minuend->getType()) {
159
+				$diff = $this->rangeInYears($min, $max) ?
160
+					$this->rangeCheckerHelper->getDifferenceInYears($minuend, $subtrahend) : $this->rangeCheckerHelper->getDifference($minuend, $subtrahend);
162 161
 
163
-				if ( $this->rangeCheckerHelper->getComparison( $min, $diff ) > 0 ||
164
-					$this->rangeCheckerHelper->getComparison( $diff, $max ) > 0
162
+				if ($this->rangeCheckerHelper->getComparison($min, $diff) > 0 ||
163
+					$this->rangeCheckerHelper->getComparison($diff, $max) > 0
165 164
 				) {
166 165
 					// at least one of $min, $max is set at this point, otherwise there could be no violation
167
-					$openness = $min !== null ? ( $max !== null ? '' : '-rightopen' ) : '-leftopen';
168
-					$message = wfMessage( "wbqc-violation-message-diff-within-range$openness" );
166
+					$openness = $min !== null ? ($max !== null ? '' : '-rightopen') : '-leftopen';
167
+					$message = wfMessage("wbqc-violation-message-diff-within-range$openness");
169 168
 					$message->rawParams(
170
-						$this->constraintParameterRenderer->formatEntityId( $context->getSnak()->getPropertyId(), Role::PREDICATE ),
171
-						$this->constraintParameterRenderer->formatDataValue( $minuend, Role::OBJECT ),
172
-						$this->constraintParameterRenderer->formatEntityId( $otherStatement->getPropertyId(), Role::PREDICATE ),
173
-						$this->constraintParameterRenderer->formatDataValue( $subtrahend, Role::OBJECT )
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)
174 173
 					);
175
-					if ( $min !== null ) {
176
-						$message->rawParams( $this->constraintParameterRenderer->formatDataValue( $min, Role::OBJECT ) );
174
+					if ($min !== null) {
175
+						$message->rawParams($this->constraintParameterRenderer->formatDataValue($min, Role::OBJECT));
177 176
 					}
178
-					if ( $max !== null ) {
179
-						$message->rawParams( $this->constraintParameterRenderer->formatDataValue( $max, Role::OBJECT ) );
177
+					if ($max !== null) {
178
+						$message->rawParams($this->constraintParameterRenderer->formatDataValue($max, Role::OBJECT));
180 179
 					}
181 180
 					$message = $message->escaped();
182 181
 					$status = CheckResult::STATUS_VIOLATION;
@@ -185,19 +184,19 @@  discard block
 block discarded – undo
185 184
 					$status = CheckResult::STATUS_COMPLIANCE;
186 185
 				}
187 186
 			} else {
188
-				$message = wfMessage( "wbqc-violation-message-diff-within-range-must-have-equal-types" )->escaped();
187
+				$message = wfMessage("wbqc-violation-message-diff-within-range-must-have-equal-types")->escaped();
189 188
 				$status = CheckResult::STATUS_VIOLATION;
190 189
 			}
191 190
 
192
-			return new CheckResult( $context, $constraint, $parameters, $status, $message );
191
+			return new CheckResult($context, $constraint, $parameters, $status, $message);
193 192
 		}
194 193
 
195
-		$message = wfMessage( "wbqc-violation-message-diff-within-range-property-must-exist" )->escaped();
194
+		$message = wfMessage("wbqc-violation-message-diff-within-range-property-must-exist")->escaped();
196 195
 		$status = CheckResult::STATUS_VIOLATION;
197
-		return new CheckResult( $context, $constraint, $parameters, $status, $message );
196
+		return new CheckResult($context, $constraint, $parameters, $status, $message);
198 197
 	}
199 198
 
200
-	public function checkConstraintParameters( Constraint $constraint ) {
199
+	public function checkConstraintParameters(Constraint $constraint) {
201 200
 		$constraintParameters = $constraint->getConstraintParameters();
202 201
 		$exceptions = [];
203 202
 		try {
@@ -206,12 +205,12 @@  discard block
 block discarded – undo
206 205
 				$constraint->getConstraintTypeItemId(),
207 206
 				'quantity'
208 207
 			);
209
-		} catch ( ConstraintParameterException $e ) {
208
+		} catch (ConstraintParameterException $e) {
210 209
 			$exceptions[] = $e;
211 210
 		}
212 211
 		try {
213
-			$this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
214
-		} catch ( ConstraintParameterException $e ) {
212
+			$this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId());
213
+		} catch (ConstraintParameterException $e) {
215 214
 			$exceptions[] = $e;
216 215
 		}
217 216
 		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
@@ -68,22 +68,22 @@  discard block
 block discarded – undo
68 68
 	 * @throws ConstraintParameterException
69 69
 	 * @return CheckResult
70 70
 	 */
71
-	public function checkConstraint( Context $context, Constraint $constraint ) {
72
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
73
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
71
+	public function checkConstraint(Context $context, Constraint $constraint) {
72
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
73
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
74 74
 		}
75
-		if ( $context->getType() !== Context::TYPE_STATEMENT ) {
75
+		if ($context->getType() !== Context::TYPE_STATEMENT) {
76 76
 			// TODO T175562
77
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_NOT_MAIN_SNAK );
77
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_NOT_MAIN_SNAK);
78 78
 		}
79 79
 
80 80
 		$parameters = [];
81 81
 		$constraintParameters = $constraint->getConstraintParameters();
82 82
 
83
-		$propertyId = $this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
84
-		$parameters['property'] = [ $propertyId ];
83
+		$propertyId = $this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId());
84
+		$parameters['property'] = [$propertyId];
85 85
 
86
-		$items = $this->constraintParameterParser->parseItemsParameter( $constraintParameters, $constraint->getConstraintTypeItemId(), false );
86
+		$items = $this->constraintParameterParser->parseItemsParameter($constraintParameters, $constraint->getConstraintTypeItemId(), false);
87 87
 		$parameters['items'] = $items;
88 88
 
89 89
 		/*
@@ -91,16 +91,16 @@  discard block
 block discarded – undo
91 91
 		 *   a) a property only
92 92
 		 *   b) a property and a number of items (each combination of property and item forming an individual claim)
93 93
 		 */
94
-		if ( $items === [] ) {
94
+		if ($items === []) {
95 95
 			$offendingStatement = $this->connectionCheckerHelper->findStatementWithProperty(
96 96
 				$context->getEntity()->getStatements(),
97 97
 				$propertyId
98 98
 			);
99
-			if ( $offendingStatement !== null ) {
100
-				$message = wfMessage( "wbqc-violation-message-conflicts-with-property" )
99
+			if ($offendingStatement !== null) {
100
+				$message = wfMessage("wbqc-violation-message-conflicts-with-property")
101 101
 						 ->rawParams(
102
-							 $this->constraintParameterRenderer->formatEntityId( $context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY ),
103
-							 $this->constraintParameterRenderer->formatEntityId( $propertyId, Role::PREDICATE )
102
+							 $this->constraintParameterRenderer->formatEntityId($context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY),
103
+							 $this->constraintParameterRenderer->formatEntityId($propertyId, Role::PREDICATE)
104 104
 						 )
105 105
 						 ->escaped();
106 106
 				$status = CheckResult::STATUS_VIOLATION;
@@ -114,13 +114,13 @@  discard block
 block discarded – undo
114 114
 				$propertyId,
115 115
 				$items
116 116
 			);
117
-			if ( $offendingStatement !== null ) {
118
-				$offendingValue = ItemIdSnakValue::fromSnak( $offendingStatement->getMainSnak() );
119
-				$message = wfMessage( "wbqc-violation-message-conflicts-with-claim" )
117
+			if ($offendingStatement !== null) {
118
+				$offendingValue = ItemIdSnakValue::fromSnak($offendingStatement->getMainSnak());
119
+				$message = wfMessage("wbqc-violation-message-conflicts-with-claim")
120 120
 						 ->rawParams(
121
-							 $this->constraintParameterRenderer->formatEntityId( $context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY ),
122
-							 $this->constraintParameterRenderer->formatEntityId( $propertyId, Role::PREDICATE ),
123
-							 $this->constraintParameterRenderer->formatItemIdSnakValue( $offendingValue, Role::OBJECT )
121
+							 $this->constraintParameterRenderer->formatEntityId($context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY),
122
+							 $this->constraintParameterRenderer->formatEntityId($propertyId, Role::PREDICATE),
123
+							 $this->constraintParameterRenderer->formatItemIdSnakValue($offendingValue, Role::OBJECT)
124 124
 						 )
125 125
 						 ->escaped();
126 126
 				$status = CheckResult::STATUS_VIOLATION;
@@ -130,20 +130,20 @@  discard block
 block discarded – undo
130 130
 			}
131 131
 		}
132 132
 
133
-		return new CheckResult( $context, $constraint, $parameters, $status, $message );
133
+		return new CheckResult($context, $constraint, $parameters, $status, $message);
134 134
 	}
135 135
 
136
-	public function checkConstraintParameters( Constraint $constraint ) {
136
+	public function checkConstraintParameters(Constraint $constraint) {
137 137
 		$constraintParameters = $constraint->getConstraintParameters();
138 138
 		$exceptions = [];
139 139
 		try {
140
-			$this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
141
-		} catch ( ConstraintParameterException $e ) {
140
+			$this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId());
141
+		} catch (ConstraintParameterException $e) {
142 142
 			$exceptions[] = $e;
143 143
 		}
144 144
 		try {
145
-			$this->constraintParameterParser->parseItemsParameter( $constraintParameters, $constraint->getConstraintTypeItemId(), false );
146
-		} catch ( ConstraintParameterException $e ) {
145
+			$this->constraintParameterParser->parseItemsParameter($constraintParameters, $constraint->getConstraintTypeItemId(), false);
146
+		} catch (ConstraintParameterException $e) {
147 147
 			$exceptions[] = $e;
148 148
 		}
149 149
 		return $exceptions;
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/OneOfChecker.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -49,43 +49,43 @@
 block discarded – undo
49 49
 	 * @throws ConstraintParameterException
50 50
 	 * @return CheckResult
51 51
 	 */
52
-	public function checkConstraint( Context $context, Constraint $constraint ) {
53
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
54
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
52
+	public function checkConstraint(Context $context, Constraint $constraint) {
53
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
54
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
55 55
 		}
56 56
 
57 57
 		$parameters = [];
58 58
 		$constraintParameters = $constraint->getConstraintParameters();
59 59
 
60
-		$items = $this->constraintParameterParser->parseItemsParameter( $constraintParameters, $constraint->getConstraintTypeItemId(), true );
60
+		$items = $this->constraintParameterParser->parseItemsParameter($constraintParameters, $constraint->getConstraintTypeItemId(), true);
61 61
 		$parameters['item'] = $items;
62 62
 
63 63
 		$snak = $context->getSnak();
64 64
 
65
-		$message = wfMessage( 'wbqc-violation-message-one-of' );
66
-		$message->rawParams( $this->constraintParameterRenderer->formatEntityId( $context->getSnak()->getPropertyId(), Role::PREDICATE ) );
67
-		$message->numParams( count( $items ) );
68
-		$message->rawParams( $this->constraintParameterRenderer->formatItemIdSnakValueList( $items, Role::OBJECT ) );
65
+		$message = wfMessage('wbqc-violation-message-one-of');
66
+		$message->rawParams($this->constraintParameterRenderer->formatEntityId($context->getSnak()->getPropertyId(), Role::PREDICATE));
67
+		$message->numParams(count($items));
68
+		$message->rawParams($this->constraintParameterRenderer->formatItemIdSnakValueList($items, Role::OBJECT));
69 69
 		$message = $message->escaped();
70 70
 		$status = CheckResult::STATUS_VIOLATION;
71 71
 
72
-		foreach ( $items as $item ) {
73
-			if ( $item->matchesSnak( $snak ) ) {
72
+		foreach ($items as $item) {
73
+			if ($item->matchesSnak($snak)) {
74 74
 				$message = '';
75 75
 				$status = CheckResult::STATUS_COMPLIANCE;
76 76
 				break;
77 77
 			}
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
 		$constraintParameters = $constraint->getConstraintParameters();
85 85
 		$exceptions = [];
86 86
 		try {
87
-			$this->constraintParameterParser->parseItemsParameter( $constraintParameters, $constraint->getConstraintTypeItemId(), true );
88
-		} catch ( ConstraintParameterException $e ) {
87
+			$this->constraintParameterParser->parseItemsParameter($constraintParameters, $constraint->getConstraintTypeItemId(), true);
88
+		} catch (ConstraintParameterException $e) {
89 89
 			$exceptions[] = $e;
90 90
 		}
91 91
 		return $exceptions;
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
@@ -50,46 +50,46 @@
 block discarded – undo
50 50
 	 * @throws ConstraintParameterException
51 51
 	 * @return CheckResult
52 52
 	 */
53
-	public function checkConstraint( Context $context, Constraint $constraint ) {
54
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
55
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
53
+	public function checkConstraint(Context $context, Constraint $constraint) {
54
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
55
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
56 56
 		}
57
-		if ( $context->getType() !== Context::TYPE_STATEMENT ) {
58
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_NOT_MAIN_SNAK );
57
+		if ($context->getType() !== Context::TYPE_STATEMENT) {
58
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_NOT_MAIN_SNAK);
59 59
 		}
60 60
 
61 61
 		$parameters = [];
62 62
 		$constraintParameters = $constraint->getConstraintParameters();
63 63
 
64
-		$propertyId = $this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
65
-		$parameters['property'] = [ $propertyId ];
64
+		$propertyId = $this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId());
65
+		$parameters['property'] = [$propertyId];
66 66
 
67
-		$message = wfMessage( "wbqc-violation-message-mandatory-qualifier" )
67
+		$message = wfMessage("wbqc-violation-message-mandatory-qualifier")
68 68
 				 ->rawParams(
69
-					 $this->constraintParameterRenderer->formatEntityId( $context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY ),
70
-					 $this->constraintParameterRenderer->formatEntityId( $propertyId, Role::QUALIFIER_PREDICATE )
69
+					 $this->constraintParameterRenderer->formatEntityId($context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY),
70
+					 $this->constraintParameterRenderer->formatEntityId($propertyId, Role::QUALIFIER_PREDICATE)
71 71
 				 )
72 72
 				 ->escaped();
73 73
 		$status = CheckResult::STATUS_VIOLATION;
74 74
 
75 75
 		/** @var Snak $qualifier */
76
-		foreach ( $context->getSnakStatement()->getQualifiers() as $qualifier ) {
77
-			if ( $propertyId->equals( $qualifier->getPropertyId() ) ) {
76
+		foreach ($context->getSnakStatement()->getQualifiers() as $qualifier) {
77
+			if ($propertyId->equals($qualifier->getPropertyId())) {
78 78
 				$message = '';
79 79
 				$status = CheckResult::STATUS_COMPLIANCE;
80 80
 				break;
81 81
 			}
82 82
 		}
83 83
 
84
-		return new CheckResult( $context, $constraint, $parameters, $status, $message );
84
+		return new CheckResult($context, $constraint, $parameters, $status, $message);
85 85
 	}
86 86
 
87
-	public function checkConstraintParameters( Constraint $constraint ) {
87
+	public function checkConstraintParameters(Constraint $constraint) {
88 88
 		$constraintParameters = $constraint->getConstraintParameters();
89 89
 		$exceptions = [];
90 90
 		try {
91
-			$this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
92
-		} catch ( ConstraintParameterException $e ) {
91
+			$this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId());
92
+		} catch (ConstraintParameterException $e) {
93 93
 			$exceptions[] = $e;
94 94
 		}
95 95
 		return $exceptions;
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/QualifiersChecker.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -50,46 +50,46 @@  discard block
 block discarded – undo
50 50
 	 * @throws ConstraintParameterException
51 51
 	 * @return CheckResult
52 52
 	 */
53
-	public function checkConstraint( Context $context, Constraint $constraint ) {
54
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
55
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
53
+	public function checkConstraint(Context $context, Constraint $constraint) {
54
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
55
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
56 56
 		}
57
-		if ( $context->getType() !== Context::TYPE_STATEMENT ) {
58
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_NOT_MAIN_SNAK );
57
+		if ($context->getType() !== Context::TYPE_STATEMENT) {
58
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_NOT_MAIN_SNAK);
59 59
 		}
60 60
 
61 61
 		$parameters = [];
62 62
 		$constraintParameters = $constraint->getConstraintParameters();
63 63
 
64
-		$properties = $this->constraintParameterParser->parsePropertiesParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
64
+		$properties = $this->constraintParameterParser->parsePropertiesParameter($constraintParameters, $constraint->getConstraintTypeItemId());
65 65
 		$parameters['property'] = $properties;
66 66
 
67 67
 		$message = '';
68 68
 		$status = CheckResult::STATUS_COMPLIANCE;
69 69
 
70 70
 		/** @var Snak $qualifier */
71
-		foreach ( $context->getSnakStatement()->getQualifiers() as $qualifier ) {
71
+		foreach ($context->getSnakStatement()->getQualifiers() as $qualifier) {
72 72
 			$allowedQualifier = false;
73
-			foreach ( $properties as $property ) {
74
-				if ( $qualifier->getPropertyId()->equals( $property ) ) {
73
+			foreach ($properties as $property) {
74
+				if ($qualifier->getPropertyId()->equals($property)) {
75 75
 					$allowedQualifier = true;
76 76
 					break;
77 77
 				}
78 78
 			}
79
-			if ( !$allowedQualifier ) {
80
-				if ( empty( $properties ) || $properties === [ '' ] ) {
81
-					$message = wfMessage( 'wbqc-violation-message-no-qualifiers' );
79
+			if (!$allowedQualifier) {
80
+				if (empty($properties) || $properties === ['']) {
81
+					$message = wfMessage('wbqc-violation-message-no-qualifiers');
82 82
 					$message->rawParams(
83
-						$this->constraintParameterRenderer->formatEntityId( $context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY )
83
+						$this->constraintParameterRenderer->formatEntityId($context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY)
84 84
 					);
85 85
 				} else {
86
-					$message = wfMessage( "wbqc-violation-message-qualifiers" );
86
+					$message = wfMessage("wbqc-violation-message-qualifiers");
87 87
 					$message->rawParams(
88
-						$this->constraintParameterRenderer->formatEntityId( $context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY ),
89
-						$this->constraintParameterRenderer->formatEntityId( $qualifier->getPropertyId(), Role::QUALIFIER_PREDICATE )
88
+						$this->constraintParameterRenderer->formatEntityId($context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY),
89
+						$this->constraintParameterRenderer->formatEntityId($qualifier->getPropertyId(), Role::QUALIFIER_PREDICATE)
90 90
 					);
91
-					$message->numParams( count( $properties ) );
92
-					$message->rawParams( $this->constraintParameterRenderer->formatPropertyIdList( $properties, Role::QUALIFIER_PREDICATE ) );
91
+					$message->numParams(count($properties));
92
+					$message->rawParams($this->constraintParameterRenderer->formatPropertyIdList($properties, Role::QUALIFIER_PREDICATE));
93 93
 				}
94 94
 				$message = $message->escaped();
95 95
 				$status = CheckResult::STATUS_VIOLATION;
@@ -97,15 +97,15 @@  discard block
 block discarded – undo
97 97
 			}
98 98
 		}
99 99
 
100
-		return new CheckResult( $context, $constraint, $parameters, $status, $message );
100
+		return new CheckResult($context, $constraint, $parameters, $status, $message);
101 101
 	}
102 102
 
103
-	public function checkConstraintParameters( Constraint $constraint ) {
103
+	public function checkConstraintParameters(Constraint $constraint) {
104 104
 		$constraintParameters = $constraint->getConstraintParameters();
105 105
 		$exceptions = [];
106 106
 		try {
107
-			$this->constraintParameterParser->parsePropertiesParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
108
-		} catch ( ConstraintParameterException $e ) {
107
+			$this->constraintParameterParser->parsePropertiesParameter($constraintParameters, $constraint->getConstraintTypeItemId());
108
+		} catch (ConstraintParameterException $e) {
109 109
 			$exceptions[] = $e;
110 110
 		}
111 111
 		return $exceptions;
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/TargetRequiredClaimChecker.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -71,25 +71,25 @@  discard block
 block discarded – undo
71 71
 	 * @throws ConstraintParameterException
72 72
 	 * @return CheckResult
73 73
 	 */
74
-	public function checkConstraint( Context $context, Constraint $constraint ) {
75
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
76
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
74
+	public function checkConstraint(Context $context, Constraint $constraint) {
75
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
76
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
77 77
 		}
78 78
 
79 79
 		$parameters = [];
80 80
 		$constraintParameters = $constraint->getConstraintParameters();
81 81
 
82
-		$propertyId = $this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
83
-		$parameters['property'] = [ $propertyId ];
82
+		$propertyId = $this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId());
83
+		$parameters['property'] = [$propertyId];
84 84
 
85
-		$items = $this->constraintParameterParser->parseItemsParameter( $constraintParameters, $constraint->getConstraintTypeItemId(), false );
85
+		$items = $this->constraintParameterParser->parseItemsParameter($constraintParameters, $constraint->getConstraintTypeItemId(), false);
86 86
 		$parameters['items'] = $items;
87 87
 
88 88
 		$snak = $context->getSnak();
89 89
 
90
-		if ( !$snak instanceof PropertyValueSnak ) {
90
+		if (!$snak instanceof PropertyValueSnak) {
91 91
 			// nothing to check
92
-			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE, '' );
92
+			return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE, '');
93 93
 		}
94 94
 
95 95
 		$dataValue = $snak->getDataValue();
@@ -98,22 +98,22 @@  discard block
 block discarded – undo
98 98
 		 * error handling:
99 99
 		 *   type of $dataValue for properties with 'Target required claim' constraint has to be 'wikibase-entityid'
100 100
 		 */
101
-		if ( $dataValue->getType() !== 'wikibase-entityid' ) {
102
-			$message = wfMessage( "wbqc-violation-message-value-needed-of-type" )
101
+		if ($dataValue->getType() !== 'wikibase-entityid') {
102
+			$message = wfMessage("wbqc-violation-message-value-needed-of-type")
103 103
 				->rawParams(
104
-					$this->constraintParameterRenderer->formatItemId( $constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM ),
104
+					$this->constraintParameterRenderer->formatItemId($constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM),
105 105
 					'wikibase-entityid' // TODO is there a message for this type so we can localize it?
106 106
 				)
107 107
 				->escaped();
108
-			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message );
108
+			return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message);
109 109
 		}
110 110
 		/** @var EntityIdValue $dataValue */
111 111
 
112 112
 		$targetEntityId = $dataValue->getEntityId();
113
-		$targetEntity = $this->entityLookup->getEntity( $targetEntityId );
114
-		if ( $targetEntity === null ) {
115
-			$message = wfMessage( "wbqc-violation-message-target-entity-must-exist" )->escaped();
116
-			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message );
113
+		$targetEntity = $this->entityLookup->getEntity($targetEntityId);
114
+		if ($targetEntity === null) {
115
+			$message = wfMessage("wbqc-violation-message-target-entity-must-exist")->escaped();
116
+			return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message);
117 117
 		}
118 118
 
119 119
 		/*
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 		 *   a) a property only
122 122
 		 *   b) a property and a number of items (each combination forming an individual claim)
123 123
 		 */
124
-		if ( $items === [] ) {
124
+		if ($items === []) {
125 125
 			$requiredStatement = $this->connectionCheckerHelper->findStatementWithProperty(
126 126
 				$targetEntity->getStatements(),
127 127
 				$propertyId
@@ -134,37 +134,37 @@  discard block
 block discarded – undo
134 134
 			);
135 135
 		}
136 136
 
137
-		if ( $requiredStatement !== null ) {
137
+		if ($requiredStatement !== null) {
138 138
 			$status = CheckResult::STATUS_COMPLIANCE;
139 139
 			$message = '';
140 140
 		} else {
141 141
 			$status = CheckResult::STATUS_VIOLATION;
142
-			$message = wfMessage( 'wbqc-violation-message-target-required-claim' );
142
+			$message = wfMessage('wbqc-violation-message-target-required-claim');
143 143
 			$message->rawParams(
144
-				$this->constraintParameterRenderer->formatEntityId( $targetEntityId, Role::SUBJECT ),
145
-				$this->constraintParameterRenderer->formatEntityId( $propertyId, Role::PREDICATE )
144
+				$this->constraintParameterRenderer->formatEntityId($targetEntityId, Role::SUBJECT),
145
+				$this->constraintParameterRenderer->formatEntityId($propertyId, Role::PREDICATE)
146 146
 			);
147
-			$message->numParams( count( $items ) );
148
-			$message->rawParams( $this->constraintParameterRenderer->formatItemIdSnakValueList( $items, Role::OBJECT ) );
147
+			$message->numParams(count($items));
148
+			$message->rawParams($this->constraintParameterRenderer->formatItemIdSnakValueList($items, Role::OBJECT));
149 149
 			$message = $message->escaped();
150 150
 		}
151 151
 
152
-		return ( new CheckResult( $context, $constraint, $parameters, $status, $message ) )
153
-			->withMetadata( Metadata::ofDependencyMetadata(
154
-				DependencyMetadata::ofEntityId( $targetEntityId ) ) );
152
+		return (new CheckResult($context, $constraint, $parameters, $status, $message))
153
+			->withMetadata(Metadata::ofDependencyMetadata(
154
+				DependencyMetadata::ofEntityId($targetEntityId) ));
155 155
 	}
156 156
 
157
-	public function checkConstraintParameters( Constraint $constraint ) {
157
+	public function checkConstraintParameters(Constraint $constraint) {
158 158
 		$constraintParameters = $constraint->getConstraintParameters();
159 159
 		$exceptions = [];
160 160
 		try {
161
-			$this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
162
-		} catch ( ConstraintParameterException $e ) {
161
+			$this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId());
162
+		} catch (ConstraintParameterException $e) {
163 163
 			$exceptions[] = $e;
164 164
 		}
165 165
 		try {
166
-			$this->constraintParameterParser->parseItemsParameter( $constraintParameters, $constraint->getConstraintTypeItemId(), false );
167
-		} catch ( ConstraintParameterException $e ) {
166
+			$this->constraintParameterParser->parseItemsParameter($constraintParameters, $constraint->getConstraintTypeItemId(), false);
167
+		} catch (ConstraintParameterException $e) {
168 168
 			$exceptions[] = $e;
169 169
 		}
170 170
 		return $exceptions;
Please login to merge, or discard this patch.