Completed
Push — master ( 32f774...cae730 )
by
unknown
02:30
created
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
 	 *
83 83
 	 * @throws SparqlHelperException if the checker uses SPARQL and the query times out or some other error occurs
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/TargetRequiredClaimChecker.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -70,25 +70,25 @@  discard block
 block discarded – undo
70 70
 	 *
71 71
 	 * @return CheckResult
72 72
 	 */
73
-	public function checkConstraint( Context $context, Constraint $constraint ) {
74
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
75
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
73
+	public function checkConstraint(Context $context, Constraint $constraint) {
74
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
75
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
76 76
 		}
77 77
 
78 78
 		$parameters = [];
79 79
 		$constraintParameters = $constraint->getConstraintParameters();
80 80
 
81
-		$propertyId = $this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
82
-		$parameters['property'] = [ $propertyId ];
81
+		$propertyId = $this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId());
82
+		$parameters['property'] = [$propertyId];
83 83
 
84
-		$items = $this->constraintParameterParser->parseItemsParameter( $constraintParameters, $constraint->getConstraintTypeItemId(), false );
84
+		$items = $this->constraintParameterParser->parseItemsParameter($constraintParameters, $constraint->getConstraintTypeItemId(), false);
85 85
 		$parameters['items'] = $items;
86 86
 
87 87
 		$snak = $context->getSnak();
88 88
 
89
-		if ( !$snak instanceof PropertyValueSnak ) {
89
+		if (!$snak instanceof PropertyValueSnak) {
90 90
 			// nothing to check
91
-			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE, '' );
91
+			return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE, '');
92 92
 		}
93 93
 
94 94
 		$dataValue = $snak->getDataValue();
@@ -97,22 +97,22 @@  discard block
 block discarded – undo
97 97
 		 * error handling:
98 98
 		 *   type of $dataValue for properties with 'Target required claim' constraint has to be 'wikibase-entityid'
99 99
 		 */
100
-		if ( $dataValue->getType() !== 'wikibase-entityid' ) {
101
-			$message = wfMessage( "wbqc-violation-message-value-needed-of-type" )
100
+		if ($dataValue->getType() !== 'wikibase-entityid') {
101
+			$message = wfMessage("wbqc-violation-message-value-needed-of-type")
102 102
 				->rawParams(
103
-					$this->constraintParameterRenderer->formatItemId( $constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM ),
103
+					$this->constraintParameterRenderer->formatItemId($constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM),
104 104
 					'wikibase-entityid' // TODO is there a message for this type so we can localize it?
105 105
 				)
106 106
 				->escaped();
107
-			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message );
107
+			return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message);
108 108
 		}
109 109
 		/** @var EntityIdValue $dataValue */
110 110
 
111 111
 		$targetEntityId = $dataValue->getEntityId();
112
-		$targetEntity = $this->entityLookup->getEntity( $targetEntityId );
113
-		if ( $targetEntity === null ) {
114
-			$message = wfMessage( "wbqc-violation-message-target-entity-must-exist" )->escaped();
115
-			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message );
112
+		$targetEntity = $this->entityLookup->getEntity($targetEntityId);
113
+		if ($targetEntity === null) {
114
+			$message = wfMessage("wbqc-violation-message-target-entity-must-exist")->escaped();
115
+			return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message);
116 116
 		}
117 117
 
118 118
 		/*
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 		 *   a) a property only
121 121
 		 *   b) a property and a number of items (each combination forming an individual claim)
122 122
 		 */
