Completed
Push — master ( e76c99...c0a2f5 )
by
unknown
02:13
created
src/ConstraintCheck/Checker/TypeChecker.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -69,32 +69,32 @@  discard block
 block discarded – undo
69 69
 	 *
70 70
 	 * @throws SparqlHelperException if the checker uses SPARQL and the query times out or some other error occurs
71 71
 	 */
72
-	public function checkConstraint( Context $context, Constraint $constraint ) {
73
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
74
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
72
+	public function checkConstraint(Context $context, Constraint $constraint) {
73
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
74
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
75 75
 		}
76
-		if ( $context->getType() === Context::TYPE_REFERENCE ) {
77
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_NOT_MAIN_SNAK );
76
+		if ($context->getType() === Context::TYPE_REFERENCE) {
77
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_NOT_MAIN_SNAK);
78 78
 		}
79 79
 
80 80
 		$parameters = [];
81 81
 		$constraintParameters = $constraint->getConstraintParameters();
82 82
 
83
-		$classes = $this->constraintParameterParser->parseClassParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
83
+		$classes = $this->constraintParameterParser->parseClassParameter($constraintParameters, $constraint->getConstraintTypeItemId());
84 84
 		$parameters['class'] = array_map(
85
-			function( $id ) {
86
-				return new ItemId( $id );
85
+			function($id) {
86
+				return new ItemId($id);
87 87
 			},
88 88
 			$classes
89 89
 		);
90 90
 
91
-		$relation = $this->constraintParameterParser->parseRelationParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
92
-		if ( $relation === 'instance' ) {
93
-			$relationId = $this->config->get( 'WBQualityConstraintsInstanceOfId' );
94
-		} elseif ( $relation === 'subclass' ) {
95
-			$relationId = $this->config->get( 'WBQualityConstraintsSubclassOfId' );
91
+		$relation = $this->constraintParameterParser->parseRelationParameter($constraintParameters, $constraint->getConstraintTypeItemId());
92
+		if ($relation === 'instance') {
93
+			$relationId = $this->config->get('WBQualityConstraintsInstanceOfId');
94
+		} elseif ($relation === 'subclass') {
95
+			$relationId = $this->config->get('WBQualityConstraintsSubclassOfId');
96 96
 		}
97
-		$parameters['relation'] = [ $relation ];
97
+		$parameters['relation'] = [$relation];
98 98
 
99 99
 		$result = $this->typeCheckerHelper->hasClassInRelation(
100 100
 			$context->getEntity()->getStatements(),
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 			$classes
103 103
 		);
104 104
 
105
-		if ( $result->getBool() ) {
105
+		if ($result->getBool()) {
106 106
 			$message = '';
107 107
 			$status = CheckResult::STATUS_COMPLIANCE;
108 108
 		} else {
@@ -116,21 +116,21 @@  discard block
 block discarded – undo
116 116
 			$status = CheckResult::STATUS_VIOLATION;
117 117
 		}
118 118
 
119
-		return ( new CheckResult( $context, $constraint, $parameters, $status, $message ) )
120
-			->withMetadata( $result->getMetadata() );
119
+		return (new CheckResult($context, $constraint, $parameters, $status, $message))
120
+			->withMetadata($result->getMetadata());
121 121
 	}
122 122
 
123
-	public function checkConstraintParameters( Constraint $constraint ) {
123
+	public function checkConstraintParameters(Constraint $constraint) {
124 124
 		$constraintParameters = $constraint->getConstraintParameters();
125 125
 		$exceptions = [];
126 126
 		try {
127
-			$this->constraintParameterParser->parseClassParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
128
-		} catch ( ConstraintParameterException $e ) {
127
+			$this->constraintParameterParser->parseClassParameter($constraintParameters, $constraint->getConstraintTypeItemId());
128
+		} catch (ConstraintParameterException $e) {
129 129
 			$exceptions[] = $e;
130 130
 		}
131 131
 		try {
132
-			$this->constraintParameterParser->parseRelationParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
133
-		} catch ( ConstraintParameterException $e ) {
132
+			$this->constraintParameterParser->parseRelationParameter($constraintParameters, $constraint->getConstraintTypeItemId());
133
+		} catch (ConstraintParameterException $e) {
134 134
 			$exceptions[] = $e;
135 135
 		}
136 136
 		return $exceptions;
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/SymmetricChecker.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -60,12 +60,12 @@  discard block
 block discarded – undo
60 60
 	 *
61 61
 	 * @return CheckResult
62 62
 	 */
63
-	public function checkConstraint( Context $context, Constraint $constraint ) {
64
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
65
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
63
+	public function checkConstraint(Context $context, Constraint $constraint) {
64
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
65
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
66 66
 		}
67
-		if ( $context->getType() !== Context::TYPE_STATEMENT ) {
68
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_NOT_MAIN_SNAK );
67
+		if ($context->getType() !== Context::TYPE_STATEMENT) {
68
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_NOT_MAIN_SNAK);
69 69
 		}
70 70
 
71 71
 		$parameters = [];
@@ -73,9 +73,9 @@  discard block
 block discarded – undo
73 73
 		$snak = $context->getSnak();
74 74
 		$propertyId = $context->getSnak()->getPropertyId();
75 75
 
76
-		if ( !$snak instanceof PropertyValueSnak ) {
76
+		if (!$snak instanceof PropertyValueSnak) {
77 77
 			// nothing to check
78
-			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE, '' );
78
+			return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE, '');
79 79
 		}
80 80
 
81 81
 		$dataValue = $snak->getDataValue();
@@ -84,22 +84,22 @@  discard block
 block discarded – undo
84 84
 		 * error handling:
85 85
 		 *   type of $dataValue for properties with 'Symmetric' constraint has to be 'wikibase-entityid'
86 86
 		 */
87
-		if ( $dataValue->getType() !== 'wikibase-entityid' ) {
88
-			$message = wfMessage( "wbqc-violation-message-value-needed-of-type" )
87
+		if ($dataValue->getType() !== 'wikibase-entityid') {
88
+			$message = wfMessage("wbqc-violation-message-value-needed-of-type")
89 89
 					 ->rawParams(
90
-						 $this->constraintParameterRenderer->formatItemId( $constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM ),
90
+						 $this->constraintParameterRenderer->formatItemId($constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM),
91 91
 						 'wikibase-entityid' // TODO is there a message for this type so we can localize it?
92 92
 					 )
93 93
 					 ->escaped();
94
-			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message );
94
+			return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message);
95 95
 		}
96 96
 		/** @var EntityIdValue $dataValue */
97 97
 
98 98
 		$targetEntityId = $dataValue->getEntityId();
99
-		$targetEntity = $this->entityLookup->getEntity( $targetEntityId );
100
-		if ( $targetEntity === null ) {
101
-			$message = wfMessage( "wbqc-violation-message-target-entity-must-exist" )->escaped();
102
-			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message );
99
+		$targetEntity = $this->entityLookup->getEntity($targetEntityId);
100
+		if ($targetEntity === null) {
101
+			$message = wfMessage("wbqc-violation-message-target-entity-must-exist")->escaped();
102
+			return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message);
103 103
 		}
104 104
 
105 105
 		$symmetricStatement = $this->connectionCheckerHelper->findStatementWithPropertyAndEntityIdValue(
@@ -107,26 +107,26 @@  discard block
 block discarded – undo
107 107
 			$propertyId,
108 108
 			$context->getEntity()->getId()
109 109
 		);
110
-		if ( $symmetricStatement !== null ) {
110
+		if ($symmetricStatement !== null) {
111 111
 			$message = '';
112 112
 			$status = CheckResult::STATUS_COMPLIANCE;
113 113
 		} else {
114
-			$message = wfMessage( 'wbqc-violation-message-symmetric' )
114
+			$message = wfMessage('wbqc-violation-message-symmetric')
115 115
 					 ->rawParams(
116
-						 $this->constraintParameterRenderer->formatEntityId( $targetEntityId, Role::SUBJECT ),
117
-						 $this->constraintParameterRenderer->formatEntityId( $propertyId, Role::PREDICATE ),
118
-						 $this->constraintParameterRenderer->formatEntityId( $context->getEntity()->getId(), Role::OBJECT )
116
+						 $this->constraintParameterRenderer->formatEntityId($targetEntityId, Role::SUBJECT),
117
+						 $this->constraintParameterRenderer->formatEntityId($propertyId, Role::PREDICATE),
118
+						 $this->constraintParameterRenderer->formatEntityId($context->getEntity()->getId(), Role::OBJECT)
119 119
 					 )
120 120
 					 ->escaped();
121 121
 			$status = CheckResult::STATUS_VIOLATION;
122 122
 		}
123 123
 
124
-		return ( new CheckResult( $context, $constraint, $parameters, $status, $message ) )
125
-			->withMetadata( Metadata::ofDependencyMetadata(
126
-				DependencyMetadata::ofEntityId( $targetEntityId ) ) );
124
+		return (new CheckResult($context, $constraint, $parameters, $status, $message))
125
+			->withMetadata(Metadata::ofDependencyMetadata(
126
+				DependencyMetadata::ofEntityId($targetEntityId) ));
127 127
 	}
128 128
 
129
-	public function checkConstraintParameters( Constraint $constraint ) {
129
+	public function checkConstraintParameters(Constraint $constraint) {
130 130
 		// no parameters
131 131
 		return [];
132 132
 	}
Please login to merge, or discard this patch.
src/ConstraintCheck/Cache/CachedArray.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
 	 */
21 21
 	private $metadata;
22 22
 
23
-	public function __construct( array $array, Metadata $metadata ) {
23
+	public function __construct(array $array, Metadata $metadata) {
24 24
 		$this->array = $array;
25 25
 		$this->metadata = $metadata;
26 26
 	}
Please login to merge, or discard this patch.
src/ConstraintCheck/Cache/DependencyMetadata.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	 * @param EntityId $entityId An entity ID from which the value was derived.
30 30
 	 * @return self Indication that a value is was derived from the entity with the given ID.
31 31
 	 */
32
-	public static function ofEntityId( EntityId $entityId ) {
32
+	public static function ofEntityId(EntityId $entityId) {
33 33
 		$ret = new self;
34 34
 		$ret->entityIds[] = $entityId;
35 35
 		return $ret;
@@ -39,11 +39,11 @@  discard block
 block discarded – undo
39 39
 	 * @param self[] $metadatas
40 40
 	 * @return self
41 41
 	 */
42
-	public static function merge( array $metadatas ) {
43
-		Assert::parameterElementType( self::class, $metadatas, '$metadatas' );
42
+	public static function merge(array $metadatas) {
43
+		Assert::parameterElementType(self::class, $metadatas, '$metadatas');
44 44
 		$ret = new self;
45
-		foreach ( $metadatas as $metadata ) {
46
-			$ret->entityIds = array_merge( $ret->entityIds, $metadata->entityIds );
45
+		foreach ($metadatas as $metadata) {
46
+			$ret->entityIds = array_merge($ret->entityIds, $metadata->entityIds);
47 47
 		}
48 48
 		return $ret;
49 49
 	}
Please login to merge, or discard this patch.
src/ConstraintCheck/Cache/CachedBool.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
 	 * @param bool $bool
25 25
 	 * @param Metadata $metadata
26 26
 	 */
27
-	public function __construct( $bool, Metadata $metadata ) {
27
+	public function __construct($bool, Metadata $metadata) {
28 28
 		$this->bool = $bool;
29 29
 		$this->metadata = $metadata;
30 30
 	}
Please login to merge, or discard this patch.
src/ConstraintCheck/Cache/CachingMetadata.php 1 patch
Spacing   +8 added lines, -8 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;
@@ -41,11 +41,11 @@  discard block
 block discarded – undo
41 41
 	 * @param self[] $metadatas
42 42
 	 * @return self
43 43
 	 */
44
-	public static function merge( array $metadatas ) {
45
-		Assert::parameterElementType( self::class, $metadatas, '$metadatas' );
44
+	public static function merge(array $metadatas) {
45
+		Assert::parameterElementType(self::class, $metadatas, '$metadatas');
46 46
 		$ret = new self;
47
-		foreach ( $metadatas as $metadata ) {
48
-			$ret->maxAge = max( $ret->maxAge, $metadata->maxAge );
47
+		foreach ($metadatas as $metadata) {
48
+			$ret->maxAge = max($ret->maxAge, $metadata->maxAge);
49 49
 		}
50 50
 		return $ret;
51 51
 	}
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 	 * For a fresh value, returns 0.
64 64
 	 */
65 65
 	public function getMaximumAgeInSeconds() {
66
-		if ( is_int( $this->maxAge ) ) {
66
+		if (is_int($this->maxAge)) {
67 67
 			return $this->maxAge;
68 68
 		} else {
69 69
 			return 0;
Please login to merge, or discard this patch.
src/ConstraintCheck/Api/CheckingResultsBuilder.php 1 patch
Spacing   +23 added lines, -24 removed lines patch added patch discarded remove patch
@@ -73,44 +73,43 @@  discard block
 block discarded – undo
73 73
 	) {
74 74
 		$response = [];
75 75
 		$metadatas = [];
76
-		foreach ( $entityIds as $entityId ) {
76
+		foreach ($entityIds as $entityId) {
77 77
 			$results = $this->delegatingConstraintChecker->checkAgainstConstraintsOnEntityId(
78 78
 				$entityId,
79 79
 				$constraintIds,
80
-				[ $this, 'defaultResults' ]
80
+				[$this, 'defaultResults']
81 81
 			);
82
-			foreach ( $results as $result ) {
82
+			foreach ($results as $result) {
83 83
 				$metadatas[] = $result->getMetadata();
84
-				$resultArray = $this->checkResultToArray( $result );
85
-				$result->getContext()->storeCheckResultInArray( $resultArray, $response );
84
+				$resultArray = $this->checkResultToArray($result);
85
+				$result->getContext()->storeCheckResultInArray($resultArray, $response);
86 86
 			}
87 87
 		}
88
-		foreach ( $claimIds as $claimId ) {
88
+		foreach ($claimIds as $claimId) {
89 89
 			$results = $this->delegatingConstraintChecker->checkAgainstConstraintsOnClaimId(
90 90
 				$claimId,
91 91
 				$constraintIds,
92
-				[ $this, 'defaultResults' ]
92
+				[$this, 'defaultResults']
93 93
 			);
94
-			foreach ( $results as $result ) {
94
+			foreach ($results as $result) {
95 95
 				$metadatas[] = $result->getMetadata();
96
-				$resultArray = $this->checkResultToArray( $result );
97
-				$result->getContext()->storeCheckResultInArray( $resultArray, $response );
96
+				$resultArray = $this->checkResultToArray($result);
97
+				$result->getContext()->storeCheckResultInArray($resultArray, $response);
98 98
 			}
99 99
 		}
100 100
 		return new CachedCheckConstraintsResponse(
101 101
 			$response,
102
-			Metadata::merge( $metadatas )
102
+			Metadata::merge($metadatas)
103 103
 		);
104 104
 	}
105 105
 
106
-	public function defaultResults( Context $context ) {
106
+	public function defaultResults(Context $context) {
107 107
 		return $context->getType() === Context::TYPE_STATEMENT ?
108
-			[ new NullResult( $context ) ] :
109
-			[];
108
+			[new NullResult($context)] : [];
110 109
 	}
111 110
 
112
-	public function checkResultToArray( CheckResult $checkResult ) {
113
-		if ( $checkResult instanceof NullResult ) {
111
+	public function checkResultToArray(CheckResult $checkResult) {
112
+		if ($checkResult instanceof NullResult) {
114 113
 			return null;
115 114
 		}
116 115
 
@@ -118,10 +117,10 @@  discard block
 block discarded – undo
118 117
 		$typeItemId = $checkResult->getConstraint()->getConstraintTypeItemId();
119 118
 		$constraintPropertyId = $checkResult->getContext()->getSnak()->getPropertyId();
120 119
 
121
-		$title = $this->entityTitleLookup->getTitleForId( $constraintPropertyId );
122
-		$typeLabel = $this->entityIdLabelFormatter->formatEntityId( new ItemId( $typeItemId ) );
120
+		$title = $this->entityTitleLookup->getTitleForId($constraintPropertyId);
121
+		$typeLabel = $this->entityIdLabelFormatter->formatEntityId(new ItemId($typeItemId));
123 122
 		// TODO link to the statement when possible (T169224)
124
-		$link = $title->getFullUrl() . '#' . $this->config->get( 'WBQualityConstraintsPropertyConstraintId' );
123
+		$link = $title->getFullUrl().'#'.$this->config->get('WBQualityConstraintsPropertyConstraintId');
125 124
 
126 125
 		$constraint = [
127 126
 			'id' => $constraintId,
@@ -129,11 +128,11 @@  discard block
 block discarded – undo
129 128
 			'typeLabel' => $typeLabel,
130 129
 			'link' => $link,
131 130
 		];
132
-		if ( $this->config->get( 'WBQualityConstraintsIncludeDetailInApi' ) ) {
131
+		if ($this->config->get('WBQualityConstraintsIncludeDetailInApi')) {
133 132
 			$parameters = $checkResult->getParameters();
134 133
 			$constraint += [
135 134
 				'detail' => $parameters,
136
-				'detailHTML' => $this->constraintParameterRenderer->formatParameters( $parameters ),
135
+				'detailHTML' => $this->constraintParameterRenderer->formatParameters($parameters),
137 136
 			];
138 137
 		}
139 138
 
@@ -143,14 +142,14 @@  discard block
 block discarded – undo
143 142
 			'constraint' => $constraint
144 143
 		];
145 144
 		$message = $checkResult->getMessage();
146
-		if ( $message ) {
145
+		if ($message) {
147 146
 			$result['message-html'] = $message;
148 147
 		}
149
-		if ( $checkResult->getContext()->getType() === Context::TYPE_STATEMENT ) {
148
+		if ($checkResult->getContext()->getType() === Context::TYPE_STATEMENT) {
150 149
 			$result['claim'] = $checkResult->getContext()->getSnakStatement()->getGuid();
151 150
 		}
152 151
 		$cachingMetadata = $checkResult->getMetadata()->getCachingMetadata();
153
-		if ( $cachingMetadata->isCached() ) {
152
+		if ($cachingMetadata->isCached()) {
154 153
 			$result['cached'] = [
155 154
 				'maximumAgeInSeconds' => $cachingMetadata->getMaximumAgeInSeconds(),
156 155
 			];
Please login to merge, or discard this patch.
src/ConstraintCheck/Cache/Metadata.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -32,14 +32,14 @@  discard block
 block discarded – undo
32 32
 		return $ret;
33 33
 	}
34 34
 
35
-	public static function ofCachingMetadata( CachingMetadata $cachingMetadata ) {
35
+	public static function ofCachingMetadata(CachingMetadata $cachingMetadata) {
36 36
 		$ret = new self;
37 37
 		$ret->cachingMetadata = $cachingMetadata;
38 38
 		$ret->dependencyMetadata = DependencyMetadata::blank();
39 39
 		return $ret;
40 40
 	}
41 41
 
42
-	public static function ofDependencyMetadata( DependencyMetadata $dependencyMetadata ) {
42
+	public static function ofDependencyMetadata(DependencyMetadata $dependencyMetadata) {
43 43
 		$ret = new self;
44 44
 		$ret->cachingMetadata = CachingMetadata::fresh();
45 45
 		$ret->dependencyMetadata = $dependencyMetadata;
@@ -50,17 +50,17 @@  discard block
 block discarded – undo
50 50
 	 * @param self[] $metadatas
51 51
 	 * @return self
52 52
 	 */
53
-	public static function merge( array $metadatas ) {
54
-		Assert::parameterElementType( self::class, $metadatas, '$metadatas' );
53
+	public static function merge(array $metadatas) {
54
+		Assert::parameterElementType(self::class, $metadatas, '$metadatas');
55 55
 		$cachingMetadatas = [];
56 56
 		$dependencyMetadatas = [];
57
-		foreach ( $metadatas as $metadata ) {
57
+		foreach ($metadatas as $metadata) {
58 58
 			$cachingMetadatas[] = $metadata->cachingMetadata;
59 59
 			$dependencyMetadatas[] = $metadata->dependencyMetadata;
60 60
 		}
61 61
 		$ret = new self;
62
-		$ret->cachingMetadata = CachingMetadata::merge( $cachingMetadatas );
63
-		$ret->dependencyMetadata = DependencyMetadata::merge( $dependencyMetadatas );
62
+		$ret->cachingMetadata = CachingMetadata::merge($cachingMetadatas);
63
+		$ret->dependencyMetadata = DependencyMetadata::merge($dependencyMetadatas);
64 64
 		return $ret;
65 65
 	}
66 66
 
Please login to merge, or discard this patch.
src/ConstraintCheck/Api/CachingResultsBuilder.php 1 patch
Spacing   +32 added lines, -33 removed lines patch added patch discarded remove patch
@@ -87,26 +87,26 @@  discard block
 block discarded – undo
87 87
 	) {
88 88
 		$results = [];
89 89
 		$metadatas = [];
90
-		if ( $this->canUseStoredResults( $entityIds, $claimIds, $constraintIds ) ) {
90
+		if ($this->canUseStoredResults($entityIds, $claimIds, $constraintIds)) {
91 91
 			$storedEntityIds = [];
92
-			foreach ( $entityIds as $entityId ) {
93
-				$storedResults = $this->getStoredResults( $entityId );
94
-				if ( $storedResults !== null ) {
92
+			foreach ($entityIds as $entityId) {
93
+				$storedResults = $this->getStoredResults($entityId);
94
+				if ($storedResults !== null) {
95 95
 					$results += $storedResults->getArray();
96 96
 					$metadatas[] = $storedResults->getMetadata();
97 97
 					$storedEntityIds[] = $entityId;
98 98
 				}
99 99
 			}
100
-			$entityIds = array_values( array_diff( $entityIds, $storedEntityIds ) );
100
+			$entityIds = array_values(array_diff($entityIds, $storedEntityIds));
101 101
 		}
102
-		if ( $entityIds !== [] || $claimIds !== [] ) {
103
-			$response = $this->getAndStoreResults( $entityIds, $claimIds, $constraintIds );
102
+		if ($entityIds !== [] || $claimIds !== []) {
103
+			$response = $this->getAndStoreResults($entityIds, $claimIds, $constraintIds);
104 104
 			$results += $response->getArray();
105 105
 			$metadatas[] = $response->getMetadata();
106 106
 		}
107 107
 		return new CachedCheckConstraintsResponse(
108 108
 			$results,
109
-			Metadata::merge( $metadatas )
109
+			Metadata::merge($metadatas)
110 110
 		);
111 111
 	}
112 112
 
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 	 * @param EntityId $entityId
133 133
 	 * @return string cache key
134 134
 	 */
135
-	public function getKey( EntityId $entityId ) {
135
+	public function getKey(EntityId $entityId) {
136 136
 		return $this->cache->makeKey(
137 137
 			'WikibaseQualityConstraints', // extension
138 138
 			'checkConstraints', // action
@@ -152,18 +152,18 @@  discard block
 block discarded – undo
152 152
 		array $claimIds,
153 153
 		array $constraintIds = null
154 154
 	) {
155
-		$results = $this->resultsBuilder->getResults( $entityIds, $claimIds, $constraintIds );
155
+		$results = $this->resultsBuilder->getResults($entityIds, $claimIds, $constraintIds);
156 156
 
157
-		if ( $this->canStoreResults( $entityIds, $claimIds, $constraintIds ) ) {
158
-			foreach ( $entityIds as $entityId ) {
159
-				$key = $this->getKey( $entityId );
157
+		if ($this->canStoreResults($entityIds, $claimIds, $constraintIds)) {
158
+			foreach ($entityIds as $entityId) {
159
+				$key = $this->getKey($entityId);
160 160
 				$value = [
161 161
 					'results' => $results->getArray()[$entityId->getSerialization()],
162 162
 					'latestRevisionIds' => $this->getLatestRevisionIds(
163 163
 						$results->getMetadata()->getDependencyMetadata()->getEntityIds()
164 164
 					),
165 165
 				];
166
-				$this->cache->set( $key, $value, $this->ttlInSeconds );
166
+				$this->cache->set($key, $value, $this->ttlInSeconds);
167 167
 			}
168 168
 		}
169 169
 
@@ -196,41 +196,40 @@  discard block
 block discarded – undo
196 196
 	public function getStoredResults(
197 197
 		EntityId $entityId
198 198
 	) {
199
-		$key = $this->getKey( $entityId );
200
-		$value = $this->cache->get( $key, $curTTL, [], $asOf );
201
-		$now = call_user_func( $this->microtime, true );
199
+		$key = $this->getKey($entityId);
200
+		$value = $this->cache->get($key, $curTTL, [], $asOf);
201
+		$now = call_user_func($this->microtime, true);
202 202
 
203
-		if ( $value === false ) {
203
+		if ($value === false) {
204 204
 			return null;
205 205
 		}
206 206
 
207
-		$ageInSeconds = (integer)ceil( $now - $asOf );
207
+		$ageInSeconds = (integer) ceil($now - $asOf);
208 208
 
209 209
 		$dependedEntityIds = array_map(
210
-			[ $this->entityIdParser, "parse" ],
211
-			array_keys( $value['latestRevisionIds'] )
210
+			[$this->entityIdParser, "parse"],
211
+			array_keys($value['latestRevisionIds'])
212 212
 		);
213 213
 
214
-		if ( $value['latestRevisionIds'] !== $this->getLatestRevisionIds( $dependedEntityIds ) ) {
214
+		if ($value['latestRevisionIds'] !== $this->getLatestRevisionIds($dependedEntityIds)) {
215 215
 			return null;
216 216
 		}
217 217
 
218 218
 		return new CachedCheckConstraintsResponse(
219
-			[ $entityId->getSerialization() => $value['results'] ],
219
+			[$entityId->getSerialization() => $value['results']],
220 220
 			array_reduce(
221 221
 				$dependedEntityIds,
222
-				function( Metadata $metadata, EntityId $entityId ) {
223
-					return Metadata::merge( [
222
+				function(Metadata $metadata, EntityId $entityId) {
223
+					return Metadata::merge([
224 224
 						$metadata,
225 225
 						Metadata::ofDependencyMetadata(
226
-							DependencyMetadata::ofEntityId( $entityId )
226
+							DependencyMetadata::ofEntityId($entityId)
227 227
 						)
228
-					] );
228
+					]);
229 229
 				},
230 230
 				Metadata::ofCachingMetadata(
231 231
 					$ageInSeconds > 0 ?
232
-						CachingMetadata::ofMaximumAgeInSeconds( $ageInSeconds ) :
233
-						CachingMetadata::fresh()
232
+						CachingMetadata::ofMaximumAgeInSeconds($ageInSeconds) : CachingMetadata::fresh()
234 233
 				)
235 234
 			)
236 235
 		);
@@ -240,11 +239,11 @@  discard block
 block discarded – undo
240 239
 	 * @param EntityId[] $entityIds
241 240
 	 * @return int[]
242 241
 	 */
243
-	private function getLatestRevisionIds( array $entityIds ) {
242
+	private function getLatestRevisionIds(array $entityIds) {
244 243
 		$latestRevisionIds = [];
245
-		foreach ( $entityIds as $entityId ) {
244
+		foreach ($entityIds as $entityId) {
246 245
 			$serialization = $entityId->getSerialization();
247
-			$latestRevisionId = $this->entityRevisionLookup->getLatestRevisionId( $entityId );
246
+			$latestRevisionId = $this->entityRevisionLookup->getLatestRevisionId($entityId);
248 247
 			$latestRevisionIds[$serialization] = $latestRevisionId;
249 248
 		}
250 249
 		return $latestRevisionIds;
@@ -255,7 +254,7 @@  discard block
 block discarded – undo
255 254
 	 *
256 255
 	 * @param callable $microtime
257 256
 	 */
258
-	public function setMicrotimeFunction( callable $microtime ) {
257
+	public function setMicrotimeFunction(callable $microtime) {
259 258
 		$this->microtime = $microtime;
260 259
 	}
261 260
 
Please login to merge, or discard this patch.