Completed
Push — master ( 08de92...05461e )
by
unknown
39s queued 14s
created
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
 	 * @return never
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/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
 	 * @param 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( NumericPropertyId $propertyId ) {
38
+	public function queryConstraintsForProperty(NumericPropertyId $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/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( NumericPropertyId $propertyId );
17
+	public function queryConstraintsForProperty(NumericPropertyId $propertyId);
18 18
 
19 19
 }
Please login to merge, or discard this patch.
src/ConstraintRepositoryLookup.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 	 * then using the main DBLoadBalancer service may be incorrect.
26 26
 	 * @param string|false $dbName Database name ($domain for ILoadBalancer methods).
27 27
 	 */
28
-	public function __construct( ILoadBalancer $lb, $dbName ) {
28
+	public function __construct(ILoadBalancer $lb, $dbName) {
29 29
 		$this->lb = $lb;
30 30
 		$this->dbName = $dbName;
31 31
 	}
@@ -35,22 +35,22 @@  discard block
 block discarded – undo
35 35
 	 *
36 36
 	 * @return Constraint[]
37 37
 	 */
38
-	public function queryConstraintsForProperty( NumericPropertyId $propertyId ) {
39
-		$dbr = $this->lb->getConnection( ILoadBalancer::DB_REPLICA, [], $this->dbName );
38
+	public function queryConstraintsForProperty(NumericPropertyId $propertyId) {
39
+		$dbr = $this->lb->getConnection(ILoadBalancer::DB_REPLICA, [], $this->dbName);
40 40
 
41 41
 		$results = $dbr->newSelectQueryBuilder()
42
-			->select( [
42
+			->select([
43 43
 				'constraint_type_qid',
44 44
 				'constraint_parameters',
45 45
 				'constraint_guid',
46 46
 				'pid',
47
-			] )
48
-			->from( 'wbqc_constraints' )
49
-			->where( [ 'pid' => $propertyId->getNumericId() ] )
50
-			->caller( __METHOD__ )
47
+			])
48
+			->from('wbqc_constraints')
49
+			->where(['pid' => $propertyId->getNumericId()])
50
+			->caller(__METHOD__)
51 51
 			->fetchResultSet();
52 52
 
53
-		return $this->convertToConstraints( $results );
53
+		return $this->convertToConstraints($results);
54 54
 	}
55 55
 
56 56
 	/**
@@ -58,26 +58,26 @@  discard block
 block discarded – undo
58 58
 	 *
59 59
 	 * @return Constraint[]
60 60
 	 */
61
-	private function convertToConstraints( IResultWrapper $results ) {
61
+	private function convertToConstraints(IResultWrapper $results) {
62 62
 		$constraints = [];
63
-		$logger = LoggerFactory::getInstance( 'WikibaseQualityConstraints' );
64
-		foreach ( $results as $result ) {
63
+		$logger = LoggerFactory::getInstance('WikibaseQualityConstraints');
64
+		foreach ($results as $result) {
65 65
 			$constraintTypeItemId = $result->constraint_type_qid;
66
-			$constraintParameters = json_decode( $result->constraint_parameters, true );
66
+			$constraintParameters = json_decode($result->constraint_parameters, true);
67 67
 
68
-			if ( $constraintParameters === null ) {
68
+			if ($constraintParameters === null) {
69 69
 				// T171295
70
-				$logger->warning( 'Constraint {constraintId} has invalid constraint parameters.', [
70
+				$logger->warning('Constraint {constraintId} has invalid constraint parameters.', [
71 71
 					'method' => __METHOD__,
72 72
 					'constraintId' => $result->constraint_guid,
73 73
 					'constraintParameters' => $result->constraint_parameters,
74
-				] );
75
-				$constraintParameters = [ '@error' => [ /* unknown */ ] ];
74
+				]);
75
+				$constraintParameters = ['@error' => [/* unknown */]];
76 76
 			}
77 77
 
78 78
 			$constraints[] = new Constraint(
79 79
 				$result->constraint_guid,
80
-				NumericPropertyId::newFromNumber( $result->pid ),
80
+				NumericPropertyId::newFromNumber($result->pid),
81 81
 				$constraintTypeItemId,
82 82
 				$constraintParameters
83 83
 			);
Please login to merge, or discard this patch.
src/ConstraintCheck/Context/ReferenceContext.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types = 1 );
3
+declare(strict_types=1);
4 4
 
5 5
 namespace WikibaseQuality\ConstraintReport\ConstraintCheck\Context;
6 6
 
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 		Reference $reference,
33 33
 		Snak $snak
34 34
 	) {
35
-		parent::__construct( $entity, $snak );
35
+		parent::__construct($entity, $snak);
36 36
 		$this->statement = $statement;
37 37
 		$this->reference = $reference;
38 38
 	}
@@ -41,16 +41,16 @@  discard block
 block discarded – undo
41 41
 		return self::TYPE_REFERENCE;
42 42
 	}
43 43
 
44
-	public function getSnakGroup( string $groupingMode, array $separators = [] ): array {
44
+	public function getSnakGroup(string $groupingMode, array $separators = []): array {
45 45
 		$snaks = $this->reference->getSnaks();
46
-		return array_values( $snaks->getArrayCopy() );
46
+		return array_values($snaks->getArrayCopy());
47 47
 	}
48 48
 
49 49
 	public function getCursor(): ContextCursor {
50 50
 		return new ReferenceContextCursor(
51 51
 			$this->entity->getId()->getSerialization(),
52 52
 			$this->statement->getPropertyId()->getSerialization(),
53
-			$this->getStatementGuid( $this->statement ),
53
+			$this->getStatementGuid($this->statement),
54 54
 			$this->snak->getHash(),
55 55
 			$this->snak->getPropertyId()->getSerialization(),
56 56
 			$this->reference->getHash()
Please login to merge, or discard this patch.
src/ConstraintCheck/Context/Context.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types = 1 );
3
+declare(strict_types=1);
4 4
 
5 5
 namespace WikibaseQuality\ConstraintReport\ConstraintCheck\Context;
6 6
 
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 	 * @return Snak[] not a SnakList because for a statement context,
120 120
 	 * the returned value might contain the same snak several times.
121 121
 	 */
122
-	public function getSnakGroup( string $groupingMode, array $separators = [] ): array;
122
+	public function getSnakGroup(string $groupingMode, array $separators = []): array;
123 123
 
124 124
 	/**
125 125
 	 * Get the cursor that can be used to address check results for this context.
Please login to merge, or discard this patch.
src/ConstraintCheck/Context/QualifierContext.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types = 1 );
3
+declare(strict_types=1);
4 4
 
5 5
 namespace WikibaseQuality\ConstraintReport\ConstraintCheck\Context;
6 6
 
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 		Statement $statement,
26 26
 		Snak $snak
27 27
 	) {
28
-		parent::__construct( $entity, $snak );
28
+		parent::__construct($entity, $snak);
29 29
 		$this->statement = $statement;
30 30
 	}
31 31
 
@@ -33,16 +33,16 @@  discard block
 block discarded – undo
33 33
 		return self::TYPE_QUALIFIER;
34 34
 	}
35 35
 
36
-	public function getSnakGroup( string $groupingMode, array $separators = [] ): array {
36
+	public function getSnakGroup(string $groupingMode, array $separators = []): array {
37 37
 		$snaks = $this->statement->getQualifiers();
38
-		return array_values( $snaks->getArrayCopy() );
38
+		return array_values($snaks->getArrayCopy());
39 39
 	}
40 40
 
41 41
 	public function getCursor(): ContextCursor {
42 42
 		return new QualifierContextCursor(
43 43
 			$this->entity->getId()->getSerialization(),
44 44
 			$this->statement->getPropertyId()->getSerialization(),
45
-			$this->getStatementGuid( $this->statement ),
45
+			$this->getStatementGuid($this->statement),
46 46
 			$this->snak->getHash(),
47 47
 			$this->snak->getPropertyId()->getSerialization()
48 48
 		);
Please login to merge, or discard this patch.
src/ConstraintCheck/Context/AbstractContext.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types = 1 );
3
+declare(strict_types=1);
4 4
 
5 5
 namespace WikibaseQuality\ConstraintReport\ConstraintCheck\Context;
6 6
 
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 
22 22
 	protected Snak $snak;
23 23
 
24
-	public function __construct( StatementListProvidingEntity $entity, Snak $snak ) {
24
+	public function __construct(StatementListProvidingEntity $entity, Snak $snak) {
25 25
 		$this->entity = $entity;
26 26
 		$this->snak = $snak;
27 27
 	}
@@ -47,15 +47,15 @@  discard block
 block discarded – undo
47 47
 	// unimplemented: getCursor
48 48
 
49 49
 	/** Helper function for {@link getCursor()} implementations. */
50
-	protected function getStatementGuid( Statement $statement ): string {
50
+	protected function getStatementGuid(Statement $statement): string {
51 51
 		$guid = $statement->getGuid();
52
-		if ( $guid === null ) {
53
-			if ( defined( 'MW_PHPUNIT_TEST' ) ) {
52
+		if ($guid === null) {
53
+			if (defined('MW_PHPUNIT_TEST')) {
54 54
 				// let unit tests get away with not specifying a statement GUID:
55 55
 				// much more convenient to fake it here than to add one to all tests
56 56
 				return 'Q0$DEADBEEF-DEAD-BEEF-DEAD-BEEFDEADBEEF';
57 57
 			} else {
58
-				throw new InvalidArgumentException( 'Statement for Context must have a GUID' );
58
+				throw new InvalidArgumentException('Statement for Context must have a GUID');
59 59
 			}
60 60
 		}
61 61
 		return $guid;
Please login to merge, or discard this patch.
src/ConstraintCheck/Context/MainSnakContext.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types = 1 );
3
+declare(strict_types=1);
4 4
 
5 5
 namespace WikibaseQuality\ConstraintReport\ConstraintCheck\Context;
6 6
 
@@ -21,8 +21,8 @@  discard block
 block discarded – undo
21 21
 
22 22
 	private Statement $statement;
23 23
 
24
-	public function __construct( StatementListProvidingEntity $entity, Statement $statement ) {
25
-		parent::__construct( $entity, $statement->getMainSnak() );
24
+	public function __construct(StatementListProvidingEntity $entity, Statement $statement) {
25
+		parent::__construct($entity, $statement->getMainSnak());
26 26
 
27 27
 		$this->statement = $statement;
28 28
 	}
@@ -39,21 +39,21 @@  discard block
 block discarded – undo
39 39
 		return $this->statement;
40 40
 	}
41 41
 
42
-	public function getSnakGroup( string $groupingMode, array $separators = [] ): array {
42
+	public function getSnakGroup(string $groupingMode, array $separators = []): array {
43 43
 		/** @var StatementList $statements */
44 44
 		$statements = $this->entity->getStatements();
45
-		switch ( $groupingMode ) {
45
+		switch ($groupingMode) {
46 46
 			case Context::GROUP_NON_DEPRECATED:
47
-				$statements = $statements->getByRank( [
47
+				$statements = $statements->getByRank([
48 48
 					Statement::RANK_NORMAL,
49 49
 					Statement::RANK_PREFERRED,
50
-				] );
50
+				]);
51 51
 				break;
52 52
 			case Context::GROUP_BEST_RANK:
53
-				$statements = $this->getBestStatementsPerPropertyId( $statements );
53
+				$statements = $this->getBestStatementsPerPropertyId($statements);
54 54
 				break;
55 55
 			default:
56
-				throw new LogicException( 'Unknown $groupingMode ' . $groupingMode );
56
+				throw new LogicException('Unknown $groupingMode '.$groupingMode);
57 57
 		}
58 58
 		return $this->getStatementsWithSameQualifiersForProperties(
59 59
 			$this->statement,
@@ -62,13 +62,13 @@  discard block
 block discarded – undo
62 62
 		)->getMainSnaks();
63 63
 	}
64 64
 
65
-	private function getBestStatementsPerPropertyId( StatementList $statements ): StatementList {
65
+	private function getBestStatementsPerPropertyId(StatementList $statements): StatementList {
66 66
 		$allBestStatements = new StatementList();
67
-		foreach ( $statements->getPropertyIds() as $propertyId ) {
68
-			$bestStatements = $statements->getByPropertyId( $propertyId )
67
+		foreach ($statements->getPropertyIds() as $propertyId) {
68
+			$bestStatements = $statements->getByPropertyId($propertyId)
69 69
 				->getBestStatements();
70
-			foreach ( $bestStatements as $bestStatement ) {
71
-				$allBestStatements->addStatement( $bestStatement );
70
+			foreach ($bestStatements as $bestStatement) {
71
+				$allBestStatements->addStatement($bestStatement);
72 72
 			}
73 73
 		}
74 74
 		return $allBestStatements;
@@ -90,20 +90,20 @@  discard block
 block discarded – undo
90 90
 		array $qualifierPropertyIds
91 91
 	): StatementList {
92 92
 		$similarStatements = new StatementList();
93
-		foreach ( $allStatements as $statement ) {
94
-			if ( $statement === $currentStatement ) {
93
+		foreach ($allStatements as $statement) {
94
+			if ($statement === $currentStatement) {
95 95
 				// if the statement has an “unknown value” qualifier,
96 96
 				// it might be considered different from itself,
97 97
 				// so add it explicitly to ensure it’s always included
98
-				$similarStatements->addStatement( $statement );
98
+				$similarStatements->addStatement($statement);
99 99
 				continue;
100 100
 			}
101
-			foreach ( $qualifierPropertyIds as $qualifierPropertyId ) {
102
-				if ( !$this->haveSameQualifiers( $currentStatement, $statement, $qualifierPropertyId ) ) {
101
+			foreach ($qualifierPropertyIds as $qualifierPropertyId) {
102
+				if (!$this->haveSameQualifiers($currentStatement, $statement, $qualifierPropertyId)) {
103 103
 					continue 2;
104 104
 				}
105 105
 			}
106
-			$similarStatements->addStatement( $statement );
106
+			$similarStatements->addStatement($statement);
107 107
 		}
108 108
 		return $similarStatements;
109 109
 	}
@@ -112,19 +112,19 @@  discard block
 block discarded – undo
112 112
 	 * Tests whether two statements have the same qualifiers with a certain property ID.
113 113
 	 * “unknown value” qualifiers are considered different from each other.
114 114
 	 */
115
-	private function haveSameQualifiers( Statement $s1, Statement $s2, PropertyId $propertyId ): bool {
116
-		$q1 = $this->getSnaksWithPropertyId( $s1->getQualifiers(), $propertyId );
117
-		$q2 = $this->getSnaksWithPropertyId( $s2->getQualifiers(), $propertyId );
115
+	private function haveSameQualifiers(Statement $s1, Statement $s2, PropertyId $propertyId): bool {
116
+		$q1 = $this->getSnaksWithPropertyId($s1->getQualifiers(), $propertyId);
117
+		$q2 = $this->getSnaksWithPropertyId($s2->getQualifiers(), $propertyId);
118 118
 
119
-		if ( $q1->count() !== $q2->count() ) {
119
+		if ($q1->count() !== $q2->count()) {
120 120
 			return false;
121 121
 		}
122 122
 
123
-		foreach ( $q1 as $qualifier ) {
124
-			switch ( $qualifier->getType() ) {
123
+		foreach ($q1 as $qualifier) {
124
+			switch ($qualifier->getType()) {
125 125
 				case 'value':
126 126
 				case 'novalue':
127
-					if ( !$q2->hasSnak( $qualifier ) ) {
127
+					if (!$q2->hasSnak($qualifier)) {
128 128
 						return false;
129 129
 					}
130 130
 					break;
@@ -142,12 +142,12 @@  discard block
 block discarded – undo
142 142
 	/**
143 143
 	 * Returns the snaks of the given snak list with the specified property ID.
144 144
 	 */
145
-	private function getSnaksWithPropertyId( SnakList $allSnaks, PropertyId $propertyId ): SnakList {
145
+	private function getSnaksWithPropertyId(SnakList $allSnaks, PropertyId $propertyId): SnakList {
146 146
 		$snaks = new SnakList();
147 147
 		/** @var Snak $snak */
148
-		foreach ( $allSnaks as $snak ) {
149
-			if ( $snak->getPropertyId()->equals( $propertyId ) ) {
150
-				$snaks->addSnak( $snak );
148
+		foreach ($allSnaks as $snak) {
149
+			if ($snak->getPropertyId()->equals($propertyId)) {
150
+				$snaks->addSnak($snak);
151 151
 			}
152 152
 		}
153 153
 		return $snaks;
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 		return new MainSnakContextCursor(
158 158
 			$this->entity->getId()->getSerialization(),
159 159
 			$this->statement->getPropertyId()->getSerialization(),
160
-			$this->getStatementGuid( $this->statement ),
160
+			$this->getStatementGuid($this->statement),
161 161
 			$this->statement->getMainSnak()->getHash()
162 162
 		);
163 163
 	}
Please login to merge, or discard this patch.