@@ -83,54 +83,53 @@ discard block |
||
83 | 83 | ) { |
84 | 84 | $response = []; |
85 | 85 | $metadatas = []; |
86 | - $statusesFlipped = array_flip( $statuses ); |
|
87 | - foreach ( $entityIds as $entityId ) { |
|
86 | + $statusesFlipped = array_flip($statuses); |
|
87 | + foreach ($entityIds as $entityId) { |
|
88 | 88 | $results = $this->delegatingConstraintChecker->checkAgainstConstraintsOnEntityId( |
89 | 89 | $entityId, |
90 | 90 | $constraintIds, |
91 | - [ $this, 'defaultResults' ] |
|
91 | + [$this, 'defaultResults'] |
|
92 | 92 | ); |
93 | - foreach ( $results as $result ) { |
|
93 | + foreach ($results as $result) { |
|
94 | 94 | $metadatas[] = $result->getMetadata(); |
95 | - if ( $this->statusSelected( $statusesFlipped, $result ) ) { |
|
96 | - $resultArray = $this->checkResultToArray( $result ); |
|
97 | - $result->getContext()->storeCheckResultInArray( $resultArray, $response ); |
|
95 | + if ($this->statusSelected($statusesFlipped, $result)) { |
|
96 | + $resultArray = $this->checkResultToArray($result); |
|
97 | + $result->getContext()->storeCheckResultInArray($resultArray, $response); |
|
98 | 98 | } |
99 | 99 | } |
100 | 100 | } |
101 | - foreach ( $claimIds as $claimId ) { |
|
101 | + foreach ($claimIds as $claimId) { |
|
102 | 102 | $results = $this->delegatingConstraintChecker->checkAgainstConstraintsOnClaimId( |
103 | 103 | $claimId, |
104 | 104 | $constraintIds, |
105 | - [ $this, 'defaultResults' ] |
|
105 | + [$this, 'defaultResults'] |
|
106 | 106 | ); |
107 | - foreach ( $results as $result ) { |
|
107 | + foreach ($results as $result) { |
|
108 | 108 | $metadatas[] = $result->getMetadata(); |
109 | - if ( $this->statusSelected( $statusesFlipped, $result ) ) { |
|
110 | - $resultArray = $this->checkResultToArray( $result ); |
|
111 | - $result->getContext()->storeCheckResultInArray( $resultArray, $response ); |
|
109 | + if ($this->statusSelected($statusesFlipped, $result)) { |
|
110 | + $resultArray = $this->checkResultToArray($result); |
|
111 | + $result->getContext()->storeCheckResultInArray($resultArray, $response); |
|
112 | 112 | } |
113 | 113 | } |
114 | 114 | } |
115 | 115 | return new CachedCheckConstraintsResponse( |
116 | 116 | $response, |
117 | - Metadata::merge( $metadatas ) |
|
117 | + Metadata::merge($metadatas) |
|
118 | 118 | ); |
119 | 119 | } |
120 | 120 | |
121 | - public function defaultResults( Context $context ) { |
|
121 | + public function defaultResults(Context $context) { |
|
122 | 122 | return $context->getType() === Context::TYPE_STATEMENT ? |
123 | - [ new NullResult( $context ) ] : |
|
124 | - []; |
|
123 | + [new NullResult($context)] : []; |
|
125 | 124 | } |
126 | 125 | |
127 | - public function statusSelected( array $statusesFlipped, CheckResult $result ) { |
|
128 | - return array_key_exists( $result->getStatus(), $statusesFlipped ) || |
|
126 | + public function statusSelected(array $statusesFlipped, CheckResult $result) { |
|
127 | + return array_key_exists($result->getStatus(), $statusesFlipped) || |
|
129 | 128 | $result instanceof NullResult; |
130 | 129 | } |
131 | 130 | |
132 | - public function checkResultToArray( CheckResult $checkResult ) { |
|
133 | - if ( $checkResult instanceof NullResult ) { |
|
131 | + public function checkResultToArray(CheckResult $checkResult) { |
|
132 | + if ($checkResult instanceof NullResult) { |
|
134 | 133 | return null; |
135 | 134 | } |
136 | 135 | |
@@ -138,10 +137,10 @@ discard block |
||
138 | 137 | $typeItemId = $checkResult->getConstraint()->getConstraintTypeItemId(); |
139 | 138 | $constraintPropertyId = $checkResult->getContext()->getSnak()->getPropertyId(); |
140 | 139 | |
141 | - $title = $this->entityTitleLookup->getTitleForId( $constraintPropertyId ); |
|
142 | - $typeLabel = $this->entityIdLabelFormatter->formatEntityId( new ItemId( $typeItemId ) ); |
|
140 | + $title = $this->entityTitleLookup->getTitleForId($constraintPropertyId); |
|
141 | + $typeLabel = $this->entityIdLabelFormatter->formatEntityId(new ItemId($typeItemId)); |
|
143 | 142 | // TODO link to the statement when possible (T169224) |
144 | - $link = $title->getFullURL() . '#' . $this->config->get( 'WBQualityConstraintsPropertyConstraintId' ); |
|
143 | + $link = $title->getFullURL().'#'.$this->config->get('WBQualityConstraintsPropertyConstraintId'); |
|
145 | 144 | |
146 | 145 | $constraint = [ |
147 | 146 | 'id' => $constraintId, |
@@ -150,11 +149,11 @@ discard block |
||
150 | 149 | 'link' => $link, |
151 | 150 | 'discussLink' => $title->getTalkPage()->getFullURL(), |
152 | 151 | ]; |
153 | - if ( $this->config->get( 'WBQualityConstraintsIncludeDetailInApi' ) ) { |
|
152 | + if ($this->config->get('WBQualityConstraintsIncludeDetailInApi')) { |
|
154 | 153 | $parameters = $checkResult->getParameters(); |
155 | 154 | $constraint += [ |
156 | 155 | 'detail' => $parameters, |
157 | - 'detailHTML' => $this->constraintParameterRenderer->formatParameters( $parameters ), |
|
156 | + 'detailHTML' => $this->constraintParameterRenderer->formatParameters($parameters), |
|
158 | 157 | ]; |
159 | 158 | } |
160 | 159 | |
@@ -164,14 +163,14 @@ discard block |
||
164 | 163 | 'constraint' => $constraint |
165 | 164 | ]; |
166 | 165 | $message = $checkResult->getMessage(); |
167 | - if ( $message ) { |
|
168 | - $result['message-html'] = $this->violationMessageRenderer->render( $message ); |
|
166 | + if ($message) { |
|
167 | + $result['message-html'] = $this->violationMessageRenderer->render($message); |
|
169 | 168 | } |
170 | - if ( $checkResult->getContext()->getType() === Context::TYPE_STATEMENT ) { |
|
169 | + if ($checkResult->getContext()->getType() === Context::TYPE_STATEMENT) { |
|
171 | 170 | $result['claim'] = $checkResult->getContext()->getSnakStatement()->getGuid(); |
172 | 171 | } |
173 | 172 | $cachingMetadataArray = $checkResult->getMetadata()->getCachingMetadata()->toArray(); |
174 | - if ( $cachingMetadataArray !== null ) { |
|
173 | + if ($cachingMetadataArray !== null) { |
|
175 | 174 | $result['cached'] = $cachingMetadataArray; |
176 | 175 | } |
177 | 176 |