@@ -23,7 +23,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -61,7 +61,7 @@ discard block |
||
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 |
||
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 |
@@ -77,7 +77,7 @@ discard block |
||
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 |
||
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 |
@@ -69,7 +69,7 @@ discard block |
||
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 |
||
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 |
@@ -84,65 +84,64 @@ discard block |
||
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 |
||
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 |
||
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 |
@@ -122,12 +122,12 @@ discard block |
||
122 | 122 | $status = self::STATUS_TODO, |
123 | 123 | $message = null |
124 | 124 | ) { |
125 | - if ( $contextCursor instanceof Context ) { |
|
125 | + if ($contextCursor instanceof Context) { |
|
126 | 126 | $context = $contextCursor; |
127 | 127 | $this->contextCursor = $context->getCursor(); |
128 | 128 | $this->snakType = $context->getSnak()->getType(); |
129 | 129 | $mainSnak = $context->getSnak(); |
130 | - if ( $mainSnak instanceof PropertyValueSnak ) { |
|
130 | + if ($mainSnak instanceof PropertyValueSnak) { |
|
131 | 131 | $this->dataValue = $mainSnak->getDataValue(); |
132 | 132 | } else { |
133 | 133 | $this->dataValue = null; |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | * @param string $key |
191 | 191 | * @param string $value |
192 | 192 | */ |
193 | - public function addParameter( $key, $value ) { |
|
193 | + public function addParameter($key, $value) { |
|
194 | 194 | $this->parameters[$key][] = $value; |
195 | 195 | } |
196 | 196 | |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | /** |
205 | 205 | * @param string $status |
206 | 206 | */ |
207 | - public function setStatus( $status ) { |
|
207 | + public function setStatus($status) { |
|
208 | 208 | $this->status = $status; |
209 | 209 | } |
210 | 210 | |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | * @param Metadata $metadata |
220 | 220 | * @return self |
221 | 221 | */ |
222 | - public function withMetadata( Metadata $metadata ) { |
|
222 | + public function withMetadata(Metadata $metadata) { |
|
223 | 223 | $this->metadata = $metadata; |
224 | 224 | return $this; |
225 | 225 | } |