Completed
Push — master ( e6a942...f6c8aa )
by
unknown
44s queued 12s
created
src/ConstraintParameterRenderer.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -71,20 +71,20 @@  discard block
 block discarded – undo
71 71
 	 *
72 72
 	 * @return string HTML
73 73
 	 */
74
-	public function formatValue( $value ) {
75
-		if ( is_string( $value ) ) {
74
+	public function formatValue($value) {
75
+		if (is_string($value)) {
76 76
 			// Cases like 'Format' 'pattern' or 'minimum'/'maximum' values, which we have stored as
77 77
 			// strings
78
-			return htmlspecialchars( $value );
79
-		} elseif ( $value instanceof EntityId ) {
78
+			return htmlspecialchars($value);
79
+		} elseif ($value instanceof EntityId) {
80 80
 			// Cases like 'Conflicts with' 'property', to which we can link
81
-			return $this->formatEntityId( $value );
82
-		} elseif ( $value instanceof ItemIdSnakValue ) {
81
+			return $this->formatEntityId($value);
82
+		} elseif ($value instanceof ItemIdSnakValue) {
83 83
 			// Cases like EntityId but can also be somevalue or novalue
84
-			return $this->formatItemIdSnakValue( $value );
84
+			return $this->formatItemIdSnakValue($value);
85 85
 		} else {
86 86
 			// Cases where we format a DataValue
87
-			return $this->formatDataValue( $value );
87
+			return $this->formatDataValue($value);
88 88
 		}
89 89
 	}
90 90
 
@@ -95,19 +95,19 @@  discard block
 block discarded – undo
95 95
 	 *
96 96
 	 * @return string|null HTML
97 97
 	 */
98
-	public function formatParameters( $parameters ) {
99
-		if ( $parameters === null || $parameters === [] ) {
98
+	public function formatParameters($parameters) {
99
+		if ($parameters === null || $parameters === []) {
100 100
 			return null;
101 101
 		}
102 102
 
103 103
 		$formattedParameters = [];
104
-		foreach ( $parameters as $parameterName => $parameterValue ) {
105
-			$formattedParameterValues = implode( ', ',
106
-				$this->limitArrayLength( array_map( [ $this, 'formatValue' ], $parameterValue ) ) );
107
-			$formattedParameters[] = sprintf( '%s: %s', $parameterName, $formattedParameterValues );
104
+		foreach ($parameters as $parameterName => $parameterValue) {
105
+			$formattedParameterValues = implode(', ',
106
+				$this->limitArrayLength(array_map([$this, 'formatValue'], $parameterValue)));
107
+			$formattedParameters[] = sprintf('%s: %s', $parameterName, $formattedParameterValues);
108 108
 		}
109 109
 
110
-		return implode( '; ', $formattedParameters );
110
+		return implode('; ', $formattedParameters);
111 111
 	}
112 112
 
113 113
 	/**
@@ -117,10 +117,10 @@  discard block
 block discarded – undo
117 117
 	 *
118 118
 	 * @return string[]
119 119
 	 */
120
-	private function limitArrayLength( array $array ) {
121
-		if ( count( $array ) > self::MAX_PARAMETER_ARRAY_LENGTH ) {
122
-			$array = array_slice( $array, 0, self::MAX_PARAMETER_ARRAY_LENGTH );
123
-			array_push( $array, '...' );
120
+	private function limitArrayLength(array $array) {
121
+		if (count($array) > self::MAX_PARAMETER_ARRAY_LENGTH) {
122
+			$array = array_slice($array, 0, self::MAX_PARAMETER_ARRAY_LENGTH);
123
+			array_push($array, '...');
124 124
 		}
125 125
 
126 126
 		return $array;
@@ -130,16 +130,16 @@  discard block
 block discarded – undo
130 130
 	 * @param DataValue $value
131 131
 	 * @return string HTML
132 132
 	 */
133
-	public function formatDataValue( DataValue $value ) {
134
-		return $this->dataValueFormatter->format( $value );
133
+	public function formatDataValue(DataValue $value) {
134
+		return $this->dataValueFormatter->format($value);
135 135
 	}
136 136
 
137 137
 	/**
138 138
 	 * @param EntityId $entityId
139 139
 	 * @return string HTML
140 140
 	 */
141
-	public function formatEntityId( EntityId $entityId ) {
142
-		return $this->entityIdLabelFormatter->formatEntityId( $entityId );
141
+	public function formatEntityId(EntityId $entityId) {
142
+		return $this->entityIdLabelFormatter->formatEntityId($entityId);
143 143
 	}
144 144
 
145 145
 	/**
@@ -148,17 +148,17 @@  discard block
 block discarded – undo
148 148
 	 * @param ItemIdSnakValue $value
149 149
 	 * @return string HTML
150 150
 	 */
151
-	public function formatItemIdSnakValue( ItemIdSnakValue $value ) {
152
-		switch ( true ) {
151
+	public function formatItemIdSnakValue(ItemIdSnakValue $value) {
152
+		switch (true) {
153 153
 			case $value->isValue():
154
-				return $this->formatEntityId( $value->getItemId() );
154
+				return $this->formatEntityId($value->getItemId());
155 155
 			case $value->isSomeValue():
156 156
 				return $this->messageLocalizer
157
-					->msg( 'wikibase-snakview-snaktypeselector-somevalue' )
157
+					->msg('wikibase-snakview-snaktypeselector-somevalue')
158 158
 					->escaped();
159 159
 			case $value->isNoValue():
160 160
 				return $this->messageLocalizer
161
-					->msg( 'wikibase-snakview-snaktypeselector-novalue' )
161
+					->msg('wikibase-snakview-snaktypeselector-novalue')
162 162
 					->escaped();
163 163
 		}
164 164
 	}
Please login to merge, or discard this patch.
src/ConstraintCheck/Context/AbstractContext.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types = 1 );
3
+declare(strict_types=1);
4 4
 
5 5
 namespace WikibaseQuality\ConstraintReport\ConstraintCheck\Context;
6 6
 
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 
22 22
 	protected Snak $snak;
23 23
 
24
-	public function __construct( StatementListProvidingEntity $entity, Snak $snak ) {
24
+	public function __construct(StatementListProvidingEntity $entity, Snak $snak) {
25 25
 		$this->entity = $entity;
26 26
 		$this->snak = $snak;
27 27
 	}
@@ -47,15 +47,15 @@  discard block
 block discarded – undo
47 47
 	// unimplemented: getCursor
48 48
 
49 49
 	/** Helper function for {@link getCursor()} implementations. */
50
-	protected function getStatementGuid( Statement $statement ): string {
50
+	protected function getStatementGuid(Statement $statement): string {
51 51
 		$guid = $statement->getGuid();
52
-		if ( $guid === null ) {
53
-			if ( defined( 'MW_PHPUNIT_TEST' ) ) {
52
+		if ($guid === null) {
53
+			if (defined('MW_PHPUNIT_TEST')) {
54 54
 				// let unit tests get away with not specifying a statement GUID:
55 55
 				// much more convenient to fake it here than to add one to all tests
56 56
 				return 'Q0$DEADBEEF-DEAD-BEEF-DEAD-BEEFDEADBEEF';
57 57
 			} else {
58
-				throw new InvalidArgumentException( 'Statement for Context must have a GUID' );
58
+				throw new InvalidArgumentException('Statement for Context must have a GUID');
59 59
 			}
60 60
 		}
61 61
 		return $guid;
Please login to merge, or discard this patch.
src/ConstraintCheck/Context/MainSnakContext.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types = 1 );
3
+declare(strict_types=1);
4 4
 
5 5
 namespace WikibaseQuality\ConstraintReport\ConstraintCheck\Context;
6 6
 
@@ -21,8 +21,8 @@  discard block
 block discarded – undo
21 21
 
22 22
 	private Statement $statement;
23 23
 
24
-	public function __construct( StatementListProvidingEntity $entity, Statement $statement ) {
25
-		parent::__construct( $entity, $statement->getMainSnak() );
24
+	public function __construct(StatementListProvidingEntity $entity, Statement $statement) {
25
+		parent::__construct($entity, $statement->getMainSnak());
26 26
 
27 27
 		$this->statement = $statement;
28 28
 	}
@@ -39,21 +39,21 @@  discard block
 block discarded – undo
39 39
 		return $this->statement;
40 40
 	}
41 41
 
42
-	public function getSnakGroup( string $groupingMode, array $separators = [] ): array {
42
+	public function getSnakGroup(string $groupingMode, array $separators = []): array {
43 43
 		/** @var StatementList $statements */
44 44
 		$statements = $this->entity->getStatements();
45
-		switch ( $groupingMode ) {
45
+		switch ($groupingMode) {
46 46
 			case Context::GROUP_NON_DEPRECATED:
47
-				$statements = $statements->getByRank( [
47
+				$statements = $statements->getByRank([
48 48
 					Statement::RANK_NORMAL,
49 49
 					Statement::RANK_PREFERRED,
50
-				] );
50
+				]);
51 51
 				break;
52 52
 			case Context::GROUP_BEST_RANK:
53
-				$statements = $this->getBestStatementsPerPropertyId( $statements );
53
+				$statements = $this->getBestStatementsPerPropertyId($statements);
54 54
 				break;
55 55
 			default:
56
-				throw new LogicException( 'Unknown $groupingMode ' . $groupingMode );
56
+				throw new LogicException('Unknown $groupingMode '.$groupingMode);
57 57
 		}
58 58
 		return $this->getStatementsWithSameQualifiersForProperties(
59 59
 			$this->statement,
@@ -62,13 +62,13 @@  discard block
 block discarded – undo
62 62
 		)->getMainSnaks();
63 63
 	}
64 64
 
65
-	private function getBestStatementsPerPropertyId( StatementList $statements ): StatementList {
65
+	private function getBestStatementsPerPropertyId(StatementList $statements): StatementList {
66 66
 		$allBestStatements = new StatementList();
67
-		foreach ( $statements->getPropertyIds() as $propertyId ) {
68
-			$bestStatements = $statements->getByPropertyId( $propertyId )
67
+		foreach ($statements->getPropertyIds() as $propertyId) {
68
+			$bestStatements = $statements->getByPropertyId($propertyId)
69 69
 				->getBestStatements();
70
-			foreach ( $bestStatements as $bestStatement ) {
71
-				$allBestStatements->addStatement( $bestStatement );
70
+			foreach ($bestStatements as $bestStatement) {
71
+				$allBestStatements->addStatement($bestStatement);
72 72
 			}
73 73
 		}
74 74
 		return $allBestStatements;
@@ -90,20 +90,20 @@  discard block
 block discarded – undo
90 90
 		array $qualifierPropertyIds
91 91
 	): StatementList {
92 92
 		$similarStatements = new StatementList();
93
-		foreach ( $allStatements as $statement ) {
94
-			if ( $statement === $currentStatement ) {
93
+		foreach ($allStatements as $statement) {
94
+			if ($statement === $currentStatement) {
95 95
 				// if the statement has an “unknown value” qualifier,
96 96
 				// it might be considered different from itself,
97 97
 				// so add it explicitly to ensure it’s always included
98
-				$similarStatements->addStatement( $statement );
98
+				$similarStatements->addStatement($statement);
99 99
 				continue;
100 100
 			}
101
-			foreach ( $qualifierPropertyIds as $qualifierPropertyId ) {
102
-				if ( !$this->haveSameQualifiers( $currentStatement, $statement, $qualifierPropertyId ) ) {
101
+			foreach ($qualifierPropertyIds as $qualifierPropertyId) {
102
+				if (!$this->haveSameQualifiers($currentStatement, $statement, $qualifierPropertyId)) {
103 103
 					continue 2;
104 104
 				}
105 105
 			}
106
-			$similarStatements->addStatement( $statement );
106
+			$similarStatements->addStatement($statement);
107 107
 		}
108 108
 		return $similarStatements;
109 109
 	}
@@ -112,19 +112,19 @@  discard block
 block discarded – undo
112 112
 	 * Tests whether two statements have the same qualifiers with a certain property ID.
113 113
 	 * “unknown value” qualifiers are considered different from each other.
114 114
 	 */
115
-	private function haveSameQualifiers( Statement $s1, Statement $s2, PropertyId $propertyId ): bool {
116
-		$q1 = $this->getSnaksWithPropertyId( $s1->getQualifiers(), $propertyId );
117
-		$q2 = $this->getSnaksWithPropertyId( $s2->getQualifiers(), $propertyId );
115
+	private function haveSameQualifiers(Statement $s1, Statement $s2, PropertyId $propertyId): bool {
116
+		$q1 = $this->getSnaksWithPropertyId($s1->getQualifiers(), $propertyId);
117
+		$q2 = $this->getSnaksWithPropertyId($s2->getQualifiers(), $propertyId);
118 118
 
119
-		if ( $q1->count() !== $q2->count() ) {
119
+		if ($q1->count() !== $q2->count()) {
120 120
 			return false;
121 121
 		}
122 122
 
123
-		foreach ( $q1 as $qualifier ) {
124
-			switch ( $qualifier->getType() ) {
123
+		foreach ($q1 as $qualifier) {
124
+			switch ($qualifier->getType()) {
125 125
 				case 'value':
126 126
 				case 'novalue':
127
-					if ( !$q2->hasSnak( $qualifier ) ) {
127
+					if (!$q2->hasSnak($qualifier)) {
128 128
 						return false;
129 129
 					}
130 130
 					break;
@@ -142,12 +142,12 @@  discard block
 block discarded – undo
142 142
 	/**
143 143
 	 * Returns the snaks of the given snak list with the specified property ID.
144 144
 	 */
145
-	private function getSnaksWithPropertyId( SnakList $allSnaks, PropertyId $propertyId ): SnakList {
145
+	private function getSnaksWithPropertyId(SnakList $allSnaks, PropertyId $propertyId): SnakList {
146 146
 		$snaks = new SnakList();
147 147
 		/** @var Snak $snak */
148
-		foreach ( $allSnaks as $snak ) {
149
-			if ( $snak->getPropertyId()->equals( $propertyId ) ) {
150
-				$snaks->addSnak( $snak );
148
+		foreach ($allSnaks as $snak) {
149
+			if ($snak->getPropertyId()->equals($propertyId)) {
150
+				$snaks->addSnak($snak);
151 151
 			}
152 152
 		}
153 153
 		return $snaks;
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 		return new MainSnakContextCursor(
158 158
 			$this->entity->getId()->getSerialization(),
159 159
 			$this->statement->getPropertyId()->getSerialization(),
160
-			$this->getStatementGuid( $this->statement ),
160
+			$this->getStatementGuid($this->statement),
161 161
 			$this->statement->getMainSnak()->getHash()
162 162
 		);
163 163
 	}
Please login to merge, or discard this patch.
src/ConstraintCheck/Message/ViolationMessageRenderer.php 1 patch
Spacing   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types = 1 );
3
+declare(strict_types=1);
4 4
 
5 5
 namespace WikibaseQuality\ConstraintReport\ConstraintCheck\Message;
6 6
 
@@ -59,17 +59,17 @@  discard block
 block discarded – undo
59 59
 		$this->maxListLength = $maxListLength;
60 60
 	}
61 61
 
62
-	public function render( ViolationMessage $violationMessage ): string {
62
+	public function render(ViolationMessage $violationMessage): string {
63 63
 		$messageKey = $violationMessage->getMessageKey();
64
-		$paramsLists = [ [] ];
65
-		foreach ( $violationMessage->getArguments() as $argument ) {
66
-			$params = $this->renderArgument( $argument );
64
+		$paramsLists = [[]];
65
+		foreach ($violationMessage->getArguments() as $argument) {
66
+			$params = $this->renderArgument($argument);
67 67
 			$paramsLists[] = $params;
68 68
 		}
69
-		$allParams = call_user_func_array( 'array_merge', $paramsLists );
69
+		$allParams = call_user_func_array('array_merge', $paramsLists);
70 70
 		return $this->messageLocalizer
71
-			->msg( $messageKey )
72
-			->params( $allParams )
71
+			->msg($messageKey)
72
+			->params($allParams)
73 73
 			->escaped();
74 74
 	}
75 75
 
@@ -78,13 +78,13 @@  discard block
 block discarded – undo
78 78
 	 * @param string|null $role one of the Role::* constants
79 79
 	 * @return string HTML
80 80
 	 */
81
-	protected function addRole( string $value, ?string $role ): string {
82
-		if ( $role === null ) {
81
+	protected function addRole(string $value, ?string $role): string {
82
+		if ($role === null) {
83 83
 			return $value;
84 84
 		}
85 85
 
86
-		return '<span class="wbqc-role wbqc-role-' . htmlspecialchars( $role ) . '">' .
87
-			$value .
86
+		return '<span class="wbqc-role wbqc-role-'.htmlspecialchars($role).'">'.
87
+			$value.
88 88
 			'</span>';
89 89
 	}
90 90
 
@@ -92,15 +92,15 @@  discard block
 block discarded – undo
92 92
 	 * @param string $key message key
93 93
 	 * @return string HTML
94 94
 	 */
95
-	protected function msgEscaped( string $key ): string {
96
-		return $this->messageLocalizer->msg( $key )->escaped();
95
+	protected function msgEscaped(string $key): string {
96
+		return $this->messageLocalizer->msg($key)->escaped();
97 97
 	}
98 98
 
99 99
 	/**
100 100
 	 * @param array $argument
101 101
 	 * @return array[] params (for Message::params)
102 102
 	 */
103
-	protected function renderArgument( array $argument ): array {
103
+	protected function renderArgument(array $argument): array {
104 104
 		$methods = [
105 105
 			ViolationMessage::TYPE_ENTITY_ID => 'renderEntityId',
106 106
 			ViolationMessage::TYPE_ENTITY_ID_LIST => 'renderEntityIdList',
@@ -121,12 +121,12 @@  discard block
 block discarded – undo
121 121
 		$value = $argument['value'];
122 122
 		$role = $argument['role'];
123 123
 
124
-		if ( array_key_exists( $type, $methods ) ) {
124
+		if (array_key_exists($type, $methods)) {
125 125
 			$method = $methods[$type];
126
-			$params = $this->$method( $value, $role );
126
+			$params = $this->$method($value, $role);
127 127
 		} else {
128 128
 			throw new InvalidArgumentException(
129
-				'Unknown ViolationMessage argument type ' . $type . '!'
129
+				'Unknown ViolationMessage argument type '.$type.'!'
130 130
 			);
131 131
 		}
132 132
 
@@ -140,36 +140,36 @@  discard block
 block discarded – undo
140 140
 	 * and return a single-element array with a raw message param (i. e. [ Message::rawParam( … ) ])
141 141
 	 * @return array[] list of parameters as accepted by Message::params()
142 142
 	 */
143
-	private function renderList( array $list, ?string $role, callable $render ): array {
144
-		if ( $list === [] ) {
143
+	private function renderList(array $list, ?string $role, callable $render): array {
144
+		if ($list === []) {
145 145
 			return [
146
-				Message::numParam( 0 ),
147
-				Message::rawParam( '<ul></ul>' ),
146
+				Message::numParam(0),
147
+				Message::rawParam('<ul></ul>'),
148 148
 			];
149 149
 		}
150 150
 
151
-		if ( count( $list ) > $this->maxListLength ) {
152
-			$list = array_slice( $list, 0, $this->maxListLength );
151
+		if (count($list) > $this->maxListLength) {
152
+			$list = array_slice($list, 0, $this->maxListLength);
153 153
 			$truncated = true;
154 154
 		}
155 155
 
156 156
 		$renderedParamsLists = array_map(
157 157
 			$render,
158 158
 			$list,
159
-			array_fill( 0, count( $list ), $role )
159
+			array_fill(0, count($list), $role)
160 160
 		);
161
-		$renderedParams = array_column( $renderedParamsLists, 0 );
162
-		$renderedElements = array_column( $renderedParams, 'raw' );
163
-		if ( isset( $truncated ) ) {
164
-			$renderedElements[] = $this->msgEscaped( 'ellipsis' );
161
+		$renderedParams = array_column($renderedParamsLists, 0);
162
+		$renderedElements = array_column($renderedParams, 'raw');
163
+		if (isset($truncated)) {
164
+			$renderedElements[] = $this->msgEscaped('ellipsis');
165 165
 		}
166 166
 
167 167
 		return array_merge(
168 168
 			[
169
-				Message::numParam( count( $list ) ),
169
+				Message::numParam(count($list)),
170 170
 				Message::rawParam(
171
-					'<ul><li>' .
172
-					implode( '</li><li>', $renderedElements ) .
171
+					'<ul><li>'.
172
+					implode('</li><li>', $renderedElements).
173 173
 					'</li></ul>'
174 174
 				),
175 175
 			],
@@ -182,11 +182,11 @@  discard block
 block discarded – undo
182 182
 	 * @param string|null $role one of the Role::* constants
183 183
 	 * @return array[] list of a single raw message param (i. e. [ Message::rawParam( … ) ])
184 184
 	 */
185
-	private function renderEntityId( EntityId $entityId, ?string $role ): array {
186
-		return [ Message::rawParam( $this->addRole(
187
-			$this->entityIdFormatter->formatEntityId( $entityId ),
185
+	private function renderEntityId(EntityId $entityId, ?string $role): array {
186
+		return [Message::rawParam($this->addRole(
187
+			$this->entityIdFormatter->formatEntityId($entityId),
188 188
 			$role
189
-		) ) ];
189
+		))];
190 190
 	}
191 191
 
192 192
 	/**
@@ -194,8 +194,8 @@  discard block
 block discarded – undo
194 194
 	 * @param string|null $role one of the Role::* constants
195 195
 	 * @return array[] list of parameters as accepted by Message::params()
196 196
 	 */
197
-	private function renderEntityIdList( array $entityIdList, ?string $role ): array {
198
-		return $this->renderList( $entityIdList, $role, [ $this, 'renderEntityId' ] );
197
+	private function renderEntityIdList(array $entityIdList, ?string $role): array {
198
+		return $this->renderList($entityIdList, $role, [$this, 'renderEntityId']);
199 199
 	}
200 200
 
201 201
 	/**
@@ -203,24 +203,24 @@  discard block
 block discarded – undo
203 203
 	 * @param string|null $role one of the Role::* constants
204 204
 	 * @return array[] list of a single raw message param (i. e. [ Message::rawParam( … ) ])
205 205
 	 */
206
-	private function renderItemIdSnakValue( ItemIdSnakValue $value, ?string $role ): array {
207
-		switch ( true ) {
206
+	private function renderItemIdSnakValue(ItemIdSnakValue $value, ?string $role): array {
207
+		switch (true) {
208 208
 			case $value->isValue():
209
-				return $this->renderEntityId( $value->getItemId(), $role );
209
+				return $this->renderEntityId($value->getItemId(), $role);
210 210
 			case $value->isSomeValue():
211
-				return [ Message::rawParam( $this->addRole(
212
-					'<span class="wikibase-snakview-variation-somevaluesnak">' .
213
-						$this->msgEscaped( 'wikibase-snakview-snaktypeselector-somevalue' ) .
211
+				return [Message::rawParam($this->addRole(
212
+					'<span class="wikibase-snakview-variation-somevaluesnak">'.
213
+						$this->msgEscaped('wikibase-snakview-snaktypeselector-somevalue').
214 214
 						'</span>',
215 215
 					$role
216
-				) ) ];
216
+				))];
217 217
 			case $value->isNoValue():
218
-				return [ Message::rawParam( $this->addRole(
219
-					'<span class="wikibase-snakview-variation-novaluesnak">' .
220
-					$this->msgEscaped( 'wikibase-snakview-snaktypeselector-novalue' ) .
218
+				return [Message::rawParam($this->addRole(
219
+					'<span class="wikibase-snakview-variation-novaluesnak">'.
220
+					$this->msgEscaped('wikibase-snakview-snaktypeselector-novalue').
221 221
 						'</span>',
222 222
 					$role
223
-				) ) ];
223
+				))];
224 224
 			default:
225 225
 				// @codeCoverageIgnoreStart
226 226
 				throw new LogicException(
@@ -235,8 +235,8 @@  discard block
 block discarded – undo
235 235
 	 * @param string|null $role one of the Role::* constants
236 236
 	 * @return array[] list of parameters as accepted by Message::params()
237 237
 	 */
238
-	private function renderItemIdSnakValueList( array $valueList, ?string $role ): array {
239
-		return $this->renderList( $valueList, $role, [ $this, 'renderItemIdSnakValue' ] );
238
+	private function renderItemIdSnakValueList(array $valueList, ?string $role): array {
239
+		return $this->renderList($valueList, $role, [$this, 'renderItemIdSnakValue']);
240 240
 	}
241 241
 
242 242
 	/**
@@ -244,11 +244,11 @@  discard block
 block discarded – undo
244 244
 	 * @param string|null $role one of the Role::* constants
245 245
 	 * @return array[] list of parameters as accepted by Message::params()
246 246
 	 */
247
-	private function renderDataValue( DataValue $dataValue, ?string $role ): array {
248
-		return [ Message::rawParam( $this->addRole(
249
-			$this->dataValueFormatter->format( $dataValue ),
247
+	private function renderDataValue(DataValue $dataValue, ?string $role): array {
248
+		return [Message::rawParam($this->addRole(
249
+			$this->dataValueFormatter->format($dataValue),
250 250
 			$role
251
-		) ) ];
251
+		))];
252 252
 	}
253 253
 
254 254
 	/**
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 	 * @param string|null $role one of the Role::* constants
257 257
 	 * @return array[] list of parameters as accepted by Message::params()
258 258
 	 */
259
-	private function renderDataValueType( string $dataValueType, ?string $role ): array {
259
+	private function renderDataValueType(string $dataValueType, ?string $role): array {
260 260
 		$messageKeys = [
261 261
 			'string' => 'datatypes-type-string',
262 262
 			'monolingualtext' => 'datatypes-type-monolingualtext',
@@ -265,15 +265,15 @@  discard block
 block discarded – undo
265 265
 			'wikibase-entityid' => 'wbqc-dataValueType-wikibase-entityid',
266 266
 		];
267 267
 
268
-		if ( array_key_exists( $dataValueType, $messageKeys ) ) {
269
-			return [ Message::rawParam( $this->addRole(
270
-				$this->msgEscaped( $messageKeys[$dataValueType] ),
268
+		if (array_key_exists($dataValueType, $messageKeys)) {
269
+			return [Message::rawParam($this->addRole(
270
+				$this->msgEscaped($messageKeys[$dataValueType]),
271 271
 				$role
272
-			) ) ];
272
+			))];
273 273
 		} else {
274 274
 			// @codeCoverageIgnoreStart
275 275
 			throw new LogicException(
276
-				'Unknown data value type ' . $dataValueType
276
+				'Unknown data value type '.$dataValueType
277 277
 			);
278 278
 			// @codeCoverageIgnoreEnd
279 279
 		}
@@ -284,11 +284,11 @@  discard block
 block discarded – undo
284 284
 	 * @param string|null $role one of the Role::* constants
285 285
 	 * @return array[] list of parameters as accepted by Message::params()
286 286
 	 */
287
-	private function renderInlineCode( string $code, ?string $role ): array {
288
-		return [ Message::rawParam( $this->addRole(
289
-			'<code>' . htmlspecialchars( $code ) . '</code>',
287
+	private function renderInlineCode(string $code, ?string $role): array {
288
+		return [Message::rawParam($this->addRole(
289
+			'<code>'.htmlspecialchars($code).'</code>',
290 290
 			$role
291
-		) ) ];
291
+		))];
292 292
 	}
293 293
 
294 294
 	/**
@@ -296,8 +296,8 @@  discard block
 block discarded – undo
296 296
 	 * @param string|null $role one of the Role::* constants
297 297
 	 * @return array[] list of a single raw message param (i. e. [ Message::rawParam( … ) ])
298 298
 	 */
299
-	private function renderConstraintScope( string $scope, ?string $role ): array {
300
-		switch ( $scope ) {
299
+	private function renderConstraintScope(string $scope, ?string $role): array {
300
+		switch ($scope) {
301 301
 			case Context::TYPE_STATEMENT:
302 302
 				$itemId = $this->config->get(
303 303
 					'WBQualityConstraintsConstraintCheckedOnMainValueId'
@@ -317,10 +317,10 @@  discard block
 block discarded – undo
317 317
 				// callers should never let this happen, but if it does happen,
318 318
 				// showing “unknown value” seems reasonable
319 319
 				// @codeCoverageIgnoreStart
320
-				return $this->renderItemIdSnakValue( ItemIdSnakValue::someValue(), $role );
320
+				return $this->renderItemIdSnakValue(ItemIdSnakValue::someValue(), $role);
321 321
 				// @codeCoverageIgnoreEnd
322 322
 		}
323
-		return $this->renderEntityId( new ItemId( $itemId ), $role );
323
+		return $this->renderEntityId(new ItemId($itemId), $role);
324 324
 	}
325 325
 
326 326
 	/**
@@ -328,8 +328,8 @@  discard block
 block discarded – undo
328 328
 	 * @param string|null $role one of the Role::* constants
329 329
 	 * @return array[] list of parameters as accepted by Message::params()
330 330
 	 */
331
-	private function renderConstraintScopeList( array $scopeList, ?string $role ): array {
332
-		return $this->renderList( $scopeList, $role, [ $this, 'renderConstraintScope' ] );
331
+	private function renderConstraintScopeList(array $scopeList, ?string $role): array {
332
+		return $this->renderList($scopeList, $role, [$this, 'renderConstraintScope']);
333 333
 	}
334 334
 
335 335
 	/**
@@ -337,25 +337,25 @@  discard block
 block discarded – undo
337 337
 	 * @param string|null $role one of the Role::* constants
338 338
 	 * @return array[] list of a single raw message param (i. e. [ Message::rawParam( … ) ])
339 339
 	 */
340
-	private function renderPropertyScope( string $scope, ?string $role ): array {
341
-		switch ( $scope ) {
340
+	private function renderPropertyScope(string $scope, ?string $role): array {
341
+		switch ($scope) {
342 342
 			case Context::TYPE_STATEMENT:
343
-				$itemId = $this->config->get( 'WBQualityConstraintsAsMainValueId' );
343
+				$itemId = $this->config->get('WBQualityConstraintsAsMainValueId');
344 344
 				break;
345 345
 			case Context::TYPE_QUALIFIER:
346
-				$itemId = $this->config->get( 'WBQualityConstraintsAsQualifiersId' );
346
+				$itemId = $this->config->get('WBQualityConstraintsAsQualifiersId');
347 347
 				break;
348 348
 			case Context::TYPE_REFERENCE:
349
-				$itemId = $this->config->get( 'WBQualityConstraintsAsReferencesId' );
349
+				$itemId = $this->config->get('WBQualityConstraintsAsReferencesId');
350 350
 				break;
351 351
 			default:
352 352
 				// callers should never let this happen, but if it does happen,
353 353
 				// showing “unknown value” seems reasonable
354 354
 				// @codeCoverageIgnoreStart
355
-				return $this->renderItemIdSnakValue( ItemIdSnakValue::someValue(), $role );
355
+				return $this->renderItemIdSnakValue(ItemIdSnakValue::someValue(), $role);
356 356
 				// @codeCoverageIgnoreEnd
357 357
 		}
358
-		return $this->renderEntityId( new ItemId( $itemId ), $role );
358
+		return $this->renderEntityId(new ItemId($itemId), $role);
359 359
 	}
360 360
 
361 361
 	/**
@@ -363,8 +363,8 @@  discard block
 block discarded – undo
363 363
 	 * @param string|null $role one of the Role::* constants
364 364
 	 * @return array[] list of parameters as accepted by Message::params()
365 365
 	 */
366
-	private function renderPropertyScopeList( array $scopeList, ?string $role ): array {
367
-		return $this->renderList( $scopeList, $role, [ $this, 'renderPropertyScope' ] );
366
+	private function renderPropertyScopeList(array $scopeList, ?string $role): array {
367
+		return $this->renderList($scopeList, $role, [$this, 'renderPropertyScope']);
368 368
 	}
369 369
 
370 370
 	/**
@@ -372,14 +372,14 @@  discard block
 block discarded – undo
372 372
 	 * @param string|null $role one of the Role::* constants
373 373
 	 * @return array[] list of parameters as accepted by Message::params()
374 374
 	 */
375
-	private function renderLanguage( string $languageCode, ?string $role ): array {
375
+	private function renderLanguage(string $languageCode, ?string $role): array {
376 376
 		return [
377 377
 			// ::renderList (through ::renderLanguageList) requires 'raw' parameter
378 378
 			// so we effectively build Message::plaintextParam here
379
-			Message::rawParam( htmlspecialchars(
380
-				$this->languageNameUtils->getLanguageName( $languageCode )
381
-			) ),
382
-			Message::plaintextParam( $languageCode ),
379
+			Message::rawParam(htmlspecialchars(
380
+				$this->languageNameUtils->getLanguageName($languageCode)
381
+			)),
382
+			Message::plaintextParam($languageCode),
383 383
 		];
384 384
 	}
385 385
 
@@ -388,8 +388,8 @@  discard block
 block discarded – undo
388 388
 	 * @param string|null $role one of the Role::* constants
389 389
 	 * @return array[] list of parameters as accepted by Message::params()
390 390
 	 */
391
-	private function renderLanguageList( array $languageCodes, ?string $role ): array {
392
-		return $this->renderList( $languageCodes, $role, [ $this, 'renderLanguage' ] );
391
+	private function renderLanguageList(array $languageCodes, ?string $role): array {
392
+		return $this->renderList($languageCodes, $role, [$this, 'renderLanguage']);
393 393
 	}
394 394
 
395 395
 }
Please login to merge, or discard this patch.
src/ConstraintCheck/Message/MultilingualTextViolationMessageRenderer.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -25,13 +25,13 @@  discard block
 block discarded – undo
25 25
 		'wbqc-violation-message-format-clarification' => 'wbqc-violation-message-format',
26 26
 	];
27 27
 
28
-	public function render( ViolationMessage $violationMessage ): string {
29
-		if ( !array_key_exists( $violationMessage->getMessageKey(), self::ALTERNATIVE_MESSAGE_KEYS ) ) {
30
-			return parent::render( $violationMessage );
28
+	public function render(ViolationMessage $violationMessage): string {
29
+		if (!array_key_exists($violationMessage->getMessageKey(), self::ALTERNATIVE_MESSAGE_KEYS)) {
30
+			return parent::render($violationMessage);
31 31
 		}
32 32
 
33 33
 		$arguments = $violationMessage->getArguments();
34
-		$multilingualTextArgument = array_pop( $arguments );
34
+		$multilingualTextArgument = array_pop($arguments);
35 35
 		$multilingualTextParams = $this->renderMultilingualText(
36 36
 			// @phan-suppress-next-line PhanTypeArraySuspiciousNullable TODO Ensure this is not an actual issue
37 37
 			$multilingualTextArgument['value'],
@@ -39,22 +39,22 @@  discard block
 block discarded – undo
39 39
 			$multilingualTextArgument['role']
40 40
 		);
41 41
 
42
-		$paramsLists = [ [] ];
43
-		foreach ( $arguments as $argument ) {
44
-			$paramsLists[] = $this->renderArgument( $argument );
42
+		$paramsLists = [[]];
43
+		foreach ($arguments as $argument) {
44
+			$paramsLists[] = $this->renderArgument($argument);
45 45
 		}
46
-		$regularParams = call_user_func_array( 'array_merge', $paramsLists );
46
+		$regularParams = call_user_func_array('array_merge', $paramsLists);
47 47
 
48
-		if ( $multilingualTextParams === null ) {
48
+		if ($multilingualTextParams === null) {
49 49
 			return $this->messageLocalizer
50
-				->msg( self::ALTERNATIVE_MESSAGE_KEYS[$violationMessage->getMessageKey()] )
51
-				->params( $regularParams )
50
+				->msg(self::ALTERNATIVE_MESSAGE_KEYS[$violationMessage->getMessageKey()])
51
+				->params($regularParams)
52 52
 				->escaped();
53 53
 		} else {
54 54
 			return $this->messageLocalizer
55
-				->msg( $violationMessage->getMessageKey() )
56
-				->params( $regularParams )
57
-				->params( $multilingualTextParams )
55
+				->msg($violationMessage->getMessageKey())
56
+				->params($regularParams)
57
+				->params($multilingualTextParams)
58 58
 				->escaped();
59 59
 		}
60 60
 	}
@@ -65,18 +65,18 @@  discard block
 block discarded – undo
65 65
 	 * @return array[]|null list of parameters as accepted by Message::params(),
66 66
 	 * or null if the text is not available in the user’s language
67 67
 	 */
68
-	protected function renderMultilingualText( MultilingualTextValue $text, $role ) {
68
+	protected function renderMultilingualText(MultilingualTextValue $text, $role) {
69 69
 		global $wgLang;
70 70
 		$languageCodes = $wgLang->getFallbackLanguages();
71
-		array_unshift( $languageCodes, $wgLang->getCode() );
71
+		array_unshift($languageCodes, $wgLang->getCode());
72 72
 
73 73
 		$texts = $text->getTexts();
74
-		foreach ( $languageCodes as $languageCode ) {
75
-			if ( array_key_exists( $languageCode, $texts ) ) {
76
-				return [ Message::rawParam( $this->addRole(
77
-					htmlspecialchars( $texts[$languageCode]->getText() ),
74
+		foreach ($languageCodes as $languageCode) {
75
+			if (array_key_exists($languageCode, $texts)) {
76
+				return [Message::rawParam($this->addRole(
77
+					htmlspecialchars($texts[$languageCode]->getText()),
78 78
 					$role
79
-				) ) ];
79
+				))];
80 80
 			}
81 81
 		}
82 82
 
Please login to merge, or discard this patch.
src/Api/CheckResultsRendererFactory.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types = 1 );
3
+declare(strict_types=1);
4 4
 
5 5
 namespace WikibaseQuality\ConstraintReport\Api;
6 6
 
@@ -41,9 +41,9 @@  discard block
 block discarded – undo
41 41
 		return new CheckResultsRenderer(
42 42
 			$this->entityTitleLookup,
43 43
 			$this->entityIdLabelFormatterFactory
44
-				->getEntityIdFormatter( $userLanguage ),
44
+				->getEntityIdFormatter($userLanguage),
45 45
 			$this->violationMessageRendererFactory
46
-				->getViolationMessageRenderer( $userLanguage, $messageLocalizer )
46
+				->getViolationMessageRenderer($userLanguage, $messageLocalizer)
47 47
 		);
48 48
 	}
49 49
 
Please login to merge, or discard this patch.
src/Api/CheckConstraints.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -119,11 +119,11 @@  discard block
 block discarded – undo
119 119
 		CheckResultsRendererFactory $checkResultsRendererFactory,
120 120
 		IBufferingStatsdDataFactory $dataFactory
121 121
 	) {
122
-		parent::__construct( $main, $name );
122
+		parent::__construct($main, $name);
123 123
 		$this->entityIdParser = $entityIdParser;
124 124
 		$this->statementGuidValidator = $statementGuidValidator;
125
-		$this->resultBuilder = $apiHelperFactory->getResultBuilder( $this );
126
-		$this->errorReporter = $apiHelperFactory->getErrorReporter( $this );
125
+		$this->resultBuilder = $apiHelperFactory->getResultBuilder($this);
126
+		$this->errorReporter = $apiHelperFactory->getErrorReporter($this);
127 127
 		$this->resultsSource = $resultsSource;
128 128
 		$this->checkResultsRendererFactory = $checkResultsRendererFactory;
129 129
 		$this->dataFactory = $dataFactory;
@@ -139,14 +139,14 @@  discard block
 block discarded – undo
139 139
 
140 140
 		$params = $this->extractRequestParams();
141 141
 
142
-		$this->validateParameters( $params );
143
-		$entityIds = $this->parseEntityIds( $params );
144
-		$claimIds = $this->parseClaimIds( $params );
142
+		$this->validateParameters($params);
143
+		$entityIds = $this->parseEntityIds($params);
144
+		$claimIds = $this->parseClaimIds($params);
145 145
 		$constraintIDs = $params[self::PARAM_CONSTRAINT_ID];
146 146
 		$statuses = $params[self::PARAM_STATUS];
147 147
 
148 148
 		$checkResultsRenderer = $this->checkResultsRendererFactory
149
-			->getCheckResultsRenderer( $this->getLanguage(), $this );
149
+			->getCheckResultsRenderer($this->getLanguage(), $this);
150 150
 
151 151
 		$this->getResult()->addValue(
152 152
 			null,
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 				)
161 161
 			)->getArray()
162 162
 		);
163
-		$this->resultBuilder->markSuccess( 1 );
163
+		$this->resultBuilder->markSuccess(1);
164 164
 	}
165 165
 
166 166
 	/**
@@ -168,24 +168,24 @@  discard block
 block discarded – undo
168 168
 	 *
169 169
 	 * @return EntityId[]
170 170
 	 */
171
-	private function parseEntityIds( array $params ) {
171
+	private function parseEntityIds(array $params) {
172 172
 		$ids = $params[self::PARAM_ID];
173 173
 
174
-		if ( $ids === null ) {
174
+		if ($ids === null) {
175 175
 			return [];
176
-		} elseif ( $ids === [] ) {
176
+		} elseif ($ids === []) {
177 177
 			$this->errorReporter->dieError(
178
-				'If ' . self::PARAM_ID . ' is specified, it must be nonempty.', 'no-data' );
178
+				'If '.self::PARAM_ID.' is specified, it must be nonempty.', 'no-data' );
179 179
 		}
180 180
 
181
-		return array_map( function ( $id ) {
181
+		return array_map(function($id) {
182 182
 			try {
183
-				return $this->entityIdParser->parse( $id );
184
-			} catch ( EntityIdParsingException $e ) {
183
+				return $this->entityIdParser->parse($id);
184
+			} catch (EntityIdParsingException $e) {
185 185
 				$this->errorReporter->dieError(
186
-					"Invalid id: $id", 'invalid-entity-id', 0, [ self::PARAM_ID => $id ] );
186
+					"Invalid id: $id", 'invalid-entity-id', 0, [self::PARAM_ID => $id] );
187 187
 			}
188
-		}, $ids );
188
+		}, $ids);
189 189
 	}
190 190
 
191 191
 	/**
@@ -193,35 +193,35 @@  discard block
 block discarded – undo
193 193
 	 *
194 194
 	 * @return string[]
195 195
 	 */
196
-	private function parseClaimIds( array $params ) {
196
+	private function parseClaimIds(array $params) {
197 197
 		$ids = $params[self::PARAM_CLAIM_ID];
198 198
 
199
-		if ( $ids === null ) {
199
+		if ($ids === null) {
200 200
 			return [];
201
-		} elseif ( $ids === [] ) {
201
+		} elseif ($ids === []) {
202 202
 			$this->errorReporter->dieError(
203
-				'If ' . self::PARAM_CLAIM_ID . ' is specified, it must be nonempty.', 'no-data' );
203
+				'If '.self::PARAM_CLAIM_ID.' is specified, it must be nonempty.', 'no-data' );
204 204
 		}
205 205
 
206
-		foreach ( $ids as $id ) {
207
-			if ( !$this->statementGuidValidator->validate( $id ) ) {
206
+		foreach ($ids as $id) {
207
+			if (!$this->statementGuidValidator->validate($id)) {
208 208
 				$this->errorReporter->dieError(
209
-					"Invalid claim id: $id", 'invalid-guid', 0, [ self::PARAM_CLAIM_ID => $id ] );
209
+					"Invalid claim id: $id", 'invalid-guid', 0, [self::PARAM_CLAIM_ID => $id] );
210 210
 			}
211 211
 		}
212 212
 
213 213
 		return $ids;
214 214
 	}
215 215
 
216
-	private function validateParameters( array $params ) {
217
-		if ( $params[self::PARAM_CONSTRAINT_ID] !== null
218
-			 && empty( $params[self::PARAM_CONSTRAINT_ID] )
216
+	private function validateParameters(array $params) {
217
+		if ($params[self::PARAM_CONSTRAINT_ID] !== null
218
+			 && empty($params[self::PARAM_CONSTRAINT_ID])
219 219
 		) {
220 220
 			$paramConstraintId = self::PARAM_CONSTRAINT_ID;
221 221
 			$this->errorReporter->dieError(
222 222
 				"If $paramConstraintId is specified, it must be nonempty.", 'no-data' );
223 223
 		}
224
-		if ( $params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null ) {
224
+		if ($params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null) {
225 225
 			$paramId = self::PARAM_ID;
226 226
 			$paramClaimId = self::PARAM_CLAIM_ID;
227 227
 			$this->errorReporter->dieError(
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
 				],
263 263
 				ParamValidator::PARAM_ISMULTI => true,
264 264
 				ParamValidator::PARAM_ALL => true,
265
-				ParamValidator::PARAM_DEFAULT => implode( '|', CachingResultsSource::CACHED_STATUSES ),
265
+				ParamValidator::PARAM_DEFAULT => implode('|', CachingResultsSource::CACHED_STATUSES),
266 266
 				ApiBase::PARAM_HELP_MSG_PER_VALUE => [],
267 267
 			],
268 268
 		];
Please login to merge, or discard this patch.
src/Api/CheckConstraintParameters.php 1 patch
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -105,9 +105,9 @@  discard block
 block discarded – undo
105 105
 		StatementGuidParser $statementGuidParser,
106 106
 		IBufferingStatsdDataFactory $dataFactory
107 107
 	) {
108
-		parent::__construct( $main, $name );
108
+		parent::__construct($main, $name);
109 109
 
110
-		$this->apiErrorReporter = $apiHelperFactory->getErrorReporter( $this );
110
+		$this->apiErrorReporter = $apiHelperFactory->getErrorReporter($this);
111 111
 		$this->delegatingConstraintChecker = $delegatingConstraintChecker;
112 112
 		$this->violationMessageRendererFactory = $violationMessageRendererFactory;
113 113
 		$this->statementGuidParser = $statementGuidParser;
@@ -122,39 +122,39 @@  discard block
 block discarded – undo
122 122
 		$params = $this->extractRequestParams();
123 123
 		$result = $this->getResult();
124 124
 
125
-		$propertyIds = $this->parsePropertyIds( $params[self::PARAM_PROPERTY_ID] );
126
-		$constraintIds = $this->parseConstraintIds( $params[self::PARAM_CONSTRAINT_ID] );
125
+		$propertyIds = $this->parsePropertyIds($params[self::PARAM_PROPERTY_ID]);
126
+		$constraintIds = $this->parseConstraintIds($params[self::PARAM_CONSTRAINT_ID]);
127 127
 
128
-		$this->checkPropertyIds( $propertyIds, $result );
129
-		$this->checkConstraintIds( $constraintIds, $result );
128
+		$this->checkPropertyIds($propertyIds, $result);
129
+		$this->checkConstraintIds($constraintIds, $result);
130 130
 
131
-		$result->addValue( null, 'success', 1 );
131
+		$result->addValue(null, 'success', 1);
132 132
 	}
133 133
 
134 134
 	/**
135 135
 	 * @param array|null $propertyIdSerializations
136 136
 	 * @return NumericPropertyId[]
137 137
 	 */
138
-	private function parsePropertyIds( $propertyIdSerializations ) {
139
-		if ( $propertyIdSerializations === null ) {
138
+	private function parsePropertyIds($propertyIdSerializations) {
139
+		if ($propertyIdSerializations === null) {
140 140
 			return [];
141
-		} elseif ( empty( $propertyIdSerializations ) ) {
141
+		} elseif (empty($propertyIdSerializations)) {
142 142
 			$this->apiErrorReporter->dieError(
143
-				'If ' . self::PARAM_PROPERTY_ID . ' is specified, it must be nonempty.',
143
+				'If '.self::PARAM_PROPERTY_ID.' is specified, it must be nonempty.',
144 144
 				'no-data'
145 145
 			);
146 146
 		}
147 147
 
148 148
 		return array_map(
149
-			function ( $propertyIdSerialization ) {
149
+			function($propertyIdSerialization) {
150 150
 				try {
151
-					return new NumericPropertyId( $propertyIdSerialization );
152
-				} catch ( InvalidArgumentException $e ) {
151
+					return new NumericPropertyId($propertyIdSerialization);
152
+				} catch (InvalidArgumentException $e) {
153 153
 					$this->apiErrorReporter->dieError(
154 154
 						"Invalid id: $propertyIdSerialization",
155 155
 						'invalid-property-id',
156 156
 						0, // default argument
157
-						[ self::PARAM_PROPERTY_ID => $propertyIdSerialization ]
157
+						[self::PARAM_PROPERTY_ID => $propertyIdSerialization]
158 158
 					);
159 159
 				}
160 160
 			},
@@ -166,35 +166,35 @@  discard block
 block discarded – undo
166 166
 	 * @param array|null $constraintIds
167 167
 	 * @return string[]
168 168
 	 */
169
-	private function parseConstraintIds( $constraintIds ) {
170
-		if ( $constraintIds === null ) {
169
+	private function parseConstraintIds($constraintIds) {
170
+		if ($constraintIds === null) {
171 171
 			return [];
172
-		} elseif ( empty( $constraintIds ) ) {
172
+		} elseif (empty($constraintIds)) {
173 173
 			$this->apiErrorReporter->dieError(
174
-				'If ' . self::PARAM_CONSTRAINT_ID . ' is specified, it must be nonempty.',
174
+				'If '.self::PARAM_CONSTRAINT_ID.' is specified, it must be nonempty.',
175 175
 				'no-data'
176 176
 			);
177 177
 		}
178 178
 
179 179
 		return array_map(
180
-			function ( $constraintId ) {
180
+			function($constraintId) {
181 181
 				try {
182
-					$propertyId = $this->statementGuidParser->parse( $constraintId )->getEntityId();
183
-					if ( !$propertyId instanceof NumericPropertyId ) {
182
+					$propertyId = $this->statementGuidParser->parse($constraintId)->getEntityId();
183
+					if (!$propertyId instanceof NumericPropertyId) {
184 184
 						$this->apiErrorReporter->dieError(
185 185
 							"Invalid property ID: {$propertyId->getSerialization()}",
186 186
 							'invalid-property-id',
187 187
 							0, // default argument
188
-							[ self::PARAM_CONSTRAINT_ID => $constraintId ]
188
+							[self::PARAM_CONSTRAINT_ID => $constraintId]
189 189
 						);
190 190
 					}
191 191
 					return $constraintId;
192
-				} catch ( StatementGuidParsingException $e ) {
192
+				} catch (StatementGuidParsingException $e) {
193 193
 					$this->apiErrorReporter->dieError(
194 194
 						"Invalid statement GUID: $constraintId",
195 195
 						'invalid-guid',
196 196
 						0, // default argument
197
-						[ self::PARAM_CONSTRAINT_ID => $constraintId ]
197
+						[self::PARAM_CONSTRAINT_ID => $constraintId]
198 198
 					);
199 199
 				}
200 200
 			},
@@ -206,12 +206,12 @@  discard block
 block discarded – undo
206 206
 	 * @param NumericPropertyId[] $propertyIds
207 207
 	 * @param ApiResult $result
208 208
 	 */
209
-	private function checkPropertyIds( array $propertyIds, ApiResult $result ) {
210
-		foreach ( $propertyIds as $propertyId ) {
211
-			$result->addArrayType( $this->getResultPathForPropertyId( $propertyId ), 'assoc' );
209
+	private function checkPropertyIds(array $propertyIds, ApiResult $result) {
210
+		foreach ($propertyIds as $propertyId) {
211
+			$result->addArrayType($this->getResultPathForPropertyId($propertyId), 'assoc');
212 212
 			$allConstraintExceptions = $this->delegatingConstraintChecker
213
-				->checkConstraintParametersOnPropertyId( $propertyId );
214
-			foreach ( $allConstraintExceptions as $constraintId => $constraintParameterExceptions ) {
213
+				->checkConstraintParametersOnPropertyId($propertyId);
214
+			foreach ($allConstraintExceptions as $constraintId => $constraintParameterExceptions) {
215 215
 				$this->addConstraintParameterExceptionsToResult(
216 216
 					$constraintId,
217 217
 					$constraintParameterExceptions,
@@ -225,15 +225,15 @@  discard block
 block discarded – undo
225 225
 	 * @param string[] $constraintIds
226 226
 	 * @param ApiResult $result
227 227
 	 */
228
-	private function checkConstraintIds( array $constraintIds, ApiResult $result ) {
229
-		foreach ( $constraintIds as $constraintId ) {
230
-			if ( $result->getResultData( $this->getResultPathForConstraintId( $constraintId ) ) ) {
228
+	private function checkConstraintIds(array $constraintIds, ApiResult $result) {
229
+		foreach ($constraintIds as $constraintId) {
230
+			if ($result->getResultData($this->getResultPathForConstraintId($constraintId))) {
231 231
 				// already checked as part of checkPropertyIds()
232 232
 				continue;
233 233
 			}
234 234
 			$constraintParameterExceptions = $this->delegatingConstraintChecker
235
-				->checkConstraintParametersOnConstraintId( $constraintId );
236
-			$this->addConstraintParameterExceptionsToResult( $constraintId, $constraintParameterExceptions, $result );
235
+				->checkConstraintParametersOnConstraintId($constraintId);
236
+			$this->addConstraintParameterExceptionsToResult($constraintId, $constraintParameterExceptions, $result);
237 237
 		}
238 238
 	}
239 239
 
@@ -241,18 +241,18 @@  discard block
 block discarded – undo
241 241
 	 * @param NumericPropertyId $propertyId
242 242
 	 * @return string[]
243 243
 	 */
244
-	private function getResultPathForPropertyId( NumericPropertyId $propertyId ) {
245
-		return [ $this->getModuleName(), $propertyId->getSerialization() ];
244
+	private function getResultPathForPropertyId(NumericPropertyId $propertyId) {
245
+		return [$this->getModuleName(), $propertyId->getSerialization()];
246 246
 	}
247 247
 
248 248
 	/**
249 249
 	 * @param string $constraintId
250 250
 	 * @return string[]
251 251
 	 */
252
-	private function getResultPathForConstraintId( $constraintId ) {
253
-		$propertyId = $this->statementGuidParser->parse( $constraintId )->getEntityId();
252
+	private function getResultPathForConstraintId($constraintId) {
253
+		$propertyId = $this->statementGuidParser->parse($constraintId)->getEntityId();
254 254
 		'@phan-var NumericPropertyId $propertyId';
255
-		return array_merge( $this->getResultPathForPropertyId( $propertyId ), [ $constraintId ] );
255
+		return array_merge($this->getResultPathForPropertyId($propertyId), [$constraintId]);
256 256
 	}
257 257
 
258 258
 	/**
@@ -267,8 +267,8 @@  discard block
 block discarded – undo
267 267
 		$constraintParameterExceptions,
268 268
 		ApiResult $result
269 269
 	) {
270
-		$path = $this->getResultPathForConstraintId( $constraintId );
271
-		if ( $constraintParameterExceptions === null ) {
270
+		$path = $this->getResultPathForConstraintId($constraintId);
271
+		if ($constraintParameterExceptions === null) {
272 272
 			$result->addValue(
273 273
 				$path,
274 274
 				self::KEY_STATUS,
@@ -278,13 +278,13 @@  discard block
 block discarded – undo
278 278
 			$result->addValue(
279 279
 				$path,
280 280
 				self::KEY_STATUS,
281
-				empty( $constraintParameterExceptions ) ? self::STATUS_OKAY : self::STATUS_NOT_OKAY
281
+				empty($constraintParameterExceptions) ? self::STATUS_OKAY : self::STATUS_NOT_OKAY
282 282
 			);
283 283
 
284 284
 			$violationMessageRenderer = $this->violationMessageRendererFactory
285
-				->getViolationMessageRenderer( $this->getLanguage(), $this );
285
+				->getViolationMessageRenderer($this->getLanguage(), $this);
286 286
 			$problems = [];
287
-			foreach ( $constraintParameterExceptions as $constraintParameterException ) {
287
+			foreach ($constraintParameterExceptions as $constraintParameterException) {
288 288
 				$problems[] = [
289 289
 					self::KEY_MESSAGE_HTML => $violationMessageRenderer->render(
290 290
 						$constraintParameterException->getViolationMessage() ),
@@ -323,8 +323,8 @@  discard block
 block discarded – undo
323 323
 		return [
324 324
 			'action=wbcheckconstraintparameters&propertyid=P247'
325 325
 				=> 'apihelp-wbcheckconstraintparameters-example-propertyid-1',
326
-			'action=wbcheckconstraintparameters&' .
327
-			'constraintid=P247$0fe1711e-4c0f-82ce-3af0-830b721d0fba|' .
326
+			'action=wbcheckconstraintparameters&'.
327
+			'constraintid=P247$0fe1711e-4c0f-82ce-3af0-830b721d0fba|'.
328 328
 			'P225$cdc71e4a-47a0-12c5-dfb3-3f6fc0b6613f'
329 329
 				=> 'apihelp-wbcheckconstraintparameters-example-constraintid-2',
330 330
 		];
Please login to merge, or discard this patch.
src/ConstraintCheck/Message/ViolationMessageRendererFactory.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types = 1 );
3
+declare(strict_types=1);
4 4
 
5 5
 namespace WikibaseQuality\ConstraintReport\ConstraintCheck\Message;
6 6
 
@@ -41,12 +41,12 @@  discard block
 block discarded – undo
41 41
 	): ViolationMessageRenderer {
42 42
 		$userLanguageCode = $userLanguage->getCode();
43 43
 		$formatterOptions = new FormatterOptions();
44
-		$formatterOptions->setOption( SnakFormatter::OPT_LANG, $userLanguageCode );
44
+		$formatterOptions->setOption(SnakFormatter::OPT_LANG, $userLanguageCode);
45 45
 		return new MultilingualTextViolationMessageRenderer(
46 46
 			$this->entityIdHtmlLinkFormatterFactory
47
-				->getEntityIdFormatter( $userLanguage ),
47
+				->getEntityIdFormatter($userLanguage),
48 48
 			$this->valueFormatterFactory
49
-				->getValueFormatter( SnakFormatter::FORMAT_HTML, $formatterOptions ),
49
+				->getValueFormatter(SnakFormatter::FORMAT_HTML, $formatterOptions),
50 50
 			$this->languageNameUtils,
51 51
 			$messageLocalizer,
52 52
 			$this->config
Please login to merge, or discard this patch.