Completed
Push — master ( 920b6c...8106e2 )
by
unknown
02:48
created
WikibaseQualityConstraints.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( function_exists( 'wfLoadExtension' ) ) {
4
-	wfLoadExtension( 'WikibaseQualityConstraints', __DIR__ . '/extension.json' );
3
+if (function_exists('wfLoadExtension')) {
4
+	wfLoadExtension('WikibaseQualityConstraints', __DIR__.'/extension.json');
5 5
 	// Keep i18n globals so mergeMessageFileList.php doesn't break
6
-	$wgMessagesDirs['WikibaseQualityConstraints'] = __DIR__ . '/i18n';
7
-	$wgExtensionMessagesFiles['WikibaseQualityConstraintsAlias'] = __DIR__ . '/WikibaseQualityConstraints.alias.php';
6
+	$wgMessagesDirs['WikibaseQualityConstraints'] = __DIR__.'/i18n';
7
+	$wgExtensionMessagesFiles['WikibaseQualityConstraintsAlias'] = __DIR__.'/WikibaseQualityConstraints.alias.php';
8 8
 	/* wfWarn(
9 9
 		'Deprecated PHP entry point used for WikibaseQualityConstraints extension. ' .
10 10
 		'Please use wfLoadExtension instead, ' .
@@ -12,5 +12,5 @@  discard block
 block discarded – undo
12 12
 	); */
13 13
 	return;
14 14
 } else {
15
-	die( 'This version of the WikibaseQualityConstraints extension requires MediaWiki 1.25+' );
15
+	die('This version of the WikibaseQualityConstraints extension requires MediaWiki 1.25+');
16 16
 }
Please login to merge, or discard this patch.
WikibaseQualityConstraints.alias.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,5 +10,5 @@
 block discarded – undo
10 10
 
11 11
 /** English (English) */
12 12
 $specialPageAliases['en'] = [
13
-	'ConstraintReport' => [ 'ConstraintReport', 'Constraint Report' ],
13
+	'ConstraintReport' => ['ConstraintReport', 'Constraint Report'],
14 14
 ];
Please login to merge, or discard this patch.
maintenance/ImportConstraintStatements.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -8,10 +8,10 @@  discard block
 block discarded – undo
8 8
 use WikibaseQuality\ConstraintReport\UpdateConstraintsTableJob;
9 9
 use Wikibase\Repo\WikibaseRepo;
10 10
 
11
-$basePath = getenv( "MW_INSTALL_PATH" ) !== false
12
-	? getenv( "MW_INSTALL_PATH" ) : __DIR__ . "/../../..";
11
+$basePath = getenv("MW_INSTALL_PATH") !== false
12
+	? getenv("MW_INSTALL_PATH") : __DIR__."/../../..";
13 13
 
14
-require_once $basePath . "/maintenance/Maintenance.php";
14
+require_once $basePath."/maintenance/Maintenance.php";
15 15
 
16 16
 /**
17 17
  * Runs {@link UpdateConstraintsTableJob} once for every property.
@@ -23,23 +23,23 @@  discard block
 block discarded – undo
23 23
 	public function __construct() {
24 24
 		parent::__construct();
25 25
 
26
-		$this->addDescription( 'Imports property constraints from statements on properties' );
26
+		$this->addDescription('Imports property constraints from statements on properties');
27 27
 	}
28 28
 
29 29
 	public function execute() {
30
-		if ( !MediaWikiServices::getInstance()->getMainConfig()->get( 'WBQualityConstraintsEnableConstraintsImportFromStatements' ) ) {
31
-			$this->error( 'Constraint statements are not enabled. Aborting.', 1 );
30
+		if (!MediaWikiServices::getInstance()->getMainConfig()->get('WBQualityConstraintsEnableConstraintsImportFromStatements')) {
31
+			$this->error('Constraint statements are not enabled. Aborting.', 1);
32 32
 		}
33 33
 
34 34
 		$propertyInfoLookup = WikibaseRepo::getDefaultInstance()->getStore()->getPropertyInfoLookup();
35
-		foreach ( $propertyInfoLookup->getAllPropertyInfo() as $propertyIdSerialization => $info ) {
36
-			$this->output( sprintf( 'Importing constraint statements for % 6s... ', $propertyIdSerialization ), $propertyIdSerialization );
37
-			$startTime = microtime( true );
38
-			$job = UpdateConstraintsTableJob::newFromGlobalState( Title::newMainPage(), [ 'propertyId' => $propertyIdSerialization ] );
35
+		foreach ($propertyInfoLookup->getAllPropertyInfo() as $propertyIdSerialization => $info) {
36
+			$this->output(sprintf('Importing constraint statements for % 6s... ', $propertyIdSerialization), $propertyIdSerialization);
37
+			$startTime = microtime(true);
38
+			$job = UpdateConstraintsTableJob::newFromGlobalState(Title::newMainPage(), ['propertyId' => $propertyIdSerialization]);
39 39
 			$job->run();
40
-			$endTime = microtime( true );
41
-			$millis = ( $endTime - $startTime ) * 1000;
42
-			$this->output( sprintf( 'done in % 6.2f ms.', $millis ), $propertyIdSerialization );
40
+			$endTime = microtime(true);
41
+			$millis = ($endTime - $startTime) * 1000;
42
+			$this->output(sprintf('done in % 6.2f ms.', $millis), $propertyIdSerialization);
43 43
 		}
44 44
 	}
45 45
 
Please login to merge, or discard this patch.
src/ConstraintLookup.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,6 +14,6 @@
 block discarded – undo
14 14
 	 *
15 15
 	 * @return Constraint[]
16 16
 	 */
17
-	public function queryConstraintsForProperty( PropertyId $propertyId );
17
+	public function queryConstraintsForProperty(PropertyId $propertyId);
18 18
 
19 19
 }
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
 
