Completed
Push — master ( b75ba6...c69ba9 )
by
unknown
01:46
created
src/ConstraintCheck/Cache/CachingMetadata.php 1 patch
Spacing   +11 added lines, -12 removed lines patch added patch discarded remove patch
@@ -29,9 +29,9 @@  discard block
 block discarded – undo
29 29
 	 * @param int $maxAge The maximum age of the cached value (in seconds).
30 30
 	 * @return self Indication that a value is possibly outdated by up to this many seconds.
31 31
 	 */
32
-	public static function ofMaximumAgeInSeconds( $maxAge ) {
33
-		Assert::parameterType( 'integer', $maxAge, '$maxAge' );
34
-		Assert::parameter( $maxAge > 0, '$maxAge', '$maxage > 0' );
32
+	public static function ofMaximumAgeInSeconds($maxAge) {
33
+		Assert::parameterType('integer', $maxAge, '$maxAge');
34
+		Assert::parameter($maxAge > 0, '$maxAge', '$maxage > 0');
35 35
 		$ret = new self;
36 36
 		$ret->maxAge = $maxAge;
37 37
 		return $ret;
@@ -42,9 +42,9 @@  discard block
 block discarded – undo
42 42
 	 * @param array|null $array As returned by toArray.
43 43
 	 * @return self
44 44
 	 */
45
-	public static function ofArray( array $array = null ) {
45
+	public static function ofArray(array $array = null) {
46 46
 		$ret = new self;
47
-		if ( $array !== null ) {
47
+		if ($array !== null) {
48 48
 			$ret->maxAge = $array['maximumAgeInSeconds'];
49 49
 		}
50 50
 		return $ret;
@@ -54,11 +54,11 @@  discard block
 block discarded – undo
54 54
 	 * @param self[] $metadatas
55 55
 	 * @return self
56 56
 	 */
57
-	public static function merge( array $metadatas ) {
58
-		Assert::parameterElementType( self::class, $metadatas, '$metadatas' );
57
+	public static function merge(array $metadatas) {
58
+		Assert::parameterElementType(self::class, $metadatas, '$metadatas');
59 59
 		$ret = new self;
60
-		foreach ( $metadatas as $metadata ) {
61
-			$ret->maxAge = max( $ret->maxAge, $metadata->maxAge );
60
+		foreach ($metadatas as $metadata) {
61
+			$ret->maxAge = max($ret->maxAge, $metadata->maxAge);
62 62
 		}
63 63
 		return $ret;
64 64
 	}
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 	 * For a fresh value, returns 0.
77 77
 	 */
78 78
 	public function getMaximumAgeInSeconds() {
79
-		if ( is_int( $this->maxAge ) ) {
79
+		if (is_int($this->maxAge)) {
80 80
 			return $this->maxAge;
81 81
 		} else {
82 82
 			return 0;
@@ -91,8 +91,7 @@  discard block
 block discarded – undo
91 91
 		return $this->isCached() ?
92 92
 			[
93 93
 				'maximumAgeInSeconds' => $this->maxAge,
94
-			] :
95
-			null;
94
+			] : null;
96 95
 	}
97 96
 
98 97
 }
Please login to merge, or discard this patch.
src/ConstraintCheck/ItemIdSnakValue.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 	 * @param ItemId $itemId
45 45
 	 * @return self
46 46
 	 */
47
-	public static function fromItemId( ItemId $itemId ) {
47
+	public static function fromItemId(ItemId $itemId) {
48 48
 		$ret = new self;
49 49
 		$ret->itemId = $itemId;
50 50
 		return $ret;
@@ -80,14 +80,14 @@  discard block
 block discarded – undo
80 80
 	 * @throws InvalidArgumentException
81 81
 	 * @return self
82 82
 	 */
83
-	public static function fromSnak( Snak $snak ) {
84
-		switch ( true ) {
83
+	public static function fromSnak(Snak $snak) {
84
+		switch (true) {
85 85
 			case $snak instanceof PropertyValueSnak:
86 86
 				$dataValue = $snak->getDataValue();
87
-				if ( $dataValue instanceof EntityIdValue
87
+				if ($dataValue instanceof EntityIdValue
88 88
 					&& $dataValue->getEntityId() instanceof ItemId
89 89
 				) {
90
-					return self::fromItemId( $dataValue->getEntityId() );
90
+					return self::fromItemId($dataValue->getEntityId());
91 91
 				}
92 92
 				break;
93 93
 			case $snak instanceof PropertySomeValueSnak:
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 				return self::noValue();
97 97
 		}
98 98
 
99
-		throw new InvalidArgumentException( 'Snak must contain item ID value or be a somevalue / novalue snak' );
99
+		throw new InvalidArgumentException('Snak must contain item ID value or be a somevalue / novalue snak');
100 100
 	}
101 101
 
102 102
 	/**
@@ -133,8 +133,8 @@  discard block
 block discarded – undo
133 133
 	 * @return ItemId
134 134
 	 */
135 135
 	public function getItemId() {
136
-		if ( ! $this->isValue() ) {
137
-			throw new DomainException( 'This value does not contain an item ID.' );
136
+		if (!$this->isValue()) {
137
+			throw new DomainException('This value does not contain an item ID.');
138 138
 		}
139 139
 		return $this->itemId;
140 140
 	}
@@ -146,13 +146,13 @@  discard block
 block discarded – undo
146 146
 	 * @param Snak $snak
147 147
 	 * @return bool
148 148
 	 */
149
-	public function matchesSnak( Snak $snak ) {
150
-		switch ( true ) {
149
+	public function matchesSnak(Snak $snak) {
150
+		switch (true) {
151 151
 			case $snak instanceof PropertyValueSnak:
152 152
 				return $this->isValue() &&
153 153
 					$snak->getDataValue() instanceof EntityIdValue &&
154 154
 					$snak->getDataValue()->getEntityId() instanceof ItemId &&
155
-					$snak->getDataValue()->getEntityId()->equals( $this->getItemId() );
155
+					$snak->getDataValue()->getEntityId()->equals($this->getItemId());
156 156
 			case $snak instanceof PropertySomeValueSnak:
157 157
 				return $this->isSomeValue();
158 158
 			case $snak instanceof PropertyNoValueSnak:
Please login to merge, or discard this patch.
src/ConstraintCheck/Helper/ConnectionCheckerHelper.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -30,8 +30,8 @@  discard block
 block discarded – undo
30 30
 		StatementList $statementList,
31 31
 		PropertyId $propertyId
32 32
 	) {
33
-		$statementListByPropertyId = $statementList->getByPropertyId( $propertyId );
34
-		if ( $statementListByPropertyId->isEmpty() ) {
33
+		$statementListByPropertyId = $statementList->getByPropertyId($propertyId);
34
+		if ($statementListByPropertyId->isEmpty()) {
35 35
 			return null;
36 36
 		} else {
37 37
 			return $statementListByPropertyId->toArray()[0];
@@ -52,14 +52,14 @@  discard block
 block discarded – undo
52 52
 		PropertyId $propertyId,
53 53
 		EntityId $value
54 54
 	) {
55
-		$statementListByPropertyId = $statementList->getByPropertyId( $propertyId );
55
+		$statementListByPropertyId = $statementList->getByPropertyId($propertyId);
56 56
 		/** @var Statement $statement */
57
-		foreach ( $statementListByPropertyId as $statement ) {
57
+		foreach ($statementListByPropertyId as $statement) {
58 58
 			$snak = $statement->getMainSnak();
59
-			if ( $snak instanceof PropertyValueSnak ) {
59
+			if ($snak instanceof PropertyValueSnak) {
60 60
 				$dataValue = $snak->getDataValue();
61
-				if ( $dataValue instanceof EntityIdValue &&
62
-					$dataValue->getEntityId()->equals( $value )
61
+				if ($dataValue instanceof EntityIdValue &&
62
+					$dataValue->getEntityId()->equals($value)
63 63
 				) {
64 64
 					return $statement;
65 65
 				}
@@ -82,12 +82,12 @@  discard block
 block discarded – undo
82 82
 		PropertyId $propertyId,
83 83
 		array $values
84 84
 	) {
85
-		$statementListByPropertyId = $statementList->getByPropertyId( $propertyId );
85
+		$statementListByPropertyId = $statementList->getByPropertyId($propertyId);
86 86
 		/** @var Statement $statement */
87
-		foreach ( $statementListByPropertyId as $statement ) {
87
+		foreach ($statementListByPropertyId as $statement) {
88 88
 			$snak = $statement->getMainSnak();
89
-			foreach ( $values as $value ) {
90
-				if ( $value->matchesSnak( $snak ) ) {
89
+			foreach ($values as $value) {
90
+				if ($value->matchesSnak($snak)) {
91 91
 					return $statement;
92 92
 				}
93 93
 			}
Please login to merge, or discard this patch.
src/UpdateConstraintsTableJob.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -26,8 +26,8 @@  discard block
 block discarded – undo
26 26
 
27 27
 	const BATCH_SIZE = 10;
28 28
 
29
-	public static function newFromGlobalState( Title $title, array $params ) {
30
-		Assert::parameterType( 'string', $params['propertyId'], '$params["propertyId"]' );
29
+	public static function newFromGlobalState(Title $title, array $params) {
30
+		Assert::parameterType('string', $params['propertyId'], '$params["propertyId"]');
31 31
 		$repo = WikibaseRepo::getDefaultInstance();
32 32
 		return new UpdateConstraintsTableJob(
33 33
 			$title,
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 		EntityLookup $entityLookup,
84 84
 		Serializer $snakSerializer
85 85
 	) {
86
-		parent::__construct( 'constraintsTableUpdate', $title, $params );
86
+		parent::__construct('constraintsTableUpdate', $title, $params);
87 87
 
88 88
 		$this->propertyId = $propertyId;
89 89
 		$this->config = $config;
@@ -92,11 +92,11 @@  discard block
 block discarded – undo
92 92
 		$this->snakSerializer = $snakSerializer;
93 93
 	}
94 94
 
95
-	public function extractParametersFromQualifiers( SnakList $qualifiers ) {
95
+	public function extractParametersFromQualifiers(SnakList $qualifiers) {
96 96
 		$parameters = [];
97
-		foreach ( $qualifiers as $qualifier ) {
97
+		foreach ($qualifiers as $qualifier) {
98 98
 			$qualifierId = $qualifier->getPropertyId()->getSerialization();
99
-			$paramSerialization = $this->snakSerializer->serialize( $qualifier );
99
+			$paramSerialization = $this->snakSerializer->serialize($qualifier);
100 100
 			$parameters[$qualifierId][] = $paramSerialization;
101 101
 		}
102 102
 		return $parameters;
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 	) {
109 109
 		$constraintId = $constraintStatement->getGuid();
110 110
 		$constraintTypeQid = $constraintStatement->getMainSnak()->getDataValue()->getEntityId()->getSerialization();
111
-		$parameters = $this->extractParametersFromQualifiers( $constraintStatement->getQualifiers() );
111
+		$parameters = $this->extractParametersFromQualifiers($constraintStatement->getQualifiers());
112 112
 		return new Constraint(
113 113
 			$constraintId,
114 114
 			$propertyId,
@@ -123,17 +123,17 @@  discard block
 block discarded – undo
123 123
 		PropertyId $propertyConstraintPropertyId
124 124
 	) {
125 125
 		$constraintsStatements = $property->getStatements()
126
-			->getByPropertyId( $propertyConstraintPropertyId )
127
-			->getByRank( [ Statement::RANK_PREFERRED, Statement::RANK_NORMAL ] );
126
+			->getByPropertyId($propertyConstraintPropertyId)
127
+			->getByRank([Statement::RANK_PREFERRED, Statement::RANK_NORMAL]);
128 128
 		$constraints = [];
129
-		foreach ( $constraintsStatements->getIterator() as $constraintStatement ) {
130
-			$constraints[] = $this->extractConstraintFromStatement( $property->getId(), $constraintStatement );
131
-			if ( count( $constraints ) >= self::BATCH_SIZE ) {
132
-				$constraintRepo->insertBatch( $constraints );
129
+		foreach ($constraintsStatements->getIterator() as $constraintStatement) {
130
+			$constraints[] = $this->extractConstraintFromStatement($property->getId(), $constraintStatement);
131
+			if (count($constraints) >= self::BATCH_SIZE) {
132
+				$constraintRepo->insertBatch($constraints);
133 133
 				$constraints = [];
134 134
 			}
135 135
 		}
136
-		$constraintRepo->insertBatch( $constraints );
136
+		$constraintRepo->insertBatch($constraints);
137 137
 	}
138 138
 
139 139
 	/**
@@ -144,15 +144,15 @@  discard block
 block discarded – undo
144 144
 	public function run() {
145 145
 		// TODO in the future: only touch constraints affected by the edit (requires T163465)
146 146
 
147
-		$propertyId = new PropertyId( $this->propertyId );
148
-		$this->constraintRepo->deleteForPropertyWhereConstraintIdIsStatementId( $propertyId );
147
+		$propertyId = new PropertyId($this->propertyId);
148
+		$this->constraintRepo->deleteForPropertyWhereConstraintIdIsStatementId($propertyId);
149 149
 
150 150
 		/** @var Property $property */
151
-		$property = $this->entityLookup->getEntity( $propertyId );
151
+		$property = $this->entityLookup->getEntity($propertyId);
152 152
 		$this->importConstraintsForProperty(
153 153
 			$property,
154 154
 			$this->constraintRepo,
155
-			new PropertyId( $this->config->get( 'WBQualityConstraintsPropertyConstraintId' ) )
155
+			new PropertyId($this->config->get('WBQualityConstraintsPropertyConstraintId'))
156 156
 		);
157 157
 
158 158
 		return true;
Please login to merge, or discard this patch.
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/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/ConstraintCheck/Checker/TypeChecker.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -83,34 +83,34 @@  discard block
 block discarded – undo
83 83
 	 * @throws SparqlHelperException if the checker uses SPARQL and the query times out or some other error occurs
84 84
 	 * @return CheckResult
85 85
 	 */
86
-	public function checkConstraint( Context $context, Constraint $constraint ) {
87
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
88
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
86
+	public function checkConstraint(Context $context, Constraint $constraint) {
87
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
88
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
89 89
 		}
90
-		if ( $context->getType() === Context::TYPE_REFERENCE ) {
91
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_NOT_IN_SCOPE );
90
+		if ($context->getType() === Context::TYPE_REFERENCE) {
91
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_NOT_IN_SCOPE);
92 92
 		}
93 93
 
94 94
 		$parameters = [];
95 95
 		$constraintParameters = $constraint->getConstraintParameters();
96 96
 
97
-		$classes = $this->constraintParameterParser->parseClassParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
97
+		$classes = $this->constraintParameterParser->parseClassParameter($constraintParameters, $constraint->getConstraintTypeItemId());
98 98
 		$parameters['class'] = array_map(
99
-			function( $id ) {
100
-				return new ItemId( $id );
99
+			function($id) {
100
+				return new ItemId($id);
101 101
 			},
102 102
 			$classes
103 103
 		);
104 104
 
105
-		$relation = $this->constraintParameterParser->parseRelationParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
105
+		$relation = $this->constraintParameterParser->parseRelationParameter($constraintParameters, $constraint->getConstraintTypeItemId());
106 106
 		$relationIds = [];
107
-		if ( $relation === 'instance' || $relation === 'instanceOrSubclass' ) {
108
-			$relationIds[] = $this->config->get( 'WBQualityConstraintsInstanceOfId' );
107
+		if ($relation === 'instance' || $relation === 'instanceOrSubclass') {
108
+			$relationIds[] = $this->config->get('WBQualityConstraintsInstanceOfId');
109 109
 		}
110
-		if ( $relation === 'subclass' || $relation === 'instanceOrSubclass' ) {
111
-			$relationIds[] = $this->config->get( 'WBQualityConstraintsSubclassOfId' );
110
+		if ($relation === 'subclass' || $relation === 'instanceOrSubclass') {
111
+			$relationIds[] = $this->config->get('WBQualityConstraintsSubclassOfId');
112 112
 		}
113
-		$parameters['relation'] = [ $relation ];
113
+		$parameters['relation'] = [$relation];
114 114
 
115 115
 		$result = $this->typeCheckerHelper->hasClassInRelation(
116 116
 			$context->getEntity()->getStatements(),
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 			$classes
119 119
 		);
120 120
 
121
-		if ( $result->getBool() ) {
121
+		if ($result->getBool()) {
122 122
 			$message = null;
123 123
 			$status = CheckResult::STATUS_COMPLIANCE;
124 124
 		} else {
@@ -132,21 +132,21 @@  discard block
 block discarded – undo
132 132
 			$status = CheckResult::STATUS_VIOLATION;
133 133
 		}
134 134
 
135
-		return ( new CheckResult( $context, $constraint, $parameters, $status, $message ) )
136
-			->withMetadata( $result->getMetadata() );
135
+		return (new CheckResult($context, $constraint, $parameters, $status, $message))
136
+			->withMetadata($result->getMetadata());
137 137
 	}
138 138
 
139
-	public function checkConstraintParameters( Constraint $constraint ) {
139
+	public function checkConstraintParameters(Constraint $constraint) {
140 140
 		$constraintParameters = $constraint->getConstraintParameters();
141 141
 		$exceptions = [];
142 142
 		try {
143
-			$this->constraintParameterParser->parseClassParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
144
-		} catch ( ConstraintParameterException $e ) {
143
+			$this->constraintParameterParser->parseClassParameter($constraintParameters, $constraint->getConstraintTypeItemId());
144
+		} catch (ConstraintParameterException $e) {
145 145
 			$exceptions[] = $e;
146 146
 		}
147 147
 		try {
148
-			$this->constraintParameterParser->parseRelationParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
149
-		} catch ( ConstraintParameterException $e ) {
148
+			$this->constraintParameterParser->parseRelationParameter($constraintParameters, $constraint->getConstraintTypeItemId());
149
+		} catch (ConstraintParameterException $e) {
150 150
 			$exceptions[] = $e;
151 151
 		}
152 152
 		return $exceptions;
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/QualifierChecker.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -47,16 +47,16 @@
 block discarded – undo
47 47
 	 *
48 48
 	 * @return CheckResult
49 49
 	 */
50
-	public function checkConstraint( Context $context, Constraint $constraint ) {
51
-		if ( $context->getType() === Context::TYPE_QUALIFIER ) {
52
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_COMPLIANCE );
50
+	public function checkConstraint(Context $context, Constraint $constraint) {
51
+		if ($context->getType() === Context::TYPE_QUALIFIER) {
52
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_COMPLIANCE);
53 53
 		} else {
54
-			$message = new ViolationMessage( 'wbqc-violation-message-qualifier' );
55
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_VIOLATION, $message );
54
+			$message = new ViolationMessage('wbqc-violation-message-qualifier');
55
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_VIOLATION, $message);
56 56
 		}
57 57
 	}
58 58
 
59
-	public function checkConstraintParameters( Constraint $constraint ) {
59
+	public function checkConstraintParameters(Constraint $constraint) {
60 60
 		// no parameters
61 61
 		return [];
62 62
 	}
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/ValueOnlyChecker.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -36,16 +36,16 @@
 block discarded – undo
36 36
 		];
37 37
 	}
38 38
 
39
-	public function checkConstraint( Context $context, Constraint $constraint ) {
40
-		if ( $context->getType() === Context::TYPE_STATEMENT ) {
41
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_COMPLIANCE );
39
+	public function checkConstraint(Context $context, Constraint $constraint) {
40
+		if ($context->getType() === Context::TYPE_STATEMENT) {
41
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_COMPLIANCE);
42 42
 		} else {
43
-			$message = new ViolationMessage( 'wbqc-violation-message-valueOnly' );
44
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_VIOLATION, $message );
43
+			$message = new ViolationMessage('wbqc-violation-message-valueOnly');
44
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_VIOLATION, $message);
45 45
 		}
46 46
 	}
47 47
 
48
-	public function checkConstraintParameters( Constraint $constraint ) {
48
+	public function checkConstraintParameters(Constraint $constraint) {
49 49
 		// no parameters
50 50
 		return [];
51 51
 	}
Please login to merge, or discard this patch.