Completed
Push — master ( 815369...52c70c )
by
unknown
02:22
created
src/ConstraintCheck/Context/MainSnakContext.php 1 patch
Spacing   +7 added lines, -7 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
 
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 		);
57 57
 	}
58 58
 
59
-	protected function &getMainArray( array &$container ) {
59
+	protected function &getMainArray(array &$container) {
60 60
 		$statementArray = &$this->getStatementArray(
61 61
 			$container,
62 62
 			$this->entity->getId()->getSerialization(),
@@ -64,8 +64,8 @@  discard block
 block discarded – undo
64 64
 			$this->statement->getGuid()
65 65
 		);
66 66
 
67
-		if ( !array_key_exists( 'mainsnak', $statementArray ) ) {
68
-			$statementArray['mainsnak'] = [ 'hash' => $this->statement->getMainSnak()->getHash() ];
67
+		if (!array_key_exists('mainsnak', $statementArray)) {
68
+			$statementArray['mainsnak'] = ['hash' => $this->statement->getMainSnak()->getHash()];
69 69
 		}
70 70
 		$mainsnakArray = &$statementArray['mainsnak'];
71 71
 
Please login to merge, or discard this patch.
src/ConstraintCheck/Context/QualifierContext.php 1 patch
Spacing   +9 added lines, -9 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() {
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 		);
47 47
 	}
48 48
 
49
-	protected function &getMainArray( array &$container ) {
49
+	protected function &getMainArray(array &$container) {
50 50
 		$statementArray = &$this->getStatementArray(
51 51
 			$container,
52 52
 			$this->entity->getId()->getSerialization(),
@@ -54,25 +54,25 @@  discard block
 block discarded – undo
54 54
 			$this->statement->getGuid()
55 55
 		);
56 56
 
57
-		if ( !array_key_exists( 'qualifiers', $statementArray ) ) {
57
+		if (!array_key_exists('qualifiers', $statementArray)) {
58 58
 			$statementArray['qualifiers'] = [];
59 59
 		}
60 60
 		$qualifiersArray = &$statementArray['qualifiers'];
61 61
 
62 62
 		$propertyId = $this->getSnak()->getPropertyId()->getSerialization();
63
-		if ( !array_key_exists( $propertyId, $qualifiersArray ) ) {
63
+		if (!array_key_exists($propertyId, $qualifiersArray)) {
64 64
 			$qualifiersArray[$propertyId] = [];
65 65
 		}
66 66
 		$propertyArray = &$qualifiersArray[$propertyId];
67 67
 
68
-		foreach ( $propertyArray as &$potentialQualifierArray ) {
69
-			if ( $potentialQualifierArray['hash'] === $this->getSnak()->getHash() ) {
68
+		foreach ($propertyArray as &$potentialQualifierArray) {
69
+			if ($potentialQualifierArray['hash'] === $this->getSnak()->getHash()) {
70 70
 				$qualifierArray = &$potentialQualifierArray;
71 71
 				break;
72 72
 			}
73 73
 		}
74
-		if ( !isset( $qualifierArray ) ) {
75
-			$qualifierArray = [ 'hash' => $this->getSnak()->getHash() ];
74
+		if (!isset($qualifierArray)) {
75
+			$qualifierArray = ['hash' => $this->getSnak()->getHash()];
76 76
 			$propertyArray[] = &$qualifierArray;
77 77
 		}
78 78
 
Please login to merge, or discard this patch.
src/ConstraintCheck/Context/MainSnakContextCursor.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 		return $this->snakHash;
62 62
 	}
63 63
 
64
-	protected function &getMainArray( array &$container ) {
64
+	protected function &getMainArray(array &$container) {
65 65
 		$statementArray = &$this->getStatementArray(
66 66
 			$container,
67 67
 			$this->entityId,
@@ -69,8 +69,8 @@  discard block
 block discarded – undo
69 69
 			$this->statementGuid
70 70
 		);
71 71
 
72
-		if ( !array_key_exists( 'mainsnak', $statementArray ) ) {
73
-			$statementArray['mainsnak'] = [ 'hash' => $this->snakHash ];
72
+		if (!array_key_exists('mainsnak', $statementArray)) {
73
+			$statementArray['mainsnak'] = ['hash' => $this->snakHash];
74 74
 		}
75 75
 		$mainsnakArray = &$statementArray['mainsnak'];
76 76
 
Please login to merge, or discard this patch.
src/ConstraintCheck/Context/ReferenceContextCursor.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 		return $this->snakHash;
78 78
 	}
79 79
 
80
-	protected function &getMainArray( array &$container ) {
80
+	protected function &getMainArray(array &$container) {
81 81
 		$statementArray = &$this->getStatementArray(
82 82
 			$container,
83 83
 			$this->entityId,
@@ -85,37 +85,37 @@  discard block
 block discarded – undo
85 85
 			$this->statementGuid
86 86
 		);
87 87
 
88
-		if ( !array_key_exists( 'references', $statementArray ) ) {
88
+		if (!array_key_exists('references', $statementArray)) {
89 89
 			$statementArray['references'] = [];
90 90
 		}
91 91
 		$referencesArray = &$statementArray['references'];
92 92
 
93
-		foreach ( $referencesArray as &$potentialReferenceArray ) {
94
-			if ( $potentialReferenceArray['hash'] === $this->referenceHash ) {
93
+		foreach ($referencesArray as &$potentialReferenceArray) {
94
+			if ($potentialReferenceArray['hash'] === $this->referenceHash) {
95 95
 				$referenceArray = &$potentialReferenceArray;
96 96
 				break;
97 97
 			}
98 98
 		}
99
-		if ( !isset( $referenceArray ) ) {
100
-			$referenceArray = [ 'hash' => $this->referenceHash, 'snaks' => [] ];
99
+		if (!isset($referenceArray)) {
100
+			$referenceArray = ['hash' => $this->referenceHash, 'snaks' => []];
101 101
 			$referencesArray[] = &$referenceArray;
102 102
 		}
103 103
 
104 104
 		$snaksArray = &$referenceArray['snaks'];
105 105
 
106
-		if ( !array_key_exists( $this->snakPropertyId, $snaksArray ) ) {
106
+		if (!array_key_exists($this->snakPropertyId, $snaksArray)) {
107 107
 			$snaksArray[$this->snakPropertyId] = [];
108 108
 		}
109 109
 		$propertyArray = &$snaksArray[$this->snakPropertyId];
110 110
 
111
-		foreach ( $propertyArray as &$potentialSnakArray ) {
112
-			if ( $potentialSnakArray['hash'] === $this->snakHash ) {
111
+		foreach ($propertyArray as &$potentialSnakArray) {
112
+			if ($potentialSnakArray['hash'] === $this->snakHash) {
113 113
 				$snakArray = &$potentialSnakArray;
114 114
 				break;
115 115
 			}
116 116
 		}
117
-		if ( !isset( $snakArray ) ) {
118
-			$snakArray = [ 'hash' => $this->snakHash ];
117
+		if (!isset($snakArray)) {
118
+			$snakArray = ['hash' => $this->snakHash];
119 119
 			$propertyArray[] = &$snakArray;
120 120
 		}
121 121
 
Please login to merge, or discard this patch.
src/ConstraintCheck/Context/QualifierContextCursor.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 		return $this->snakHash;
70 70
 	}
71 71
 
72
-	protected function &getMainArray( array &$container ) {
72
+	protected function &getMainArray(array &$container) {
73 73
 		$statementArray = &$this->getStatementArray(
74 74
 			$container,
75 75
 			$this->entityId,
@@ -77,24 +77,24 @@  discard block
 block discarded – undo
77 77
 			$this->statementGuid
78 78
 		);
79 79
 
80
-		if ( !array_key_exists( 'qualifiers', $statementArray ) ) {
80
+		if (!array_key_exists('qualifiers', $statementArray)) {
81 81
 			$statementArray['qualifiers'] = [];
82 82
 		}
83 83
 		$qualifiersArray = &$statementArray['qualifiers'];
84 84
 
85
-		if ( !array_key_exists( $this->snakPropertyId, $qualifiersArray ) ) {
85
+		if (!array_key_exists($this->snakPropertyId, $qualifiersArray)) {
86 86
 			$qualifiersArray[$this->snakPropertyId] = [];
87 87
 		}
88 88
 		$propertyArray = &$qualifiersArray[$this->snakPropertyId];
89 89
 
90
-		foreach ( $propertyArray as &$potentialQualifierArray ) {
91
-			if ( $potentialQualifierArray['hash'] === $this->snakHash ) {
90
+		foreach ($propertyArray as &$potentialQualifierArray) {
91
+			if ($potentialQualifierArray['hash'] === $this->snakHash) {
92 92
 				$qualifierArray = &$potentialQualifierArray;
93 93
 				break;
94 94
 			}
95 95
 		}
96
-		if ( !isset( $qualifierArray ) ) {
97
-			$qualifierArray = [ 'hash' => $this->snakHash ];
96
+		if (!isset($qualifierArray)) {
97
+			$qualifierArray = ['hash' => $this->snakHash];
98 98
 			$propertyArray[] = &$qualifierArray;
99 99
 		}
100 100
 
Please login to merge, or discard this patch.
src/Api/CheckingResultsBuilder.php 1 patch
Spacing   +30 added lines, -31 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,
@@ -151,11 +150,11 @@  discard block
 block discarded – undo
151 150
 			'link' => $link,
152 151
 			'discussLink' => $title->getTalkPage()->getFullURL(),
153 152
 		];
154
-		if ( $this->config->get( 'WBQualityConstraintsIncludeDetailInApi' ) ) {
153
+		if ($this->config->get('WBQualityConstraintsIncludeDetailInApi')) {
155 154
 			$parameters = $checkResult->getParameters();
156 155
 			$constraint += [
157 156
 				'detail' => $parameters,
158
-				'detailHTML' => $this->constraintParameterRenderer->formatParameters( $parameters ),
157
+				'detailHTML' => $this->constraintParameterRenderer->formatParameters($parameters),
159 158
 			];
160 159
 		}
161 160
 
@@ -165,14 +164,14 @@  discard block
 block discarded – undo
165 164
 			'constraint' => $constraint
166 165
 		];
167 166
 		$message = $checkResult->getMessage();
168
-		if ( $message ) {
169
-			$result['message-html'] = $this->violationMessageRenderer->render( $message );
167
+		if ($message) {
168
+			$result['message-html'] = $this->violationMessageRenderer->render($message);
170 169
 		}
171
-		if ( $checkResult->getContextCursor()->getType() === Context::TYPE_STATEMENT ) {
170
+		if ($checkResult->getContextCursor()->getType() === Context::TYPE_STATEMENT) {
172 171
 			$result['claim'] = $checkResult->getContextCursor()->getStatementGuid();
173 172
 		}
174 173
 		$cachingMetadataArray = $checkResult->getMetadata()->getCachingMetadata()->toArray();
175
-		if ( $cachingMetadataArray !== null ) {
174
+		if ($cachingMetadataArray !== null) {
176 175
 			$result['cached'] = $cachingMetadataArray;
177 176
 		}
178 177
 
Please login to merge, or discard this patch.