Completed
Push — master ( 11e3bd...1a1840 )
by
unknown
03:54
created
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.
src/ConstraintCheck/Context/ContextCursorDeserializer.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -11,8 +11,8 @@  discard block
 block discarded – undo
11 11
  */
12 12
 class ContextCursorDeserializer {
13 13
 
14
-	public function deserialize( array $serialization ) {
15
-		switch ( $serialization['t'] ) {
14
+	public function deserialize(array $serialization) {
15
+		switch ($serialization['t']) {
16 16
 			case Context::TYPE_STATEMENT:
17 17
 				return new MainSnakContextCursor(
18 18
 					$serialization['i'],
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 				);
40 40
 			default:
41 41
 				throw new InvalidArgumentException(
42
-					'Unknown serialization type ' . $serialization['t']
42
+					'Unknown serialization type '.$serialization['t']
43 43
 				);
44 44
 		}
45 45
 	}
Please login to merge, or discard this patch.
src/Api/CheckingResultsBuilder.php 1 patch
Spacing   +28 added lines, -29 removed lines patch added patch discarded remove patch
@@ -84,65 +84,64 @@  discard block
 block discarded – undo
84 84
 	) {
85 85
 		$response = [];
86 86
 		$metadatas = [];
87
-		$statusesFlipped = array_flip( $statuses );
88
-		foreach ( $entityIds as $entityId ) {
87
+		$statusesFlipped = array_flip($statuses);
88
+		foreach ($entityIds as $entityId) {
89 89
 			$results = $this->delegatingConstraintChecker->checkAgainstConstraintsOnEntityId(
90 90
 				$entityId,
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
-				if ( $this->statusSelected( $statusesFlipped, $result ) ) {
97
-					$resultArray = $this->checkResultToArray( $result );
98
-					$result->getContextCursor()->storeCheckResultInArray( $resultArray, $response );
96
+				if ($this->statusSelected($statusesFlipped, $result)) {
97
+					$resultArray = $this->checkResultToArray($result);
98
+					$result->getContextCursor()->storeCheckResultInArray($resultArray, $response);
99 99
 				}
100 100
 			}
101 101
 		}
102
-		foreach ( $claimIds as $claimId ) {
102
+		foreach ($claimIds as $claimId) {
103 103
 			$results = $this->delegatingConstraintChecker->checkAgainstConstraintsOnClaimId(
104 104
 				$claimId,
105 105
 				$constraintIds,
106
-				[ $this, 'defaultResults' ]
106
+				[$this, 'defaultResults']
107 107
 			);
108
-			foreach ( $results as $result ) {
108
+			foreach ($results as $result) {
109 109
 				$metadatas[] = $result->getMetadata();
110
-				if ( $this->statusSelected( $statusesFlipped, $result ) ) {
111
-					$resultArray = $this->checkResultToArray( $result );
112
-					$result->getContextCursor()->storeCheckResultInArray( $resultArray, $response );
110
+				if ($this->statusSelected($statusesFlipped, $result)) {
111
+					$resultArray = $this->checkResultToArray($result);
112
+					$result->getContextCursor()->storeCheckResultInArray($resultArray, $response);
113 113
 				}
114 114
 			}
115 115
 		}
116 116
 		return new CachedCheckConstraintsResponse(
117 117
 			$response,
118
-			Metadata::merge( $metadatas )
118
+			Metadata::merge($metadatas)
119 119
 		);
120 120
 	}
121 121
 
122
-	public function defaultResults( Context $context ) {
122
+	public function defaultResults(Context $context) {
123 123
 		return $context->getType() === Context::TYPE_STATEMENT ?
124
-			[ new NullResult( $context ) ] :
125
-			[];
124
+			[new NullResult($context)] : [];
126 125
 	}
127 126
 
128
-	public function statusSelected( array $statusesFlipped, CheckResult $result ) {
129
-		return array_key_exists( $result->getStatus(), $statusesFlipped ) ||
127
+	public function statusSelected(array $statusesFlipped, CheckResult $result) {
128
+		return array_key_exists($result->getStatus(), $statusesFlipped) ||
130 129
 			$result instanceof NullResult;
131 130
 	}
132 131
 
133
-	public function checkResultToArray( CheckResult $checkResult ) {
134
-		if ( $checkResult instanceof NullResult ) {
132
+	public function checkResultToArray(CheckResult $checkResult) {
133
+		if ($checkResult instanceof NullResult) {
135 134
 			return null;
136 135
 		}
137 136
 
138 137
 		$constraintId = $checkResult->getConstraint()->getConstraintId();
139 138
 		$typeItemId = $checkResult->getConstraint()->getConstraintTypeItemId();
140
-		$constraintPropertyId = new PropertyId( $checkResult->getContextCursor()->getSnakPropertyId() );
139
+		$constraintPropertyId = new PropertyId($checkResult->getContextCursor()->getSnakPropertyId());
141 140
 
142
-		$title = $this->entityTitleLookup->getTitleForId( $constraintPropertyId );
143
-		$typeLabel = $this->entityIdLabelFormatter->formatEntityId( new ItemId( $typeItemId ) );
141
+		$title = $this->entityTitleLookup->getTitleForId($constraintPropertyId);
142
+		$typeLabel = $this->entityIdLabelFormatter->formatEntityId(new ItemId($typeItemId));
144 143
 		// TODO link to the statement when possible (T169224)
145
-		$link = $title->getFullURL() . '#' . $this->config->get( 'WBQualityConstraintsPropertyConstraintId' );
144
+		$link = $title->getFullURL().'#'.$this->config->get('WBQualityConstraintsPropertyConstraintId');
146 145
 
147 146
 		$constraint = [
148 147
 			'id' => $constraintId,
@@ -158,14 +157,14 @@  discard block
 block discarded – undo
158 157
 			'constraint' => $constraint
159 158
 		];
160 159
 		$message = $checkResult->getMessage();
161
-		if ( $message ) {
162
-			$result['message-html'] = $this->violationMessageRenderer->render( $message );
160
+		if ($message) {
161
+			$result['message-html'] = $this->violationMessageRenderer->render($message);
163 162
 		}
164
-		if ( $checkResult->getContextCursor()->getType() === Context::TYPE_STATEMENT ) {
163
+		if ($checkResult->getContextCursor()->getType() === Context::TYPE_STATEMENT) {
165 164
 			$result['claim'] = $checkResult->getContextCursor()->getStatementGuid();
166 165
 		}
167 166
 		$cachingMetadataArray = $checkResult->getMetadata()->getCachingMetadata()->toArray();
168
-		if ( $cachingMetadataArray !== null ) {
167
+		if ($cachingMetadataArray !== null) {
169 168
 			$result['cached'] = $cachingMetadataArray;
170 169
 		}
171 170
 
Please login to merge, or discard this patch.
src/ConstraintCheck/Result/CheckResultSerializer.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -72,27 +72,27 @@  discard block
 block discarded – undo
72 72
 	 * @param CheckResult $checkResult
73 73
 	 * @return array
74 74
 	 */
75
-	public function serialize( CheckResult $checkResult ) {
75
+	public function serialize(CheckResult $checkResult) {
76 76
 		$contextCursor = $checkResult->getContextCursor();
77 77
 		$constraint = $checkResult->getConstraint();
78 78
 		$violationMessage = $checkResult->getMessage();
79 79
 		$cachingMetadata = $checkResult->getMetadata()->getCachingMetadata();
80 80
 
81 81
 		$serialization = [
82
-			self::KEY_CONTEXT_CURSOR => $this->contextCursorSerializer->serialize( $contextCursor ),
83
-			self::KEY_CONSTRAINT => $this->constraintSerializer->serialize( $constraint ),
82
+			self::KEY_CONTEXT_CURSOR => $this->contextCursorSerializer->serialize($contextCursor),
83
+			self::KEY_CONSTRAINT => $this->constraintSerializer->serialize($constraint),
84 84
 			self::KEY_CHECK_RESULT_STATUS => $checkResult->getStatus(),
85
-			self::KEY_CACHING_METADATA => $this->serializeCachingMetadata( $cachingMetadata ),
85
+			self::KEY_CACHING_METADATA => $this->serializeCachingMetadata($cachingMetadata),
86 86
 		];
87 87
 
88
-		if ( $violationMessage !== null ) {
88
+		if ($violationMessage !== null) {
89 89
 			$serialization[self::KEY_VIOLATION_MESSAGE] =
90
-				$this->violationMessageSerializer->serialize( $violationMessage );
90
+				$this->violationMessageSerializer->serialize($violationMessage);
91 91
 		}
92 92
 
93
-		if ( $this->serializeDependencyMetadata ) {
93
+		if ($this->serializeDependencyMetadata) {
94 94
 			$serialization[self::KEY_DEPENDENCY_METADATA] =
95
-				$this->serializeDependencyMetadata( $checkResult );
95
+				$this->serializeDependencyMetadata($checkResult);
96 96
 		}
97 97
 
98 98
 		return $serialization;
@@ -102,12 +102,12 @@  discard block
 block discarded – undo
102 102
 	 * @param CachingMetadata $cachingMetadata
103 103
 	 * @return array
104 104
 	 */
105
-	private function serializeCachingMetadata( CachingMetadata $cachingMetadata ) {
105
+	private function serializeCachingMetadata(CachingMetadata $cachingMetadata) {
106 106
 		$maximumAge = $cachingMetadata->getMaximumAgeInSeconds();
107 107
 
108 108
 		$serialization = [];
109 109
 
110
-		if ( $maximumAge > 0 ) {
110
+		if ($maximumAge > 0) {
111 111
 			$serialization[self::KEY_CACHING_METADATA_MAX_AGE] = $maximumAge;
112 112
 		}
113 113
 
@@ -118,21 +118,21 @@  discard block
 block discarded – undo
118 118
 	 * @param CheckResult $checkResult
119 119
 	 * @return array
120 120
 	 */
121
-	private function serializeDependencyMetadata( CheckResult $checkResult ) {
121
+	private function serializeDependencyMetadata(CheckResult $checkResult) {
122 122
 		$dependencyMetadata = $checkResult->getMetadata()->getDependencyMetadata();
123 123
 		$entityIds = $dependencyMetadata->getEntityIds();
124 124
 		$futureTime = $dependencyMetadata->getFutureTime();
125 125
 
126 126
 		$serialization = [
127 127
 			self::KEY_DEPENDENCY_METADATA_ENTITY_IDS => array_map(
128
-				function ( EntityId $entityId ) {
128
+				function(EntityId $entityId) {
129 129
 					return $entityId->getSerialization();
130 130
 				},
131 131
 				$entityIds
132 132
 			),
133 133
 		];
134 134
 
135
-		if ( $futureTime !== null ) {
135
+		if ($futureTime !== null) {
136 136
 			$serialization[self::KEY_DEPENDENCY_METADATA_FUTURE_TIME] =
137 137
 				$futureTime->getArrayValue();
138 138
 		}
Please login to merge, or discard this patch.
src/ConstraintCheck/Result/CheckResultDeserializer.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	 * @param array $serialization
56 56
 	 * @return CheckResult
57 57
 	 */
58
-	public function deserialize( array $serialization ) {
58
+	public function deserialize(array $serialization) {
59 59
 		$contextCursor = $this->contextCursorDeserializer->deserialize(
60 60
 			$serialization[CheckResultSerializer::KEY_CONTEXT_CURSOR]
61 61
 		);
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 
69 69
 		$status = $serialization[CheckResultSerializer::KEY_CHECK_RESULT_STATUS];
70 70
 
71
-		if ( array_key_exists( CheckResultSerializer::KEY_VIOLATION_MESSAGE, $serialization ) ) {
71
+		if (array_key_exists(CheckResultSerializer::KEY_VIOLATION_MESSAGE, $serialization)) {
72 72
 			$violationMessage = $this->violationMessageDeserializer->deserialize(
73 73
 				$serialization[CheckResultSerializer::KEY_VIOLATION_MESSAGE]
74 74
 			);
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 			$serialization[CheckResultSerializer::KEY_CACHING_METADATA]
81 81
 		);
82 82
 
83
-		if ( array_key_exists( CheckResultSerializer::KEY_DEPENDENCY_METADATA, $serialization ) ) {
83
+		if (array_key_exists(CheckResultSerializer::KEY_DEPENDENCY_METADATA, $serialization)) {
84 84
 			$dependencyMetadata = $this->deserializeDependencyMetadata(
85 85
 				$serialization[CheckResultSerializer::KEY_DEPENDENCY_METADATA]
86 86
 			);
@@ -88,17 +88,17 @@  discard block
 block discarded – undo
88 88
 			$dependencyMetadata = DependencyMetadata::blank();
89 89
 		}
90 90
 
91
-		return ( new CheckResult(
91
+		return (new CheckResult(
92 92
 			$contextCursor,
93 93
 			$constraint,
94 94
 			$parameters,
95 95
 			$status,
96 96
 			$violationMessage
97
-		) )->withMetadata(
98
-			Metadata::merge( [
99
-				Metadata::ofCachingMetadata( $cachingMetadata ),
100
-				Metadata::ofDependencyMetadata( $dependencyMetadata ),
101
-			] )
97
+		))->withMetadata(
98
+			Metadata::merge([
99
+				Metadata::ofCachingMetadata($cachingMetadata),
100
+				Metadata::ofDependencyMetadata($dependencyMetadata),
101
+			])
102 102
 		);
103 103
 	}
104 104
 
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 	 * @param array $serialization
107 107
 	 * @return CachingMetadata
108 108
 	 */
109
-	private function deserializeCachingMetadata( array $serialization ) {
109
+	private function deserializeCachingMetadata(array $serialization) {
110 110
 		if (
111 111
 			array_key_exists(
112 112
 				CheckResultSerializer::KEY_CACHING_METADATA_MAX_AGE,
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 	 * @param array $serialization
126 126
 	 * @return DependencyMetadata
127 127
 	 */
128
-	private function deserializeDependencyMetadata( array $serialization ) {
128
+	private function deserializeDependencyMetadata(array $serialization) {
129 129
 		if (
130 130
 			array_key_exists(
131 131
 				CheckResultSerializer::KEY_DEPENDENCY_METADATA_FUTURE_TIME,
@@ -135,20 +135,20 @@  discard block
 block discarded – undo
135 135
 			$futureTime = TimeValue::newFromArray(
136 136
 				$serialization[CheckResultSerializer::KEY_DEPENDENCY_METADATA_FUTURE_TIME]
137 137
 			);
138
-			$futureTimeDependencyMetadata = DependencyMetadata::ofFutureTime( $futureTime );
138
+			$futureTimeDependencyMetadata = DependencyMetadata::ofFutureTime($futureTime);
139 139
 		} else {
140 140
 			$futureTimeDependencyMetadata = DependencyMetadata::blank();
141 141
 		}
142 142
 
143 143
 		$dependencyMetadata = array_reduce(
144 144
 			$serialization[CheckResultSerializer::KEY_DEPENDENCY_METADATA_ENTITY_IDS],
145
-			function ( DependencyMetadata $metadata, $entityIdSerialization ) {
146
-				$entityId = $this->entityIdParser->parse( $entityIdSerialization );
145
+			function(DependencyMetadata $metadata, $entityIdSerialization) {
146
+				$entityId = $this->entityIdParser->parse($entityIdSerialization);
147 147
 
148
-				return DependencyMetadata::merge( [
148
+				return DependencyMetadata::merge([
149 149
 					$metadata,
150
-					DependencyMetadata::ofEntityId( $entityId )
151
-				] );
150
+					DependencyMetadata::ofEntityId($entityId)
151
+				]);
152 152
 			},
153 153
 			$futureTimeDependencyMetadata
154 154
 		);
Please login to merge, or discard this patch.