Completed
Push — master ( bb53d1...f77362 )
by
unknown
02:42
created
src/ConstraintCheck/Context/QualifierContext.php 1 patch
Spacing   +2 added lines, -2 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,7 +33,7 @@  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 39
 	public function getCursor() {
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
@@ -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,7 +43,7 @@  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
 
Please login to merge, or discard this patch.
src/ConstraintCheck/Context/ReferenceContext.php 1 patch
Spacing   +2 added lines, -2 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,7 +41,7 @@  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 47
 	public function getCursor() {
Please login to merge, or discard this patch.
src/WikibaseQualityConstraintsHooks.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -28,36 +28,36 @@  discard block
 block discarded – undo
28 28
 	/**
29 29
 	 * @param DatabaseUpdater $updater
30 30
 	 */
31
-	public static function onCreateSchema( DatabaseUpdater $updater ) {
32
-		$updater->addExtensionTable( 'wbqc_constraints', __DIR__ . '/../sql/create_wbqc_constraints.sql' );
33
-		$updater->addExtensionField( 'wbqc_constraints', 'constraint_id', __DIR__ . '/../sql/patch-wbqc_constraints-constraint_id.sql' );
31
+	public static function onCreateSchema(DatabaseUpdater $updater) {
32
+		$updater->addExtensionTable('wbqc_constraints', __DIR__.'/../sql/create_wbqc_constraints.sql');
33
+		$updater->addExtensionField('wbqc_constraints', 'constraint_id', __DIR__.'/../sql/patch-wbqc_constraints-constraint_id.sql');
34 34
 	}
35 35
 
36
-	public static function onWikibaseChange( Change $change ) {
36
+	public static function onWikibaseChange(Change $change) {
37 37
 		$config = MediaWikiServices::getInstance()->getMainConfig();
38
-		if ( $config->get( 'WBQualityConstraintsEnableConstraintsImportFromStatements' ) &&
39
-			self::isConstraintStatementsChange( $config, $change )
38
+		if ($config->get('WBQualityConstraintsEnableConstraintsImportFromStatements') &&
39
+			self::isConstraintStatementsChange($config, $change)
40 40
 		) {
41 41
 			/** @var EntityChange $change */
42 42
 			$title = Title::newMainPage();
43
-			$params = [ 'propertyId' => $change->getEntityId()->getSerialization() ];
43
+			$params = ['propertyId' => $change->getEntityId()->getSerialization()];
44 44
 			JobQueueGroup::singleton()->push(
45
-				new JobSpecification( 'constraintsTableUpdate', $params, [], $title )
45
+				new JobSpecification('constraintsTableUpdate', $params, [], $title)
46 46
 			);
47 47
 		}
48 48
 	}
49 49
 
50
-	public static function isConstraintStatementsChange( Config $config, Change $change ) {
51
-		if ( !( $change instanceof EntityChange ) ||
50
+	public static function isConstraintStatementsChange(Config $config, Change $change) {
51
+		if (!($change instanceof EntityChange) ||
52 52
 			 $change->getAction() !== EntityChange::UPDATE ||
53
-			 !( $change->getEntityId() instanceof PropertyId )
53
+			 !($change->getEntityId() instanceof PropertyId)
54 54
 		) {
55 55
 			return false;
56 56
 		}
57 57
 
58 58
 		$info = $change->getInfo();
59 59
 
60
-		if ( !array_key_exists( 'compactDiff', $info ) ) {
60
+		if (!array_key_exists('compactDiff', $info)) {
61 61
 			// the non-compact diff ($info['diff']) does not contain statement diffs (T110996),
62 62
 			// so we only know that the change *might* affect the constraint statements
63 63
 			return true;
@@ -66,18 +66,18 @@  discard block
 block discarded – undo
66 66
 		/** @var EntityDiffChangedAspects $aspects */
67 67
 		$aspects = $info['compactDiff'];
68 68
 
69
-		$propertyConstraintId = $config->get( 'WBQualityConstraintsPropertyConstraintId' );
70
-		return in_array( $propertyConstraintId, $aspects->getStatementChanges() );
69
+		$propertyConstraintId = $config->get('WBQualityConstraintsPropertyConstraintId');
70
+		return in_array($propertyConstraintId, $aspects->getStatementChanges());
71 71
 	}
72 72
 
73
-	public static function onArticlePurge( WikiPage $wikiPage ) {
73
+	public static function onArticlePurge(WikiPage $wikiPage) {
74 74
 		$repo = WikibaseRepo::getDefaultInstance();
75 75
 
76 76
 		$entityContentFactory = $repo->getEntityContentFactory();
77
-		if ( $entityContentFactory->isEntityContentModel( $wikiPage->getContentModel() ) ) {
78
-			$entityId = $entityContentFactory->getEntityIdForTitle( $wikiPage->getTitle() );
77
+		if ($entityContentFactory->isEntityContentModel($wikiPage->getContentModel())) {
78
+			$entityId = $entityContentFactory->getEntityIdForTitle($wikiPage->getTitle());
79 79
 			$resultsCache = ResultsCache::getDefaultInstance();
80
-			$resultsCache->delete( $entityId );
80
+			$resultsCache->delete($entityId);
81 81
 		}
82 82
 	}
83 83
 
@@ -86,18 +86,18 @@  discard block
 block discarded – undo
86 86
 	 * @param int $timestamp UTC timestamp (seconds since the Epoch)
87 87
 	 * @return bool
88 88
 	 */
89
-	public static function isGadgetEnabledForUserName( $userName, $timestamp ) {
89
+	public static function isGadgetEnabledForUserName($userName, $timestamp) {
90 90
 		$initial = $userName[0];
91 91
 
92
-		if ( $initial === 'Z' ) {
92
+		if ($initial === 'Z') {
93 93
 			$firstWeek = 0;
94
-		} elseif ( $initial >= 'W' && $initial < 'Z' ) {
94
+		} elseif ($initial >= 'W' && $initial < 'Z') {
95 95
 			$firstWeek = 1;
96
-		} elseif ( $initial >= 'T' && $initial < 'W' ) {
96
+		} elseif ($initial >= 'T' && $initial < 'W') {
97 97
 			$firstWeek = 2;
98
-		} elseif ( $initial >= 'N' && $initial < 'T' ) {
98
+		} elseif ($initial >= 'N' && $initial < 'T') {
99 99
 			$firstWeek = 3;
100
-		} elseif ( $initial >= 'E' && $initial < 'N' ) {
100
+		} elseif ($initial >= 'E' && $initial < 'N') {
101 101
 			$firstWeek = 4;
102 102
 		} else {
103 103
 			$firstWeek = 5;
@@ -115,27 +115,27 @@  discard block
 block discarded – undo
115 115
 		return $timestamp >= $threshold;
116 116
 	}
117 117
 
118
-	public static function onBeforePageDisplay( OutputPage $out, Skin $skin ) {
118
+	public static function onBeforePageDisplay(OutputPage $out, Skin $skin) {
119 119
 		$repo = WikibaseRepo::getDefaultInstance();
120 120
 
121 121
 		$lookup = $repo->getEntityNamespaceLookup();
122 122
 		$title = $out->getTitle();
123
-		if ( $title === null ) {
123
+		if ($title === null) {
124 124
 			return;
125 125
 		}
126 126
 
127
-		if ( !$lookup->isEntityNamespace( $title->getNamespace() ) ) {
127
+		if (!$lookup->isEntityNamespace($title->getNamespace())) {
128 128
 			return;
129 129
 		}
130
-		if ( !$out->getUser()->isLoggedIn() ) {
130
+		if (!$out->getUser()->isLoggedIn()) {
131 131
 			return;
132 132
 		}
133
-		if ( empty( $out->getJsConfigVars()['wbIsEditView'] ) ) {
133
+		if (empty($out->getJsConfigVars()['wbIsEditView'])) {
134 134
 			return;
135 135
 		}
136 136
 
137
-		if ( self::isGadgetEnabledForUserName( $out->getUser()->getName(), time() ) ) {
138
-			$out->addModules( 'wikibase.quality.constraints.gadget' );
137
+		if (self::isGadgetEnabledForUserName($out->getUser()->getName(), time())) {
138
+			$out->addModules('wikibase.quality.constraints.gadget');
139 139
 		}
140 140
 	}
141 141
 
Please login to merge, or discard this patch.
src/ConstraintCheck/Context/ReferenceContextCursor.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -92,43 +92,43 @@
 block discarded – undo
92 92
 		return $this->referenceHash;
93 93
 	}
94 94
 
95
-	protected function &getMainArray( array &$container ) {
96
-		$statementArray = &$this->getStatementArray( $container );
95
+	protected function &getMainArray(array &$container) {
96
+		$statementArray = &$this->getStatementArray($container);
97 97
 
98
-		if ( !array_key_exists( 'references', $statementArray ) ) {
98
+		if (!array_key_exists('references', $statementArray)) {
99 99
 			$statementArray['references'] = [];
100 100
 		}
101 101
 		$referencesArray = &$statementArray['references'];
102 102
 
103 103
 		$referenceHash = $this->getReferenceHash();
104
-		foreach ( $referencesArray as &$potentialReferenceArray ) {
105
-			if ( $potentialReferenceArray['hash'] === $referenceHash ) {
104
+		foreach ($referencesArray as &$potentialReferenceArray) {
105
+			if ($potentialReferenceArray['hash'] === $referenceHash) {
106 106
 				$referenceArray = &$potentialReferenceArray;
107 107
 				break;
108 108
 			}
109 109
 		}
110
-		if ( !isset( $referenceArray ) ) {
111
-			$referenceArray = [ 'hash' => $referenceHash, 'snaks' => [] ];
110
+		if (!isset($referenceArray)) {
111
+			$referenceArray = ['hash' => $referenceHash, 'snaks' => []];
112 112
 			$referencesArray[] = &$referenceArray;
113 113
 		}
114 114
 
115 115
 		$snaksArray = &$referenceArray['snaks'];
116 116
 
117 117
 		$snakPropertyId = $this->getSnakPropertyId();
118
-		if ( !array_key_exists( $snakPropertyId, $snaksArray ) ) {
118
+		if (!array_key_exists($snakPropertyId, $snaksArray)) {
119 119
 			$snaksArray[$snakPropertyId] = [];
120 120
 		}
121 121
 		$propertyArray = &$snaksArray[$snakPropertyId];
122 122
 
123 123
 		$snakHash = $this->getSnakHash();
124
-		foreach ( $propertyArray as &$potentialSnakArray ) {
125
-			if ( $potentialSnakArray['hash'] === $snakHash ) {
124
+		foreach ($propertyArray as &$potentialSnakArray) {
125
+			if ($potentialSnakArray['hash'] === $snakHash) {
126 126
 				$snakArray = &$potentialSnakArray;
127 127
 				break;
128 128
 			}
129 129
 		}
130
-		if ( !isset( $snakArray ) ) {
131
-			$snakArray = [ 'hash' => $snakHash ];
130
+		if (!isset($snakArray)) {
131
+			$snakArray = ['hash' => $snakHash];
132 132
 			$propertyArray[] = &$snakArray;
133 133
 		}
134 134
 
Please login to merge, or discard this patch.
src/ConstraintCheck/Context/QualifierContextCursor.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -80,29 +80,29 @@
 block discarded – undo
80 80
 		return $this->snakHash;
81 81
 	}
82 82
 
83
-	protected function &getMainArray( array &$container ) {
84
-		$statementArray = &$this->getStatementArray( $container );
83
+	protected function &getMainArray(array &$container) {
84
+		$statementArray = &$this->getStatementArray($container);
85 85
 
86
-		if ( !array_key_exists( 'qualifiers', $statementArray ) ) {
86
+		if (!array_key_exists('qualifiers', $statementArray)) {
87 87
 			$statementArray['qualifiers'] = [];
88 88
 		}
89 89
 		$qualifiersArray = &$statementArray['qualifiers'];
90 90
 
91 91
 		$snakPropertyId = $this->getSnakPropertyId();
92
-		if ( !array_key_exists( $snakPropertyId, $qualifiersArray ) ) {
92
+		if (!array_key_exists($snakPropertyId, $qualifiersArray)) {
93 93
 			$qualifiersArray[$snakPropertyId] = [];
94 94
 		}
95 95
 		$propertyArray = &$qualifiersArray[$snakPropertyId];
96 96
 
97 97
 		$snakHash = $this->getSnakHash();
98
-		foreach ( $propertyArray as &$potentialQualifierArray ) {
99
-			if ( $potentialQualifierArray['hash'] === $snakHash ) {
98
+		foreach ($propertyArray as &$potentialQualifierArray) {
99
+			if ($potentialQualifierArray['hash'] === $snakHash) {
100 100
 				$qualifierArray = &$potentialQualifierArray;
101 101
 				break;
102 102
 			}
103 103
 		}
104
-		if ( !isset( $qualifierArray ) ) {
105
-			$qualifierArray = [ 'hash' => $snakHash ];
104
+		if (!isset($qualifierArray)) {
105
+			$qualifierArray = ['hash' => $snakHash];
106 106
 			$propertyArray[] = &$qualifierArray;
107 107
 		}
108 108
 
Please login to merge, or discard this patch.
src/ConstraintCheck/Context/MainSnakContextCursor.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -72,12 +72,12 @@
 block discarded – undo
72 72
 		return $this->snakHash;
73 73
 	}
74 74
 
75
-	protected function &getMainArray( array &$container ) {
76
-		$statementArray = &$this->getStatementArray( $container );
75
+	protected function &getMainArray(array &$container) {
76
+		$statementArray = &$this->getStatementArray($container);
77 77
 
78
-		if ( !array_key_exists( 'mainsnak', $statementArray ) ) {
78
+		if (!array_key_exists('mainsnak', $statementArray)) {
79 79
 			$snakHash = $this->getSnakHash();
80
-			$statementArray['mainsnak'] = [ 'hash' => $snakHash ];
80
+			$statementArray['mainsnak'] = ['hash' => $snakHash];
81 81
 		}
82 82
 		$mainsnakArray = &$statementArray['mainsnak'];
83 83
 
Please login to merge, or discard this patch.
src/ConstraintCheck/Context/ApiV2ContextCursor.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -27,34 +27,34 @@  discard block
 block discarded – undo
27 27
 	 * @param array[] &$container
28 28
 	 * @return array
29 29
 	 */
30
-	protected function &getStatementArray( array &$container ) {
30
+	protected function &getStatementArray(array &$container) {
31 31
 		$entityId = $this->getEntityId();
32 32
 		$statementPropertyId = $this->getStatementPropertyId();
33 33
 		$statementGuid = $this->getStatementGuid();
34 34
 
35
-		if ( !array_key_exists( $entityId, $container ) ) {
35
+		if (!array_key_exists($entityId, $container)) {
36 36
 			$container[$entityId] = [];
37 37
 		}
38 38
 		$entityContainer = &$container[$entityId];
39 39
 
40
-		if ( !array_key_exists( 'claims', $entityContainer ) ) {
40
+		if (!array_key_exists('claims', $entityContainer)) {
41 41
 			$entityContainer['claims'] = [];
42 42
 		}
43 43
 		$claimsContainer = &$entityContainer['claims'];
44 44
 
45
-		if ( !array_key_exists( $statementPropertyId, $claimsContainer ) ) {
45
+		if (!array_key_exists($statementPropertyId, $claimsContainer)) {
46 46
 			$claimsContainer[$statementPropertyId] = [];
47 47
 		}
48 48
 		$propertyContainer = &$claimsContainer[$statementPropertyId];
49 49
 
50
-		foreach ( $propertyContainer as &$statement ) {
51
-			if ( $statement['id'] === $statementGuid ) {
50
+		foreach ($propertyContainer as &$statement) {
51
+			if ($statement['id'] === $statementGuid) {
52 52
 				$statementArray = &$statement;
53 53
 				break;
54 54
 			}
55 55
 		}
56
-		if ( !isset( $statementArray ) ) {
57
-			$statementArray = [ 'id' => $statementGuid ];
56
+		if (!isset($statementArray)) {
57
+			$statementArray = ['id' => $statementGuid];
58 58
 			$propertyContainer[] = &$statementArray;
59 59
 		}
60 60
 
@@ -69,19 +69,19 @@  discard block
 block discarded – undo
69 69
 	 * @param array[] &$container
70 70
 	 * @return array
71 71
 	 */
72
-	abstract protected function &getMainArray( array &$container );
72
+	abstract protected function &getMainArray(array &$container);
73 73
 
74 74
 	/**
75 75
 	 * @param array|null $result
76 76
 	 * @param array[] &$container
77 77
 	 */
78
-	public function storeCheckResultInArray( array $result = null, array &$container ) {
79
-		$mainArray = &$this->getMainArray( $container );
80
-		if ( !array_key_exists( 'results', $mainArray ) ) {
78
+	public function storeCheckResultInArray(array $result = null, array &$container) {
79
+		$mainArray = &$this->getMainArray($container);
80
+		if (!array_key_exists('results', $mainArray)) {
81 81
 			$mainArray['results'] = [];
82 82
 		}
83 83
 
84
-		if ( $result !== null ) {
84
+		if ($result !== null) {
85 85
 			$mainArray['results'][] = $result;
86 86
 		}
87 87
 	}
Please login to merge, or discard this patch.
src/ConstraintCheck/Context/ContextCursorSerializer.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 	 * @param ContextCursor $cursor
14 14
 	 * @return array
15 15
 	 */
16
-	public function serialize( ContextCursor $cursor ) {
16
+	public function serialize(ContextCursor $cursor) {
17 17
 		$type = $cursor->getType();
18 18
 		$serialization = [
19 19
 			't' => $type,
@@ -23,9 +23,9 @@  discard block
 block discarded – undo
23 23
 			'h' => $cursor->getSnakHash(),
24 24
 		];
25 25
 
26
-		if ( $type === Context::TYPE_QUALIFIER || $type === Context::TYPE_REFERENCE ) {
26
+		if ($type === Context::TYPE_QUALIFIER || $type === Context::TYPE_REFERENCE) {
27 27
 			$serialization['P'] = $cursor->getSnakPropertyId();
28
-			if ( $type === Context::TYPE_REFERENCE ) {
28
+			if ($type === Context::TYPE_REFERENCE) {
29 29
 				/** @var ReferenceContextCursor $cursor */
30 30
 				$serialization['r'] = $cursor->getReferenceHash();
31 31
 			}
Please login to merge, or discard this patch.