Completed
Push — master ( 1d7888...0497b4 )
by
unknown
03:57 queued 01:15
created
src/ConstraintCheck/Checker/FormatChecker.php 1 patch
Spacing   +30 added lines, -31 removed lines patch added patch discarded remove patch
@@ -71,26 +71,26 @@  discard block
 block discarded – undo
71 71
 	 * @throws ConstraintParameterException
72 72
 	 * @return CheckResult
73 73
 	 */
74
-	public function checkConstraint( Context $context, Constraint $constraint ) {
74
+	public function checkConstraint(Context $context, Constraint $constraint) {
75 75
 		$parameters = [];
76 76
 		$constraintParameters = $constraint->getConstraintParameters();
77 77
 
78
-		$format = $this->constraintParameterParser->parseFormatParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
79
-		$parameters['pattern'] = [ $format ];
78
+		$format = $this->constraintParameterParser->parseFormatParameter($constraintParameters, $constraint->getConstraintTypeItemId());
79
+		$parameters['pattern'] = [$format];
80 80
 
81 81
 		$syntaxClarification = $this->constraintParameterParser->parseSyntaxClarificationParameter(
82 82
 			$constraintParameters,
83 83
 			WikibaseRepo::getDefaultInstance()->getUserLanguage() // TODO make this part of the Context?
84 84
 		);
85
-		if ( $syntaxClarification !== null ) {
86
-			$parameters['clarification'] = [ $syntaxClarification ];
85
+		if ($syntaxClarification !== null) {
86
+			$parameters['clarification'] = [$syntaxClarification];
87 87
 		}
88 88
 
89 89
 		$snak = $context->getSnak();
90 90
 
91
-		if ( !$snak instanceof PropertyValueSnak ) {
91
+		if (!$snak instanceof PropertyValueSnak) {
92 92
 			// nothing to check
93
-			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE, '' );
93
+			return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE, '');
94 94
 		}
95 95
 
96 96
 		$dataValue = $snak->getDataValue();
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 		 * error handling:
100 100
 		 *   type of $dataValue for properties with 'Format' constraint has to be 'string' or 'monolingualtext'
101 101
 		 */
102
-		switch ( $dataValue->getType() ) {
102
+		switch ($dataValue->getType()) {
103 103
 			case 'string':
104 104
 				$text = $dataValue->getValue();
105 105
 				break;
@@ -108,60 +108,59 @@  discard block
 block discarded – undo
108 108
 				$text = $dataValue->getText();
109 109
 				break;
110 110
 			default:
111
-				$message = wfMessage( "wbqc-violation-message-value-needed-of-type" )
111
+				$message = wfMessage("wbqc-violation-message-value-needed-of-type")
112 112
 						 ->rawParams(
113
-							 $this->constraintParameterRenderer->formatItemId( $constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM ),
114
-							 wfMessage( 'datatypes-type-string' )->escaped(),
115
-							 wfMessage( 'datatypes-type-monolingualtext' )->escaped()
113
+							 $this->constraintParameterRenderer->formatItemId($constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM),
114
+							 wfMessage('datatypes-type-string')->escaped(),
115
+							 wfMessage('datatypes-type-monolingualtext')->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
-		if ( $this->sparqlHelper !== null && $this->config->get( 'WBQualityConstraintsCheckFormatConstraint' ) ) {
122
-			if ( $this->sparqlHelper->matchesRegularExpression( $text, $format ) ) {
121
+		if ($this->sparqlHelper !== null && $this->config->get('WBQualityConstraintsCheckFormatConstraint')) {
122
+			if ($this->sparqlHelper->matchesRegularExpression($text, $format)) {
123 123
 				$message = '';
124 124
 				$status = CheckResult::STATUS_COMPLIANCE;
125 125
 			} else {
126 126
 				$message = wfMessage(
127 127
 					$syntaxClarification !== null ?
128
-						'wbqc-violation-message-format-clarification' :
129
-						'wbqc-violation-message-format'
128
+						'wbqc-violation-message-format-clarification' : 'wbqc-violation-message-format'
130 129
 				)->rawParams(
131
-					$this->constraintParameterRenderer->formatEntityId( $context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY ),
132
-					$this->constraintParameterRenderer->formatDataValue( new StringValue( $text ), Role::OBJECT ),
133
-					$this->constraintParameterRenderer->formatByRole( Role::CONSTRAINT_PARAMETER_VALUE,
134
-						'<code><nowiki>' . htmlspecialchars( $format ) . '</nowiki></code>' )
130
+					$this->constraintParameterRenderer->formatEntityId($context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY),
131
+					$this->constraintParameterRenderer->formatDataValue(new StringValue($text), Role::OBJECT),
132
+					$this->constraintParameterRenderer->formatByRole(Role::CONSTRAINT_PARAMETER_VALUE,
133
+						'<code><nowiki>'.htmlspecialchars($format).'</nowiki></code>')
135 134
 				);
136
-				if ( $syntaxClarification !== null ) {
137
-					$message->params( $syntaxClarification );
135
+				if ($syntaxClarification !== null) {
136
+					$message->params($syntaxClarification);
138 137
 				}
139 138
 				$message = $message->escaped();
140 139
 				$status = CheckResult::STATUS_VIOLATION;
141 140
 			}
142 141
 		} else {
143
-			$message = wfMessage( "wbqc-violation-message-security-reason" )
144
-					 ->rawParams( $this->constraintParameterRenderer->formatItemId( $constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM ) )
142
+			$message = wfMessage("wbqc-violation-message-security-reason")
143
+					 ->rawParams($this->constraintParameterRenderer->formatItemId($constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM))
145 144
 					 ->escaped();
146 145
 			$status = CheckResult::STATUS_TODO;
147 146
 		}
148
-		return new CheckResult( $context, $constraint, $parameters, $status, $message );
147
+		return new CheckResult($context, $constraint, $parameters, $status, $message);
149 148
 	}
150 149
 
151
-	public function checkConstraintParameters( Constraint $constraint ) {
150
+	public function checkConstraintParameters(Constraint $constraint) {
152 151
 		$constraintParameters = $constraint->getConstraintParameters();
153 152
 		$exceptions = [];
154 153
 		try {
155
-			$this->constraintParameterParser->parseFormatParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
156
-		} catch ( ConstraintParameterException $e ) {
154
+			$this->constraintParameterParser->parseFormatParameter($constraintParameters, $constraint->getConstraintTypeItemId());
155
+		} catch (ConstraintParameterException $e) {
157 156
 			$exceptions[] = $e;
158 157
 		}
159 158
 		try {
160 159
 			$this->constraintParameterParser->parseSyntaxClarificationParameter(
161 160
 				$constraintParameters,
162
-				Language::factory( 'en' ) // errors are reported independent of language requested
161
+				Language::factory('en') // errors are reported independent of language requested
163 162
 			);
164
-		} catch ( ConstraintParameterException $e ) {
163
+		} catch (ConstraintParameterException $e) {
165 164
 			$exceptions[] = $e;
166 165
 		}
167 166
 		return $exceptions;
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/ValueTypeChecker.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -82,35 +82,35 @@  discard block
 block discarded – undo
82 82
 	 * @throws SparqlHelperException if the checker uses SPARQL and the query times out or some other error occurs
83 83
 	 * @return CheckResult
84 84
 	 */
85
-	public function checkConstraint( Context $context, Constraint $constraint ) {
86
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
87
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
85
+	public function checkConstraint(Context $context, Constraint $constraint) {
86
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
87
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
88 88
 		}
89 89
 
90 90
 		$parameters = [];
91 91
 		$constraintParameters = $constraint->getConstraintParameters();
92 92
 
93
-		$classes = $this->constraintParameterParser->parseClassParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
93
+		$classes = $this->constraintParameterParser->parseClassParameter($constraintParameters, $constraint->getConstraintTypeItemId());
94 94
 		$parameters['class'] = array_map(
95
-			function( $id ) {
96
-				return new ItemId( $id );
95
+			function($id) {
96
+				return new ItemId($id);
97 97
 			},
98 98
 			$classes
99 99
 		);
100 100
 
101
-		$relation = $this->constraintParameterParser->parseRelationParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
102
-		if ( $relation === 'instance' ) {
103
-			$relationId = $this->config->get( 'WBQualityConstraintsInstanceOfId' );
104
-		} elseif ( $relation === 'subclass' ) {
105
-			$relationId = $this->config->get( 'WBQualityConstraintsSubclassOfId' );
101
+		$relation = $this->constraintParameterParser->parseRelationParameter($constraintParameters, $constraint->getConstraintTypeItemId());
102
+		if ($relation === 'instance') {
103
+			$relationId = $this->config->get('WBQualityConstraintsInstanceOfId');
104
+		} elseif ($relation === 'subclass') {
105
+			$relationId = $this->config->get('WBQualityConstraintsSubclassOfId');
106 106
 		}
107
-		$parameters['relation'] = [ $relation ];
107
+		$parameters['relation'] = [$relation];
108 108
 
109 109
 		$snak = $context->getSnak();
110 110
 
111
-		if ( !$snak instanceof PropertyValueSnak ) {
111
+		if (!$snak instanceof PropertyValueSnak) {
112 112
 			// nothing to check
113
-			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE, '' );
113
+			return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE, '');
114 114
 		}
115 115
 
116 116
 		$dataValue = $snak->getDataValue();
@@ -119,22 +119,22 @@  discard block
 block discarded – undo
119 119
 		 * error handling:
120 120
 		 *   type of $dataValue for properties with 'Value type' constraint has to be 'wikibase-entityid'
121 121
 		 */
122
-		if ( $dataValue->getType() !== 'wikibase-entityid' ) {
123
-			$message = wfMessage( "wbqc-violation-message-value-needed-of-type" )
122
+		if ($dataValue->getType() !== 'wikibase-entityid') {
123
+			$message = wfMessage("wbqc-violation-message-value-needed-of-type")
124 124
 				->rawParams(
125
-					$this->constraintParameterRenderer->formatItemId( $constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM ),
125
+					$this->constraintParameterRenderer->formatItemId($constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM),
126 126
 					'wikibase-entityid' // TODO is there a message for this type so we can localize it?
127 127
 				)
128 128
 				->escaped();
129
-			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message );
129
+			return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message);
130 130
 		}
131 131
 		/** @var EntityIdValue $dataValue */
132 132
 
133
-		$item = $this->entityLookup->getEntity( $dataValue->getEntityId() );
133
+		$item = $this->entityLookup->getEntity($dataValue->getEntityId());
134 134
 
135
-		if ( !( $item instanceof StatementListProvider ) ) {
136
-			$message = wfMessage( "wbqc-violation-message-value-entity-must-exist" )->escaped();
137
-			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message );
135
+		if (!($item instanceof StatementListProvider)) {
136
+			$message = wfMessage("wbqc-violation-message-value-entity-must-exist")->escaped();
137
+			return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message);
138 138
 		}
139 139
 
140 140
 		$statements = $item->getStatements();
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 			$classes
146 146
 		);
147 147
 
148
-		if ( $result->getBool() ) {
148
+		if ($result->getBool()) {
149 149
 			$message = '';
150 150
 			$status = CheckResult::STATUS_COMPLIANCE;
151 151
 		} else {
@@ -159,21 +159,21 @@  discard block
 block discarded – undo
159 159
 			$status = CheckResult::STATUS_VIOLATION;
160 160
 		}
161 161
 
162
-		return ( new CheckResult( $context, $constraint, $parameters, $status, $message ) )
163
-			->withMetadata( $result->getMetadata() );
162
+		return (new CheckResult($context, $constraint, $parameters, $status, $message))
163
+			->withMetadata($result->getMetadata());
164 164
 	}
165 165
 
166
-	public function checkConstraintParameters( Constraint $constraint ) {
166
+	public function checkConstraintParameters(Constraint $constraint) {
167 167
 		$constraintParameters = $constraint->getConstraintParameters();
168 168
 		$exceptions = [];
169 169
 		try {
170
-			$this->constraintParameterParser->parseClassParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
171
-		} catch ( ConstraintParameterException $e ) {
170
+			$this->constraintParameterParser->parseClassParameter($constraintParameters, $constraint->getConstraintTypeItemId());
171
+		} catch (ConstraintParameterException $e) {
172 172
 			$exceptions[] = $e;
173 173
 		}
174 174
 		try {
175
-			$this->constraintParameterParser->parseRelationParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
176
-		} catch ( ConstraintParameterException $e ) {
175
+			$this->constraintParameterParser->parseRelationParameter($constraintParameters, $constraint->getConstraintTypeItemId());
176
+		} catch (ConstraintParameterException $e) {
177 177
 			$exceptions[] = $e;
178 178
 		}
179 179
 		return $exceptions;
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/UniqueValueChecker.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -50,22 +50,22 @@  discard block
 block discarded – undo
50 50
 	 * @throws SparqlHelperException if the checker uses SPARQL and the query times out or some other error occurs
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 57
 
58 58
 		$parameters = [];
59 59
 
60
-		if ( $this->sparqlHelper !== null ) {
61
-			if ( $context->getType() === 'statement' ) {
60
+		if ($this->sparqlHelper !== null) {
61
+			if ($context->getType() === 'statement') {
62 62
 				$result = $this->sparqlHelper->findEntitiesWithSameStatement(
63 63
 					$context->getSnakStatement(),
64 64
 					true // ignore deprecated statements
65 65
 				);
66 66
 			} else {
67
-				if ( $context->getSnak()->getType() !== 'value' ) {
68
-					return new CheckResult( $context, $constraint, [], CheckResult::STATUS_COMPLIANCE );
67
+				if ($context->getSnak()->getType() !== 'value') {
68
+					return new CheckResult($context, $constraint, [], CheckResult::STATUS_COMPLIANCE);
69 69
 				}
70 70
 				$result = $this->sparqlHelper->findEntitiesWithSameQualifierOrReference(
71 71
 					$context->getEntity()->getId(),
@@ -78,29 +78,29 @@  discard block
 block discarded – undo
78 78
 			$otherEntities = $result->getArray();
79 79
 			$metadata = $result->getMetadata();
80 80
 
81
-			if ( $otherEntities === [] ) {
81
+			if ($otherEntities === []) {
82 82
 				$status = CheckResult::STATUS_COMPLIANCE;
83 83
 				$message = '';
84 84
 			} else {
85 85
 				$status = CheckResult::STATUS_VIOLATION;
86
-				$message = wfMessage( 'wbqc-violation-message-unique-value' )
87
-						 ->numParams( count( $otherEntities ) )
88
-						 ->rawParams( $this->constraintParameterRenderer->formatEntityIdList( $otherEntities, Role::SUBJECT ) )
86
+				$message = wfMessage('wbqc-violation-message-unique-value')
87
+						 ->numParams(count($otherEntities))
88
+						 ->rawParams($this->constraintParameterRenderer->formatEntityIdList($otherEntities, Role::SUBJECT))
89 89
 						 ->escaped();
90 90
 			}
91 91
 		} else {
92 92
 			$status = CheckResult::STATUS_TODO;
93
-			$message = wfMessage( "wbqc-violation-message-not-yet-implemented" )
94
-					 ->rawParams( $this->constraintParameterRenderer->formatItemId( $constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM ) )
93
+			$message = wfMessage("wbqc-violation-message-not-yet-implemented")
94
+					 ->rawParams($this->constraintParameterRenderer->formatItemId($constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM))
95 95
 					 ->escaped();
96 96
 			$metadata = Metadata::blank();
97 97
 		}
98 98
 
99
-		return ( new CheckResult( $context, $constraint, $parameters, $status, $message ) )
100
-			->withMetadata( $metadata );
99
+		return (new CheckResult($context, $constraint, $parameters, $status, $message))
100
+			->withMetadata($metadata);
101 101
 	}
102 102
 
103
-	public function checkConstraintParameters( Constraint $constraint ) {
103
+	public function checkConstraintParameters(Constraint $constraint) {
104 104
 		// no parameters
105 105
 		return [];
106 106
 	}
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/ItemChecker.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -67,22 +67,22 @@  discard block
 block discarded – undo
67 67
 	 * @throws ConstraintParameterException
68 68
 	 * @return CheckResult
69 69
 	 */
70
-	public function checkConstraint( Context $context, Constraint $constraint ) {
71
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
72
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
70
+	public function checkConstraint(Context $context, Constraint $constraint) {
71
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
72
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
73 73
 		}
74
-		if ( $context->getType() !== Context::TYPE_STATEMENT ) {
74
+		if ($context->getType() !== Context::TYPE_STATEMENT) {
75 75
 			// TODO T175562
76
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_NOT_MAIN_SNAK );
76
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_NOT_MAIN_SNAK);
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
 		/*
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 		 *   a) a property only
91 91
 		 *   b) a property and a number of items (each combination of property and item forming an individual claim)
92 92
 		 */
93
-		if ( $items === [] ) {
93
+		if ($items === []) {
94 94
 			$requiredStatement = $this->connectionCheckerHelper->findStatementWithProperty(
95 95
 				$context->getEntity()->getStatements(),
96 96
 				$propertyId
@@ -103,35 +103,35 @@  discard block
 block discarded – undo
103 103
 			);
104 104
 		}
105 105
 
106
-		if ( $requiredStatement !== null ) {
106
+		if ($requiredStatement !== null) {
107 107
 			$status = CheckResult::STATUS_COMPLIANCE;
108 108
 			$message = '';
109 109
 		} else {
110 110
 			$status = CheckResult::STATUS_VIOLATION;
111
-			$message = wfMessage( 'wbqc-violation-message-item' );
111
+			$message = wfMessage('wbqc-violation-message-item');
112 112
 			$message->rawParams(
113
-				$this->constraintParameterRenderer->formatEntityId( $context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY ),
114
-				$this->constraintParameterRenderer->formatEntityId( $propertyId, Role::PREDICATE )
113
+				$this->constraintParameterRenderer->formatEntityId($context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY),
114
+				$this->constraintParameterRenderer->formatEntityId($propertyId, Role::PREDICATE)
115 115
 			);
116
-			$message->numParams( count( $items ) );
117
-			$message->rawParams( $this->constraintParameterRenderer->formatItemIdSnakValueList( $items, Role::OBJECT ) );
116
+			$message->numParams(count($items));
117
+			$message->rawParams($this->constraintParameterRenderer->formatItemIdSnakValueList($items, Role::OBJECT));
118 118
 			$message = $message->escaped();
119 119
 		}
120 120
 
121
-		return new CheckResult( $context, $constraint, $parameters, $status, $message );
121
+		return new CheckResult($context, $constraint, $parameters, $status, $message);
122 122
 	}
123 123
 
124
-	public function checkConstraintParameters( Constraint $constraint ) {
124
+	public function checkConstraintParameters(Constraint $constraint) {
125 125
 		$constraintParameters = $constraint->getConstraintParameters();
126 126
 		$exceptions = [];
127 127
 		try {
128
-			$this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
129
-		} catch ( ConstraintParameterException $e ) {
128
+			$this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId());
129
+		} catch (ConstraintParameterException $e) {
130 130
 			$exceptions[] = $e;
131 131
 		}
132 132
 		try {
133
-			$this->constraintParameterParser->parseItemsParameter( $constraintParameters, $constraint->getConstraintTypeItemId(), false );
134
-		} catch ( ConstraintParameterException $e ) {
133
+			$this->constraintParameterParser->parseItemsParameter($constraintParameters, $constraint->getConstraintTypeItemId(), false);
134
+		} catch (ConstraintParameterException $e) {
135 135
 			$exceptions[] = $e;
136 136
 		}
137 137
 		return $exceptions;
Please login to merge, or discard this patch.
src/UpdateConstraintsTableJob.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -26,8 +26,8 @@  discard block
 block discarded – undo
26 26
 
27 27
 	const BATCH_SIZE = 10;
28 28
 
29
-	public static function newFromGlobalState( Title $title, array $params ) {
30
-		Assert::parameterType( 'string', $params['propertyId'], '$params["propertyId"]' );
29
+	public static function newFromGlobalState(Title $title, array $params) {
30
+		Assert::parameterType('string', $params['propertyId'], '$params["propertyId"]');
31 31
 		$repo = WikibaseRepo::getDefaultInstance();
32 32
 		return new UpdateConstraintsTableJob(
33 33
 			$title,
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 		EntityLookup $entityLookup,
84 84
 		Serializer $snakSerializer
85 85
 	) {
86
-		parent::__construct( 'constraintsTableUpdate', $title, $params );
86
+		parent::__construct('constraintsTableUpdate', $title, $params);
87 87
 
88 88
 		$this->propertyId = $propertyId;
89 89
 		$this->config = $config;
@@ -92,11 +92,11 @@  discard block
 block discarded – undo
92 92
 		$this->snakSerializer = $snakSerializer;
93 93
 	}
94 94
 
95
-	public function extractParametersFromQualifiers( SnakList $qualifiers ) {
95
+	public function extractParametersFromQualifiers(SnakList $qualifiers) {
96 96
 		$parameters = [];
97
-		foreach ( $qualifiers as $qualifier ) {
97
+		foreach ($qualifiers as $qualifier) {
98 98
 			$qualifierId = $qualifier->getPropertyId()->getSerialization();
99
-			$paramSerialization = $this->snakSerializer->serialize( $qualifier );
99
+			$paramSerialization = $this->snakSerializer->serialize($qualifier);
100 100
 			$parameters[$qualifierId][] = $paramSerialization;
101 101
 		}
102 102
 		return $parameters;
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 	) {
109 109
 		$constraintId = $constraintStatement->getGuid();
110 110
 		$constraintTypeQid = $constraintStatement->getMainSnak()->getDataValue()->getEntityId()->getSerialization();
111
-		$parameters = $this->extractParametersFromQualifiers( $constraintStatement->getQualifiers() );
111
+		$parameters = $this->extractParametersFromQualifiers($constraintStatement->getQualifiers());
112 112
 		return new Constraint(
113 113
 			$constraintId,
114 114
 			$propertyId,
@@ -123,17 +123,17 @@  discard block
 block discarded – undo
123 123
 		PropertyId $propertyConstraintPropertyId
124 124
 	) {
125 125
 		$constraintsStatements = $property->getStatements()
126
-			->getByPropertyId( $propertyConstraintPropertyId )
127
-			->getByRank( [ Statement::RANK_PREFERRED, Statement::RANK_NORMAL ] );
126
+			->getByPropertyId($propertyConstraintPropertyId)
127
+			->getByRank([Statement::RANK_PREFERRED, Statement::RANK_NORMAL]);
128 128
 		$constraints = [];
129
-		foreach ( $constraintsStatements->getIterator() as $constraintStatement ) {
130
-			$constraints[] = $this->extractConstraintFromStatement( $property->getId(), $constraintStatement );
131
-			if ( count( $constraints ) >= self::BATCH_SIZE ) {
132
-				$constraintRepo->insertBatch( $constraints );
129
+		foreach ($constraintsStatements->getIterator() as $constraintStatement) {
130
+			$constraints[] = $this->extractConstraintFromStatement($property->getId(), $constraintStatement);
131
+			if (count($constraints) >= self::BATCH_SIZE) {
132
+				$constraintRepo->insertBatch($constraints);
133 133
 				$constraints = [];
134 134
 			}
135 135
 		}
136
-		$constraintRepo->insertBatch( $constraints );
136
+		$constraintRepo->insertBatch($constraints);
137 137
 	}
138 138
 
139 139
 	/**
@@ -144,14 +144,14 @@  discard block
 block discarded – undo
144 144
 	public function run() {
145 145
 		// TODO in the future: only touch constraints affected by the edit (requires T163465)
146 146
 
147
-		$propertyId = new PropertyId( $this->propertyId );
148
-		$this->constraintRepo->deleteForPropertyWhereConstraintIdIsStatementId( $propertyId );
147
+		$propertyId = new PropertyId($this->propertyId);
148
+		$this->constraintRepo->deleteForPropertyWhereConstraintIdIsStatementId($propertyId);
149 149
 
150
-		$property = $this->entityLookup->getEntity( $propertyId );
150
+		$property = $this->entityLookup->getEntity($propertyId);
151 151
 		$this->importConstraintsForProperty(
152 152
 			$property,
153 153
 			$this->constraintRepo,
154
-			new PropertyId( $this->config->get( 'WBQualityConstraintsPropertyConstraintId' ) )
154
+			new PropertyId($this->config->get('WBQualityConstraintsPropertyConstraintId'))
155 155
 		);
156 156
 
157 157
 		return true;
Please login to merge, or discard this patch.
src/ConstraintCheck/Helper/ConstraintParameterParser.php 1 patch
Spacing   +206 added lines, -206 removed lines patch added patch discarded remove patch
@@ -76,15 +76,15 @@  discard block
 block discarded – undo
76 76
 	 * @param array $parameters
77 77
 	 * @throws ConstraintParameterException
78 78
 	 */
79
-	public function checkError( array $parameters ) {
80
-		if ( array_key_exists( '@error', $parameters ) ) {
79
+	public function checkError(array $parameters) {
80
+		if (array_key_exists('@error', $parameters)) {
81 81
 			$error = $parameters['@error'];
82
-			if ( array_key_exists( 'toolong', $error ) && $error['toolong'] ) {
82
+			if (array_key_exists('toolong', $error) && $error['toolong']) {
83 83
 				$msg = 'wbqc-violation-message-parameters-error-toolong';
84 84
 			} else {
85 85
 				$msg = 'wbqc-violation-message-parameters-error-unknown';
86 86
 			}
87
-			throw new ConstraintParameterException( wfMessage( $msg )->escaped() );
87
+			throw new ConstraintParameterException(wfMessage($msg)->escaped());
88 88
 		}
89 89
 	}
90 90
 
@@ -94,11 +94,11 @@  discard block
 block discarded – undo
94 94
 	 * @param string $parameterId
95 95
 	 * @throws ConstraintParameterException
96 96
 	 */
97
-	private function requireSingleParameter( array $parameters, $parameterId ) {
98
-		if ( count( $parameters[$parameterId] ) !== 1 ) {
97
+	private function requireSingleParameter(array $parameters, $parameterId) {
98
+		if (count($parameters[$parameterId]) !== 1) {
99 99
 			throw new ConstraintParameterException(
100
-				wfMessage( 'wbqc-violation-message-parameter-single' )
101
-					->rawParams( $this->constraintParameterRenderer->formatPropertyId( $parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY ) )
100
+				wfMessage('wbqc-violation-message-parameter-single')
101
+					->rawParams($this->constraintParameterRenderer->formatPropertyId($parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY))
102 102
 					->escaped()
103 103
 			);
104 104
 		}
@@ -111,11 +111,11 @@  discard block
 block discarded – undo
111 111
 	 * @return void
112 112
 	 * @throws ConstraintParameterException
113 113
 	 */
114
-	private function requireValueParameter( Snak $snak, $parameterId ) {
115
-		if ( !( $snak instanceof PropertyValueSnak ) ) {
114
+	private function requireValueParameter(Snak $snak, $parameterId) {
115
+		if (!($snak instanceof PropertyValueSnak)) {
116 116
 			throw new ConstraintParameterException(
117
-				wfMessage( 'wbqc-violation-message-parameter-value' )
118
-					->rawParams( $this->constraintParameterRenderer->formatPropertyId( $parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY ) )
117
+				wfMessage('wbqc-violation-message-parameter-value')
118
+					->rawParams($this->constraintParameterRenderer->formatPropertyId($parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY))
119 119
 					->escaped()
120 120
 			);
121 121
 		}
@@ -128,18 +128,18 @@  discard block
 block discarded – undo
128 128
 	 * @throws ConstraintParameterException
129 129
 	 * @return EntityId
130 130
 	 */
131
-	private function parseEntityIdParameter( array $snakSerialization, $parameterId ) {
132
-		$snak = $this->snakDeserializer->deserialize( $snakSerialization );
133
-		$this->requireValueParameter( $snak, $parameterId );
131
+	private function parseEntityIdParameter(array $snakSerialization, $parameterId) {
132
+		$snak = $this->snakDeserializer->deserialize($snakSerialization);
133
+		$this->requireValueParameter($snak, $parameterId);
134 134
 		$value = $snak->getDataValue();
135
-		if ( $value instanceof EntityIdValue ) {
135
+		if ($value instanceof EntityIdValue) {
136 136
 			return $value->getEntityId();
137 137
 		} else {
138 138
 			throw new ConstraintParameterException(
139
-				wfMessage( 'wbqc-violation-message-parameter-entity' )
139
+				wfMessage('wbqc-violation-message-parameter-entity')
140 140
 					->rawParams(
141
-						$this->constraintParameterRenderer->formatPropertyId( $parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY ),
142
-						$this->constraintParameterRenderer->formatDataValue( $value, Role::CONSTRAINT_PARAMETER_VALUE )
141
+						$this->constraintParameterRenderer->formatPropertyId($parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY),
142
+						$this->constraintParameterRenderer->formatDataValue($value, Role::CONSTRAINT_PARAMETER_VALUE)
143 143
 					)
144 144
 					->escaped()
145 145
 			);
@@ -152,21 +152,21 @@  discard block
 block discarded – undo
152 152
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
153 153
 	 * @return string[] class entity ID serializations
154 154
 	 */
155
-	public function parseClassParameter( array $constraintParameters, $constraintTypeItemId ) {
156
-		$this->checkError( $constraintParameters );
157
-		$classId = $this->config->get( 'WBQualityConstraintsClassId' );
158
-		if ( !array_key_exists( $classId, $constraintParameters ) ) {
155
+	public function parseClassParameter(array $constraintParameters, $constraintTypeItemId) {
156
+		$this->checkError($constraintParameters);
157
+		$classId = $this->config->get('WBQualityConstraintsClassId');
158
+		if (!array_key_exists($classId, $constraintParameters)) {
159 159
 			throw new ConstraintParameterException(
160
-				wfMessage( 'wbqc-violation-message-parameter-needed' )
161
-					->rawParams( $this->constraintParameterRenderer->formatItemId( $constraintTypeItemId, Role::CONSTRAINT_TYPE_ITEM ) )
162
-					->rawParams( $this->constraintParameterRenderer->formatPropertyId( $classId, Role::CONSTRAINT_PARAMETER_PROPERTY ) )
160
+				wfMessage('wbqc-violation-message-parameter-needed')
161
+					->rawParams($this->constraintParameterRenderer->formatItemId($constraintTypeItemId, Role::CONSTRAINT_TYPE_ITEM))
162
+					->rawParams($this->constraintParameterRenderer->formatPropertyId($classId, Role::CONSTRAINT_PARAMETER_PROPERTY))
163 163
 					->escaped()
164 164
 			);
165 165
 		}
166 166
 
167 167
 		$classes = [];
168
-		foreach ( $constraintParameters[$classId] as $class ) {
169
-			$classes[] = $this->parseEntityIdParameter( $class, $classId )->getSerialization();
168
+		foreach ($constraintParameters[$classId] as $class) {
169
+			$classes[] = $this->parseEntityIdParameter($class, $classId)->getSerialization();
170 170
 		}
171 171
 		return $classes;
172 172
 	}
@@ -177,33 +177,33 @@  discard block
 block discarded – undo
177 177
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
178 178
 	 * @return string 'instance' or 'subclass'
179 179
 	 */
180
-	public function parseRelationParameter( array $constraintParameters, $constraintTypeItemId ) {
181
-		$this->checkError( $constraintParameters );
182
-		$relationId = $this->config->get( 'WBQualityConstraintsRelationId' );
183
-		if ( !array_key_exists( $relationId, $constraintParameters ) ) {
180
+	public function parseRelationParameter(array $constraintParameters, $constraintTypeItemId) {
181
+		$this->checkError($constraintParameters);
182
+		$relationId = $this->config->get('WBQualityConstraintsRelationId');
183
+		if (!array_key_exists($relationId, $constraintParameters)) {
184 184
 			throw new ConstraintParameterException(
185
-				wfMessage( 'wbqc-violation-message-parameter-needed' )
186
-					->rawParams( $this->constraintParameterRenderer->formatItemId( $constraintTypeItemId, Role::CONSTRAINT_TYPE_ITEM ) )
187
-					->rawParams( $this->constraintParameterRenderer->formatPropertyId( $relationId, Role::CONSTRAINT_PARAMETER_PROPERTY ) )
185
+				wfMessage('wbqc-violation-message-parameter-needed')
186
+					->rawParams($this->constraintParameterRenderer->formatItemId($constraintTypeItemId, Role::CONSTRAINT_TYPE_ITEM))
187
+					->rawParams($this->constraintParameterRenderer->formatPropertyId($relationId, Role::CONSTRAINT_PARAMETER_PROPERTY))
188 188
 					->escaped()
189 189
 			);
190 190
 		}
191 191
 
192
-		$this->requireSingleParameter( $constraintParameters, $relationId );
193
-		$relationEntityId = $this->parseEntityIdParameter( $constraintParameters[$relationId][0], $relationId );
194
-		$instanceId = $this->config->get( 'WBQualityConstraintsInstanceOfRelationId' );
195
-		$subclassId = $this->config->get( 'WBQualityConstraintsSubclassOfRelationId' );
196
-		switch ( $relationEntityId ) {
192
+		$this->requireSingleParameter($constraintParameters, $relationId);
193
+		$relationEntityId = $this->parseEntityIdParameter($constraintParameters[$relationId][0], $relationId);
194
+		$instanceId = $this->config->get('WBQualityConstraintsInstanceOfRelationId');
195
+		$subclassId = $this->config->get('WBQualityConstraintsSubclassOfRelationId');
196
+		switch ($relationEntityId) {
197 197
 			case $instanceId:
198 198
 				return 'instance';
199 199
 			case $subclassId:
200 200
 				return 'subclass';
201 201
 			default:
202 202
 				throw new ConstraintParameterException(
203
-					wfMessage( 'wbqc-violation-message-parameter-oneof' )
204
-						->rawParams( $this->constraintParameterRenderer->formatPropertyId( $relationId, Role::CONSTRAINT_PARAMETER_PROPERTY ) )
205
-						->numParams( 2 )
206
-						->rawParams( $this->constraintParameterRenderer->formatItemIdList( [ $instanceId, $subclassId ], Role::CONSTRAINT_PARAMETER_VALUE ) )
203
+					wfMessage('wbqc-violation-message-parameter-oneof')
204
+						->rawParams($this->constraintParameterRenderer->formatPropertyId($relationId, Role::CONSTRAINT_PARAMETER_PROPERTY))
205
+						->numParams(2)
206
+						->rawParams($this->constraintParameterRenderer->formatItemIdList([$instanceId, $subclassId], Role::CONSTRAINT_PARAMETER_VALUE))
207 207
 						->escaped()
208 208
 				);
209 209
 		}
@@ -216,21 +216,21 @@  discard block
 block discarded – undo
216 216
 	 * @throws ConstraintParameterException
217 217
 	 * @return PropertyId
218 218
 	 */
219
-	private function parsePropertyIdParameter( array $snakSerialization, $parameterId ) {
220
-		$snak = $this->snakDeserializer->deserialize( $snakSerialization );
221
-		$this->requireValueParameter( $snak, $parameterId );
219
+	private function parsePropertyIdParameter(array $snakSerialization, $parameterId) {
220
+		$snak = $this->snakDeserializer->deserialize($snakSerialization);
221
+		$this->requireValueParameter($snak, $parameterId);
222 222
 		$value = $snak->getDataValue();
223
-		if ( $value instanceof EntityIdValue ) {
223
+		if ($value instanceof EntityIdValue) {
224 224
 			$id = $value->getEntityId();
225
-			if ( $id instanceof PropertyId ) {
225
+			if ($id instanceof PropertyId) {
226 226
 				return $id;
227 227
 			}
228 228
 		}
229 229
 		throw new ConstraintParameterException(
230
-			wfMessage( 'wbqc-violation-message-parameter-property' )
230
+			wfMessage('wbqc-violation-message-parameter-property')
231 231
 				->rawParams(
232
-					$this->constraintParameterRenderer->formatPropertyId( $parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY ),
233
-					$this->constraintParameterRenderer->formatDataValue( $value, Role::CONSTRAINT_PARAMETER_VALUE )
232
+					$this->constraintParameterRenderer->formatPropertyId($parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY),
233
+					$this->constraintParameterRenderer->formatDataValue($value, Role::CONSTRAINT_PARAMETER_VALUE)
234 234
 				)
235 235
 				->escaped()
236 236
 		);
@@ -243,33 +243,33 @@  discard block
 block discarded – undo
243 243
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
244 244
 	 * @return PropertyId
245 245
 	 */
246
-	public function parsePropertyParameter( array $constraintParameters, $constraintTypeItemId ) {
247
-		$this->checkError( $constraintParameters );
248
-		$propertyId = $this->config->get( 'WBQualityConstraintsPropertyId' );
249
-		if ( !array_key_exists( $propertyId, $constraintParameters ) ) {
246
+	public function parsePropertyParameter(array $constraintParameters, $constraintTypeItemId) {
247
+		$this->checkError($constraintParameters);
248
+		$propertyId = $this->config->get('WBQualityConstraintsPropertyId');
249
+		if (!array_key_exists($propertyId, $constraintParameters)) {
250 250
 			throw new ConstraintParameterException(
251
-				wfMessage( 'wbqc-violation-message-parameter-needed' )
252
-					->rawParams( $this->constraintParameterRenderer->formatItemId( $constraintTypeItemId, Role::CONSTRAINT_TYPE_ITEM ) )
253
-					->rawParams( $this->constraintParameterRenderer->formatPropertyId( $propertyId, Role::CONSTRAINT_PARAMETER_PROPERTY ) )
251
+				wfMessage('wbqc-violation-message-parameter-needed')
252
+					->rawParams($this->constraintParameterRenderer->formatItemId($constraintTypeItemId, Role::CONSTRAINT_TYPE_ITEM))
253
+					->rawParams($this->constraintParameterRenderer->formatPropertyId($propertyId, Role::CONSTRAINT_PARAMETER_PROPERTY))
254 254
 					->escaped()
255 255
 			);
256 256
 		}
257 257
 
258
-		$this->requireSingleParameter( $constraintParameters, $propertyId );
259
-		return $this->parsePropertyIdParameter( $constraintParameters[$propertyId][0], $propertyId );
258
+		$this->requireSingleParameter($constraintParameters, $propertyId);
259
+		return $this->parsePropertyIdParameter($constraintParameters[$propertyId][0], $propertyId);
260 260
 	}
261 261
 
262
-	private function parseItemIdParameter( PropertyValueSnak $snak, $parameterId ) {
263
-		if ( $snak->getDataValue() instanceof EntityIdValue &&
262
+	private function parseItemIdParameter(PropertyValueSnak $snak, $parameterId) {
263
+		if ($snak->getDataValue() instanceof EntityIdValue &&
264 264
 			$snak->getDataValue()->getEntityId() instanceof ItemId
265 265
 		) {
266
-			return ItemIdSnakValue::fromItemId( $snak->getDataValue()->getEntityId() );
266
+			return ItemIdSnakValue::fromItemId($snak->getDataValue()->getEntityId());
267 267
 		} else {
268 268
 			throw new ConstraintParameterException(
269
-				wfMessage( 'wbqc-violation-message-parameter-item' )
269
+				wfMessage('wbqc-violation-message-parameter-item')
270 270
 					->rawParams(
271
-						$this->constraintParameterRenderer->formatPropertyId( $parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY ),
272
-						$this->constraintParameterRenderer->formatDataValue( $snak->getDataValue(), Role::CONSTRAINT_PARAMETER_VALUE )
271
+						$this->constraintParameterRenderer->formatPropertyId($parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY),
272
+						$this->constraintParameterRenderer->formatDataValue($snak->getDataValue(), Role::CONSTRAINT_PARAMETER_VALUE)
273 273
 					)
274 274
 					->escaped()
275 275
 			);
@@ -283,15 +283,15 @@  discard block
 block discarded – undo
283 283
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
284 284
 	 * @return ItemIdSnakValue[] array of values
285 285
 	 */
286
-	public function parseItemsParameter( array $constraintParameters, $constraintTypeItemId, $required ) {
287
-		$this->checkError( $constraintParameters );
288
-		$qualifierId = $this->config->get( 'WBQualityConstraintsQualifierOfPropertyConstraintId' );
289
-		if ( !array_key_exists( $qualifierId, $constraintParameters ) ) {
290
-			if ( $required ) {
286
+	public function parseItemsParameter(array $constraintParameters, $constraintTypeItemId, $required) {
287
+		$this->checkError($constraintParameters);
288
+		$qualifierId = $this->config->get('WBQualityConstraintsQualifierOfPropertyConstraintId');
289
+		if (!array_key_exists($qualifierId, $constraintParameters)) {
290
+			if ($required) {
291 291
 				throw new ConstraintParameterException(
292
-					wfMessage( 'wbqc-violation-message-parameter-needed' )
293
-						->rawParams( $this->constraintParameterRenderer->formatItemId( $constraintTypeItemId, Role::CONSTRAINT_TYPE_ITEM ) )
294
-						->rawParams( $this->constraintParameterRenderer->formatPropertyId( $qualifierId, Role::CONSTRAINT_PARAMETER_PROPERTY ) )
292
+					wfMessage('wbqc-violation-message-parameter-needed')
293
+						->rawParams($this->constraintParameterRenderer->formatItemId($constraintTypeItemId, Role::CONSTRAINT_TYPE_ITEM))
294
+						->rawParams($this->constraintParameterRenderer->formatPropertyId($qualifierId, Role::CONSTRAINT_PARAMETER_PROPERTY))
295 295
 						->escaped()
296 296
 				);
297 297
 			} else {
@@ -300,11 +300,11 @@  discard block
 block discarded – undo
300 300
 		}
301 301
 
302 302
 		$values = [];
303
-		foreach ( $constraintParameters[$qualifierId] as $parameter ) {
304
-			$snak = $this->snakDeserializer->deserialize( $parameter );
305
-			switch ( true ) {
303
+		foreach ($constraintParameters[$qualifierId] as $parameter) {
304
+			$snak = $this->snakDeserializer->deserialize($parameter);
305
+			switch (true) {
306 306
 				case $snak instanceof PropertyValueSnak:
307
-					$values[] = $this->parseItemIdParameter( $snak, $qualifierId );
307
+					$values[] = $this->parseItemIdParameter($snak, $qualifierId);
308 308
 					break;
309 309
 				case $snak instanceof PropertySomeValueSnak:
310 310
 					$values[] = ItemIdSnakValue::someValue();
@@ -323,28 +323,28 @@  discard block
 block discarded – undo
323 323
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
324 324
 	 * @return PropertyId[]
325 325
 	 */
326
-	public function parsePropertiesParameter( array $constraintParameters, $constraintTypeItemId ) {
327
-		$this->checkError( $constraintParameters );
328
-		$propertyId = $this->config->get( 'WBQualityConstraintsPropertyId' );
329
-		if ( !array_key_exists( $propertyId, $constraintParameters ) ) {
326
+	public function parsePropertiesParameter(array $constraintParameters, $constraintTypeItemId) {
327
+		$this->checkError($constraintParameters);
328
+		$propertyId = $this->config->get('WBQualityConstraintsPropertyId');
329
+		if (!array_key_exists($propertyId, $constraintParameters)) {
330 330
 			throw new ConstraintParameterException(
331
-				wfMessage( 'wbqc-violation-message-parameter-needed' )
332
-					->rawParams( $this->constraintParameterRenderer->formatItemId( $constraintTypeItemId, Role::CONSTRAINT_TYPE_ITEM ) )
333
-					->rawParams( $this->constraintParameterRenderer->formatPropertyId( $propertyId, Role::CONSTRAINT_PARAMETER_PROPERTY ) )
331
+				wfMessage('wbqc-violation-message-parameter-needed')
332
+					->rawParams($this->constraintParameterRenderer->formatItemId($constraintTypeItemId, Role::CONSTRAINT_TYPE_ITEM))
333
+					->rawParams($this->constraintParameterRenderer->formatPropertyId($propertyId, Role::CONSTRAINT_PARAMETER_PROPERTY))
334 334
 					->escaped()
335 335
 			);
336 336
 		}
337 337
 
338 338
 		$parameters = $constraintParameters[$propertyId];
339
-		if ( count( $parameters ) === 1 &&
340
-			$this->snakDeserializer->deserialize( $parameters[0] ) instanceof PropertyNoValueSnak
339
+		if (count($parameters) === 1 &&
340
+			$this->snakDeserializer->deserialize($parameters[0]) instanceof PropertyNoValueSnak
341 341
 		) {
342 342
 			return [];
343 343
 		}
344 344
 
345 345
 		$properties = [];
346
-		foreach ( $parameters as $parameter ) {
347
-			$properties[] = $this->parsePropertyIdParameter( $parameter, $propertyId );
346
+		foreach ($parameters as $parameter) {
347
+			$properties[] = $this->parsePropertyIdParameter($parameter, $propertyId);
348 348
 		}
349 349
 		return $properties;
350 350
 	}
@@ -355,16 +355,16 @@  discard block
 block discarded – undo
355 355
 	 * @throws ConstraintParameterException
356 356
 	 * @return DataValue|null
357 357
 	 */
358
-	private function parseValueOrNoValueParameter( array $snakSerialization, $parameterId ) {
359
-		$snak = $this->snakDeserializer->deserialize( $snakSerialization );
360
-		if ( $snak instanceof PropertyValueSnak ) {
358
+	private function parseValueOrNoValueParameter(array $snakSerialization, $parameterId) {
359
+		$snak = $this->snakDeserializer->deserialize($snakSerialization);
360
+		if ($snak instanceof PropertyValueSnak) {
361 361
 			return $snak->getDataValue();
362
-		} elseif ( $snak instanceof PropertyNoValueSnak ) {
362
+		} elseif ($snak instanceof PropertyNoValueSnak) {
363 363
 			return null;
364 364
 		} else {
365 365
 			throw new ConstraintParameterException(
366
-				wfMessage( 'wbqc-violation-message-parameter-value-or-novalue' )
367
-					->rawParams( $this->constraintParameterRenderer->formatPropertyId( $parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY ) )
366
+				wfMessage('wbqc-violation-message-parameter-value-or-novalue')
367
+					->rawParams($this->constraintParameterRenderer->formatPropertyId($parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY))
368 368
 					->escaped()
369 369
 			);
370 370
 		}
@@ -375,13 +375,13 @@  discard block
 block discarded – undo
375 375
 	 * @param string $parameterId
376 376
 	 * @return DataValue|null
377 377
 	 */
378
-	private function parseValueOrNoValueOrNowParameter( array $snakSerialization, $parameterId ) {
378
+	private function parseValueOrNoValueOrNowParameter(array $snakSerialization, $parameterId) {
379 379
 		try {
380
-			return $this->parseValueOrNoValueParameter( $snakSerialization, $parameterId );
381
-		} catch ( ConstraintParameterException $e ) {
380
+			return $this->parseValueOrNoValueParameter($snakSerialization, $parameterId);
381
+		} catch (ConstraintParameterException $e) {
382 382
 			// unknown value means “now”
383
-			$timeParser = ( new TimeParserFactory() )->getTimeParser();
384
-			return $timeParser->parse( gmdate( '+Y-m-d\T00:00:00\Z' ) );
383
+			$timeParser = (new TimeParserFactory())->getTimeParser();
384
+			return $timeParser->parse(gmdate('+Y-m-d\T00:00:00\Z'));
385 385
 		}
386 386
 	}
387 387
 
@@ -392,14 +392,14 @@  discard block
 block discarded – undo
392 392
 	 * @param string $unit
393 393
 	 * @return bool
394 394
 	 */
395
-	private function exactlyOneQuantityWithUnit( DataValue $min = null, DataValue $max = null, $unit ) {
396
-		if ( $min === null || $max === null ) {
395
+	private function exactlyOneQuantityWithUnit(DataValue $min = null, DataValue $max = null, $unit) {
396
+		if ($min === null || $max === null) {
397 397
 			return false;
398 398
 		}
399
-		if ( $min->getType() !== 'quantity' || $max->getType() !== 'quantity' ) {
399
+		if ($min->getType() !== 'quantity' || $max->getType() !== 'quantity') {
400 400
 			return false;
401 401
 		}
402
-		return ( $min->getUnit() === $unit ) !== ( $max->getUnit() === $unit );
402
+		return ($min->getUnit() === $unit) !== ($max->getUnit() === $unit);
403 403
 	}
404 404
 
405 405
 	/**
@@ -410,9 +410,9 @@  discard block
 block discarded – undo
410 410
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
411 411
 	 * @return DataValue[] a pair of two quantity-type data values, either of which may be null to signify an open range
412 412
 	 */
413
-	public function parseRangeParameter( array $constraintParameters, $constraintTypeItemId, $type ) {
414
-		$this->checkError( $constraintParameters );
415
-		switch ( $type ) {
413
+	public function parseRangeParameter(array $constraintParameters, $constraintTypeItemId, $type) {
414
+		$this->checkError($constraintParameters);
415
+		switch ($type) {
416 416
 			case 'quantity':
417 417
 				$configKey = 'Quantity';
418 418
 				break;
@@ -421,46 +421,46 @@  discard block
 block discarded – undo
421 421
 				break;
422 422
 			default:
423 423
 				throw new ConstraintParameterException(
424
-					wfMessage( 'wbqc-violation-message-value-needed-of-types-2' )
424
+					wfMessage('wbqc-violation-message-value-needed-of-types-2')
425 425
 						->rawParams(
426
-							wfMessage( 'datatypes-type-quantity' )->escaped(),
427
-							wfMessage( 'datatypes-type-time' )->escaped()
426
+							wfMessage('datatypes-type-quantity')->escaped(),
427
+							wfMessage('datatypes-type-time')->escaped()
428 428
 						)
429 429
 						->escaped()
430 430
 				);
431 431
 		}
432
-		$minimumId = $this->config->get( 'WBQualityConstraintsMinimum' . $configKey . 'Id' );
433
-		$maximumId = $this->config->get( 'WBQualityConstraintsMaximum' . $configKey . 'Id' );
434
-		if ( !array_key_exists( $minimumId, $constraintParameters ) ||
435
-			!array_key_exists( $maximumId, $constraintParameters )
432
+		$minimumId = $this->config->get('WBQualityConstraintsMinimum'.$configKey.'Id');
433
+		$maximumId = $this->config->get('WBQualityConstraintsMaximum'.$configKey.'Id');
434
+		if (!array_key_exists($minimumId, $constraintParameters) ||
435
+			!array_key_exists($maximumId, $constraintParameters)
436 436
 		) {
437 437
 			throw new ConstraintParameterException(
438
-				wfMessage( 'wbqc-violation-message-range-parameters-needed' )
438
+				wfMessage('wbqc-violation-message-range-parameters-needed')
439 439
 					->rawParams(
440
-						wfMessage( 'datatypes-type-' . $type )->escaped(),
441
-						$this->constraintParameterRenderer->formatPropertyId( $minimumId, Role::CONSTRAINT_PARAMETER_PROPERTY ),
442
-						$this->constraintParameterRenderer->formatPropertyId( $maximumId, Role::CONSTRAINT_PARAMETER_PROPERTY )
440
+						wfMessage('datatypes-type-'.$type)->escaped(),
441
+						$this->constraintParameterRenderer->formatPropertyId($minimumId, Role::CONSTRAINT_PARAMETER_PROPERTY),
442
+						$this->constraintParameterRenderer->formatPropertyId($maximumId, Role::CONSTRAINT_PARAMETER_PROPERTY)
443 443
 					)
444
-					->rawParams( $this->constraintParameterRenderer->formatItemId( $constraintTypeItemId, Role::CONSTRAINT_TYPE_ITEM ) )
444
+					->rawParams($this->constraintParameterRenderer->formatItemId($constraintTypeItemId, Role::CONSTRAINT_TYPE_ITEM))
445 445
 					->escaped()
446 446
 			);
447 447
 		}
448 448
 
449
-		$this->requireSingleParameter( $constraintParameters, $minimumId );
450
-		$this->requireSingleParameter( $constraintParameters, $maximumId );
449
+		$this->requireSingleParameter($constraintParameters, $minimumId);
450
+		$this->requireSingleParameter($constraintParameters, $maximumId);
451 451
 		$parseFunction = $configKey === 'Date' ? 'parseValueOrNoValueOrNowParameter' : 'parseValueOrNoValueParameter';
452
-		$min = $this->$parseFunction( $constraintParameters[$minimumId][0], $minimumId );
453
-		$max = $this->$parseFunction( $constraintParameters[$maximumId][0], $maximumId );
452
+		$min = $this->$parseFunction($constraintParameters[$minimumId][0], $minimumId);
453
+		$max = $this->$parseFunction($constraintParameters[$maximumId][0], $maximumId);
454 454
 
455
-		$yearUnit = $this->config->get( 'WBQualityConstraintsYearUnit' );
456
-		if ( $this->exactlyOneQuantityWithUnit( $min, $max, $yearUnit ) ) {
455
+		$yearUnit = $this->config->get('WBQualityConstraintsYearUnit');
456
+		if ($this->exactlyOneQuantityWithUnit($min, $max, $yearUnit)) {
457 457
 			throw new ConstraintParameterException(
458
-				wfMessage( 'wbqc-violation-message-range-parameters-one-year' )
458
+				wfMessage('wbqc-violation-message-range-parameters-one-year')
459 459
 					->escaped()
460 460
 			);
461 461
 		}
462 462
 
463
-		return [ $min, $max ];
463
+		return [$min, $max];
464 464
 	}
465 465
 
466 466
 	/**
@@ -470,18 +470,18 @@  discard block
 block discarded – undo
470 470
 	 * @throws ConstraintParameterException
471 471
 	 * @return string
472 472
 	 */
473
-	private function parseStringParameter( array $snakSerialization, $parameterId ) {
474
-		$snak = $this->snakDeserializer->deserialize( $snakSerialization );
475
-		$this->requireValueParameter( $snak, $parameterId );
473
+	private function parseStringParameter(array $snakSerialization, $parameterId) {
474
+		$snak = $this->snakDeserializer->deserialize($snakSerialization);
475
+		$this->requireValueParameter($snak, $parameterId);
476 476
 		$value = $snak->getDataValue();
477
-		if ( $value instanceof StringValue ) {
477
+		if ($value instanceof StringValue) {
478 478
 			return $value->getValue();
479 479
 		} else {
480 480
 			throw new ConstraintParameterException(
481
-				wfMessage( 'wbqc-violation-message-parameter-string' )
481
+				wfMessage('wbqc-violation-message-parameter-string')
482 482
 					->rawParams(
483
-						$this->constraintParameterRenderer->formatPropertyId( $parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY ),
484
-						$this->constraintParameterRenderer->formatDataValue( $value, Role::CONSTRAINT_PARAMETER_VALUE )
483
+						$this->constraintParameterRenderer->formatPropertyId($parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY),
484
+						$this->constraintParameterRenderer->formatDataValue($value, Role::CONSTRAINT_PARAMETER_VALUE)
485 485
 					)
486 486
 					->escaped()
487 487
 			);
@@ -494,15 +494,15 @@  discard block
 block discarded – undo
494 494
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
495 495
 	 * @return string
496 496
 	 */
497
-	public function parseNamespaceParameter( array $constraintParameters, $constraintTypeItemId ) {
498
-		$this->checkError( $constraintParameters );
499
-		$namespaceId = $this->config->get( 'WBQualityConstraintsNamespaceId' );
500
-		if ( !array_key_exists( $namespaceId, $constraintParameters ) ) {
497
+	public function parseNamespaceParameter(array $constraintParameters, $constraintTypeItemId) {
498
+		$this->checkError($constraintParameters);
499
+		$namespaceId = $this->config->get('WBQualityConstraintsNamespaceId');
500
+		if (!array_key_exists($namespaceId, $constraintParameters)) {
501 501
 			return '';
502 502
 		}
503 503
 
504
-		$this->requireSingleParameter( $constraintParameters, $namespaceId );
505
-		return $this->parseStringParameter( $constraintParameters[$namespaceId][0], $namespaceId );
504
+		$this->requireSingleParameter($constraintParameters, $namespaceId);
505
+		return $this->parseStringParameter($constraintParameters[$namespaceId][0], $namespaceId);
506 506
 	}
507 507
 
508 508
 	/**
@@ -511,20 +511,20 @@  discard block
 block discarded – undo
511 511
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
512 512
 	 * @return string
513 513
 	 */
514
-	public function parseFormatParameter( array $constraintParameters, $constraintTypeItemId ) {
515
-		$this->checkError( $constraintParameters );
516
-		$formatId = $this->config->get( 'WBQualityConstraintsFormatAsARegularExpressionId' );
517
-		if ( !array_key_exists( $formatId, $constraintParameters ) ) {
514
+	public function parseFormatParameter(array $constraintParameters, $constraintTypeItemId) {
515
+		$this->checkError($constraintParameters);
516
+		$formatId = $this->config->get('WBQualityConstraintsFormatAsARegularExpressionId');
517
+		if (!array_key_exists($formatId, $constraintParameters)) {
518 518
 			throw new ConstraintParameterException(
519
-				wfMessage( 'wbqc-violation-message-parameter-needed' )
520
-					->rawParams( $this->constraintParameterRenderer->formatItemId( $constraintTypeItemId, Role::CONSTRAINT_TYPE_ITEM ) )
521
-					->rawParams( $this->constraintParameterRenderer->formatPropertyId( $formatId, Role::CONSTRAINT_PARAMETER_PROPERTY ) )
519
+				wfMessage('wbqc-violation-message-parameter-needed')
520
+					->rawParams($this->constraintParameterRenderer->formatItemId($constraintTypeItemId, Role::CONSTRAINT_TYPE_ITEM))
521
+					->rawParams($this->constraintParameterRenderer->formatPropertyId($formatId, Role::CONSTRAINT_PARAMETER_PROPERTY))
522 522
 					->escaped()
523 523
 			);
524 524
 		}
525 525
 
526
-		$this->requireSingleParameter( $constraintParameters, $formatId );
527
-		return $this->parseStringParameter( $constraintParameters[$formatId][0], $formatId );
526
+		$this->requireSingleParameter($constraintParameters, $formatId);
527
+		return $this->parseStringParameter($constraintParameters[$formatId][0], $formatId);
528 528
 	}
529 529
 
530 530
 	/**
@@ -532,16 +532,16 @@  discard block
 block discarded – undo
532 532
 	 * @throws ConstraintParameterException if the parameter is invalid
533 533
 	 * @return EntityId[]
534 534
 	 */
535
-	public function parseExceptionParameter( array $constraintParameters ) {
536
-		$this->checkError( $constraintParameters );
537
-		$exceptionId = $this->config->get( 'WBQualityConstraintsExceptionToConstraintId' );
538
-		if ( !array_key_exists( $exceptionId, $constraintParameters ) ) {
535
+	public function parseExceptionParameter(array $constraintParameters) {
536
+		$this->checkError($constraintParameters);
537
+		$exceptionId = $this->config->get('WBQualityConstraintsExceptionToConstraintId');
538
+		if (!array_key_exists($exceptionId, $constraintParameters)) {
539 539
 			return [];
540 540
 		}
541 541
 
542 542
 		return array_map(
543
-			function( $snakSerialization ) use ( $exceptionId ) {
544
-				return $this->parseEntityIdParameter( $snakSerialization, $exceptionId );
543
+			function($snakSerialization) use ($exceptionId) {
544
+				return $this->parseEntityIdParameter($snakSerialization, $exceptionId);
545 545
 			},
546 546
 			$constraintParameters[$exceptionId]
547 547
 		);
@@ -552,27 +552,27 @@  discard block
 block discarded – undo
552 552
 	 * @throws ConstraintParameterException if the parameter is invalid
553 553
 	 * @return string|null 'mandatory' or null
554 554
 	 */
555
-	public function parseConstraintStatusParameter( array $constraintParameters ) {
556
-		$this->checkError( $constraintParameters );
557
-		$constraintStatusId = $this->config->get( 'WBQualityConstraintsConstraintStatusId' );
558
-		if ( !array_key_exists( $constraintStatusId, $constraintParameters ) ) {
555
+	public function parseConstraintStatusParameter(array $constraintParameters) {
556
+		$this->checkError($constraintParameters);
557
+		$constraintStatusId = $this->config->get('WBQualityConstraintsConstraintStatusId');
558
+		if (!array_key_exists($constraintStatusId, $constraintParameters)) {
559 559
 			return null;
560 560
 		}
561 561
 
562
-		$mandatoryId = $this->config->get( 'WBQualityConstraintsMandatoryConstraintId' );
563
-		$this->requireSingleParameter( $constraintParameters, $constraintStatusId );
564
-		$snak = $this->snakDeserializer->deserialize( $constraintParameters[$constraintStatusId][0] );
565
-		$this->requireValueParameter( $snak, $constraintStatusId );
562
+		$mandatoryId = $this->config->get('WBQualityConstraintsMandatoryConstraintId');
563
+		$this->requireSingleParameter($constraintParameters, $constraintStatusId);
564
+		$snak = $this->snakDeserializer->deserialize($constraintParameters[$constraintStatusId][0]);
565
+		$this->requireValueParameter($snak, $constraintStatusId);
566 566
 		$statusId = $snak->getDataValue()->getEntityId()->getSerialization();
567 567
 
568
-		if ( $statusId === $mandatoryId ) {
568
+		if ($statusId === $mandatoryId) {
569 569
 			return 'mandatory';
570 570
 		} else {
571 571
 			throw new ConstraintParameterException(
572
-				wfMessage( 'wbqc-violation-message-parameter-oneof' )
573
-					->rawParams( $this->constraintParameterRenderer->formatPropertyId( $constraintStatusId, Role::CONSTRAINT_PARAMETER_PROPERTY ) )
574
-					->numParams( 1 )
575
-					->rawParams( $this->constraintParameterRenderer->formatItemIdList( [ $mandatoryId ], Role::CONSTRAINT_PARAMETER_VALUE ) )
572
+				wfMessage('wbqc-violation-message-parameter-oneof')
573
+					->rawParams($this->constraintParameterRenderer->formatPropertyId($constraintStatusId, Role::CONSTRAINT_PARAMETER_PROPERTY))
574
+					->numParams(1)
575
+					->rawParams($this->constraintParameterRenderer->formatItemIdList([$mandatoryId], Role::CONSTRAINT_PARAMETER_VALUE))
576 576
 					->escaped()
577 577
 			);
578 578
 		}
@@ -585,13 +585,13 @@  discard block
 block discarded – undo
585 585
 	 * @return void
586 586
 	 * @throws ConstraintParameterException
587 587
 	 */
588
-	private function requireMonolingualTextParameter( DataValue $dataValue, $parameterId ) {
589
-		if ( !( $dataValue instanceof MonolingualTextValue ) ) {
588
+	private function requireMonolingualTextParameter(DataValue $dataValue, $parameterId) {
589
+		if (!($dataValue instanceof MonolingualTextValue)) {
590 590
 			throw new ConstraintParameterException(
591
-				wfMessage( 'wbqc-violation-message-parameter-monolingualtext' )
591
+				wfMessage('wbqc-violation-message-parameter-monolingualtext')
592 592
 					->rawParams(
593
-						$this->constraintParameterRenderer->formatPropertyId( $parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY ),
594
-						$this->constraintParameterRenderer->formatDataValue( $dataValue, Role::CONSTRAINT_PARAMETER_VALUE )
593
+						$this->constraintParameterRenderer->formatPropertyId($parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY),
594
+						$this->constraintParameterRenderer->formatDataValue($dataValue, Role::CONSTRAINT_PARAMETER_VALUE)
595 595
 					)
596 596
 					->escaped()
597 597
 			);
@@ -606,26 +606,26 @@  discard block
 block discarded – undo
606 606
 	 * @throws ConstraintParameterException if invalid snaks are found or a language has multiple texts
607 607
 	 * @return string[]
608 608
 	 */
609
-	private function parseMultilingualTextParameter( array $snakSerializations, $parameterId ) {
609
+	private function parseMultilingualTextParameter(array $snakSerializations, $parameterId) {
610 610
 		$result = [];
611 611
 
612
-		foreach ( $snakSerializations as $snakSerialization ) {
613
-			$snak = $this->snakDeserializer->deserialize( $snakSerialization );
614
-			$this->requireValueParameter( $snak, $parameterId );
612
+		foreach ($snakSerializations as $snakSerialization) {
613
+			$snak = $this->snakDeserializer->deserialize($snakSerialization);
614
+			$this->requireValueParameter($snak, $parameterId);
615 615
 
616 616
 			$value = $snak->getDataValue();
617
-			$this->requireMonolingualTextParameter( $value, $parameterId );
617
+			$this->requireMonolingualTextParameter($value, $parameterId);
618 618
 			/** @var MonolingualTextValue $value */
619 619
 
620 620
 			$code = $value->getLanguageCode();
621
-			if ( array_key_exists( $code, $result ) ) {
621
+			if (array_key_exists($code, $result)) {
622 622
 				throw new ConstraintParameterException(
623
-					wfMessage( 'wbqc-violation-message-parameter-single-per-language' )
623
+					wfMessage('wbqc-violation-message-parameter-single-per-language')
624 624
 						->rawParams(
625
-							$this->constraintParameterRenderer->formatPropertyId( $parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY )
625
+							$this->constraintParameterRenderer->formatPropertyId($parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY)
626 626
 						)
627 627
 						->plaintextParams(
628
-							Language::fetchLanguageName( $code ),
628
+							Language::fetchLanguageName($code),
629 629
 							$code
630 630
 						)
631 631
 						->escaped()
@@ -644,23 +644,23 @@  discard block
 block discarded – undo
644 644
 	 * @throws ConstraintParameterException if the parameter is invalid
645 645
 	 * @return string|null
646 646
 	 */
647
-	public function parseSyntaxClarificationParameter( array $constraintParameters, Language $language ) {
648
-		$syntaxClarificationId = $this->config->get( 'WBQualityConstraintsSyntaxClarificationId' );
647
+	public function parseSyntaxClarificationParameter(array $constraintParameters, Language $language) {
648
+		$syntaxClarificationId = $this->config->get('WBQualityConstraintsSyntaxClarificationId');
649 649
 
650
-		if ( !array_key_exists( $syntaxClarificationId, $constraintParameters ) ) {
650
+		if (!array_key_exists($syntaxClarificationId, $constraintParameters)) {
651 651
 			return null;
652 652
 		}
653 653
 
654 654
 		$languageCodes = $language->getFallbackLanguages();
655
-		array_unshift( $languageCodes, $language->getCode() );
655
+		array_unshift($languageCodes, $language->getCode());
656 656
 
657 657
 		$syntaxClarifications = $this->parseMultilingualTextParameter(
658 658
 			$constraintParameters[$syntaxClarificationId],
659 659
 			$syntaxClarificationId
660 660
 		);
661 661
 
662
-		foreach ( $languageCodes as $languageCode ) {
663
-			if ( array_key_exists( $languageCode, $syntaxClarifications ) ) {
662
+		foreach ($languageCodes as $languageCode) {
663
+			if (array_key_exists($languageCode, $syntaxClarifications)) {
664 664
 				return $syntaxClarifications[$languageCode];
665 665
 			}
666 666
 		}
@@ -676,20 +676,20 @@  discard block
 block discarded – undo
676 676
 	 * @throws ConstraintParameterException if the parameter is invalid
677 677
 	 * @return string[]|null Context::TYPE_* constants
678 678
 	 */
679
-	public function parseConstraintScopeParameter( array $constraintParameters, $constraintTypeItemId, array $validScopes = null ) {
680
-		$constraintScopeId = $this->config->get( 'WBQualityConstraintsConstraintScopeId' );
681
-		$mainSnakId = $this->config->get( 'WBQualityConstraintsConstraintCheckedOnMainValueId' );
682
-		$qualifiersId = $this->config->get( 'WBQualityConstraintsConstraintCheckedOnQualifiersId' );
683
-		$referencesId = $this->config->get( 'WBQualityConstraintsConstraintCheckedOnReferencesId' );
679
+	public function parseConstraintScopeParameter(array $constraintParameters, $constraintTypeItemId, array $validScopes = null) {
680
+		$constraintScopeId = $this->config->get('WBQualityConstraintsConstraintScopeId');
681
+		$mainSnakId = $this->config->get('WBQualityConstraintsConstraintCheckedOnMainValueId');
682
+		$qualifiersId = $this->config->get('WBQualityConstraintsConstraintCheckedOnQualifiersId');
683
+		$referencesId = $this->config->get('WBQualityConstraintsConstraintCheckedOnReferencesId');
684 684
 
685
-		if ( !array_key_exists( $constraintScopeId, $constraintParameters ) ) {
685
+		if (!array_key_exists($constraintScopeId, $constraintParameters)) {
686 686
 			return null;
687 687
 		}
688 688
 
689 689
 		$contextTypes = [];
690
-		foreach ( $constraintParameters[$constraintScopeId] as $snakSerialization ) {
691
-			$scopeEntityId = $this->parseEntityIdParameter( $snakSerialization, $constraintScopeId );
692
-			switch ( $scopeEntityId->getSerialization() ) {
690
+		foreach ($constraintParameters[$constraintScopeId] as $snakSerialization) {
691
+			$scopeEntityId = $this->parseEntityIdParameter($snakSerialization, $constraintScopeId);
692
+			switch ($scopeEntityId->getSerialization()) {
693 693
 				case $mainSnakId:
694 694
 					$contextTypes[] = Context::TYPE_STATEMENT;
695 695
 					break;
@@ -701,14 +701,14 @@  discard block
 block discarded – undo
701 701
 					break;
702 702
 				default:
703 703
 					throw new ConstraintParameterException(
704
-						wfMessage( 'wbqc-violation-message-parameter-oneof' )
704
+						wfMessage('wbqc-violation-message-parameter-oneof')
705 705
 							->rawParams(
706 706
 								$this->constraintParameterRenderer->formatPropertyId(
707 707
 									$constraintScopeId,
708 708
 									Role::CONSTRAINT_PARAMETER_PROPERTY
709 709
 								)
710 710
 							)
711
-							->numParams( 3 )
711
+							->numParams(3)
712 712
 							->rawParams(
713 713
 								$this->constraintParameterRenderer->formatItemIdList(
714 714
 									[
@@ -724,12 +724,12 @@  discard block
 block discarded – undo
724 724
 			}
725 725
 		}
726 726
 
727
-		if ( $validScopes !== null ) {
728
-			$invalidScopes = array_diff( $contextTypes, $validScopes );
729
-			if ( $invalidScopes !== [] ) {
730
-				$invalidScope = array_pop( $invalidScopes );
727
+		if ($validScopes !== null) {
728
+			$invalidScopes = array_diff($contextTypes, $validScopes);
729
+			if ($invalidScopes !== []) {
730
+				$invalidScope = array_pop($invalidScopes);
731 731
 				throw new ConstraintParameterException(
732
-					wfMessage( 'wbqc-violation-message-invalid-scope' )
732
+					wfMessage('wbqc-violation-message-invalid-scope')
733 733
 						->rawParams(
734 734
 							$this->constraintParameterRenderer->formatConstraintScope(
735 735
 								$invalidScope,
@@ -740,7 +740,7 @@  discard block
 block discarded – undo
740 740
 								Role::CONSTRAINT_TYPE_ITEM
741 741
 							)
742 742
 						)
743
-						->numParams( count( $validScopes ) )
743
+						->numParams(count($validScopes))
744 744
 						->rawParams(
745 745
 							$this->constraintParameterRenderer->formatConstraintScopeList(
746 746
 								$validScopes,
Please login to merge, or discard this patch.
src/ConstraintParameterRenderer.php 1 patch
Spacing   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -64,20 +64,20 @@  discard block
 block discarded – undo
64 64
 	 *
65 65
 	 * @return string HTML
66 66
 	 */
67
-	public function formatValue( $value ) {
68
-		if ( is_string( $value ) ) {
67
+	public function formatValue($value) {
68
+		if (is_string($value)) {
69 69
 			// Cases like 'Format' 'pattern' or 'minimum'/'maximum' values, which we have stored as
70 70
 			// strings
71
-			return htmlspecialchars( $value );
72
-		} elseif ( $value instanceof EntityId ) {
71
+			return htmlspecialchars($value);
72
+		} elseif ($value instanceof EntityId) {
73 73
 			// Cases like 'Conflicts with' 'property', to which we can link
74
-			return $this->formatEntityId( $value );
75
-		} elseif ( $value instanceof ItemIdSnakValue ) {
74
+			return $this->formatEntityId($value);
75
+		} elseif ($value instanceof ItemIdSnakValue) {
76 76
 			// Cases like EntityId but can also be somevalue or novalue
77
-			return $this->formatItemIdSnakValue( $value );
77
+			return $this->formatItemIdSnakValue($value);
78 78
 		} else {
79 79
 			// Cases where we format a DataValue
80
-			return $this->formatDataValue( $value );
80
+			return $this->formatDataValue($value);
81 81
 		}
82 82
 	}
83 83
 
@@ -88,23 +88,23 @@  discard block
 block discarded – undo
88 88
 	 *
89 89
 	 * @return string HTML
90 90
 	 */
91
-	public function formatParameters( $parameters ) {
92
-		if ( $parameters === null || count( $parameters ) == 0 ) {
91
+	public function formatParameters($parameters) {
92
+		if ($parameters === null || count($parameters) == 0) {
93 93
 			return null;
94 94
 		}
95 95
 
96
-		$valueFormatter = function ( $value ) {
97
-			return $this->formatValue( $value );
96
+		$valueFormatter = function($value) {
97
+			return $this->formatValue($value);
98 98
 		};
99 99
 
100 100
 		$formattedParameters = [];
101
-		foreach ( $parameters as $parameterName => $parameterValue ) {
102
-			$formattedParameterValues = implode( ', ',
103
-				$this->limitArrayLength( array_map( $valueFormatter, $parameterValue ) ) );
104
-			$formattedParameters[] = sprintf( '%s: %s', $parameterName, $formattedParameterValues );
101
+		foreach ($parameters as $parameterName => $parameterValue) {
102
+			$formattedParameterValues = implode(', ',
103
+				$this->limitArrayLength(array_map($valueFormatter, $parameterValue)));
104
+			$formattedParameters[] = sprintf('%s: %s', $parameterName, $formattedParameterValues);
105 105
 		}
106 106
 
107
-		return implode( '; ', $formattedParameters );
107
+		return implode('; ', $formattedParameters);
108 108
 	}
109 109
 
110 110
 	/**
@@ -114,10 +114,10 @@  discard block
 block discarded – undo
114 114
 	 *
115 115
 	 * @return array
116 116
 	 */
117
-	private function limitArrayLength( array $array ) {
118
-		if ( count( $array ) > self::MAX_PARAMETER_ARRAY_LENGTH ) {
119
-			$array = array_slice( $array, 0, self::MAX_PARAMETER_ARRAY_LENGTH );
120
-			array_push( $array, '...' );
117
+	private function limitArrayLength(array $array) {
118
+		if (count($array) > self::MAX_PARAMETER_ARRAY_LENGTH) {
119
+			$array = array_slice($array, 0, self::MAX_PARAMETER_ARRAY_LENGTH);
120
+			array_push($array, '...');
121 121
 		}
122 122
 
123 123
 		return $array;
@@ -130,12 +130,12 @@  discard block
 block discarded – undo
130 130
 	 * @param string $value HTML
131 131
 	 * @return string HTML
132 132
 	 */
133
-	public static function formatByRole( $role, $value ) {
134
-		if ( $role === null ) {
133
+	public static function formatByRole($role, $value) {
134
+		if ($role === null) {
135 135
 			return $value;
136 136
 		}
137 137
 
138
-		return '<span class="wbqc-role wbqc-role-' . htmlspecialchars( $role ) . '">'
138
+		return '<span class="wbqc-role wbqc-role-'.htmlspecialchars($role).'">'
139 139
 			. $value
140 140
 			. '</span>';
141 141
 	}
@@ -145,9 +145,9 @@  discard block
 block discarded – undo
145 145
 	 * @param string|null $role one of the Role constants or null
146 146
 	 * @return string HTML
147 147
 	 */
148
-	public function formatDataValue( DataValue $value, $role = null ) {
149
-		return self::formatByRole( $role,
150
-			$this->dataValueFormatter->format( $value ) );
148
+	public function formatDataValue(DataValue $value, $role = null) {
149
+		return self::formatByRole($role,
150
+			$this->dataValueFormatter->format($value));
151 151
 	}
152 152
 
153 153
 	/**
@@ -155,9 +155,9 @@  discard block
 block discarded – undo
155 155
 	 * @param string|null $role one of the Role constants or null
156 156
 	 * @return string HTML
157 157
 	 */
158
-	public function formatEntityId( EntityId $entityId, $role = null ) {
159
-		return self::formatByRole( $role,
160
-			$this->entityIdLabelFormatter->formatEntityId( $entityId ) );
158
+	public function formatEntityId(EntityId $entityId, $role = null) {
159
+		return self::formatByRole($role,
160
+			$this->entityIdLabelFormatter->formatEntityId($entityId));
161 161
 	}
162 162
 
163 163
 	/**
@@ -169,18 +169,18 @@  discard block
 block discarded – undo
169 169
 	 * @param string|null $role one of the Role constants or null
170 170
 	 * @return string HTML
171 171
 	 */
172
-	public function formatPropertyId( $propertyId, $role = null ) {
173
-		if ( $propertyId instanceof PropertyId ) {
174
-			return $this->formatEntityId( $propertyId, $role );
175
-		} elseif ( is_string( $propertyId ) ) {
172
+	public function formatPropertyId($propertyId, $role = null) {
173
+		if ($propertyId instanceof PropertyId) {
174
+			return $this->formatEntityId($propertyId, $role);
175
+		} elseif (is_string($propertyId)) {
176 176
 			try {
177
-				return $this->formatEntityId( new PropertyId( $propertyId ), $role );
178
-			} catch ( InvalidArgumentException $e ) {
179
-				return self::formatByRole( $role,
180
-					htmlspecialchars( $propertyId ) );
177
+				return $this->formatEntityId(new PropertyId($propertyId), $role);
178
+			} catch (InvalidArgumentException $e) {
179
+				return self::formatByRole($role,
180
+					htmlspecialchars($propertyId));
181 181
 			}
182 182
 		} else {
183
-			throw new InvalidArgumentException( '$propertyId must be either PropertyId or string' );
183
+			throw new InvalidArgumentException('$propertyId must be either PropertyId or string');
184 184
 		}
185 185
 	}
186 186
 
@@ -193,18 +193,18 @@  discard block
 block discarded – undo
193 193
 	 * @param string|null $role one of the Role constants or null
194 194
 	 * @return string HTML
195 195
 	 */
196
-	public function formatItemId( $itemId, $role = null ) {
197
-		if ( $itemId instanceof ItemId ) {
198
-			return $this->formatEntityId( $itemId, $role );
199
-		} elseif ( is_string( $itemId ) ) {
196
+	public function formatItemId($itemId, $role = null) {
197
+		if ($itemId instanceof ItemId) {
198
+			return $this->formatEntityId($itemId, $role);
199
+		} elseif (is_string($itemId)) {
200 200
 			try {
201
-				return $this->formatEntityId( new ItemId( $itemId ), $role );
202
-			} catch ( InvalidArgumentException $e ) {
203
-				return self::formatByRole( $role,
204
-					htmlspecialchars( $itemId ) );
201
+				return $this->formatEntityId(new ItemId($itemId), $role);
202
+			} catch (InvalidArgumentException $e) {
203
+				return self::formatByRole($role,
204
+					htmlspecialchars($itemId));
205 205
 			}
206 206
 		} else {
207
-			throw new InvalidArgumentException( '$itemId must be either ItemId or string' );
207
+			throw new InvalidArgumentException('$itemId must be either ItemId or string');
208 208
 		}
209 209
 	}
210 210
 
@@ -215,20 +215,20 @@  discard block
 block discarded – undo
215 215
 	 * @param string|null $role one of the Role constants or null
216 216
 	 * @return string HTML
217 217
 	 */
218
-	public function formatItemIdSnakValue( ItemIdSnakValue $value, $role = null ) {
219
-		switch ( true ) {
218
+	public function formatItemIdSnakValue(ItemIdSnakValue $value, $role = null) {
219
+		switch (true) {
220 220
 			case $value->isValue():
221
-				return $this->formatEntityId( $value->getItemId(), $role );
221
+				return $this->formatEntityId($value->getItemId(), $role);
222 222
 			case $value->isSomeValue():
223
-				return self::formatByRole( $role,
223
+				return self::formatByRole($role,
224 224
 					'<span class="wikibase-snakview-variation-somevaluesnak">'
225
-						. wfMessage( 'wikibase-snakview-snaktypeselector-somevalue' )->escaped()
226
-						. '</span>' );
225
+						. wfMessage('wikibase-snakview-snaktypeselector-somevalue')->escaped()
226
+						. '</span>');
227 227
 			case $value->isNoValue():
228
-				return self::formatByRole( $role,
228
+				return self::formatByRole($role,
229 229
 					'<span class="wikibase-snakview-variation-novaluesnak">'
230
-						. wfMessage( 'wikibase-snakview-snaktypeselector-novalue' )->escaped()
231
-						. '</span>' );
230
+						. wfMessage('wikibase-snakview-snaktypeselector-novalue')->escaped()
231
+						. '</span>');
232 232
 		}
233 233
 	}
234 234
 
@@ -239,8 +239,8 @@  discard block
 block discarded – undo
239 239
 	 * @param string|null $role one of the Role constants or null
240 240
 	 * @return string HTML
241 241
 	 */
242
-	public function formatConstraintScope( $scope, $role = null ) {
243
-		switch ( $scope ) {
242
+	public function formatConstraintScope($scope, $role = null) {
243
+		switch ($scope) {
244 244
 			case Context::TYPE_STATEMENT:
245 245
 				$itemId = $this->config->get(
246 246
 					'WBQualityConstraintsConstraintCheckedOnMainValueId'
@@ -260,10 +260,10 @@  discard block
 block discarded – undo
260 260
 				// callers should never let this happen, but if it does happen,
261 261
 				// showing “unknown value” seems reasonable
262 262
 				// @codeCoverageIgnoreStart
263
-				return $this->formatItemIdSnakValue( ItemIdSnakValue::someValue(), $role );
263
+				return $this->formatItemIdSnakValue(ItemIdSnakValue::someValue(), $role);
264 264
 				// @codeCoverageIgnoreEnd
265 265
 		}
266
-		return $this->formatItemId( $itemId, $role );
266
+		return $this->formatItemId($itemId, $role);
267 267
 	}
268 268
 
269 269
 	/**
@@ -276,15 +276,15 @@  discard block
 block discarded – undo
276 276
 	 * @param string|null $role one of the Role constants or null
277 277
 	 * @return string[] HTML
278 278
 	 */
279
-	public function formatPropertyIdList( array $propertyIds, $role = null ) {
280
-		if ( empty( $propertyIds ) ) {
281
-			return [ '<ul></ul>' ];
279
+	public function formatPropertyIdList(array $propertyIds, $role = null) {
280
+		if (empty($propertyIds)) {
281
+			return ['<ul></ul>'];
282 282
 		}
283
-		$propertyIds = $this->limitArrayLength( $propertyIds );
284
-		$formattedPropertyIds = array_map( [ $this, "formatPropertyId" ], $propertyIds, array_fill( 0, count( $propertyIds ), $role ) );
283
+		$propertyIds = $this->limitArrayLength($propertyIds);
284
+		$formattedPropertyIds = array_map([$this, "formatPropertyId"], $propertyIds, array_fill(0, count($propertyIds), $role));
285 285
 		array_unshift(
286 286
 			$formattedPropertyIds,
287
-			'<ul><li>' . implode( '</li><li>', $formattedPropertyIds ) . '</li></ul>'
287
+			'<ul><li>'.implode('</li><li>', $formattedPropertyIds).'</li></ul>'
288 288
 		);
289 289
 		return $formattedPropertyIds;
290 290
 	}
@@ -299,15 +299,15 @@  discard block
 block discarded – undo
299 299
 	 * @param string|null $role one of the Role constants or null
300 300
 	 * @return string[] HTML
301 301
 	 */
302
-	public function formatItemIdList( array $itemIds, $role = null ) {
303
-		if ( empty( $itemIds ) ) {
304
-			return [ '<ul></ul>' ];
302
+	public function formatItemIdList(array $itemIds, $role = null) {
303
+		if (empty($itemIds)) {
304
+			return ['<ul></ul>'];
305 305
 		}
306
-		$itemIds = $this->limitArrayLength( $itemIds );
307
-		$formattedItemIds = array_map( [ $this, "formatItemId" ], $itemIds, array_fill( 0, count( $itemIds ), $role ) );
306
+		$itemIds = $this->limitArrayLength($itemIds);
307
+		$formattedItemIds = array_map([$this, "formatItemId"], $itemIds, array_fill(0, count($itemIds), $role));
308 308
 		array_unshift(
309 309
 			$formattedItemIds,
310
-			'<ul><li>' . implode( '</li><li>', $formattedItemIds ) . '</li></ul>'
310
+			'<ul><li>'.implode('</li><li>', $formattedItemIds).'</li></ul>'
311 311
 		);
312 312
 		return $formattedItemIds;
313 313
 	}
@@ -322,23 +322,23 @@  discard block
 block discarded – undo
322 322
 	 * @param string|null $role one of the Role constants or null
323 323
 	 * @return string[] HTML
324 324
 	 */
325
-	public function formatEntityIdList( array $entityIds, $role = null ) {
326
-		if ( empty( $entityIds ) ) {
327
-			return [ '<ul></ul>' ];
325
+	public function formatEntityIdList(array $entityIds, $role = null) {
326
+		if (empty($entityIds)) {
327
+			return ['<ul></ul>'];
328 328
 		}
329 329
 		$formattedEntityIds = [];
330
-		foreach ( $entityIds as $entityId ) {
331
-			if ( count( $formattedEntityIds ) >= self::MAX_PARAMETER_ARRAY_LENGTH ) {
330
+		foreach ($entityIds as $entityId) {
331
+			if (count($formattedEntityIds) >= self::MAX_PARAMETER_ARRAY_LENGTH) {
332 332
 				$formattedEntityIds[] = '...';
333 333
 				break;
334 334
 			}
335
-			if ( $entityId !== null ) {
336
-				$formattedEntityIds[] = $this->formatEntityId( $entityId, $role );
335
+			if ($entityId !== null) {
336
+				$formattedEntityIds[] = $this->formatEntityId($entityId, $role);
337 337
 			}
338 338
 		}
339 339
 		array_unshift(
340 340
 			$formattedEntityIds,
341
-			'<ul><li>' . implode( '</li><li>', $formattedEntityIds ) . '</li></ul>'
341
+			'<ul><li>'.implode('</li><li>', $formattedEntityIds).'</li></ul>'
342 342
 		);
343 343
 		return $formattedEntityIds;
344 344
 	}
@@ -353,24 +353,24 @@  discard block
 block discarded – undo
353 353
 	 * @param string|null $role one of the Role constants or null
354 354
 	 * @return string[] HTML
355 355
 	 */
356
-	public function formatItemIdSnakValueList( array $values, $role = null ) {
357
-		if ( empty( $values ) ) {
358
-			return [ '<ul></ul>' ];
356
+	public function formatItemIdSnakValueList(array $values, $role = null) {
357
+		if (empty($values)) {
358
+			return ['<ul></ul>'];
359 359
 		}
360
-		$values = $this->limitArrayLength( $values );
360
+		$values = $this->limitArrayLength($values);
361 361
 		$formattedValues = array_map(
362
-			function( $value ) use ( $role ) {
363
-				if ( $value === '...' ) {
362
+			function($value) use ($role) {
363
+				if ($value === '...') {
364 364
 					return '...';
365 365
 				} else {
366
-					return $this->formatItemIdSnakValue( $value, $role );
366
+					return $this->formatItemIdSnakValue($value, $role);
367 367
 				}
368 368
 			},
369 369
 			$values
370 370
 		);
371 371
 		array_unshift(
372 372
 			$formattedValues,
373
-			'<ul><li>' . implode( '</li><li>', $formattedValues ) . '</li></ul>'
373
+			'<ul><li>'.implode('</li><li>', $formattedValues).'</li></ul>'
374 374
 		);
375 375
 		return $formattedValues;
376 376
 	}
@@ -385,24 +385,24 @@  discard block
 block discarded – undo
385 385
 	 * @param string|null $role one of the Role constants or null
386 386
 	 * @return string[] HTML
387 387
 	 */
388
-	public function formatConstraintScopeList( array $scopes, $role = null ) {
389
-		if ( empty( $scopes ) ) {
390
-			return [ '<ul></ul>' ];
388
+	public function formatConstraintScopeList(array $scopes, $role = null) {
389
+		if (empty($scopes)) {
390
+			return ['<ul></ul>'];
391 391
 		}
392
-		$scopes = $this->limitArrayLength( $scopes );
392
+		$scopes = $this->limitArrayLength($scopes);
393 393
 		$formattedScopes = array_map(
394
-			function( $scope ) use ( $role ) {
395
-				if ( $scope === '...' ) {
394
+			function($scope) use ($role) {
395
+				if ($scope === '...') {
396 396
 					return '...';
397 397
 				} else {
398
-					return $this->formatConstraintScope( $scope, $role );
398
+					return $this->formatConstraintScope($scope, $role);
399 399
 				}
400 400
 			},
401 401
 			$scopes
402 402
 		);
403 403
 		array_unshift(
404 404
 			$formattedScopes,
405
-			'<ul><li>' . implode( '</li><li>', $formattedScopes ) . '</li></ul>'
405
+			'<ul><li>'.implode('</li><li>', $formattedScopes).'</li></ul>'
406 406
 		);
407 407
 		return $formattedScopes;
408 408
 	}
Please login to merge, or discard this patch.
src/Api/CheckConstraints.php 1 patch
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -73,21 +73,21 @@  discard block
 block discarded – undo
73 73
 	 *
74 74
 	 * @return self
75 75
 	 */
76
-	public static function newFromGlobalState( ApiMain $main, $name, $prefix = '' ) {
76
+	public static function newFromGlobalState(ApiMain $main, $name, $prefix = '') {
77 77
 		$repo = WikibaseRepo::getDefaultInstance();
78 78
 
79 79
 		$language = $repo->getUserLanguage();
80 80
 		$formatterOptions = new FormatterOptions();
81
-		$formatterOptions->setOption( SnakFormatter::OPT_LANG, $language->getCode() );
81
+		$formatterOptions->setOption(SnakFormatter::OPT_LANG, $language->getCode());
82 82
 		$valueFormatterFactory = $repo->getValueFormatterFactory();
83
-		$valueFormatter = $valueFormatterFactory->getValueFormatter( SnakFormatter::FORMAT_HTML, $formatterOptions );
83
+		$valueFormatter = $valueFormatterFactory->getValueFormatter(SnakFormatter::FORMAT_HTML, $formatterOptions);
84 84
 
85 85
 		$languageFallbackLabelDescriptionLookupFactory = $repo->getLanguageFallbackLabelDescriptionLookupFactory();
86
-		$labelDescriptionLookup = $languageFallbackLabelDescriptionLookupFactory->newLabelDescriptionLookup( $language );
86
+		$labelDescriptionLookup = $languageFallbackLabelDescriptionLookupFactory->newLabelDescriptionLookup($language);
87 87
 		$entityIdHtmlLinkFormatterFactory = $repo->getEntityIdHtmlLinkFormatterFactory();
88
-		$entityIdHtmlLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter( $labelDescriptionLookup );
88
+		$entityIdHtmlLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter($labelDescriptionLookup);
89 89
 		$entityIdLabelFormatterFactory = new EntityIdLabelFormatterFactory();
90
-		$entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter( $labelDescriptionLookup );
90
+		$entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter($labelDescriptionLookup);
91 91
 		$config = MediaWikiServices::getInstance()->getMainConfig();
92 92
 		$titleParser = MediaWikiServices::getInstance()->getTitleParser();
93 93
 		$unitConverter = $repo->getUnitConverter();
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 			$constraintParameterRenderer,
123 123
 			$config
124 124
 		);
125
-		if ( $config->get( 'WBQualityConstraintsCacheCheckConstraintsResults' ) ) {
125
+		if ($config->get('WBQualityConstraintsCacheCheckConstraintsResults')) {
126 126
 			$wikiPageEntityMetaDataAccessor = new WikiPageEntityMetaDataLookup(
127 127
 				$repo->getEntityNamespaceLookup()
128 128
 			);
@@ -133,12 +133,12 @@  discard block
 block discarded – undo
133 133
 				ResultsCache::getDefaultInstance(),
134 134
 				$wikiPageEntityMetaDataAccessor,
135 135
 				$entityIdParser,
136
-				$config->get( 'WBQualityConstraintsCacheCheckConstraintsTTLSeconds' ),
136
+				$config->get('WBQualityConstraintsCacheCheckConstraintsTTLSeconds'),
137 137
 				[
138
-					$config->get( 'WBQualityConstraintsCommonsLinkConstraintId' ),
139
-					$config->get( 'WBQualityConstraintsTypeConstraintId' ),
140
-					$config->get( 'WBQualityConstraintsValueTypeConstraintId' ),
141
-					$config->get( 'WBQualityConstraintsDistinctValuesConstraintId' ),
138
+					$config->get('WBQualityConstraintsCommonsLinkConstraintId'),
139
+					$config->get('WBQualityConstraintsTypeConstraintId'),
140
+					$config->get('WBQualityConstraintsValueTypeConstraintId'),
141
+					$config->get('WBQualityConstraintsDistinctValuesConstraintId'),
142 142
 				],
143 143
 				$dataFactory
144 144
 			);
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 			$prefix,
151 151
 			$repo->getEntityIdParser(),
152 152
 			$repo->getStatementGuidValidator(),
153
-			$repo->getApiHelperFactory( RequestContext::getMain() ),
153
+			$repo->getApiHelperFactory(RequestContext::getMain()),
154 154
 			$resultsBuilder,
155 155
 			$dataFactory
156 156
 		);
@@ -176,11 +176,11 @@  discard block
 block discarded – undo
176 176
 		ResultsBuilder $resultsBuilder,
177 177
 		IBufferingStatsdDataFactory $dataFactory
178 178
 	) {
179
-		parent::__construct( $main, $name, $prefix );
179
+		parent::__construct($main, $name, $prefix);
180 180
 		$this->entityIdParser = $entityIdParser;
181 181
 		$this->statementGuidValidator = $statementGuidValidator;
182
-		$this->resultBuilder = $apiHelperFactory->getResultBuilder( $this );
183
-		$this->errorReporter = $apiHelperFactory->getErrorReporter( $this );
182
+		$this->resultBuilder = $apiHelperFactory->getResultBuilder($this);
183
+		$this->errorReporter = $apiHelperFactory->getErrorReporter($this);
184 184
 		$this->resultsBuilder = $resultsBuilder;
185 185
 		$this->dataFactory = $dataFactory;
186 186
 	}
@@ -195,9 +195,9 @@  discard block
 block discarded – undo
195 195
 
196 196
 		$params = $this->extractRequestParams();
197 197
 
198
-		$this->validateParameters( $params );
199
-		$entityIds = $this->parseEntityIds( $params );
200
-		$claimIds = $this->parseClaimIds( $params );
198
+		$this->validateParameters($params);
199
+		$entityIds = $this->parseEntityIds($params);
200
+		$claimIds = $this->parseClaimIds($params);
201 201
 		$constraintIDs = $params[self::PARAM_CONSTRAINT_ID];
202 202
 
203 203
 		$this->getResult()->addValue(
@@ -209,64 +209,64 @@  discard block
 block discarded – undo
209 209
 			)->getArray()
210 210
 		);
211 211
 		// ensure that result contains the given entity IDs even if they have no statements
212
-		foreach ( $entityIds as $entityId ) {
212
+		foreach ($entityIds as $entityId) {
213 213
 			$this->getResult()->addArrayType(
214
-				[ $this->getModuleName(), $entityId->getSerialization() ],
214
+				[$this->getModuleName(), $entityId->getSerialization()],
215 215
 				'assoc'
216 216
 			);
217 217
 		}
218
-		$this->resultBuilder->markSuccess( 1 );
218
+		$this->resultBuilder->markSuccess(1);
219 219
 	}
220 220
 
221
-	private function parseEntityIds( array $params ) {
221
+	private function parseEntityIds(array $params) {
222 222
 		$ids = $params[self::PARAM_ID];
223 223
 
224
-		if ( $ids === null ) {
224
+		if ($ids === null) {
225 225
 			return [];
226
-		} elseif ( $ids === [] ) {
226
+		} elseif ($ids === []) {
227 227
 			$this->errorReporter->dieError(
228
-				'If ' . self::PARAM_ID . ' is specified, it must be nonempty.', 'no-data' );
228
+				'If '.self::PARAM_ID.' is specified, it must be nonempty.', 'no-data' );
229 229
 		}
230 230
 
231
-		return array_map( function ( $id ) {
231
+		return array_map(function($id) {
232 232
 			try {
233
-				return $this->entityIdParser->parse( $id );
234
-			} catch ( EntityIdParsingException $e ) {
233
+				return $this->entityIdParser->parse($id);
234
+			} catch (EntityIdParsingException $e) {
235 235
 				$this->errorReporter->dieError(
236
-					"Invalid id: $id", 'invalid-entity-id', 0, [ self::PARAM_ID => $id ] );
236
+					"Invalid id: $id", 'invalid-entity-id', 0, [self::PARAM_ID => $id] );
237 237
 			}
238
-		}, $ids );
238
+		}, $ids);
239 239
 	}
240 240
 
241
-	private function parseClaimIds( array $params ) {
241
+	private function parseClaimIds(array $params) {
242 242
 		$ids = $params[self::PARAM_CLAIM_ID];
243 243
 
244
-		if ( $ids === null ) {
244
+		if ($ids === null) {
245 245
 			return [];
246
-		} elseif ( $ids === [] ) {
246
+		} elseif ($ids === []) {
247 247
 			$this->errorReporter->dieError(
248
-				'If ' . self::PARAM_CLAIM_ID . ' is specified, it must be nonempty.', 'no-data' );
248
+				'If '.self::PARAM_CLAIM_ID.' is specified, it must be nonempty.', 'no-data' );
249 249
 		}
250 250
 
251
-		foreach ( $ids as $id ) {
252
-			if ( !$this->statementGuidValidator->validate( $id ) ) {
251
+		foreach ($ids as $id) {
252
+			if (!$this->statementGuidValidator->validate($id)) {
253 253
 				$this->errorReporter->dieError(
254
-					"Invalid claim id: $id", 'invalid-guid', 0, [ self::PARAM_CLAIM_ID => $id ] );
254
+					"Invalid claim id: $id", 'invalid-guid', 0, [self::PARAM_CLAIM_ID => $id] );
255 255
 			}
256 256
 		}
257 257
 
258 258
 		return $ids;
259 259
 	}
260 260
 
261
-	private function validateParameters( array $params ) {
262
-		if ( $params[self::PARAM_CONSTRAINT_ID] !== null
263
-			 && empty( $params[self::PARAM_CONSTRAINT_ID] )
261
+	private function validateParameters(array $params) {
262
+		if ($params[self::PARAM_CONSTRAINT_ID] !== null
263
+			 && empty($params[self::PARAM_CONSTRAINT_ID])
264 264
 		) {
265 265
 			$paramConstraintId = self::PARAM_CONSTRAINT_ID;
266 266
 			$this->errorReporter->dieError(
267 267
 				"If $paramConstraintId is specified, it must be nonempty.", 'no-data' );
268 268
 		}
269
-		if ( $params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null ) {
269
+		if ($params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null) {
270 270
 			$paramId = self::PARAM_ID;
271 271
 			$paramClaimId = self::PARAM_CLAIM_ID;
272 272
 			$this->errorReporter->dieError(
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/TypeChecker.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -89,32 +89,32 @@  discard block
 block discarded – undo
89 89
 	 * @throws SparqlHelperException if the checker uses SPARQL and the query times out or some other error occurs
90 90
 	 * @return CheckResult
91 91
 	 */
92
-	public function checkConstraint( Context $context, Constraint $constraint ) {
93
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
94
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
92
+	public function checkConstraint(Context $context, Constraint $constraint) {
93
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
94
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
95 95
 		}
96
-		if ( $context->getType() === Context::TYPE_REFERENCE ) {
97
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_NOT_IN_SCOPE );
96
+		if ($context->getType() === Context::TYPE_REFERENCE) {
97
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_NOT_IN_SCOPE);
98 98
 		}
99 99
 
100 100
 		$parameters = [];
101 101
 		$constraintParameters = $constraint->getConstraintParameters();
102 102
 
103
-		$classes = $this->constraintParameterParser->parseClassParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
103
+		$classes = $this->constraintParameterParser->parseClassParameter($constraintParameters, $constraint->getConstraintTypeItemId());
104 104
 		$parameters['class'] = array_map(
105
-			function( $id ) {
106
-				return new ItemId( $id );
105
+			function($id) {
106
+				return new ItemId($id);
107 107
 			},
108 108
 			$classes
109 109
 		);
110 110
 
111
-		$relation = $this->constraintParameterParser->parseRelationParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
112
-		if ( $relation === 'instance' ) {
113
-			$relationId = $this->config->get( 'WBQualityConstraintsInstanceOfId' );
114
-		} elseif ( $relation === 'subclass' ) {
115
-			$relationId = $this->config->get( 'WBQualityConstraintsSubclassOfId' );
111
+		$relation = $this->constraintParameterParser->parseRelationParameter($constraintParameters, $constraint->getConstraintTypeItemId());
112
+		if ($relation === 'instance') {
113
+			$relationId = $this->config->get('WBQualityConstraintsInstanceOfId');
114
+		} elseif ($relation === 'subclass') {
115
+			$relationId = $this->config->get('WBQualityConstraintsSubclassOfId');
116 116
 		}
117
-		$parameters['relation'] = [ $relation ];
117
+		$parameters['relation'] = [$relation];
118 118
 
119 119
 		$result = $this->typeCheckerHelper->hasClassInRelation(
120 120
 			$context->getEntity()->getStatements(),
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 			$classes
123 123
 		);
124 124
 
125
-		if ( $result->getBool() ) {
125
+		if ($result->getBool()) {
126 126
 			$message = '';
127 127
 			$status = CheckResult::STATUS_COMPLIANCE;
128 128
 		} else {
@@ -136,21 +136,21 @@  discard block
 block discarded – undo
136 136
 			$status = CheckResult::STATUS_VIOLATION;
137 137
 		}
138 138
 
139
-		return ( new CheckResult( $context, $constraint, $parameters, $status, $message ) )
140
-			->withMetadata( $result->getMetadata() );
139
+		return (new CheckResult($context, $constraint, $parameters, $status, $message))
140
+			->withMetadata($result->getMetadata());
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->parseClassParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
148
-		} catch ( ConstraintParameterException $e ) {
147
+			$this->constraintParameterParser->parseClassParameter($constraintParameters, $constraint->getConstraintTypeItemId());
148
+		} catch (ConstraintParameterException $e) {
149 149
 			$exceptions[] = $e;
150 150
 		}
151 151
 		try {
152
-			$this->constraintParameterParser->parseRelationParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
153
-		} catch ( ConstraintParameterException $e ) {
152
+			$this->constraintParameterParser->parseRelationParameter($constraintParameters, $constraint->getConstraintTypeItemId());
153
+		} catch (ConstraintParameterException $e) {
154 154
 			$exceptions[] = $e;
155 155
 		}
156 156
 		return $exceptions;
Please login to merge, or discard this patch.