Completed
Push — master ( 16f39d...70074f )
by
unknown
07:00
created
src/ConstraintCheck/Helper/ValueCountCheckerHelper.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -20,13 +20,13 @@
 block discarded – undo
20 20
 	 * @param PropertyId $propertyId
21 21
 	 * @return int
22 22
 	 */
23
-	public function getPropertyCount( array $snaks, PropertyId $propertyId ) {
24
-		return count( array_filter(
23
+	public function getPropertyCount(array $snaks, PropertyId $propertyId) {
24
+		return count(array_filter(
25 25
 			$snaks,
26
-			function ( Snak $snak ) use ( $propertyId ) {
27
-				return $snak->getPropertyId()->equals( $propertyId );
26
+			function(Snak $snak) use ($propertyId) {
27
+				return $snak->getPropertyId()->equals($propertyId);
28 28
 			}
29
-		) );
29
+		));
30 30
 	}
31 31
 
32 32
 }
Please login to merge, or discard this patch.
src/Api/ResultsCache.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -19,10 +19,10 @@  discard block
 block discarded – undo
19 19
 	private $cache;
20 20
 
21 21
 	public static function getDefaultInstance() {
22
-		return new self( MediaWikiServices::getInstance()->getMainWANObjectCache() );
22
+		return new self(MediaWikiServices::getInstance()->getMainWANObjectCache());
23 23
 	}
24 24
 
25
-	public function __construct( WANObjectCache $cache ) {
25
+	public function __construct(WANObjectCache $cache) {
26 26
 		$this->cache = $cache;
27 27
 	}
28 28
 
@@ -31,12 +31,12 @@  discard block
 block discarded – undo
31 31
 	 * @param string|null $languageCode defaults to user language
32 32
 	 * @return string cache key
33 33
 	 */
34
-	public function makeKey( EntityId $entityId, $languageCode = null ) {
34
+	public function makeKey(EntityId $entityId, $languageCode = null) {
35 35
 		global $wgLang, $wgContLang;
36
-		if ( $languageCode === null ) {
36
+		if ($languageCode === null) {
37 37
 			$languageCode = $wgLang->getCode();
38 38
 		}
39
-		if ( !Language::isKnownLanguageTag( $languageCode ) && $languageCode !== 'qqx' ) {
39
+		if (!Language::isKnownLanguageTag($languageCode) && $languageCode !== 'qqx') {
40 40
 			$languageCode = $wgContLang->getCode();
41 41
 		}
42 42
 		return $this->cache->makeKey(
@@ -55,8 +55,8 @@  discard block
 block discarded – undo
55 55
 	 * @param float &$asOf
56 56
 	 * @return mixed
57 57
 	 */
58
-	public function get( EntityId $key, &$curTTL = null, array $checkKeys = [], &$asOf = null ) {
59
-		return $this->cache->get( $this->makeKey( $key ), $curTTL, $checkKeys, $asOf );
58
+	public function get(EntityId $key, &$curTTL = null, array $checkKeys = [], &$asOf = null) {
59
+		return $this->cache->get($this->makeKey($key), $curTTL, $checkKeys, $asOf);
60 60
 	}
61 61
 
62 62
 	/**
@@ -66,20 +66,20 @@  discard block
 block discarded – undo
66 66
 	 * @param array $opts
67 67
 	 * @return bool
68 68
 	 */
69
-	public function set( EntityId $key, $value, $ttl = 0, array $opts = [] ) {
70
-		return $this->cache->set( $this->makeKey( $key ), $value, $ttl, $opts );
69
+	public function set(EntityId $key, $value, $ttl = 0, array $opts = []) {
70
+		return $this->cache->set($this->makeKey($key), $value, $ttl, $opts);
71 71
 	}
72 72
 
73 73
 	/**
74 74
 	 * @param EntityId $key
75 75
 	 * @return bool
76 76
 	 */
77
-	public function delete( EntityId $key ) {
77
+	public function delete(EntityId $key) {
78 78
 		$ok = true;
79
-		$languageCodes = array_keys( Language::fetchLanguageNames( null, 'all' ) );
79
+		$languageCodes = array_keys(Language::fetchLanguageNames(null, 'all'));
80 80
 		$languageCodes[] = 'qqx';
81
-		foreach ( $languageCodes as $languageCode ) {
82
-			$ok = $this->cache->delete( $this->makeKey( $key, $languageCode ) ) && $ok;
81
+		foreach ($languageCodes as $languageCode) {
82
+			$ok = $this->cache->delete($this->makeKey($key, $languageCode)) && $ok;
83 83
 		}
84 84
 		return $ok;
85 85
 	}
Please login to merge, or discard this patch.
src/ConstraintRepository.php 1 patch
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -20,23 +20,23 @@  discard block
 block discarded – undo
20 20
 	 *
21 21
 	 * @return Constraint[]
22 22
 	 */
23
-	public function queryConstraintsForProperty( PropertyId $propertyId ) {
24
-		$db = wfGetDB( DB_REPLICA );
23
+	public function queryConstraintsForProperty(PropertyId $propertyId) {
24
+		$db = wfGetDB(DB_REPLICA);
25 25
 
26 26
 		$results = $db->select(
27 27
 			'wbqc_constraints',
28 28
 			'*',
29
-			[ 'pid' => $propertyId->getNumericId() ]
29
+			['pid' => $propertyId->getNumericId()]
30 30
 		);
31 31
 
32
-		return $this->convertToConstraints( $results );
32
+		return $this->convertToConstraints($results);
33 33
 	}
34 34
 
35
-	private function encodeConstraintParameters( array $constraintParameters ) {
36
-		$json = json_encode( $constraintParameters, JSON_FORCE_OBJECT );
35
+	private function encodeConstraintParameters(array $constraintParameters) {
36
+		$json = json_encode($constraintParameters, JSON_FORCE_OBJECT);
37 37
 
38
-		if ( strlen( $json ) > 50000 ) {
39
-			$json = json_encode( [ '@error' => [ 'toolong' => true ] ] );
38
+		if (strlen($json) > 50000) {
39
+			$json = json_encode(['@error' => ['toolong' => true]]);
40 40
 		}
41 41
 
42 42
 		return $json;
@@ -48,21 +48,21 @@  discard block
 block discarded – undo
48 48
 	 * @throws DBUnexpectedError
49 49
 	 * @return bool
50 50
 	 */
51
-	public function insertBatch( array $constraints ) {
51
+	public function insertBatch(array $constraints) {
52 52
 		$accumulator = array_map(
53
-			function ( Constraint $constraint ) {
53
+			function(Constraint $constraint) {
54 54
 				return [
55 55
 					'constraint_guid' => $constraint->getConstraintId(),
56 56
 					'pid' => $constraint->getPropertyId()->getNumericId(),
57 57
 					'constraint_type_qid' => $constraint->getConstraintTypeItemId(),
58
-					'constraint_parameters' => $this->encodeConstraintParameters( $constraint->getConstraintParameters() )
58
+					'constraint_parameters' => $this->encodeConstraintParameters($constraint->getConstraintParameters())
59 59
 				];
60 60
 			},
61 61
 			$constraints
62 62
 		);
63 63
 
64
-		$db = wfGetDB( DB_MASTER );
65
-		return $db->insert( 'wbqc_constraints', $accumulator );
64
+		$db = wfGetDB(DB_MASTER);
65
+		return $db->insert('wbqc_constraints', $accumulator);
66 66
 	}
67 67
 
68 68
 	/**
@@ -70,13 +70,13 @@  discard block
 block discarded – undo
70 70
 	 *
71 71
 	 * @return array
72 72
 	 */
73
-	private function uuidPattern( LikeMatch $any ) {
73
+	private function uuidPattern(LikeMatch $any) {
74 74
 		return array_merge(
75
-			array_fill( 0, 8, $any ), [ '-' ],
76
-			array_fill( 0, 4, $any ), [ '-' ],
77
-			array_fill( 0, 4, $any ), [ '-' ],
78
-			array_fill( 0, 4, $any ), [ '-' ],
79
-			array_fill( 0, 12, $any )
75
+			array_fill(0, 8, $any), ['-'],
76
+			array_fill(0, 4, $any), ['-'],
77
+			array_fill(0, 4, $any), ['-'],
78
+			array_fill(0, 4, $any), ['-'],
79
+			array_fill(0, 12, $any)
80 80
 		);
81 81
 	}
82 82
 
@@ -87,11 +87,11 @@  discard block
 block discarded – undo
87 87
 	 * @throws DBUnexpectedError
88 88
 	 */
89 89
 	public function deleteWhereConstraintIdIsUuid() {
90
-		$db = wfGetDB( DB_MASTER );
90
+		$db = wfGetDB(DB_MASTER);
91 91
 		$db->delete(
92 92
 			'wbqc_constraints',
93 93
 			// WHERE constraint_guid LIKE ________-____-____-____-____________
94
-			'constraint_guid ' . $db->buildLike( $this->uuidPattern( $db->anyChar() ) )
94
+			'constraint_guid '.$db->buildLike($this->uuidPattern($db->anyChar()))
95 95
 		);
96 96
 	}
97 97
 
@@ -103,14 +103,14 @@  discard block
 block discarded – undo
103 103
 	 *
104 104
 	 * @throws DBUnexpectedError
105 105
 	 */
106
-	public function deleteForPropertyWhereConstraintIdIsStatementId( PropertyId $propertyId ) {
107
-		$db = wfGetDB( DB_MASTER );
106
+	public function deleteForPropertyWhereConstraintIdIsStatementId(PropertyId $propertyId) {
107
+		$db = wfGetDB(DB_MASTER);
108 108
 		$db->delete(
109 109
 			'wbqc_constraints',
110 110
 			[
111 111
 				'pid' => $propertyId->getNumericId(),
112 112
 				// AND constraint_guid LIKE %$________-____-____-____-____________
113
-				'constraint_guid ' . $db->buildLike( array_merge( [ $db->anyString(), '$' ], $this->uuidPattern( $db->anyChar() ) ) )
113
+				'constraint_guid '.$db->buildLike(array_merge([$db->anyString(), '$'], $this->uuidPattern($db->anyChar())))
114 114
 			]
115 115
 		);
116 116
 	}
@@ -121,20 +121,20 @@  discard block
 block discarded – undo
121 121
 	 * @throws InvalidArgumentException
122 122
 	 * @throws DBUnexpectedError
123 123
 	 */
124
-	public function deleteAll( $batchSize = 1000 ) {
125
-		if ( !is_int( $batchSize ) ) {
124
+	public function deleteAll($batchSize = 1000) {
125
+		if (!is_int($batchSize)) {
126 126
 			throw new InvalidArgumentException();
127 127
 		}
128
-		$db = wfGetDB( DB_MASTER );
129
-		if ( $db->getType() === 'sqlite' ) {
130
-			$db->delete( 'wbqc_constraints', '*' );
128
+		$db = wfGetDB(DB_MASTER);
129
+		if ($db->getType() === 'sqlite') {
130
+			$db->delete('wbqc_constraints', '*');
131 131
 		} else {
132 132
 			do {
133
-				$db->commit( __METHOD__, 'flush' );
133
+				$db->commit(__METHOD__, 'flush');
134 134
 				wfGetLBFactory()->waitForReplication();
135
-				$table = $db->tableName( 'wbqc_constraints' );
136
-				$db->query( sprintf( 'DELETE FROM %s LIMIT %d', $table, $batchSize ) );
137
-			} while ( $db->affectedRows() > 0 );
135
+				$table = $db->tableName('wbqc_constraints');
136
+				$db->query(sprintf('DELETE FROM %s LIMIT %d', $table, $batchSize));
137
+			} while ($db->affectedRows() > 0);
138 138
 		}
139 139
 	}
140 140
 
@@ -143,26 +143,26 @@  discard block
 block discarded – undo
143 143
 	 *
144 144
 	 * @return Constraint[]
145 145
 	 */
146
-	private function convertToConstraints( IResultWrapper $results ) {
146
+	private function convertToConstraints(IResultWrapper $results) {
147 147
 		$constraints = [];
148
-		foreach ( $results as $result ) {
148
+		foreach ($results as $result) {
149 149
 			$constraintTypeItemId = $result->constraint_type_qid;
150
-			$constraintParameters = json_decode( $result->constraint_parameters, true );
150
+			$constraintParameters = json_decode($result->constraint_parameters, true);
151 151
 
152
-			if ( $constraintParameters === null ) {
152
+			if ($constraintParameters === null) {
153 153
 				// T171295
154
-				LoggerFactory::getInstance( 'WikibaseQualityConstraints' )
155
-					->warning( 'Constraint {constraintId} has invalid constraint parameters.', [
154
+				LoggerFactory::getInstance('WikibaseQualityConstraints')
155
+					->warning('Constraint {constraintId} has invalid constraint parameters.', [
156 156
 						'method' => __METHOD__,
157 157
 						'constraintId' => $result->constraint_guid,
158 158
 						'constraintParameters' => $result->constraint_parameters,
159
-					] );
160
-				$constraintParameters = [ '@error' => [ /* unknown */ ] ];
159
+					]);
160
+				$constraintParameters = ['@error' => [/* unknown */]];
161 161
 			}
162 162
 
163 163
 			$constraints[] = new Constraint(
164 164
 				$result->constraint_guid,
165
-				PropertyId::newFromNumber( $result->pid ),
165
+				PropertyId::newFromNumber($result->pid),
166 166
 				$constraintTypeItemId,
167 167
 				$constraintParameters
168 168
 			);
Please login to merge, or discard this patch.
maintenance/ImportConstraintStatements.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -9,10 +9,10 @@  discard block
 block discarded – undo
9 9
 use Wikibase\Repo\WikibaseRepo;
10 10
 
11 11
 // @codeCoverageIgnoreStart
12
-$basePath = getenv( "MW_INSTALL_PATH" ) !== false
13
-	? getenv( "MW_INSTALL_PATH" ) : __DIR__ . "/../../..";
12
+$basePath = getenv("MW_INSTALL_PATH") !== false
13
+	? getenv("MW_INSTALL_PATH") : __DIR__."/../../..";
14 14
 
15
-require_once $basePath . "/maintenance/Maintenance.php";
15
+require_once $basePath."/maintenance/Maintenance.php";
16 16
 // @codeCoverageIgnoreEnd
17 17
 
18 18
 /**
@@ -38,31 +38,31 @@  discard block
 block discarded – undo
38 38
 		parent::__construct();
39 39
 		$repo = WikibaseRepo::getDefaultInstance();
40 40
 		$this->propertyInfoLookup = $repo->getStore()->getPropertyInfoLookup();
41
-		$this->newUpdateConstraintsTableJob = function ( $propertyIdSerialization ) {
41
+		$this->newUpdateConstraintsTableJob = function($propertyIdSerialization) {
42 42
 			return UpdateConstraintsTableJob::newFromGlobalState(
43 43
 				Title::newMainPage(),
44
-				[ 'propertyId' => $propertyIdSerialization ]
44
+				['propertyId' => $propertyIdSerialization]
45 45
 			);
46 46
 		};
47 47
 
48
-		$this->addDescription( 'Imports property constraints from statements on properties' );
49
-		$this->requireExtension( 'WikibaseQualityConstraints' );
48
+		$this->addDescription('Imports property constraints from statements on properties');
49
+		$this->requireExtension('WikibaseQualityConstraints');
50 50
 	}
51 51
 
52 52
 	public function execute() {
53
-		if ( !$this->getConfig()->get( 'WBQualityConstraintsEnableConstraintsImportFromStatements' ) ) {
54
-			$this->error( 'Constraint statements are not enabled. Aborting.' );
53
+		if (!$this->getConfig()->get('WBQualityConstraintsEnableConstraintsImportFromStatements')) {
54
+			$this->error('Constraint statements are not enabled. Aborting.');
55 55
 			return;
56 56
 		}
57 57
 
58
-		foreach ( $this->propertyInfoLookup->getAllPropertyInfo() as $propertyIdSerialization => $info ) {
59
-			$this->output( sprintf( 'Importing constraint statements for % 6s... ', $propertyIdSerialization ), $propertyIdSerialization );
60
-			$startTime = microtime( true );
61
-			$job = call_user_func( $this->newUpdateConstraintsTableJob, $propertyIdSerialization );
58
+		foreach ($this->propertyInfoLookup->getAllPropertyInfo() as $propertyIdSerialization => $info) {
59
+			$this->output(sprintf('Importing constraint statements for % 6s... ', $propertyIdSerialization), $propertyIdSerialization);
60
+			$startTime = microtime(true);
61
+			$job = call_user_func($this->newUpdateConstraintsTableJob, $propertyIdSerialization);
62 62
 			$job->run();
63
-			$endTime = microtime( true );
64
-			$millis = ( $endTime - $startTime ) * 1000;
65
-			$this->output( sprintf( 'done in % 6.2f ms.', $millis ), $propertyIdSerialization );
63
+			$endTime = microtime(true);
64
+			$millis = ($endTime - $startTime) * 1000;
65
+			$this->output(sprintf('done in % 6.2f ms.', $millis), $propertyIdSerialization);
66 66
 		}
67 67
 	}
68 68
 
Please login to merge, or discard this patch.
src/Api/CheckingResultsBuilder.php 1 patch
Spacing   +30 added lines, -31 removed lines patch added patch discarded remove patch
@@ -83,54 +83,53 @@  discard block
 block discarded – undo
83 83
 	) {
84 84
 		$response = [];
85 85
 		$metadatas = [];
86
-		$statusesFlipped = array_flip( $statuses );
87
-		foreach ( $entityIds as $entityId ) {
86
+		$statusesFlipped = array_flip($statuses);
87
+		foreach ($entityIds as $entityId) {
88 88
 			$results = $this->delegatingConstraintChecker->checkAgainstConstraintsOnEntityId(
89 89
 				$entityId,
90 90
 				$constraintIds,
91
-				[ $this, 'defaultResults' ]
91
+				[$this, 'defaultResults']
92 92
 			);
93
-			$results = array_filter( $results, $this->statusSelected( $statusesFlipped ) );
94
-			foreach ( $results as $result ) {
93
+			$results = array_filter($results, $this->statusSelected($statusesFlipped));
94
+			foreach ($results as $result) {
95 95
 				$metadatas[] = $result->getMetadata();
96
-				$resultArray = $this->checkResultToArray( $result );
97
-				$result->getContext()->storeCheckResultInArray( $resultArray, $response );
96
+				$resultArray = $this->checkResultToArray($result);
97
+				$result->getContext()->storeCheckResultInArray($resultArray, $response);
98 98
 			}
99 99
 		}
100
-		foreach ( $claimIds as $claimId ) {
100
+		foreach ($claimIds as $claimId) {
101 101
 			$results = $this->delegatingConstraintChecker->checkAgainstConstraintsOnClaimId(
102 102
 				$claimId,
103 103
 				$constraintIds,
104
-				[ $this, 'defaultResults' ]
104
+				[$this, 'defaultResults']
105 105
 			);
106
-			$results = array_filter( $results, $this->statusSelected( $statusesFlipped ) );
107
-			foreach ( $results as $result ) {
106
+			$results = array_filter($results, $this->statusSelected($statusesFlipped));
107
+			foreach ($results as $result) {
108 108
 				$metadatas[] = $result->getMetadata();
109
-				$resultArray = $this->checkResultToArray( $result );
110
-				$result->getContext()->storeCheckResultInArray( $resultArray, $response );
109
+				$resultArray = $this->checkResultToArray($result);
110
+				$result->getContext()->storeCheckResultInArray($resultArray, $response);
111 111
 			}
112 112
 		}
113 113
 		return new CachedCheckConstraintsResponse(
114 114
 			$response,
115
-			Metadata::merge( $metadatas )
115
+			Metadata::merge($metadatas)
116 116
 		);
117 117
 	}
118 118
 
119
-	public function defaultResults( Context $context ) {
119
+	public function defaultResults(Context $context) {
120 120
 		return $context->getType() === Context::TYPE_STATEMENT ?
121
-			[ new NullResult( $context ) ] :
122
-			[];
121
+			[new NullResult($context)] : [];
123 122
 	}
124 123
 
125
-	public function statusSelected( array $statusesFlipped ) {
126
-		return function( CheckResult $result ) use ( $statusesFlipped ) {
127
-			return array_key_exists( $result->getStatus(), $statusesFlipped ) ||
124
+	public function statusSelected(array $statusesFlipped) {
125
+		return function(CheckResult $result) use ($statusesFlipped) {
126
+			return array_key_exists($result->getStatus(), $statusesFlipped) ||
128 127
 				$result instanceof NullResult;
129 128
 		};
130 129
 	}
131 130
 
132
-	public function checkResultToArray( CheckResult $checkResult ) {
133
-		if ( $checkResult instanceof NullResult ) {
131
+	public function checkResultToArray(CheckResult $checkResult) {
132
+		if ($checkResult instanceof NullResult) {
134 133
 			return null;
135 134
 		}
136 135
 
@@ -138,10 +137,10 @@  discard block
 block discarded – undo
138 137
 		$typeItemId = $checkResult->getConstraint()->getConstraintTypeItemId();
139 138
 		$constraintPropertyId = $checkResult->getContext()->getSnak()->getPropertyId();
140 139
 
141
-		$title = $this->entityTitleLookup->getTitleForId( $constraintPropertyId );
142
-		$typeLabel = $this->entityIdLabelFormatter->formatEntityId( new ItemId( $typeItemId ) );
140
+		$title = $this->entityTitleLookup->getTitleForId($constraintPropertyId);
141
+		$typeLabel = $this->entityIdLabelFormatter->formatEntityId(new ItemId($typeItemId));
143 142
 		// TODO link to the statement when possible (T169224)
144
-		$link = $title->getFullURL() . '#' . $this->config->get( 'WBQualityConstraintsPropertyConstraintId' );
143
+		$link = $title->getFullURL().'#'.$this->config->get('WBQualityConstraintsPropertyConstraintId');
145 144
 
146 145
 		$constraint = [
147 146
 			'id' => $constraintId,
@@ -150,11 +149,11 @@  discard block
 block discarded – undo
150 149
 			'link' => $link,
151 150
 			'discussLink' => $title->getTalkPage()->getFullURL(),
152 151
 		];
153
-		if ( $this->config->get( 'WBQualityConstraintsIncludeDetailInApi' ) ) {
152
+		if ($this->config->get('WBQualityConstraintsIncludeDetailInApi')) {
154 153
 			$parameters = $checkResult->getParameters();
155 154
 			$constraint += [
156 155
 				'detail' => $parameters,
157
-				'detailHTML' => $this->constraintParameterRenderer->formatParameters( $parameters ),
156
+				'detailHTML' => $this->constraintParameterRenderer->formatParameters($parameters),
158 157
 			];
159 158
 		}
160 159
 
@@ -164,14 +163,14 @@  discard block
 block discarded – undo
164 163
 			'constraint' => $constraint
165 164
 		];
166 165
 		$message = $checkResult->getMessage();
167
-		if ( $message ) {
168
-			$result['message-html'] = $this->violationMessageRenderer->render( $message );
166
+		if ($message) {
167
+			$result['message-html'] = $this->violationMessageRenderer->render($message);
169 168
 		}
170
-		if ( $checkResult->getContext()->getType() === Context::TYPE_STATEMENT ) {
169
+		if ($checkResult->getContext()->getType() === Context::TYPE_STATEMENT) {
171 170
 			$result['claim'] = $checkResult->getContext()->getSnakStatement()->getGuid();
172 171
 		}
173 172
 		$cachingMetadataArray = $checkResult->getMetadata()->getCachingMetadata()->toArray();
174
-		if ( $cachingMetadataArray !== null ) {
173
+		if ($cachingMetadataArray !== null) {
175 174
 			$result['cached'] = $cachingMetadataArray;
176 175
 		}
177 176
 
Please login to merge, or discard this patch.
src/ConstraintCheck/Helper/LoggingHelper.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
 		$this->dataFactory = $dataFactory;
47 47
 		$this->logger = $logger;
48 48
 		$this->constraintCheckDurationLimits = [
49
-			'info' => $config->get( 'WBQualityConstraintsCheckDurationInfoSeconds' ),
50
-			'warning' => $config->get( 'WBQualityConstraintsCheckDurationWarningSeconds' ),
49
+			'info' => $config->get('WBQualityConstraintsCheckDurationInfoSeconds'),
50
+			'warning' => $config->get('WBQualityConstraintsCheckDurationWarningSeconds'),
51 51
 		];
52 52
 	}
53 53
 
@@ -73,46 +73,46 @@  discard block
 block discarded – undo
73 73
 		$durationSeconds,
74 74
 		$method
75 75
 	) {
76
-		$constraintCheckerClassShortName = substr( strrchr( $constraintCheckerClass, '\\' ), 1 );
76
+		$constraintCheckerClassShortName = substr(strrchr($constraintCheckerClass, '\\'), 1);
77 77
 		$constraintTypeItemId = $constraint->getConstraintTypeItemId();
78 78
 
79 79
 		$this->dataFactory->timing(
80
-			'wikibase.quality.constraints.check.timing.' .
81
-				$constraintTypeItemId . '-' .
80
+			'wikibase.quality.constraints.check.timing.'.
81
+				$constraintTypeItemId.'-'.
82 82
 				$constraintCheckerClassShortName,
83 83
 			$durationSeconds * 1000
84 84
 		);
85 85
 
86 86
 		// find the longest limit (and associated log level) that the duration exceeds
87
-		foreach ( $this->constraintCheckDurationLimits as $level => $limit ) {
87
+		foreach ($this->constraintCheckDurationLimits as $level => $limit) {
88 88
 			if (
89 89
 				// duration exceeds this limit
90
-				isset( $limit ) && $durationSeconds > $limit &&
90
+				isset($limit) && $durationSeconds > $limit &&
91 91
 				// this limit is longer than previous longest limit
92
-				( !isset( $limitSeconds ) || $limit > $limitSeconds )
92
+				(!isset($limitSeconds) || $limit > $limitSeconds)
93 93
 			) {
94 94
 				$limitSeconds = $limit;
95 95
 				$logLevel = $level;
96 96
 			}
97 97
 		}
98 98
 
99
-		if ( !isset( $limitSeconds ) ) {
99
+		if (!isset($limitSeconds)) {
100 100
 			return;
101 101
 		}
102
-		if ( $context->getType() !== Context::TYPE_STATEMENT ) {
102
+		if ($context->getType() !== Context::TYPE_STATEMENT) {
103 103
 			// TODO log less details but still log something
104 104
 			return;
105 105
 		}
106 106
 
107 107
 		$resultMessage = $result->getMessage();
108
-		if ( $resultMessage instanceof ViolationMessage ) {
108
+		if ($resultMessage instanceof ViolationMessage) {
109 109
 			$resultMessage = $resultMessage->getMessageKey();
110 110
 		}
111 111
 
112 112
 		$this->logger->log(
113 113
 			$logLevel,
114
-			'Constraint check with {constraintCheckerClassShortName} ' .
115
-			'took longer than {limitSeconds} second(s) ' .
114
+			'Constraint check with {constraintCheckerClassShortName} '.
115
+			'took longer than {limitSeconds} second(s) '.
116 116
 			'(duration: {durationSeconds} seconds).',
117 117
 			[
118 118
 				'method' => $method,
Please login to merge, or discard this patch.
src/Specials/SpecialConstraintReport.php 1 patch
Spacing   +109 added lines, -110 removed lines patch added patch discarded remove patch
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 		Config $config,
134 134
 		IBufferingStatsdDataFactory $dataFactory
135 135
 	) {
136
-		parent::__construct( 'ConstraintReport' );
136
+		parent::__construct('ConstraintReport');
137 137
 
138 138
 		$this->entityLookup = $entityLookup;
139 139
 		$this->entityTitleLookup = $entityTitleLookup;
@@ -142,13 +142,13 @@  discard block
 block discarded – undo
142 142
 		$language = $this->getLanguage();
143 143
 
144 144
 		$formatterOptions = new FormatterOptions();
145
-		$formatterOptions->setOption( SnakFormatter::OPT_LANG, $language->getCode() );
145
+		$formatterOptions->setOption(SnakFormatter::OPT_LANG, $language->getCode());
146 146
 		$this->dataValueFormatter = $valueFormatterFactory->getValueFormatter(
147 147
 			SnakFormatter::FORMAT_HTML,
148 148
 			$formatterOptions
149 149
 		);
150 150
 
151
-		$labelLookup = $fallbackLabelDescLookupFactory->newLabelDescriptionLookup( $language );
151
+		$labelLookup = $fallbackLabelDescLookupFactory->newLabelDescriptionLookup($language);
152 152
 
153 153
 		$this->entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter(
154 154
 			$labelLookup
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
 	 * @return array
178 178
 	 */
179 179
 	private function getModules() {
180
-		return [ 'SpecialConstraintReportPage' ];
180
+		return ['SpecialConstraintReportPage'];
181 181
 	}
182 182
 
183 183
 	/**
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 	 * @return string
196 196
 	 */
197 197
 	public function getDescription() {
198
-		return $this->msg( 'wbqc-constraintreport' )->escaped();
198
+		return $this->msg('wbqc-constraintreport')->escaped();
199 199
 	}
200 200
 
201 201
 	/**
@@ -207,42 +207,42 @@  discard block
 block discarded – undo
207 207
 	 * @throws EntityIdParsingException
208 208
 	 * @throws UnexpectedValueException
209 209
 	 */
210
-	public function execute( $subPage ) {
210
+	public function execute($subPage) {
211 211
 		$out = $this->getOutput();
212 212
 
213
-		$postRequest = $this->getContext()->getRequest()->getVal( 'entityid' );
214
-		if ( $postRequest ) {
215
-			$out->redirect( $this->getPageTitle( strtoupper( $postRequest ) )->getLocalURL() );
213
+		$postRequest = $this->getContext()->getRequest()->getVal('entityid');
214
+		if ($postRequest) {
215
+			$out->redirect($this->getPageTitle(strtoupper($postRequest))->getLocalURL());
216 216
 			return;
217 217
 		}
218 218
 
219
-		$out->addModules( $this->getModules() );
219
+		$out->addModules($this->getModules());
220 220
 
221 221
 		$this->setHeaders();
222 222
 
223
-		$out->addHTML( $this->getExplanationText() );
223
+		$out->addHTML($this->getExplanationText());
224 224
 		$this->buildEntityIdForm();
225 225
 
226
-		if ( !$subPage ) {
226
+		if (!$subPage) {
227 227
 			return;
228 228
 		}
229 229
 
230
-		if ( !is_string( $subPage ) ) {
231
-			throw new InvalidArgumentException( '$subPage must be string.' );
230
+		if (!is_string($subPage)) {
231
+			throw new InvalidArgumentException('$subPage must be string.');
232 232
 		}
233 233
 
234 234
 		try {
235
-			$entityId = $this->entityIdParser->parse( $subPage );
236
-		} catch ( EntityIdParsingException $e ) {
235
+			$entityId = $this->entityIdParser->parse($subPage);
236
+		} catch (EntityIdParsingException $e) {
237 237
 			$out->addHTML(
238
-				$this->buildNotice( 'wbqc-constraintreport-invalid-entity-id', true )
238
+				$this->buildNotice('wbqc-constraintreport-invalid-entity-id', true)
239 239
 			);
240 240
 			return;
241 241
 		}
242 242
 
243
-		if ( !$this->entityLookup->hasEntity( $entityId ) ) {
243
+		if (!$this->entityLookup->hasEntity($entityId)) {
244 244
 			$out->addHTML(
245
-				$this->buildNotice( 'wbqc-constraintreport-not-existent-entity', true )
245
+				$this->buildNotice('wbqc-constraintreport-not-existent-entity', true)
246 246
 			);
247 247
 			return;
248 248
 		}
@@ -250,18 +250,18 @@  discard block
 block discarded – undo
250 250
 		$this->dataFactory->increment(
251 251
 			'wikibase.quality.constraints.specials.specialConstraintReport.executeCheck'
252 252
 		);
253
-		$results = $this->constraintChecker->checkAgainstConstraintsOnEntityId( $entityId );
253
+		$results = $this->constraintChecker->checkAgainstConstraintsOnEntityId($entityId);
254 254
 
255
-		if ( count( $results ) > 0 ) {
255
+		if (count($results) > 0) {
256 256
 			$out->addHTML(
257
-				$this->buildResultHeader( $entityId )
258
-				. $this->buildSummary( $results )
259
-				. $this->buildResultTable( $entityId, $results )
257
+				$this->buildResultHeader($entityId)
258
+				. $this->buildSummary($results)
259
+				. $this->buildResultTable($entityId, $results)
260 260
 			);
261 261
 		} else {
262 262
 			$out->addHTML(
263
-				$this->buildResultHeader( $entityId )
264
-				. $this->buildNotice( 'wbqc-constraintreport-empty-result' )
263
+				$this->buildResultHeader($entityId)
264
+				. $this->buildNotice('wbqc-constraintreport-empty-result')
265 265
 			);
266 266
 		}
267 267
 	}
@@ -277,15 +277,15 @@  discard block
 block discarded – undo
277 277
 				'name' => 'entityid',
278 278
 				'label-message' => 'wbqc-constraintreport-form-entityid-label',
279 279
 				'cssclass' => 'wbqc-constraintreport-form-entity-id',
280
-				'placeholder' => $this->msg( 'wbqc-constraintreport-form-entityid-placeholder' )->escaped()
280
+				'placeholder' => $this->msg('wbqc-constraintreport-form-entityid-placeholder')->escaped()
281 281
 			]
282 282
 		];
283
-		$htmlForm = HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext(), 'wbqc-constraintreport-form' );
284
-		$htmlForm->setSubmitText( $this->msg( 'wbqc-constraintreport-form-submit-label' )->escaped() );
285
-		$htmlForm->setSubmitCallback( function() {
283
+		$htmlForm = HTMLForm::factory('ooui', $formDescriptor, $this->getContext(), 'wbqc-constraintreport-form');
284
+		$htmlForm->setSubmitText($this->msg('wbqc-constraintreport-form-submit-label')->escaped());
285
+		$htmlForm->setSubmitCallback(function() {
286 286
 			return false;
287 287
 		} );
288
-		$htmlForm->setMethod( 'post' );
288
+		$htmlForm->setMethod('post');
289 289
 		$htmlForm->show();
290 290
 	}
291 291
 
@@ -299,16 +299,16 @@  discard block
 block discarded – undo
299 299
 	 *
300 300
 	 * @return string HTML
301 301
 	 */
302
-	private function buildNotice( $messageKey, $error = false ) {
303
-		if ( !is_string( $messageKey ) ) {
304
-			throw new InvalidArgumentException( '$message must be string.' );
302
+	private function buildNotice($messageKey, $error = false) {
303
+		if (!is_string($messageKey)) {
304
+			throw new InvalidArgumentException('$message must be string.');
305 305
 		}
306
-		if ( !is_bool( $error ) ) {
307
-			throw new InvalidArgumentException( '$error must be bool.' );
306
+		if (!is_bool($error)) {
307
+			throw new InvalidArgumentException('$error must be bool.');
308 308
 		}
309 309
 
310 310
 		$cssClasses = 'wbqc-constraintreport-notice';
311
-		if ( $error ) {
311
+		if ($error) {
312 312
 			$cssClasses .= ' wbqc-constraintreport-notice-error';
313 313
 		}
314 314
 
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 				[
318 318
 					'class' => $cssClasses
319 319
 				],
320
-				$this->msg( $messageKey )->escaped()
320
+				$this->msg($messageKey)->escaped()
321 321
 			);
322 322
 	}
323 323
 
@@ -327,16 +327,16 @@  discard block
 block discarded – undo
327 327
 	private function getExplanationText() {
328 328
 		return Html::rawElement(
329 329
 			'div',
330
-			[ 'class' => 'wbqc-explanation' ],
330
+			['class' => 'wbqc-explanation'],
331 331
 			Html::rawElement(
332 332
 				'p',
333 333
 				[],
334
-				$this->msg( 'wbqc-constraintreport-explanation-part-one' )->escaped()
334
+				$this->msg('wbqc-constraintreport-explanation-part-one')->escaped()
335 335
 			)
336 336
 			. Html::rawElement(
337 337
 				'p',
338 338
 				[],
339
-				$this->msg( 'wbqc-constraintreport-explanation-part-two' )->escaped()
339
+				$this->msg('wbqc-constraintreport-explanation-part-two')->escaped()
340 340
 			)
341 341
 		);
342 342
 	}
@@ -347,71 +347,70 @@  discard block
 block discarded – undo
347 347
 	 *
348 348
 	 * @return string HTML
349 349
 	 */
350
-	private function buildResultTable( EntityId $entityId, array $results ) {
350
+	private function buildResultTable(EntityId $entityId, array $results) {
351 351
 		// Set table headers
352 352
 		$table = new HtmlTableBuilder(
353 353
 			[
354 354
 				new HtmlTableHeaderBuilder(
355
-					$this->msg( 'wbqc-constraintreport-result-table-header-status' )->escaped(),
355
+					$this->msg('wbqc-constraintreport-result-table-header-status')->escaped(),
356 356
 					true
357 357
 				),
358 358
 				new HtmlTableHeaderBuilder(
359
-					$this->msg( 'wbqc-constraintreport-result-table-header-claim' )->escaped(),
359
+					$this->msg('wbqc-constraintreport-result-table-header-claim')->escaped(),
360 360
 					true
361 361
 				),
362 362
 				new HtmlTableHeaderBuilder(
363
-					$this->msg( 'wbqc-constraintreport-result-table-header-constraint' )->escaped(),
363
+					$this->msg('wbqc-constraintreport-result-table-header-constraint')->escaped(),
364 364
 					true
365 365
 				)
366 366
 			]
367 367
 		);
368 368
 
369
-		foreach ( $results as $result ) {
370
-			$table = $this->appendToResultTable( $table, $entityId, $result );
369
+		foreach ($results as $result) {
370
+			$table = $this->appendToResultTable($table, $entityId, $result);
371 371
 		}
372 372
 
373 373
 		return $table->toHtml();
374 374
 	}
375 375
 
376
-	private function appendToResultTable( HtmlTableBuilder $table, EntityId $entityId, CheckResult $result ) {
376
+	private function appendToResultTable(HtmlTableBuilder $table, EntityId $entityId, CheckResult $result) {
377 377
 		// Status column
378 378
 		$statusColumn = $this->buildTooltipElement(
379
-			$this->formatStatus( $result->getStatus() ),
379
+			$this->formatStatus($result->getStatus()),
380 380
 			$result->getMessage() !== null ?
381
-				$this->violationMessageRenderer->render( $result->getMessage() ) :
382
-				null,
381
+				$this->violationMessageRenderer->render($result->getMessage()) : null,
383 382
 			'[?]'
384 383
 		);
385 384
 
386 385
 		// Claim column
387
-		$property = $this->entityIdLabelFormatter->formatEntityId( $result->getContext()->getSnak()->getPropertyId() );
388
-		if ( $result->getSnakType() === 'value' ) {
389
-			$value = $this->constraintParameterRenderer->formatValue( $result->getDataValue() );
386
+		$property = $this->entityIdLabelFormatter->formatEntityId($result->getContext()->getSnak()->getPropertyId());
387
+		if ($result->getSnakType() === 'value') {
388
+			$value = $this->constraintParameterRenderer->formatValue($result->getDataValue());
390 389
 		} else {
391
-			$value = htmlspecialchars( $result->getSnakType() );
390
+			$value = htmlspecialchars($result->getSnakType());
392 391
 		}
393 392
 
394 393
 		$claimColumn = $this->getClaimLink(
395 394
 			$entityId,
396 395
 			$result->getContext()->getSnak()->getPropertyId(),
397
-			$property . ': ' . $value
396
+			$property.': '.$value
398 397
 		);
399 398
 
400 399
 		// Constraint column
401 400
 		$constraintTypeItemId = $result->getConstraint()->getConstraintTypeItemId();
402 401
 		try {
403
-			$constraintTypeLabel = $this->entityIdLabelFormatter->formatEntityId( new ItemId( $constraintTypeItemId ) );
404
-		} catch ( InvalidArgumentException $e ) {
405
-			$constraintTypeLabel = htmlspecialchars( $constraintTypeItemId );
402
+			$constraintTypeLabel = $this->entityIdLabelFormatter->formatEntityId(new ItemId($constraintTypeItemId));
403
+		} catch (InvalidArgumentException $e) {
404
+			$constraintTypeLabel = htmlspecialchars($constraintTypeItemId);
406 405
 		}
407 406
 		$constraintLink = $this->getClaimLink(
408 407
 			$result->getContext()->getSnak()->getPropertyId(),
409
-			new PropertyId( $this->config->get( 'WBQualityConstraintsPropertyConstraintId' ) ),
408
+			new PropertyId($this->config->get('WBQualityConstraintsPropertyConstraintId')),
410 409
 			$constraintTypeLabel
411 410
 		);
412 411
 		$constraintColumn = $this->buildExpandableElement(
413 412
 			$constraintLink,
414
-			$this->constraintParameterRenderer->formatParameters( $result->getParameters() ),
413
+			$this->constraintParameterRenderer->formatParameters($result->getParameters()),
415 414
 			'[...]'
416 415
 		);
417 416
 
@@ -446,15 +445,15 @@  discard block
 block discarded – undo
446 445
 	 *
447 446
 	 * @return string HTML
448 447
 	 */
449
-	protected function buildResultHeader( EntityId $entityId ) {
450
-		$entityLink = sprintf( '%s (%s)',
451
-							   $this->entityIdLinkFormatter->formatEntityId( $entityId ),
452
-							   htmlspecialchars( $entityId->getSerialization() ) );
448
+	protected function buildResultHeader(EntityId $entityId) {
449
+		$entityLink = sprintf('%s (%s)',
450
+							   $this->entityIdLinkFormatter->formatEntityId($entityId),
451
+							   htmlspecialchars($entityId->getSerialization()));
453 452
 
454 453
 		return Html::rawElement(
455 454
 			'h3',
456 455
 			[],
457
-			sprintf( '%s %s', $this->msg( 'wbqc-constraintreport-result-headline' )->escaped(), $entityLink )
456
+			sprintf('%s %s', $this->msg('wbqc-constraintreport-result-headline')->escaped(), $entityLink)
458 457
 		);
459 458
 	}
460 459
 
@@ -465,24 +464,24 @@  discard block
 block discarded – undo
465 464
 	 *
466 465
 	 * @return string HTML
467 466
 	 */
468
-	protected function buildSummary( array $results ) {
467
+	protected function buildSummary(array $results) {
469 468
 		$statuses = [];
470
-		foreach ( $results as $result ) {
471
-			$status = strtolower( $result->getStatus() );
472
-			$statuses[$status] = isset( $statuses[$status] ) ? $statuses[$status] + 1 : 1;
469
+		foreach ($results as $result) {
470
+			$status = strtolower($result->getStatus());
471
+			$statuses[$status] = isset($statuses[$status]) ? $statuses[$status] + 1 : 1;
473 472
 		}
474 473
 
475 474
 		$statusElements = [];
476
-		foreach ( $statuses as $status => $count ) {
477
-			if ( $count > 0 ) {
475
+		foreach ($statuses as $status => $count) {
476
+			if ($count > 0) {
478 477
 				$statusElements[] =
479
-					$this->formatStatus( $status )
478
+					$this->formatStatus($status)
480 479
 					. ': '
481 480
 					. $count;
482 481
 			}
483 482
 		}
484 483
 
485
-		return Html::rawElement( 'p', [], implode( ', ', $statusElements ) );
484
+		return Html::rawElement('p', [], implode(', ', $statusElements));
486 485
 	}
487 486
 
488 487
 	/**
@@ -497,15 +496,15 @@  discard block
 block discarded – undo
497 496
 	 *
498 497
 	 * @return string HTML
499 498
 	 */
500
-	protected function buildTooltipElement( $content, $tooltipContent, $indicator ) {
501
-		if ( !is_string( $content ) ) {
502
-			throw new InvalidArgumentException( '$content has to be string.' );
499
+	protected function buildTooltipElement($content, $tooltipContent, $indicator) {
500
+		if (!is_string($content)) {
501
+			throw new InvalidArgumentException('$content has to be string.');
503 502
 		}
504
-		if ( $tooltipContent && ( !is_string( $tooltipContent ) ) ) {
505
-			throw new InvalidArgumentException( '$tooltipContent, if provided, has to be string.' );
503
+		if ($tooltipContent && (!is_string($tooltipContent))) {
504
+			throw new InvalidArgumentException('$tooltipContent, if provided, has to be string.');
506 505
 		}
507 506
 
508
-		if ( empty( $tooltipContent ) ) {
507
+		if (empty($tooltipContent)) {
509 508
 			return $content;
510 509
 		}
511 510
 
@@ -522,13 +521,13 @@  discard block
 block discarded – undo
522 521
 			[
523 522
 				'class' => 'wbqc-indicator'
524 523
 			],
525
-			htmlspecialchars( $indicator ) . $tooltip
524
+			htmlspecialchars($indicator).$tooltip
526 525
 		);
527 526
 
528 527
 		return Html::rawElement(
529 528
 			'span',
530 529
 			[],
531
-			sprintf( '%s %s', $content, $tooltipIndicator )
530
+			sprintf('%s %s', $content, $tooltipIndicator)
532 531
 		);
533 532
 	}
534 533
 
@@ -544,15 +543,15 @@  discard block
 block discarded – undo
544 543
 	 *
545 544
 	 * @return string HTML
546 545
 	 */
547
-	protected function buildExpandableElement( $content, $expandableContent, $indicator ) {
548
-		if ( !is_string( $content ) ) {
549
-			throw new InvalidArgumentException( '$content has to be string.' );
546
+	protected function buildExpandableElement($content, $expandableContent, $indicator) {
547
+		if (!is_string($content)) {
548
+			throw new InvalidArgumentException('$content has to be string.');
550 549
 		}
551
-		if ( $expandableContent && ( !is_string( $expandableContent ) ) ) {
552
-			throw new InvalidArgumentException( '$tooltipContent, if provided, has to be string.' );
550
+		if ($expandableContent && (!is_string($expandableContent))) {
551
+			throw new InvalidArgumentException('$tooltipContent, if provided, has to be string.');
553 552
 		}
554 553
 
555
-		if ( empty( $expandableContent ) ) {
554
+		if (empty($expandableContent)) {
556 555
 			return $content;
557 556
 		}
558 557
 
@@ -573,7 +572,7 @@  discard block
 block discarded – undo
573 572
 		);
574 573
 
575 574
 		return
576
-			sprintf( '%s %s %s', $content, $tooltipIndicator, $expandableContent );
575
+			sprintf('%s %s %s', $content, $tooltipIndicator, $expandableContent);
577 576
 	}
578 577
 
579 578
 	/**
@@ -585,16 +584,16 @@  discard block
 block discarded – undo
585 584
 	 *
586 585
 	 * @return string HTML
587 586
 	 */
588
-	private function formatStatus( $status ) {
589
-		$messageName = "wbqc-constraintreport-status-" . strtolower( $status );
587
+	private function formatStatus($status) {
588
+		$messageName = "wbqc-constraintreport-status-".strtolower($status);
590 589
 
591 590
 		$formattedStatus =
592 591
 			Html::element(
593 592
 				'span',
594 593
 				[
595
-					'class' => 'wbqc-status wbqc-status-' . $status
594
+					'class' => 'wbqc-status wbqc-status-'.$status
596 595
 				],
597
-				$this->msg( $messageName )->text()
596
+				$this->msg($messageName)->text()
598 597
 			);
599 598
 
600 599
 		return $formattedStatus;
@@ -610,26 +609,26 @@  discard block
 block discarded – undo
610 609
 	 *
611 610
 	 * @return string HTML
612 611
 	 */
613
-	protected function formatDataValues( $dataValues, $separator = ', ' ) {
614
-		if ( $dataValues instanceof DataValue ) {
615
-			$dataValues = [ $dataValues ];
616
-		} elseif ( !is_array( $dataValues ) ) {
617
-			throw new InvalidArgumentException( '$dataValues has to be instance of DataValue or an array of DataValues.' );
612
+	protected function formatDataValues($dataValues, $separator = ', ') {
613
+		if ($dataValues instanceof DataValue) {
614
+			$dataValues = [$dataValues];
615
+		} elseif (!is_array($dataValues)) {
616
+			throw new InvalidArgumentException('$dataValues has to be instance of DataValue or an array of DataValues.');
618 617
 		}
619 618
 
620 619
 		$formattedDataValues = [];
621
-		foreach ( $dataValues as $dataValue ) {
622
-			if ( !( $dataValue instanceof DataValue ) ) {
623
-				throw new InvalidArgumentException( '$dataValues has to be instance of DataValue or an array of DataValues.' );
620
+		foreach ($dataValues as $dataValue) {
621
+			if (!($dataValue instanceof DataValue)) {
622
+				throw new InvalidArgumentException('$dataValues has to be instance of DataValue or an array of DataValues.');
624 623
 			}
625
-			if ( $dataValue instanceof EntityIdValue ) {
626
-				$formattedDataValues[ ] = $this->entityIdLabelFormatter->formatEntityId( $dataValue->getEntityId() );
624
+			if ($dataValue instanceof EntityIdValue) {
625
+				$formattedDataValues[] = $this->entityIdLabelFormatter->formatEntityId($dataValue->getEntityId());
627 626
 			} else {
628
-				$formattedDataValues[ ] = $this->dataValueFormatter->format( $dataValue );
627
+				$formattedDataValues[] = $this->dataValueFormatter->format($dataValue);
629 628
 			}
630 629
 		}
631 630
 
632
-		return implode( $separator, $formattedDataValues );
631
+		return implode($separator, $formattedDataValues);
633 632
 	}
634 633
 
635 634
 	/**
@@ -641,12 +640,12 @@  discard block
 block discarded – undo
641 640
 	 *
642 641
 	 * @return string HTML
643 642
 	 */
644
-	private function getClaimLink( EntityId $entityId, PropertyId $propertyId, $text ) {
643
+	private function getClaimLink(EntityId $entityId, PropertyId $propertyId, $text) {
645 644
 		return
646 645
 			Html::rawElement(
647 646
 				'a',
648 647
 				[
649
-					'href' => $this->getClaimUrl( $entityId, $propertyId ),
648
+					'href' => $this->getClaimUrl($entityId, $propertyId),
650 649
 					'target' => '_blank'
651 650
 				],
652 651
 				$text
@@ -661,9 +660,9 @@  discard block
 block discarded – undo
661 660
 	 *
662 661
 	 * @return string
663 662
 	 */
664
-	private function getClaimUrl( EntityId $entityId, PropertyId $propertyId ) {
665
-		$title = $this->entityTitleLookup->getTitleForId( $entityId );
666
-		$entityUrl = sprintf( '%s#%s', $title->getLocalURL(), $propertyId->getSerialization() );
663
+	private function getClaimUrl(EntityId $entityId, PropertyId $propertyId) {
664
+		$title = $this->entityTitleLookup->getTitleForId($entityId);
665
+		$entityUrl = sprintf('%s#%s', $title->getLocalURL(), $propertyId->getSerialization());
667 666
 
668 667
 		return $entityUrl;
669 668
 	}
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/RangeChecker.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -84,9 +84,9 @@  discard block
 block discarded – undo
84 84
 	 * @throws ConstraintParameterException
85 85
 	 * @return CheckResult
86 86
 	 */
87
-	public function checkConstraint( Context $context, Constraint $constraint ) {
88
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
89
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
87
+	public function checkConstraint(Context $context, Constraint $constraint) {
88
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
89
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
90 90
 		}
91 91
 
92 92
 		$parameters = [];
@@ -94,42 +94,42 @@  discard block
 block discarded – undo
94 94
 
95 95
 		$snak = $context->getSnak();
96 96
 
97
-		if ( !$snak instanceof PropertyValueSnak ) {
97
+		if (!$snak instanceof PropertyValueSnak) {
98 98
 			// nothing to check
99
-			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE );
99
+			return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE);
100 100
 		}
101 101
 
102 102
 		$dataValue = $snak->getDataValue();
103 103
 
104
-		list( $min, $max ) = $this->constraintParameterParser->parseRangeParameter(
104
+		list($min, $max) = $this->constraintParameterParser->parseRangeParameter(
105 105
 			$constraintParameters,
106 106
 			$constraint->getConstraintTypeItemId(),
107 107
 			$dataValue->getType()
108 108
 		);
109 109
 		$parameterKey = $dataValue->getType() === 'quantity' ? 'quantity' : 'date';
110
-		if ( $min !== null ) {
111
-			$parameters['minimum_' . $parameterKey] = [ $min ];
110
+		if ($min !== null) {
111
+			$parameters['minimum_'.$parameterKey] = [$min];
112 112
 		}
113
-		if ( $max !== null ) {
114
-			$parameters['maximum_' . $parameterKey] = [ $max ];
113
+		if ($max !== null) {
114
+			$parameters['maximum_'.$parameterKey] = [$max];
115 115
 		}
116 116
 
117
-		if ( $this->rangeCheckerHelper->getComparison( $min, $dataValue ) > 0 ||
118
-			 $this->rangeCheckerHelper->getComparison( $dataValue, $max ) > 0
117
+		if ($this->rangeCheckerHelper->getComparison($min, $dataValue) > 0 ||
118
+			 $this->rangeCheckerHelper->getComparison($dataValue, $max) > 0
119 119
 		) {
120 120
 			// at least one of $min, $max is set at this point, otherwise there could be no violation
121 121
 			$type = $dataValue->getType();
122
-			$openness = $min !== null ? ( $max !== null ? 'closed' : 'rightopen' ) : 'leftopen';
123
-			$message = wfMessage( "wbqc-violation-message-range-$type-$openness" );
122
+			$openness = $min !== null ? ($max !== null ? 'closed' : 'rightopen') : 'leftopen';
123
+			$message = wfMessage("wbqc-violation-message-range-$type-$openness");
124 124
 			$message->rawParams(
125
-				$this->constraintParameterRenderer->formatEntityId( $context->getSnak()->getPropertyId(), Role::PREDICATE ),
126
-				$this->constraintParameterRenderer->formatDataValue( $dataValue, Role::OBJECT )
125
+				$this->constraintParameterRenderer->formatEntityId($context->getSnak()->getPropertyId(), Role::PREDICATE),
126
+				$this->constraintParameterRenderer->formatDataValue($dataValue, Role::OBJECT)
127 127
 			);
128
-			if ( $min !== null ) {
129
-				$message->rawParams( $this->constraintParameterRenderer->formatDataValue( $min, Role::OBJECT ) );
128
+			if ($min !== null) {
129
+				$message->rawParams($this->constraintParameterRenderer->formatDataValue($min, Role::OBJECT));
130 130
 			}
131
-			if ( $max !== null ) {
132
-				$message->rawParams( $this->constraintParameterRenderer->formatDataValue( $max, Role::OBJECT ) );
131
+			if ($max !== null) {
132
+				$message->rawParams($this->constraintParameterRenderer->formatDataValue($max, Role::OBJECT));
133 133
 			}
134 134
 			$message = $message->escaped();
135 135
 			$status = CheckResult::STATUS_VIOLATION;
@@ -138,22 +138,22 @@  discard block
 block discarded – undo
138 138
 			$status = CheckResult::STATUS_COMPLIANCE;
139 139
 		}
140 140
 
141
-		return new CheckResult( $context, $constraint, $parameters, $status, $message );
141
+		return new CheckResult($context, $constraint, $parameters, $status, $message);
142 142
 	}
143 143
 
144
-	public function checkConstraintParameters( Constraint $constraint ) {
144
+	public function checkConstraintParameters(Constraint $constraint) {
145 145
 		$constraintParameters = $constraint->getConstraintParameters();
146 146
 		$exceptions = [];
147 147
 		try {
148 148
 			// we don’t have a data value here, so get the type from the property instead
149 149
 			// (the distinction between data type and data value type is irrelevant for 'quantity' and 'time')
150
-			$type = $this->propertyDataTypeLookup->getDataTypeIdForProperty( $constraint->getPropertyId() );
150
+			$type = $this->propertyDataTypeLookup->getDataTypeIdForProperty($constraint->getPropertyId());
151 151
 			$this->constraintParameterParser->parseRangeParameter(
152 152
 				$constraintParameters,
153 153
 				$constraint->getConstraintTypeItemId(),
154 154
 				$type
155 155
 			);
156
-		} catch ( ConstraintParameterException $e ) {
156
+		} catch (ConstraintParameterException $e) {
157 157
 			$exceptions[] = $e;
158 158
 		}
159 159
 		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
@@ -83,34 +83,34 @@  discard block
 block discarded – undo
83 83
 	 * @throws SparqlHelperException if the checker uses SPARQL and the query times out or some other error occurs
84 84
 	 * @return CheckResult
85 85
 	 */
86
-	public function checkConstraint( Context $context, Constraint $constraint ) {
87
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
88
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
86
+	public function checkConstraint(Context $context, Constraint $constraint) {
87
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
88
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
89 89
 		}
90
-		if ( $context->getType() === Context::TYPE_REFERENCE ) {
91
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_NOT_IN_SCOPE );
90
+		if ($context->getType() === Context::TYPE_REFERENCE) {
91
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_NOT_IN_SCOPE);
92 92
 		}
93 93
 
94 94
 		$parameters = [];
95 95
 		$constraintParameters = $constraint->getConstraintParameters();
96 96
 
97
-		$classes = $this->constraintParameterParser->parseClassParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
97
+		$classes = $this->constraintParameterParser->parseClassParameter($constraintParameters, $constraint->getConstraintTypeItemId());
98 98
 		$parameters['class'] = array_map(
99
-			function( $id ) {
100
-				return new ItemId( $id );
99
+			function($id) {
100
+				return new ItemId($id);
101 101
 			},
102 102
 			$classes
103 103
 		);
104 104
 
105
-		$relation = $this->constraintParameterParser->parseRelationParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
105
+		$relation = $this->constraintParameterParser->parseRelationParameter($constraintParameters, $constraint->getConstraintTypeItemId());
106 106
 		$relationIds = [];
107
-		if ( $relation === 'instance' || $relation === 'instanceOrSubclass' ) {
108
-			$relationIds[] = $this->config->get( 'WBQualityConstraintsInstanceOfId' );
107
+		if ($relation === 'instance' || $relation === 'instanceOrSubclass') {
108
+			$relationIds[] = $this->config->get('WBQualityConstraintsInstanceOfId');
109 109
 		}
110
-		if ( $relation === 'subclass' || $relation === 'instanceOrSubclass' ) {
111
-			$relationIds[] = $this->config->get( 'WBQualityConstraintsSubclassOfId' );
110
+		if ($relation === 'subclass' || $relation === 'instanceOrSubclass') {
111
+			$relationIds[] = $this->config->get('WBQualityConstraintsSubclassOfId');
112 112
 		}
113
-		$parameters['relation'] = [ $relation ];
113
+		$parameters['relation'] = [$relation];
114 114
 
115 115
 		$result = $this->typeCheckerHelper->hasClassInRelation(
116 116
 			$context->getEntity()->getStatements(),
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 			$classes
119 119
 		);
120 120
 
121
-		if ( $result->getBool() ) {
121
+		if ($result->getBool()) {
122 122
 			$message = null;
123 123
 			$status = CheckResult::STATUS_COMPLIANCE;
124 124
 		} else {
@@ -132,21 +132,21 @@  discard block
 block discarded – undo
132 132
 			$status = CheckResult::STATUS_VIOLATION;
133 133
 		}
134 134
 
135
-		return ( new CheckResult( $context, $constraint, $parameters, $status, $message ) )
136
-			->withMetadata( $result->getMetadata() );
135
+		return (new CheckResult($context, $constraint, $parameters, $status, $message))
136
+			->withMetadata($result->getMetadata());
137 137
 	}
138 138
 
139
-	public function checkConstraintParameters( Constraint $constraint ) {
139
+	public function checkConstraintParameters(Constraint $constraint) {
140 140
 		$constraintParameters = $constraint->getConstraintParameters();
141 141
 		$exceptions = [];
142 142
 		try {
143
-			$this->constraintParameterParser->parseClassParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
144
-		} catch ( ConstraintParameterException $e ) {
143
+			$this->constraintParameterParser->parseClassParameter($constraintParameters, $constraint->getConstraintTypeItemId());
144
+		} catch (ConstraintParameterException $e) {
145 145
 			$exceptions[] = $e;
146 146
 		}
147 147
 		try {
148
-			$this->constraintParameterParser->parseRelationParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
149
-		} catch ( ConstraintParameterException $e ) {
148
+			$this->constraintParameterParser->parseRelationParameter($constraintParameters, $constraint->getConstraintTypeItemId());
149
+		} catch (ConstraintParameterException $e) {
150 150
 			$exceptions[] = $e;
151 151
 		}
152 152
 		return $exceptions;
Please login to merge, or discard this patch.