@@ -101,14 +101,14 @@  discard block
 block discarded – undo
101 101
 	 *
102 102
 	 * @throws DBUnexpectedError
103 103
 	 */
104
-	public function deleteForPropertyWhereConstraintIdIsStatementId( PropertyId $propertyId ) {
105
-		$db = wfGetDB( DB_MASTER );
104
+	public function deleteForPropertyWhereConstraintIdIsStatementId(PropertyId $propertyId) {
105
+		$db = wfGetDB(DB_MASTER);
106 106
 		$db->delete(
107 107
 			'wbqc_constraints',
108 108
 			[
109 109
 				'pid' => $propertyId->getNumericId(),
110 110
 				// AND constraint_guid LIKE %$________-____-____-____-____________
111
-				'constraint_guid ' . $db->buildLike( array_merge( [ $db->anyString(), '$' ], $this->uuidPattern( $db->anyChar() ) ) )
111
+				'constraint_guid '.$db->buildLike(array_merge([$db->anyString(), '$'], $this->uuidPattern($db->anyChar())))
112 112
 			]
113 113
 		);
114 114
 	}
@@ -119,20 +119,20 @@  discard block
 block discarded – undo
119 119
 	 * @throws InvalidArgumentException
120 120
 	 * @throws DBUnexpectedError
121 121
 	 */
122
-	public function deleteAll( $batchSize = 1000 ) {
123
-		if ( !is_int( $batchSize ) ) {
122
+	public function deleteAll($batchSize = 1000) {
123
+		if (!is_int($batchSize)) {
124 124
 			throw new InvalidArgumentException();
125 125
 		}
126
-		$db = wfGetDB( DB_MASTER );
127
-		if ( $db->getType() === 'sqlite' ) {
128
-			$db->delete( 'wbqc_constraints', '*' );
126
+		$db = wfGetDB(DB_MASTER);
127
+		if ($db->getType() === 'sqlite') {
128
+			$db->delete('wbqc_constraints', '*');
129 129
 		} else {
130 130
 			do {
131
-				$db->commit( __METHOD__, 'flush' );
131
+				$db->commit(__METHOD__, 'flush');
132 132
 				wfGetLBFactory()->waitForReplication();
133
-				$table = $db->tableName( 'wbqc_constraints' );
134
-				$db->query( sprintf( 'DELETE FROM %s LIMIT %d', $table, $batchSize ) );
135
-			} while ( $db->affectedRows() > 0 );
133
+				$table = $db->tableName('wbqc_constraints');
134
+				$db->query(sprintf('DELETE FROM %s LIMIT %d', $table, $batchSize));
135
+			} while ($db->affectedRows() > 0);
136 136
 		}
137 137
 	}
138 138
 
@@ -141,26 +141,26 @@  discard block
 block discarded – undo
141 141
 	 *
142 142
 	 * @return Constraint[]
143 143
 	 */
144
-	private function convertToConstraints( ResultWrapper $results ) {
144
+	private function convertToConstraints(ResultWrapper $results) {
145 145
 		$constraints = [];
146
-		foreach ( $results as $result ) {
146
+		foreach ($results as $result) {
147 147
 			$constraintTypeItemId = $result->constraint_type_qid;
148
-			$constraintParameters = json_decode( $result->constraint_parameters, true );
148
+			$constraintParameters = json_decode($result->constraint_parameters, true);
149 149
 
150
-			if ( $constraintParameters === null ) {
150
+			if ($constraintParameters === null) {
151 151
 				// T171295
152
-				LoggerFactory::getInstance( 'WikibaseQualityConstraints' )
153
-					->warning( 'Constraint {constraintId} has invalid constraint parameters.', [
152
+				LoggerFactory::getInstance('WikibaseQualityConstraints')
153
+					->warning('Constraint {constraintId} has invalid constraint parameters.', [
154 154
 						'method' => __METHOD__,
155 155
 						'constraintId' => $result->constraint_guid,
156 156
 						'constraintParameters' => $result->constraint_parameters,
157
-					] );
158
-				$constraintParameters = [ '@error' => [ /* unknown */ ] ];
157
+					]);
158
+				$constraintParameters = ['@error' => [/* unknown */]];
159 159
 			}
160 160
 
161 161
 			$constraints[] = new Constraint(
162 162
 				$result->constraint_guid,
163
-				PropertyId::newFromNumber( $result->pid ),
163
+				PropertyId::newFromNumber($result->pid),
164 164
 				$constraintTypeItemId,
165 165
 				$constraintParameters
166 166
 			);
Please login to merge, or discard this patch.
src/CachingConstraintLookup.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	/**
27 27
 	 * @var ConstraintLookup $lookup The lookup to which all queries are delegated.
28 28
 	 */
29
-	public function __construct( ConstraintLookup $lookup ) {
29
+	public function __construct(ConstraintLookup $lookup) {
30 30
 		$this->lookup = $lookup;
31 31
 	}
32 32
 
@@ -35,10 +35,10 @@  discard block
 block discarded – undo
35 35
 	 *
36 36
 	 * @return Constraint[]
37 37
 	 */
38
-	public function queryConstraintsForProperty( PropertyId $propertyId ) {
38
+	public function queryConstraintsForProperty(PropertyId $propertyId) {
39 39
 		$id = $propertyId->getSerialization();
40
-		if ( !array_key_exists( $id, $this->cache ) ) {
41
-			$this->cache[$id] = $this->lookup->queryConstraintsForProperty( $propertyId );
40
+		if (!array_key_exists($id, $this->cache)) {
41
+			$this->cache[$id] = $this->lookup->queryConstraintsForProperty($propertyId);
42 42
 		}
43 43
 		return $this->cache[$id];
44 44
 	}
Please login to merge, or discard this patch.
src/Role.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@
 block discarded – undo
72 72
 	 * @codeCoverageIgnore
73 73
 	 */
74 74
 	private function __construct() {
75
-		throw new LogicException( 'This class should never be instantiated.' );
75
+		throw new LogicException('This class should never be instantiated.');
76 76
 	}
77 77
 
78 78
 }
Please login to merge, or discard this patch.
src/ConstraintCheck/Context/MainSnakContext.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 		EntityDocument $entity,
24 24
 		Statement $statement
25 25
 	) {
26
-		parent::__construct( $entity, $statement->getMainSnak() );
26
+		parent::__construct($entity, $statement->getMainSnak());
27 27
 		$this->statement = $statement;
28 28
 	}
29 29
 
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 		return $this->statement;
40 40
 	}
41 41
 
42
-	protected function &getMainArray( array &$container ) {
42
+	protected function &getMainArray(array &$container) {
43 43
 		$statementArray = &$this->getStatementArray(
44 44
 			$container,
45 45
 			$this->entity->getId()->getSerialization(),
@@ -47,8 +47,8 @@  discard block
 block discarded – undo
47 47
 			$this->statement->getGuid()
48 48
 		);
49 49
 
50
-		if ( !array_key_exists( 'mainsnak', $statementArray ) ) {
51
-			$statementArray['mainsnak'] = [ 'hash' => $this->statement->getMainSnak()->getHash() ];
50
+		if (!array_key_exists('mainsnak', $statementArray)) {
51
+			$statementArray['mainsnak'] = ['hash' => $this->statement->getMainSnak()->getHash()];
52 52
 		}
53 53
 		$mainsnakArray = &$statementArray['mainsnak'];
54 54
 
Please login to merge, or discard this patch.
src/ConstraintCheck/Context/QualifierContext.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 		Statement $statement,
22 22
 		Snak $snak
23 23
 	) {
24
-		parent::__construct( $entity, $snak );
24
+		parent::__construct($entity, $snak);
25 25
 		$this->statement = $statement;
26 26
 	}
27 27
 
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 		return self::TYPE_QUALIFIER;
30 30
 	}
31 31
 
32
-	protected function &getMainArray( array &$container ) {
32
+	protected function &getMainArray(array &$container) {
33 33
 		$statementArray = &$this->getStatementArray(
34 34
 			$container,
35 35
 			$this->entity->getId()->getSerialization(),
@@ -37,25 +37,25 @@  discard block
 block discarded – undo
37 37
 			$this->statement->getGuid()
38 38
 		);
39 39
 
40
-		if ( !array_key_exists( 'qualifiers', $statementArray ) ) {
40
+		if (!array_key_exists('qualifiers', $statementArray)) {
41 41
 			$statementArray['qualifiers'] = [];
42 42
 		}
43 43
 		$qualifiersArray = &$statementArray['qualifiers'];
44 44
 
45 45
 		$propertyId = $this->getSnak()->getPropertyId()->getSerialization();
46
-		if ( !array_key_exists( $propertyId, $qualifiersArray ) ) {
46
+		if (!array_key_exists($propertyId, $qualifiersArray)) {
47 47
 			$qualifiersArray[$propertyId] = [];
48 48
 		}
49 49
 		$propertyArray = &$qualifiersArray[$propertyId];
50 50
 
51
-		foreach ( $propertyArray as &$potentialQualifierArray ) {
52
-			if ( $potentialQualifierArray['hash'] === $this->getSnak()->getHash() ) {
51
+		foreach ($propertyArray as &$potentialQualifierArray) {
52
+			if ($potentialQualifierArray['hash'] === $this->getSnak()->getHash()) {
53 53
 				$qualifierArray = &$potentialQualifierArray;
54 54
 				break;
55 55
 			}
56 56
 		}
57
-		if ( !isset( $qualifierArray ) ) {
58
-			$qualifierArray = [ 'hash' => $this->getSnak()->getHash() ];
57
+		if (!isset($qualifierArray)) {
58
+			$qualifierArray = ['hash' => $this->getSnak()->getHash()];
59 59
 			$propertyArray[] = &$qualifierArray;
60 60
 		}
61 61
 
Please login to merge, or discard this patch.