123
-		if ( $items === [] ) {
123
+		if ($items === []) {
124 124
 			$requiredStatement = $this->connectionCheckerHelper->findStatementWithProperty(
125 125
 				$targetEntity->getStatements(),
126 126
 				$propertyId
@@ -133,37 +133,37 @@  discard block
 block discarded – undo
133 133
 			);
134 134
 		}
135 135
 
136
-		if ( $requiredStatement !== null ) {
136
+		if ($requiredStatement !== null) {
137 137
 			$status = CheckResult::STATUS_COMPLIANCE;
138 138
 			$message = '';
139 139
 		} else {
140 140
 			$status = CheckResult::STATUS_VIOLATION;
141
-			$message = wfMessage( 'wbqc-violation-message-target-required-claim' );
141
+			$message = wfMessage('wbqc-violation-message-target-required-claim');
142 142
 			$message->rawParams(
143
-				$this->constraintParameterRenderer->formatEntityId( $targetEntityId, Role::SUBJECT ),
144
-				$this->constraintParameterRenderer->formatEntityId( $propertyId, Role::PREDICATE )
143
+				$this->constraintParameterRenderer->formatEntityId($targetEntityId, Role::SUBJECT),
144
+				$this->constraintParameterRenderer->formatEntityId($propertyId, Role::PREDICATE)
145 145
 			);
146
-			$message->numParams( count( $items ) );
147
-			$message->rawParams( $this->constraintParameterRenderer->formatItemIdSnakValueList( $items, Role::OBJECT ) );
146
+			$message->numParams(count($items));
147
+			$message->rawParams($this->constraintParameterRenderer->formatItemIdSnakValueList($items, Role::OBJECT));
148 148
 			$message = $message->escaped();
149 149
 		}
150 150
 
151
-		return ( new CheckResult( $context, $constraint, $parameters, $status, $message ) )
152
-			->withMetadata( Metadata::ofDependencyMetadata(
153
-				DependencyMetadata::ofEntityId( $targetEntityId ) ) );
151
+		return (new CheckResult($context, $constraint, $parameters, $status, $message))
152
+			->withMetadata(Metadata::ofDependencyMetadata(
153
+				DependencyMetadata::ofEntityId($targetEntityId) ));
154 154
 	}
155 155
 
156
-	public function checkConstraintParameters( Constraint $constraint ) {
156
+	public function checkConstraintParameters(Constraint $constraint) {
157 157
 		$constraintParameters = $constraint->getConstraintParameters();
158 158
 		$exceptions = [];
159 159
 		try {
160
-			$this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
161
-		} catch ( ConstraintParameterException $e ) {
160
+			$this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId());
161
+		} catch (ConstraintParameterException $e) {
162 162
 			$exceptions[] = $e;
163 163
 		}
164 164
 		try {
165
-			$this->constraintParameterParser->parseItemsParameter( $constraintParameters, $constraint->getConstraintTypeItemId(), false );
166
-		} catch ( ConstraintParameterException $e ) {
165
+			$this->constraintParameterParser->parseItemsParameter($constraintParameters, $constraint->getConstraintTypeItemId(), false);
166
+		} catch (ConstraintParameterException $e) {
167 167
 			$exceptions[] = $e;
168 168
 		}
169 169
 		return $exceptions;
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
@@ -69,32 +69,32 @@  discard block
 block discarded – undo
69 69
 	 *
70 70
 	 * @throws SparqlHelperException if the checker uses SPARQL and the query times out or some other error occurs
71 71
 	 */
72
-	public function checkConstraint( Context $context, Constraint $constraint ) {
73
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
74
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
72
+	public function checkConstraint(Context $context, Constraint $constraint) {
73
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
74
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
75 75
 		}
76
-		if ( $context->getType() === Context::TYPE_REFERENCE ) {
77
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_NOT_MAIN_SNAK );
76
+		if ($context->getType() === Context::TYPE_REFERENCE) {
77
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_NOT_MAIN_SNAK);
78 78
 		}
79 79
 
80 80
 		$parameters = [];
81 81
 		$constraintParameters = $constraint->getConstraintParameters();
82 82
 
83
-		$classes = $this->constraintParameterParser->parseClassParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
83
+		$classes = $this->constraintParameterParser->parseClassParameter($constraintParameters, $constraint->getConstraintTypeItemId());
84 84
 		$parameters['class'] = array_map(
85
-			function( $id ) {
86
-				return new ItemId( $id );
85
+			function($id) {
86
+				return new ItemId($id);
87 87
 			},
88 88
 			$classes
89 89
 		);
90 90
 
91
-		$relation = $this->constraintParameterParser->parseRelationParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
92
-		if ( $relation === 'instance' ) {
93
-			$relationId = $this->config->get( 'WBQualityConstraintsInstanceOfId' );
94
-		} elseif ( $relation === 'subclass' ) {
95
-			$relationId = $this->config->get( 'WBQualityConstraintsSubclassOfId' );
91
+		$relation = $this->constraintParameterParser->parseRelationParameter($constraintParameters, $constraint->getConstraintTypeItemId());
92
+		if ($relation === 'instance') {
93
+			$relationId = $this->config->get('WBQualityConstraintsInstanceOfId');
94
+		} elseif ($relation === 'subclass') {
95
+			$relationId = $this->config->get('WBQualityConstraintsSubclassOfId');
96 96
 		}
97
-		$parameters['relation'] = [ $relation ];
97
+		$parameters['relation'] = [$relation];
98 98
 
99 99
 		$result = $this->typeCheckerHelper->hasClassInRelation(
100 100
 			$context->getEntity()->getStatements(),
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 			$classes
103 103
 		);
104 104
 
105
-		if ( $result->getBool() ) {
105
+		if ($result->getBool()) {
106 106
 			$message = '';
107 107
 			$status = CheckResult::STATUS_COMPLIANCE;
108 108
 		} else {
@@ -116,21 +116,21 @@  discard block
 block discarded – undo
116 116
 			$status = CheckResult::STATUS_VIOLATION;
117 117
 		}
118 118
 
119
-		return ( new CheckResult( $context, $constraint, $parameters, $status, $message ) )
120
-			->withMetadata( $result->getMetadata() );
119
+		return (new CheckResult($context, $constraint, $parameters, $status, $message))
120
+			->withMetadata($result->getMetadata());
121 121
 	}
122 122
 
123
-	public function checkConstraintParameters( Constraint $constraint ) {
123
+	public function checkConstraintParameters(Constraint $constraint) {
124 124
 		$constraintParameters = $constraint->getConstraintParameters();
125 125
 		$exceptions = [];
126 126
 		try {
127
-			$this->constraintParameterParser->parseClassParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
128
-		} catch ( ConstraintParameterException $e ) {
127
+			$this->constraintParameterParser->parseClassParameter($constraintParameters, $constraint->getConstraintTypeItemId());
128
+		} catch (ConstraintParameterException $e) {
129 129
 			$exceptions[] = $e;
130 130
 		}
131 131
 		try {
132
-			$this->constraintParameterParser->parseRelationParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
133
-		} catch ( ConstraintParameterException $e ) {
132
+			$this->constraintParameterParser->parseRelationParameter($constraintParameters, $constraint->getConstraintTypeItemId());
133
+		} catch (ConstraintParameterException $e) {
134 134
 			$exceptions[] = $e;
135 135
 		}
136 136
 		return $exceptions;
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/SymmetricChecker.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -60,12 +60,12 @@  discard block
 block discarded – undo
60 60
 	 *
61 61
 	 * @return CheckResult
62 62
 	 */
63
-	public function checkConstraint( Context $context, Constraint $constraint ) {
64
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
65
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
63
+	public function checkConstraint(Context $context, Constraint $constraint) {
64
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
65
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
66 66
 		}
67
-		if ( $context->getType() !== Context::TYPE_STATEMENT ) {
68
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_NOT_MAIN_SNAK );
67
+		if ($context->getType() !== Context::TYPE_STATEMENT) {
68
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_NOT_MAIN_SNAK);
69 69
 		}
70 70
 
71 71
 		$parameters = [];
@@ -73,9 +73,9 @@  discard block
 block discarded – undo
73 73
 		$snak = $context->getSnak();
74 74
 		$propertyId = $context->getSnak()->getPropertyId();
75 75
 
76
-		if ( !$snak instanceof PropertyValueSnak ) {
76
+		if (!$snak instanceof PropertyValueSnak) {
77 77
 			// nothing to check
78
-			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE, '' );
78
+			return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE, '');
79 79
 		}
80 80
 
81 81
 		$dataValue = $snak->getDataValue();
@@ -84,22 +84,22 @@  discard block
 block discarded – undo
84 84
 		 * error handling:
85 85
 		 *   type of $dataValue for properties with 'Symmetric' constraint has to be 'wikibase-entityid'
86 86
 		 */
87
-		if ( $dataValue->getType() !== 'wikibase-entityid' ) {
88
-			$message = wfMessage( "wbqc-violation-message-value-needed-of-type" )
87
+		if ($dataValue->getType() !== 'wikibase-entityid') {
88
+			$message = wfMessage("wbqc-violation-message-value-needed-of-type")
89 89
 					 ->rawParams(
90
-						 $this->constraintParameterRenderer->formatItemId( $constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM ),
90
+						 $this->constraintParameterRenderer->formatItemId($constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM),
91 91
 						 'wikibase-entityid' // TODO is there a message for this type so we can localize it?
92 92
 					 )
93 93
 					 ->escaped();
94
-			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message );
94
+			return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message);
95 95
 		}
96 96
 		/** @var EntityIdValue $dataValue */
97 97
 
98 98
 		$targetEntityId = $dataValue->getEntityId();
99
-		$targetEntity = $this->entityLookup->getEntity( $targetEntityId );
100
-		if ( $targetEntity === null ) {
101
-			$message = wfMessage( "wbqc-violation-message-target-entity-must-exist" )->escaped();
102
-			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message );
99
+		$targetEntity = $this->entityLookup->getEntity($targetEntityId);
100
+		if ($targetEntity === null) {
101
+			$message = wfMessage("wbqc-violation-message-target-entity-must-exist")->escaped();
102
+			return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message);
103 103
 		}
104 104
 
105 105
 		$symmetricStatement = $this->connectionCheckerHelper->findStatementWithPropertyAndEntityIdValue(
@@ -107,26 +107,26 @@  discard block
 block discarded – undo
107 107
 			$propertyId,
108 108
 			$context->getEntity()->getId()
109 109
 		);
110
-		if ( $symmetricStatement !== null ) {
110
+		if ($symmetricStatement !== null) {
111 111
 			$message = '';
112 112
 			$status = CheckResult::STATUS_COMPLIANCE;
113 113
 		} else {
114
-			$message = wfMessage( 'wbqc-violation-message-symmetric' )
114
+			$message = wfMessage('wbqc-violation-message-symmetric')
115 115
 					 ->rawParams(
116
-						 $this->constraintParameterRenderer->formatEntityId( $targetEntityId, Role::SUBJECT ),
117
-						 $this->constraintParameterRenderer->formatEntityId( $propertyId, Role::PREDICATE ),
118
-						 $this->constraintParameterRenderer->formatEntityId( $context->getEntity()->getId(), Role::OBJECT )
116
+						 $this->constraintParameterRenderer->formatEntityId($targetEntityId, Role::SUBJECT),
117
+						 $this->constraintParameterRenderer->formatEntityId($propertyId, Role::PREDICATE),
118
+						 $this->constraintParameterRenderer->formatEntityId($context->getEntity()->getId(), Role::OBJECT)
119 119
 					 )
120 120
 					 ->escaped();
121 121
 			$status = CheckResult::STATUS_VIOLATION;
122 122
 		}
123 123
 
124
-		return ( new CheckResult( $context, $constraint, $parameters, $status, $message ) )
125
-			->withMetadata( Metadata::ofDependencyMetadata(
126
-				DependencyMetadata::ofEntityId( $targetEntityId ) ) );
124
+		return (new CheckResult($context, $constraint, $parameters, $status, $message))
125
+			->withMetadata(Metadata::ofDependencyMetadata(
126
+				DependencyMetadata::ofEntityId($targetEntityId) ));
127 127
 	}
128 128
 
129
-	public function checkConstraintParameters( Constraint $constraint ) {
129
+	public function checkConstraintParameters(Constraint $constraint) {
130 130
 		// no parameters
131 131
 		return [];
132 132
 	}
Please login to merge, or discard this patch.
src/ConstraintCheck/Cache/CachedArray.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
 	 */
21 21
 	private $metadata;
22 22
 
23
-	public function __construct( array $array, Metadata $metadata ) {
23
+	public function __construct(array $array, Metadata $metadata) {
24 24
 		$this->array = $array;
25 25
 		$this->metadata = $metadata;
26 26
 	}
Please login to merge, or discard this patch.
src/ConstraintCheck/Cache/DependencyMetadata.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	 * @param EntityId $entityId An entity ID from which the value was derived.
30 30
 	 * @return self Indication that a value is was derived from the entity with the given ID.
31 31
 	 */
32
-	public static function ofEntityId( EntityId $entityId ) {
32
+	public static function ofEntityId(EntityId $entityId) {
33 33
 		$ret = new self;
34 34
 		$ret->entityIds[] = $entityId;
35 35
 		return $ret;
@@ -39,11 +39,11 @@  discard block
 block discarded – undo
39 39
 	 * @param self[] $metadatas
40 40
 	 * @return self
41 41
 	 */
42
-	public static function merge( array $metadatas ) {
43
-		Assert::parameterElementType( self::class, $metadatas, '$metadatas' );
42
+	public static function merge(array $metadatas) {
43
+		Assert::parameterElementType(self::class, $metadatas, '$metadatas');
44 44
 		$ret = new self;
45
-		foreach ( $metadatas as $metadata ) {
46
-			$ret->entityIds = array_merge( $ret->entityIds, $metadata->entityIds );
45
+		foreach ($metadatas as $metadata) {
46
+			$ret->entityIds = array_merge($ret->entityIds, $metadata->entityIds);
47 47
 		}
48 48
 		return $ret;
49 49
 	}
Please login to merge, or discard this patch.
src/ConstraintCheck/Cache/CachedBool.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
 	 * @param bool $bool
25 25
 	 * @param Metadata $metadata
26 26
 	 */
27
-	public function __construct( $bool, Metadata $metadata ) {
27
+	public function __construct($bool, Metadata $metadata) {
28 28
 		$this->bool = $bool;
29 29
 		$this->metadata = $metadata;
30 30
 	}
Please login to merge, or discard this patch.
src/ConstraintCheck/Cache/Metadata.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -32,14 +32,14 @@  discard block
 block discarded – undo
32 32
 		return $ret;
33 33
 	}
34 34
 
35
-	public static function ofCachingMetadata( CachingMetadata $cachingMetadata ) {
35
+	public static function ofCachingMetadata(CachingMetadata $cachingMetadata) {
36 36
 		$ret = new self;
37 37
 		$ret->cachingMetadata = $cachingMetadata;
38 38
 		$ret->dependencyMetadata = DependencyMetadata::blank();
39 39
 		return $ret;
40 40
 	}
41 41
 
42
-	public static function ofDependencyMetadata( DependencyMetadata $dependencyMetadata ) {
42
+	public static function ofDependencyMetadata(DependencyMetadata $dependencyMetadata) {
43 43
 		$ret = new self;
44 44
 		$ret->cachingMetadata = CachingMetadata::fresh();
45 45
 		$ret->dependencyMetadata = $dependencyMetadata;
@@ -50,17 +50,17 @@  discard block
 block discarded – undo
50 50
 	 * @param self[] $metadatas
51 51
 	 * @return self
52 52
 	 */
53
-	public static function merge( array $metadatas ) {
54
-		Assert::parameterElementType( self::class, $metadatas, '$metadatas' );
53
+	public static function merge(array $metadatas) {
54
+		Assert::parameterElementType(self::class, $metadatas, '$metadatas');
55 55
 		$cachingMetadatas = [];
56 56
 		$dependencyMetadatas = [];
57
-		foreach ( $metadatas as $metadata ) {
57
+		foreach ($metadatas as $metadata) {
58 58
 			$cachingMetadatas[] = $metadata->cachingMetadata;
59 59
 			$dependencyMetadatas[] = $metadata->dependencyMetadata;
60 60
 		}
61 61
 		$ret = new self;
62
-		$ret->cachingMetadata = CachingMetadata::merge( $cachingMetadatas );
63
-		$ret->dependencyMetadata = DependencyMetadata::merge( $dependencyMetadatas );
62
+		$ret->cachingMetadata = CachingMetadata::merge($cachingMetadatas);
63
+		$ret->dependencyMetadata = DependencyMetadata::merge($dependencyMetadatas);
64 64
 		return $ret;
65 65
 	}
66 66
 
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/CommonsLinkChecker.php 1 patch
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -60,22 +60,22 @@  discard block
 block discarded – undo
60 60
 	 * @return array first element is the namespace number (default namespace for TitleParser),
61 61
 	 * second element is a string to prepend to the title before giving it to the TitleParser
62 62
 	 */
63
-	private function getCommonsNamespace( $namespace ) {
63
+	private function getCommonsNamespace($namespace) {
64 64
 		// for namespace numbers see mediawiki-config repo, wmf-config/InitialiseSettings.php,
65 65
 		// 'wgExtraNamespaces' key, 'commonswiki' subkey
66
-		switch ( $namespace ) {
66
+		switch ($namespace) {
67 67
 			case '':
68
-				return [ NS_MAIN, '' ];
68
+				return [NS_MAIN, ''];
69 69
 			case 'Creator':
70
-				return [ 100, '' ];
70
+				return [100, ''];
71 71
 			case 'TimedText':
72
-				return [ 102, '' ];
72
+				return [102, ''];
73 73
 			case 'Sequence':
74
-				return [ 104, '' ];
74
+				return [104, ''];
75 75
 			case 'Institution':
76
-				return [ 106, '' ];
76
+				return [106, ''];
77 77
 			default:
78
-				return [ NS_MAIN, $namespace . ':' ];
78
+				return [NS_MAIN, $namespace.':'];
79 79
 		}
80 80
 	}
81 81
 
@@ -87,17 +87,17 @@  discard block
 block discarded – undo
87 87
 	 *
88 88
 	 * @return CheckResult
89 89
 	 */
90
-	public function checkConstraint( Context $context, Constraint $constraint ) {
90
+	public function checkConstraint(Context $context, Constraint $constraint) {
91 91
 		$parameters = [];
92 92
 		$constraintParameters = $constraint->getConstraintParameters();
93
-		$namespace = $this->constraintParameterParser->parseNamespaceParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
94
-		$parameters['namespace'] = [ $namespace ];
93
+		$namespace = $this->constraintParameterParser->parseNamespaceParameter($constraintParameters, $constraint->getConstraintTypeItemId());
94
+		$parameters['namespace'] = [$namespace];
95 95
 
96 96
 		$snak = $context->getSnak();
97 97
 
98
-		if ( !$snak instanceof PropertyValueSnak ) {
98
+		if (!$snak instanceof PropertyValueSnak) {
99 99
 			// nothing to check
100
-			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE, '' );
100
+			return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE, '');
101 101
 		}
102 102
 
103 103
 		$dataValue = $snak->getDataValue();
@@ -107,49 +107,49 @@  discard block
 block discarded – undo
107 107
 		 *   type of $dataValue for properties with 'Commons link' constraint has to be 'string'
108 108
 		 *   parameter $namespace can be null, works for commons galleries
109 109
 		 */
110
-		if ( $dataValue->getType() !== 'string' ) {
111
-			$message = wfMessage( "wbqc-violation-message-value-needed-of-type" )
110
+		if ($dataValue->getType() !== 'string') {
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()
113
+						 $this->constraintParameterRenderer->formatItemId($constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM),
114
+						 wfMessage('datatypes-type-string')->escaped()
115 115
 					 )
116 116
 					 ->escaped();
117
-			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message );
117
+			return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message);
118 118
 		}
119 119
 
120 120
 		$commonsLink = $dataValue->getValue();
121 121
 
122 122
 		try {
123
-			if ( !$this->commonsLinkIsWellFormed( $commonsLink ) ) {
124
-				throw new MalformedTitleException( 'wbqc-violation-message-commons-link-not-well-formed', $commonsLink ); // caught below
123
+			if (!$this->commonsLinkIsWellFormed($commonsLink)) {
124
+				throw new MalformedTitleException('wbqc-violation-message-commons-link-not-well-formed', $commonsLink); // caught below
125 125
 			}
126
-			list ( $defaultNamespace, $prefix ) = $this->getCommonsNamespace( $namespace );
127
-			$title = $this->titleParser->parseTitle( $prefix . $commonsLink, $defaultNamespace );
128
-			if ( $this->pageExists( $title ) ) {
126
+			list ($defaultNamespace, $prefix) = $this->getCommonsNamespace($namespace);
127
+			$title = $this->titleParser->parseTitle($prefix.$commonsLink, $defaultNamespace);
128
+			if ($this->pageExists($title)) {
129 129
 				$message = '';
130 130
 				$status = CheckResult::STATUS_COMPLIANCE;
131 131
 			} else {
132
-				if ( $this->valueIncludesNamespace( $commonsLink, $namespace ) ) {
133
-					throw new MalformedTitleException( 'wbqc-violation-message-commons-link-not-well-formed', $commonsLink ); // caught below
132
+				if ($this->valueIncludesNamespace($commonsLink, $namespace)) {
133
+					throw new MalformedTitleException('wbqc-violation-message-commons-link-not-well-formed', $commonsLink); // caught below
134 134
 				} else {
135
-					$message = wfMessage( "wbqc-violation-message-commons-link-no-existent" )->escaped();
135
+					$message = wfMessage("wbqc-violation-message-commons-link-no-existent")->escaped();
136 136
 					$status = CheckResult::STATUS_VIOLATION;
137 137
 				}
138 138
 			}
139
-		} catch ( MalformedTitleException $e ) {
140
-			$message = wfMessage( "wbqc-violation-message-commons-link-not-well-formed" )->escaped();
139
+		} catch (MalformedTitleException $e) {
140
+			$message = wfMessage("wbqc-violation-message-commons-link-not-well-formed")->escaped();
141 141
 			$status = CheckResult::STATUS_VIOLATION;
142 142
 		}
143 143
 
144
-		return new CheckResult( $context, $constraint, $parameters, $status, $message );
144
+		return new CheckResult($context, $constraint, $parameters, $status, $message);
145 145
 	}
146 146
 
147
-	public function checkConstraintParameters( Constraint $constraint ) {
147
+	public function checkConstraintParameters(Constraint $constraint) {
148 148
 		$constraintParameters = $constraint->getConstraintParameters();
149 149
 		$exceptions = [];
150 150
 		try {
151
-			$this->constraintParameterParser->parseNamespaceParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
152
-		} catch ( ConstraintParameterException $e ) {
151
+			$this->constraintParameterParser->parseNamespaceParameter($constraintParameters, $constraint->getConstraintTypeItemId());
152
+		} catch (ConstraintParameterException $e) {
153 153
 			$exceptions[] = $e;
154 154
 		}
155 155
 		return $exceptions;
@@ -160,19 +160,19 @@  discard block
 block discarded – undo
160 160
 	 *
161 161
 	 * @return bool
162 162
 	 */
163
-	private function pageExists( TitleValue $title ) {
163
+	private function pageExists(TitleValue $title) {
164 164
 		$commonsWikiId = 'commonswiki';
165
-		if ( defined( 'MW_PHPUNIT_TEST' ) ) {
165
+		if (defined('MW_PHPUNIT_TEST')) {
166 166
 			$commonsWikiId = false;
167 167
 		}
168 168
 
169
-		$dbLoadBalancer = wfGetLB( $commonsWikiId );
169
+		$dbLoadBalancer = wfGetLB($commonsWikiId);
170 170
 		$dbConnection = $dbLoadBalancer->getConnection(
171 171
 			DB_REPLICA, false, $commonsWikiId );
172
-		$row = $dbConnection->selectRow( 'page', '*', [
172
+		$row = $dbConnection->selectRow('page', '*', [
173 173
 			'page_title' => $title->getDBkey(),
174 174
 			'page_namespace' => $title->getNamespace()
175
-		] );
175
+		]);
176 176
 
177 177
 		return $row !== false;
178 178
 	}
@@ -182,9 +182,9 @@  discard block
 block discarded – undo
182 182
 	 *
183 183
 	 * @return bool
184 184
 	 */
185
-	private function commonsLinkIsWellFormed( $commonsLink ) {
186
-		$toReplace = [ "_", "%20" ];
187
-		$compareString = trim( str_replace( $toReplace, '', $commonsLink ) );
185
+	private function commonsLinkIsWellFormed($commonsLink) {
186
+		$toReplace = ["_", "%20"];
187
+		$compareString = trim(str_replace($toReplace, '', $commonsLink));
188 188
 		return $commonsLink === $compareString;
189 189
 	}
190 190
 
@@ -197,9 +197,9 @@  discard block
 block discarded – undo
197 197
 	 *
198 198
 	 * @return bool
199 199
 	 */
200
-	private function valueIncludesNamespace( $value, $namespace ) {
200
+	private function valueIncludesNamespace($value, $namespace) {
201 201
 		return $namespace !== '' &&
202
-			strncasecmp( $value, $namespace . ':', strlen( $namespace ) + 1 ) === 0;
202
+			strncasecmp($value, $namespace.':', strlen($namespace) + 1) === 0;
203 203
 	}
204 204
 
205 205
 }
Please login to merge, or discard this patch.