Completed
Push — master ( f01a3a...0f0d16 )
by
unknown
10:05
created
src/ConstraintCheck/Context/AbstractContext.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
 	 */
24 24
 	protected $snak;
25 25
 
26
-	public function __construct( EntityDocument $entity, Snak $snak ) {
26
+	public function __construct(EntityDocument $entity, Snak $snak) {
27 27
 		$this->entity = $entity;
28 28
 		$this->snak = $snak;
29 29
 	}
Please login to merge, or discard this patch.
src/ConstraintCheck/Context/QualifierContext.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 		Statement $statement,
24 24
 		Snak $snak
25 25
 	) {
26
-		parent::__construct( $entity, $snak );
26
+		parent::__construct($entity, $snak);
27 27
 		$this->statement = $statement;
28 28
 	}
29 29
 
@@ -33,10 +33,10 @@  discard block
 block discarded – undo
33 33
 
34 34
 	public function getSnakGroup() {
35 35
 		$snaks = $this->statement->getQualifiers();
36
-		return array_values( $snaks->getArrayCopy() );
36
+		return array_values($snaks->getArrayCopy());
37 37
 	}
38 38
 
39
-	protected function &getMainArray( array &$container ) {
39
+	protected function &getMainArray(array &$container) {
40 40
 		$statementArray = &$this->getStatementArray(
41 41
 			$container,
42 42
 			$this->entity->getId()->getSerialization(),
@@ -44,25 +44,25 @@  discard block
 block discarded – undo
44 44
 			$this->statement->getGuid()
45 45
 		);
46 46
 
47
-		if ( !array_key_exists( 'qualifiers', $statementArray ) ) {
47
+		if (!array_key_exists('qualifiers', $statementArray)) {
48 48
 			$statementArray['qualifiers'] = [];
49 49
 		}
50 50
 		$qualifiersArray = &$statementArray['qualifiers'];
51 51
 
52 52
 		$propertyId = $this->getSnak()->getPropertyId()->getSerialization();
53
-		if ( !array_key_exists( $propertyId, $qualifiersArray ) ) {
53
+		if (!array_key_exists($propertyId, $qualifiersArray)) {
54 54
 			$qualifiersArray[$propertyId] = [];
55 55
 		}
56 56
 		$propertyArray = &$qualifiersArray[$propertyId];
57 57
 
58
-		foreach ( $propertyArray as &$potentialQualifierArray ) {
59
-			if ( $potentialQualifierArray['hash'] === $this->getSnak()->getHash() ) {
58
+		foreach ($propertyArray as &$potentialQualifierArray) {
59
+			if ($potentialQualifierArray['hash'] === $this->getSnak()->getHash()) {
60 60
 				$qualifierArray = &$potentialQualifierArray;
61 61
 				break;
62 62
 			}
63 63
 		}
64
-		if ( !isset( $qualifierArray ) ) {
65
-			$qualifierArray = [ 'hash' => $this->getSnak()->getHash() ];
64
+		if (!isset($qualifierArray)) {
65
+			$qualifierArray = ['hash' => $this->getSnak()->getHash()];
66 66
 			$propertyArray[] = &$qualifierArray;
67 67
 		}
68 68
 
Please login to merge, or discard this patch.
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/WikibaseQualityConstraintsHooks.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -30,36 +30,36 @@  discard block
 block discarded – undo
30 30
 	 *
31 31
 	 * @return bool
32 32
 	 */
33
-	public static function onCreateSchema( DatabaseUpdater $updater ) {
34
-		$updater->addExtensionTable( 'wbqc_constraints', __DIR__ . '/../sql/create_wbqc_constraints.sql' );
33
+	public static function onCreateSchema(DatabaseUpdater $updater) {
34
+		$updater->addExtensionTable('wbqc_constraints', __DIR__.'/../sql/create_wbqc_constraints.sql');
35 35
 		return true;
36 36
 	}
37 37
 
38
-	public static function onWikibaseChange( Change $change ) {
38
+	public static function onWikibaseChange(Change $change) {
39 39
 		$config = MediaWikiServices::getInstance()->getMainConfig();
40
-		if ( $config->get( 'WBQualityConstraintsEnableConstraintsImportFromStatements' ) &&
41
-			self::isConstraintStatementsChange( $config, $change )
40
+		if ($config->get('WBQualityConstraintsEnableConstraintsImportFromStatements') &&
41
+			self::isConstraintStatementsChange($config, $change)
42 42
 		) {
43 43
 			/** @var EntityChange $change */
44 44
 			$title = Title::newMainPage();
45
-			$params = [ 'propertyId' => $change->getEntityId()->getSerialization() ];
45
+			$params = ['propertyId' => $change->getEntityId()->getSerialization()];
46 46
 			JobQueueGroup::singleton()->push(
47
-				new JobSpecification( 'constraintsTableUpdate', $params, [], $title )
47
+				new JobSpecification('constraintsTableUpdate', $params, [], $title)
48 48
 			);
49 49
 		}
50 50
 	}
51 51
 
52
-	public static function isConstraintStatementsChange( Config $config, Change $change ) {
53
-		if ( !( $change instanceof EntityChange ) ||
52
+	public static function isConstraintStatementsChange(Config $config, Change $change) {
53
+		if (!($change instanceof EntityChange) ||
54 54
 			 $change->getAction() !== EntityChange::UPDATE ||
55
-			 !( $change->getEntityId() instanceof PropertyId )
55
+			 !($change->getEntityId() instanceof PropertyId)
56 56
 		) {
57 57
 			return false;
58 58
 		}
59 59
 
60 60
 		$info = $change->getInfo();
61 61
 
62
-		if ( !array_key_exists( 'compactDiff', $info ) ) {
62
+		if (!array_key_exists('compactDiff', $info)) {
63 63
 			// the non-compact diff ($info['diff']) does not contain statement diffs (T110996),
64 64
 			// so we only know that the change *might* affect the constraint statements
65 65
 			return true;
@@ -68,18 +68,18 @@  discard block
 block discarded – undo
68 68
 		/** @var EntityDiffChangedAspects $aspects */
69 69
 		$aspects = $info['compactDiff'];
70 70
 
71
-		$propertyConstraintId = $config->get( 'WBQualityConstraintsPropertyConstraintId' );
72
-		return in_array( $propertyConstraintId, $aspects->getStatementChanges() );
71
+		$propertyConstraintId = $config->get('WBQualityConstraintsPropertyConstraintId');
72
+		return in_array($propertyConstraintId, $aspects->getStatementChanges());
73 73
 	}
74 74
 
75
-	public static function onArticlePurge( WikiPage $wikiPage ) {
75
+	public static function onArticlePurge(WikiPage $wikiPage) {
76 76
 		$repo = WikibaseRepo::getDefaultInstance();
77 77
 
78 78
 		$entityContentFactory = $repo->getEntityContentFactory();
79
-		if ( $entityContentFactory->isEntityContentModel( $wikiPage->getContentModel() ) ) {
80
-			$entityId = $entityContentFactory->getEntityIdForTitle( $wikiPage->getTitle() );
79
+		if ($entityContentFactory->isEntityContentModel($wikiPage->getContentModel())) {
80
+			$entityId = $entityContentFactory->getEntityIdForTitle($wikiPage->getTitle());
81 81
 			$resultsCache = ResultsCache::getDefaultInstance();
82
-			$resultsCache->delete( $entityId );
82
+			$resultsCache->delete($entityId);
83 83
 		}
84 84
 	}
85 85
 
@@ -88,18 +88,18 @@  discard block
 block discarded – undo
88 88
 	 * @param int $timestamp UTC timestamp (seconds since the Epoch)
89 89
 	 * @return bool
90 90
 	 */
91
-	public static function isGadgetEnabledForUserName( $userName, $timestamp ) {
91
+	public static function isGadgetEnabledForUserName($userName, $timestamp) {
92 92
 		$initial = $userName[0];
93 93
 
94
-		if ( $initial === 'Z' ) {
94
+		if ($initial === 'Z') {
95 95
 			$firstWeek = 0;
96
-		} elseif ( $initial >= 'W' && $initial < 'Z' ) {
96
+		} elseif ($initial >= 'W' && $initial < 'Z') {
97 97
 			$firstWeek = 1;
98
-		} elseif ( $initial >= 'T' && $initial < 'W' ) {
98
+		} elseif ($initial >= 'T' && $initial < 'W') {
99 99
 			$firstWeek = 2;
100
-		} elseif ( $initial >= 'N' && $initial < 'T' ) {
100
+		} elseif ($initial >= 'N' && $initial < 'T') {
101 101
 			$firstWeek = 3;
102
-		} elseif ( $initial >= 'E' && $initial < 'N' ) {
102
+		} elseif ($initial >= 'E' && $initial < 'N') {
103 103
 			$firstWeek = 4;
104 104
 		} else {
105 105
 			$firstWeek = 5;
@@ -117,27 +117,27 @@  discard block
 block discarded – undo
117 117
 		return $timestamp >= $threshold;
118 118
 	}
119 119
 
120
-	public static function onBeforePageDisplay( OutputPage &$out, Skin &$skin ) {
120
+	public static function onBeforePageDisplay(OutputPage &$out, Skin &$skin) {
121 121
 		$repo = WikibaseRepo::getDefaultInstance();
122 122
 
123 123
 		$lookup = $repo->getEntityNamespaceLookup();
124 124
 		$title = $out->getTitle();
125
-		if ( $title === null ) {
125
+		if ($title === null) {
126 126
 			return;
127 127
 		}
128 128
 
129
-		if ( !$lookup->isEntityNamespace( $title->getNamespace() ) ) {
129
+		if (!$lookup->isEntityNamespace($title->getNamespace())) {
130 130
 			return;
131 131
 		}
132
-		if ( !$out->getUser()->isLoggedIn() ) {
132
+		if (!$out->getUser()->isLoggedIn()) {
133 133
 			return;
134 134
 		}
135
-		if ( !$out->getJsConfigVars()['wbIsEditView'] ) {
135
+		if (!$out->getJsConfigVars()['wbIsEditView']) {
136 136
 			return;
137 137
 		}
138 138
 
139
-		if ( self::isGadgetEnabledForUserName( $out->getUser()->getName(), time() ) ) {
140
-			$out->addModules( 'wikibase.quality.constraints.gadget' );
139
+		if (self::isGadgetEnabledForUserName($out->getUser()->getName(), time())) {
140
+			$out->addModules('wikibase.quality.constraints.gadget');
141 141
 		}
142 142
 	}
143 143
 
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.