Completed
Push — master ( 98f049...b1ce3a )
by
unknown
02:43
created
src/ConstraintCheck/Context/ReferenceContext.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 		Reference $reference,
31 31
 		Snak $snak
32 32
 	) {
33
-		parent::__construct( $entity, $snak );
33
+		parent::__construct($entity, $snak);
34 34
 		$this->statement = $statement;
35 35
 		$this->reference = $reference;
36 36
 	}
@@ -41,10 +41,10 @@  discard block
 block discarded – undo
41 41
 
42 42
 	public function getSnakGroup() {
43 43
 		$snaks = $this->reference->getSnaks();
44
-		return array_values( $snaks->getArrayCopy() );
44
+		return array_values($snaks->getArrayCopy());
45 45
 	}
46 46
 
47
-	protected function &getMainArray( array &$container ) {
47
+	protected function &getMainArray(array &$container) {
48 48
 		$statementArray = &$this->getStatementArray(
49 49
 			$container,
50 50
 			$this->entity->getId()->getSerialization(),
@@ -52,38 +52,38 @@  discard block
 block discarded – undo
52 52
 			$this->statement->getGuid()
53 53
 		);
54 54
 
55
-		if ( !array_key_exists( 'references', $statementArray ) ) {
55
+		if (!array_key_exists('references', $statementArray)) {
56 56
 			$statementArray['references'] = [];
57 57
 		}
58 58
 		$referencesArray = &$statementArray['references'];
59 59
 
60
-		foreach ( $referencesArray as &$potentialReferenceArray ) {
61
-			if ( $potentialReferenceArray['hash'] === $this->reference->getHash() ) {
60
+		foreach ($referencesArray as &$potentialReferenceArray) {
61
+			if ($potentialReferenceArray['hash'] === $this->reference->getHash()) {
62 62
 				$referenceArray = &$potentialReferenceArray;
63 63
 				break;
64 64
 			}
65 65
 		}
66
-		if ( !isset( $referenceArray ) ) {
67
-			$referenceArray = [ 'hash' => $this->reference->getHash(), 'snaks' => [] ];
66
+		if (!isset($referenceArray)) {
67
+			$referenceArray = ['hash' => $this->reference->getHash(), 'snaks' => []];
68 68
 			$referencesArray[] = &$referenceArray;
69 69
 		}
70 70
 
71 71
 		$snaksArray = &$referenceArray['snaks'];
72 72
 
73 73
 		$propertyId = $this->getSnak()->getPropertyId()->getSerialization();
74
-		if ( !array_key_exists( $propertyId, $snaksArray ) ) {
74
+		if (!array_key_exists($propertyId, $snaksArray)) {
75 75
 			$snaksArray[$propertyId] = [];
76 76
 		}
77 77
 		$propertyArray = &$snaksArray[$propertyId];
78 78
 
79
-		foreach ( $propertyArray as &$potentialSnakArray ) {
80
-			if ( $potentialSnakArray['hash'] === $this->getSnak()->getHash() ) {
79
+		foreach ($propertyArray as &$potentialSnakArray) {
80
+			if ($potentialSnakArray['hash'] === $this->getSnak()->getHash()) {
81 81
 				$snakArray = &$potentialSnakArray;
82 82
 				break;
83 83
 			}
84 84
 		}
85
-		if ( !isset( $snakArray ) ) {
86
-			$snakArray = [ 'hash' => $this->getSnak()->getHash() ];
85
+		if (!isset($snakArray)) {
86
+			$snakArray = ['hash' => $this->getSnak()->getHash()];
87 87
 			$propertyArray[] = &$snakArray;
88 88
 		}
89 89
 
Please login to merge, or discard this patch.
src/ConstraintCheck/Context/MainSnakContext.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -20,9 +20,9 @@  discard block
 block discarded – undo
20 20
 	 */
21 21
 	private $statement;
22 22
 
23
-	public function __construct( EntityDocument $entity, Statement $statement ) {
24
-		Assert::parameterType( StatementListProvider::class, $entity, '$entity' );
25
-		parent::__construct( $entity, $statement->getMainSnak() );
23
+	public function __construct(EntityDocument $entity, Statement $statement) {
24
+		Assert::parameterType(StatementListProvider::class, $entity, '$entity');
25
+		parent::__construct($entity, $statement->getMainSnak());
26 26
 
27 27
 		$this->statement = $statement;
28 28
 	}
@@ -43,11 +43,11 @@  discard block
 block discarded – undo
43 43
 		/** @var StatementList $statements */
44 44
 		$statements = $this->entity->getStatements();
45 45
 		return $statements
46
-			->getByRank( [ Statement::RANK_NORMAL, Statement::RANK_PREFERRED ] )
46
+			->getByRank([Statement::RANK_NORMAL, Statement::RANK_PREFERRED])
47 47
 			->getMainSnaks();
48 48
 	}
49 49
 
50
-	protected function &getMainArray( array &$container ) {
50
+	protected function &getMainArray(array &$container) {
51 51
 		$statementArray = &$this->getStatementArray(
52 52
 			$container,
53 53
 			$this->entity->getId()->getSerialization(),
@@ -55,8 +55,8 @@  discard block
 block discarded – undo
55 55
 			$this->statement->getGuid()
56 56
 		);
57 57
 
58
-		if ( !array_key_exists( 'mainsnak', $statementArray ) ) {
59
-			$statementArray['mainsnak'] = [ 'hash' => $this->statement->getMainSnak()->getHash() ];
58
+		if (!array_key_exists('mainsnak', $statementArray)) {
59
+			$statementArray['mainsnak'] = ['hash' => $this->statement->getMainSnak()->getHash()];
60 60
 		}
61 61
 		$mainsnakArray = &$statementArray['mainsnak'];
62 62
 
Please login to merge, or discard this patch.
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/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.