Completed
Push — master ( 959f5f...dece17 )
by
unknown
02:35
created
src/Api/CheckConstraintsRdf.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -39,13 +39,13 @@  discard block
 block discarded – undo
39 39
 		EntityIdLookup $entityIdLookup,
40 40
 		RdfVocabulary $rdfVocabulary
41 41
 	) {
42
-		parent::__construct( $page, $context );
42
+		parent::__construct($page, $context);
43 43
 		$this->resultsSource = $resultsSource;
44 44
 		$this->entityIdLookup = $entityIdLookup;
45 45
 		$this->rdfVocabulary = $rdfVocabulary;
46 46
 	}
47 47
 
48
-	public static function newFromGlobalState( Page $page, IContextSource $context ) {
48
+	public static function newFromGlobalState(Page $page, IContextSource $context) {
49 49
 		$repo = WikibaseRepo::getDefaultInstance();
50 50
 
51 51
 		return new static(
@@ -92,8 +92,8 @@  discard block
 block discarded – undo
92 92
 	 * @param string $guid
93 93
 	 * @return string
94 94
 	 */
95
-	private function cleanupGuid( $guid ) {
96
-		return preg_replace( '/[^\w-]/', '-', $guid );
95
+	private function cleanupGuid($guid) {
96
+		return preg_replace('/[^\w-]/', '-', $guid);
97 97
 	}
98 98
 
99 99
 	/**
@@ -105,51 +105,51 @@  discard block
 block discarded – undo
105 105
 		$response = $this->getRequest()->response();
106 106
 		$this->getOutput()->disable();
107 107
 
108
-		if ( !$this->resultsSource instanceof CachingResultsSource ) {
108
+		if (!$this->resultsSource instanceof CachingResultsSource) {
109 109
 			// TODO: make configurable whether only cached results are returned
110
-			$response->statusHeader( 501 ); // Not Implemented
110
+			$response->statusHeader(501); // Not Implemented
111 111
 			return null;
112 112
 		}
113 113
 
114
-		$entityId = $this->entityIdLookup->getEntityIdForTitle( $this->getTitle() );
115
-		if ( $entityId === null ) {
116
-			$response->statusHeader( 404 ); // Not Found
114
+		$entityId = $this->entityIdLookup->getEntityIdForTitle($this->getTitle());
115
+		if ($entityId === null) {
116
+			$response->statusHeader(404); // Not Found
117 117
 			return null;
118 118
 		}
119 119
 
120
-		$results = $this->resultsSource->getStoredResults( $entityId );
121
-		if ( $results === null ) {
122
-			$response->statusHeader( 204 ); // No Content
120
+		$results = $this->resultsSource->getStoredResults($entityId);
121
+		if ($results === null) {
122
+			$response->statusHeader(204); // No Content
123 123
 			return null;
124 124
 		}
125 125
 
126 126
 		$format = 'ttl'; // TODO: make format an option
127 127
 
128 128
 		$writerFactory = new RdfWriterFactory();
129
-		$formatName = $writerFactory->getFormatName( $format );
130
-		$contentType = $writerFactory->getMimeTypes( $formatName )[0];
129
+		$formatName = $writerFactory->getFormatName($format);
130
+		$contentType = $writerFactory->getMimeTypes($formatName)[0];
131 131
 
132
-		$response->header( "Content-Type: $contentType; charset=UTF-8" );
132
+		$response->header("Content-Type: $contentType; charset=UTF-8");
133 133
 
134
-		$writer = $writerFactory->getWriter( $formatName );
135
-		foreach ( [ RdfVocabulary::NS_STATEMENT, RdfVocabulary::NS_ONTOLOGY ] as $ns ) {
136
-			$writer->prefix( $ns, $this->rdfVocabulary->getNamespaceURI( $ns ) );
134
+		$writer = $writerFactory->getWriter($formatName);
135
+		foreach ([RdfVocabulary::NS_STATEMENT, RdfVocabulary::NS_ONTOLOGY] as $ns) {
136
+			$writer->prefix($ns, $this->rdfVocabulary->getNamespaceURI($ns));
137 137
 		}
138 138
 		$writer->start();
139 139
 
140
-		foreach ( $results->getArray() as $checkResult ) {
141
-			if ( $checkResult instanceof NullResult ) {
140
+		foreach ($results->getArray() as $checkResult) {
141
+			if ($checkResult instanceof NullResult) {
142 142
 				continue;
143 143
 			}
144
-			if ( $checkResult->getStatus() === CheckResult::STATUS_BAD_PARAMETERS ) {
144
+			if ($checkResult->getStatus() === CheckResult::STATUS_BAD_PARAMETERS) {
145 145
 				continue;
146 146
 			}
147 147
 
148
-			$writer->about( RdfVocabulary::NS_STATEMENT,
149
-				$this->cleanupGuid( $checkResult->getContextCursor()->getStatementGuid() ) )
150
-				->say( RdfVocabulary::NS_ONTOLOGY, 'hasViolationForConstraint' )
151
-				->is( RdfVocabulary::NS_STATEMENT,
152
-					$this->cleanupGuid( $checkResult->getConstraint()->getConstraintId() ) );
148
+			$writer->about(RdfVocabulary::NS_STATEMENT,
149
+				$this->cleanupGuid($checkResult->getContextCursor()->getStatementGuid()))
150
+				->say(RdfVocabulary::NS_ONTOLOGY, 'hasViolationForConstraint')
151
+				->is(RdfVocabulary::NS_STATEMENT,
152
+					$this->cleanupGuid($checkResult->getConstraint()->getConstraintId()));
153 153
 		}
154 154
 		$writer->finish();
155 155
 		echo $writer->drain();
Please login to merge, or discard this patch.
maintenance/ImportConstraintEntities.php 1 patch
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -15,10 +15,10 @@  discard block
 block discarded – undo
15 15
 use Wikibase\Repo\WikibaseRepo;
16 16
 
17 17
 // @codeCoverageIgnoreStart
18
-$basePath = getenv( "MW_INSTALL_PATH" ) !== false
19
-	? getenv( "MW_INSTALL_PATH" ) : __DIR__ . "/../../..";
18
+$basePath = getenv("MW_INSTALL_PATH") !== false
19
+	? getenv("MW_INSTALL_PATH") : __DIR__."/../../..";
20 20
 
21
-require_once $basePath . "/maintenance/Maintenance.php";
21
+require_once $basePath."/maintenance/Maintenance.php";
22 22
 // @codeCoverageIgnoreEnd
23 23
 
24 24
 /**
@@ -52,13 +52,13 @@  discard block
 block discarded – undo
52 52
 		parent::__construct();
53 53
 
54 54
 		$this->addDescription(
55
-			'Import entities needed for constraint checks ' .
55
+			'Import entities needed for constraint checks '.
56 56
 			'from Wikidata into the local repository.'
57 57
 		);
58 58
 		$this->addOption(
59 59
 			'config-format',
60
-			'The format in which the resulting configuration will be omitted: ' .
61
-			'"globals" for directly settings global variables, suitable for inclusion in LocalSettings.php (default), ' .
60
+			'The format in which the resulting configuration will be omitted: '.
61
+			'"globals" for directly settings global variables, suitable for inclusion in LocalSettings.php (default), '.
62 62
 			'or "wgConf" for printing parts of arrays suitable for inclusion in $wgConf->settings.'
63 63
 		);
64 64
 		$this->addOption(
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 		$this->entitySerializer = $repo->getAllTypesEntitySerializer();
76 76
 		$this->entityDeserializer = $repo->getInternalFormatEntityDeserializer();
77 77
 		$this->entityStore = $repo->getEntityStore();
78
-		$this->user = User::newSystemUser( 'WikibaseQualityConstraints importer' );
78
+		$this->user = User::newSystemUser('WikibaseQualityConstraints importer');
79 79
 	}
80 80
 
81 81
 	public function execute() {
@@ -83,20 +83,20 @@  discard block
 block discarded – undo
83 83
 
84 84
 		$configUpdates = [];
85 85
 
86
-		$extensionJsonFile = __DIR__ . '/../extension.json';
87
-		$extensionJsonText = file_get_contents( $extensionJsonFile );
88
-		$extensionJson = json_decode( $extensionJsonText, /* assoc = */ true );
89
-		$wikidataEntityIds = $this->getEntitiesToImport( $extensionJson['config'], $this->getConfig() );
86
+		$extensionJsonFile = __DIR__.'/../extension.json';
87
+		$extensionJsonText = file_get_contents($extensionJsonFile);
88
+		$extensionJson = json_decode($extensionJsonText, /* assoc = */ true);
89
+		$wikidataEntityIds = $this->getEntitiesToImport($extensionJson['config'], $this->getConfig());
90 90
 
91
-		foreach ( $wikidataEntityIds as $key => $wikidataEntityId ) {
92
-			$localEntityId = $this->importEntityFromWikidata( $wikidataEntityId );
91
+		foreach ($wikidataEntityIds as $key => $wikidataEntityId) {
92
+			$localEntityId = $this->importEntityFromWikidata($wikidataEntityId);
93 93
 			$configUpdates[$key] = [
94 94
 				'wikidata' => $wikidataEntityId,
95 95
 				'local' => $localEntityId,
96 96
 			];
97 97
 		}
98 98
 
99
-		$this->outputConfigUpdates( $configUpdates );
99
+		$this->outputConfigUpdates($configUpdates);
100 100
 	}
101 101
 
102 102
 	/**
@@ -104,18 +104,18 @@  discard block
 block discarded – undo
104 104
 	 * @param Config $wikiConfig
105 105
 	 * @return string[]
106 106
 	 */
107
-	private function getEntitiesToImport( array $extensionJsonConfig, Config $wikiConfig ) {
107
+	private function getEntitiesToImport(array $extensionJsonConfig, Config $wikiConfig) {
108 108
 		$wikidataEntityIds = [];
109 109
 
110
-		foreach ( $extensionJsonConfig as $key => $value ) {
111
-			if ( !preg_match( '/Id$/', $key ) ) {
110
+		foreach ($extensionJsonConfig as $key => $value) {
111
+			if (!preg_match('/Id$/', $key)) {
112 112
 				continue;
113 113
 			}
114 114
 
115 115
 			$wikidataEntityId = $value['value'];
116
-			$localEntityId = $wikiConfig->get( $key );
116
+			$localEntityId = $wikiConfig->get($key);
117 117
 
118
-			if ( $localEntityId === $wikidataEntityId ) {
118
+			if ($localEntityId === $wikidataEntityId) {
119 119
 				$wikidataEntityIds[$key] = $wikidataEntityId;
120 120
 			}
121 121
 		}
@@ -127,10 +127,10 @@  discard block
 block discarded – undo
127 127
 	 * @param string $wikidataEntityId
128 128
 	 * @return string local entity ID
129 129
 	 */
130
-	private function importEntityFromWikidata( $wikidataEntityId ) {
130
+	private function importEntityFromWikidata($wikidataEntityId) {
131 131
 		$wikidataEntityUrl = "https://www.wikidata.org/wiki/Special:EntityData/$wikidataEntityId.json";
132
-		$wikidataEntitiesJson = file_get_contents( $wikidataEntityUrl );
133
-		return $this->importEntityFromJson( $wikidataEntityId, $wikidataEntitiesJson );
132
+		$wikidataEntitiesJson = file_get_contents($wikidataEntityUrl);
133
+		return $this->importEntityFromJson($wikidataEntityId, $wikidataEntitiesJson);
134 134
 	}
135 135
 
136 136
 	/**
@@ -138,23 +138,23 @@  discard block
 block discarded – undo
138 138
 	 * @param string $wikidataEntitiesJson
139 139
 	 * @return string local entity ID
140 140
 	 */
141
-	private function importEntityFromJson( $wikidataEntityId, $wikidataEntitiesJson ) {
142
-		$wikidataEntityArray = json_decode( $wikidataEntitiesJson, true )['entities'][$wikidataEntityId];
143
-		$wikidataEntity = $this->entityDeserializer->deserialize( $wikidataEntityArray );
141
+	private function importEntityFromJson($wikidataEntityId, $wikidataEntitiesJson) {
142
+		$wikidataEntityArray = json_decode($wikidataEntitiesJson, true)['entities'][$wikidataEntityId];
143
+		$wikidataEntity = $this->entityDeserializer->deserialize($wikidataEntityArray);
144 144
 
145
-		$wikidataEntity->setId( null );
145
+		$wikidataEntity->setId(null);
146 146
 
147
-		if ( $wikidataEntity instanceof StatementListProvider ) {
147
+		if ($wikidataEntity instanceof StatementListProvider) {
148 148
 			$wikidataEntity->getStatements()->clear();
149 149
 		}
150 150
 
151
-		if ( $wikidataEntity instanceof Item ) {
152
-			$wikidataEntity->setSiteLinkList( new SiteLinkList() );
151
+		if ($wikidataEntity instanceof Item) {
152
+			$wikidataEntity->setSiteLinkList(new SiteLinkList());
153 153
 		}
154 154
 
155
-		if ( $this->getOption( 'dry-run', false ) ) {
156
-			$wikidataEntityJson = json_encode( $this->entitySerializer->serialize( $wikidataEntity ) );
157
-			$this->output( $wikidataEntityJson . "\n" );
155
+		if ($this->getOption('dry-run', false)) {
156
+			$wikidataEntityJson = json_encode($this->entitySerializer->serialize($wikidataEntity));
157
+			$this->output($wikidataEntityJson."\n");
158 158
 			return "-$wikidataEntityId";
159 159
 		}
160 160
 
@@ -167,14 +167,14 @@  discard block
 block discarded – undo
167 167
 			)->getEntity();
168 168
 
169 169
 			return $localEntity->getId()->getSerialization();
170
-		} catch ( StorageException $storageException ) {
170
+		} catch (StorageException $storageException) {
171 171
 			$message = $storageException->getMessage();
172 172
 			// example message:
173 173
 			// * Item [[Item:Q475|Q475]] already has label "as references" associated with language code en, using the same description text.
174 174
 			// note that the label and language code may vary (conflicts in any language),
175 175
 			// and that the item link may or may not be in the main namespace
176 176
 			$pattern = '/[[|]([^]|]*)]] already has label .* using the same description text/';
177
-			if ( preg_match( $pattern, $message, $matches ) ) {
177
+			if (preg_match($pattern, $message, $matches)) {
178 178
 				return $matches[1];
179 179
 			} else {
180 180
 				throw $storageException;
@@ -182,35 +182,35 @@  discard block
 block discarded – undo
182 182
 		}
183 183
 	}
184 184
 
185
-	private function outputConfigUpdates( array $configUpdates ) {
186
-		$configFormat = $this->getOption( 'config-format', 'globals' );
187
-		switch ( $configFormat ) {
185
+	private function outputConfigUpdates(array $configUpdates) {
186
+		$configFormat = $this->getOption('config-format', 'globals');
187
+		switch ($configFormat) {
188 188
 			case 'globals':
189
-				$this->outputConfigUpdatesGlobals( $configUpdates );
189
+				$this->outputConfigUpdatesGlobals($configUpdates);
190 190
 				break;
191 191
 			case 'wgConf':
192
-				$this->outputConfigUpdatesWgConf( $configUpdates );
192
+				$this->outputConfigUpdatesWgConf($configUpdates);
193 193
 				break;
194 194
 			default:
195
-				$this->error( "Invalid config format \"$configFormat\", using \"globals\"" );
196
-				$this->outputConfigUpdatesGlobals( $configUpdates );
195
+				$this->error("Invalid config format \"$configFormat\", using \"globals\"");
196
+				$this->outputConfigUpdatesGlobals($configUpdates);
197 197
 				break;
198 198
 		}
199 199
 	}
200 200
 
201
-	private function outputConfigUpdatesGlobals( array $configUpdates ) {
202
-		foreach ( $configUpdates as $key => $value ) {
203
-			$localValueCode = var_export( $value['local'], true );
204
-			$this->output( "\$wg$key = $localValueCode;\n" );
201
+	private function outputConfigUpdatesGlobals(array $configUpdates) {
202
+		foreach ($configUpdates as $key => $value) {
203
+			$localValueCode = var_export($value['local'], true);
204
+			$this->output("\$wg$key = $localValueCode;\n");
205 205
 		}
206 206
 	}
207 207
 
208
-	private function outputConfigUpdatesWgConf( array $configUpdates ) {
209
-		foreach ( $configUpdates as $key => $value ) {
210
-			$keyCode = var_export( $key, true );
211
-			$wikidataValueCode = var_export( $value['wikidata'], true );
212
-			$localValueCode = var_export( $value['local'], true );
213
-			$wikiIdCode = var_export( wfWikiID(), true );
208
+	private function outputConfigUpdatesWgConf(array $configUpdates) {
209
+		foreach ($configUpdates as $key => $value) {
210
+			$keyCode = var_export($key, true);
211
+			$wikidataValueCode = var_export($value['wikidata'], true);
212
+			$localValueCode = var_export($value['local'], true);
213
+			$wikiIdCode = var_export(wfWikiID(), true);
214 214
 			$block = <<< EOF
215 215
 $keyCode => [
216 216
 	'default' => $wikidataValueCode,
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 
220 220
 
221 221
 EOF;
222
-			$this->output( $block );
222
+			$this->output($block);
223 223
 		}
224 224
 	}
225 225
 
Please login to merge, or discard this patch.
src/ConstraintCheck/Helper/TypeCheckerHelper.php 1 patch
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -80,23 +80,23 @@  discard block
 block discarded – undo
80 80
 	 * @return bool
81 81
 	 * @throws OverflowException if $entitiesChecked exceeds the configured limit
82 82
 	 */
83
-	private function isSubclassOf( EntityId $comparativeClass, array $classesToCheck, &$entitiesChecked = 0 ) {
84
-		$maxEntities = $this->config->get( 'WBQualityConstraintsTypeCheckMaxEntities' );
83
+	private function isSubclassOf(EntityId $comparativeClass, array $classesToCheck, &$entitiesChecked = 0) {
84
+		$maxEntities = $this->config->get('WBQualityConstraintsTypeCheckMaxEntities');
85 85
 		if ( ++$entitiesChecked > $maxEntities ) {
86
-			throw new OverflowException( 'Too many entities to check' );
86
+			throw new OverflowException('Too many entities to check');
87 87
 		}
88 88
 
89
-		$item = $this->entityLookup->getEntity( $comparativeClass );
90
-		if ( !( $item instanceof StatementListProvider ) ) {
89
+		$item = $this->entityLookup->getEntity($comparativeClass);
90
+		if (!($item instanceof StatementListProvider)) {
91 91
 			return false; // lookup failed, probably because item doesn't exist
92 92
 		}
93 93
 
94
-		$subclassId = $this->config->get( 'WBQualityConstraintsSubclassOfId' );
94
+		$subclassId = $this->config->get('WBQualityConstraintsSubclassOfId');
95 95
 		/** @var Statement $statement */
96
-		foreach ( $item->getStatements()->getByPropertyId( new PropertyId( $subclassId ) ) as $statement ) {
96
+		foreach ($item->getStatements()->getByPropertyId(new PropertyId($subclassId)) as $statement) {
97 97
 			$mainSnak = $statement->getMainSnak();
98 98
 
99
-			if ( !( $this->hasCorrectType( $mainSnak ) ) ) {
99
+			if (!($this->hasCorrectType($mainSnak))) {
100 100
 				continue;
101 101
 			}
102 102
 			/** @var PropertyValueSnak $mainSnak */
@@ -105,11 +105,11 @@  discard block
 block discarded – undo
105 105
 			$dataValue = $mainSnak->getDataValue();
106 106
 			$comparativeClass = $dataValue->getEntityId();
107 107
 
108
-			if ( in_array( $comparativeClass->getSerialization(), $classesToCheck ) ) {
108
+			if (in_array($comparativeClass->getSerialization(), $classesToCheck)) {
109 109
 				return true;
110 110
 			}
111 111
 
112
-			if ( $this->isSubclassOf( $comparativeClass, $classesToCheck, $entitiesChecked ) ) {
112
+			if ($this->isSubclassOf($comparativeClass, $classesToCheck, $entitiesChecked)) {
113 113
 				return true;
114 114
 			}
115 115
 		}
@@ -130,48 +130,48 @@  discard block
 block discarded – undo
130 130
 	 * @return CachedBool
131 131
 	 * @throws SparqlHelperException if SPARQL is used and the query times out or some other error occurs
132 132
 	 */
133
-	public function isSubclassOfWithSparqlFallback( EntityId $comparativeClass, array $classesToCheck ) {
133
+	public function isSubclassOfWithSparqlFallback(EntityId $comparativeClass, array $classesToCheck) {
134 134
 		try {
135 135
 			$entitiesChecked = 0;
136
-			$start1 = microtime( true );
137
-			$isSubclass = $this->isSubclassOf( $comparativeClass, $classesToCheck, $entitiesChecked );
138
-			$end1 = microtime( true );
136
+			$start1 = microtime(true);
137
+			$isSubclass = $this->isSubclassOf($comparativeClass, $classesToCheck, $entitiesChecked);
138
+			$end1 = microtime(true);
139 139
 			$this->dataFactory->timing(
140 140
 				'wikibase.quality.constraints.type.php.success.timing',
141
-				( $end1 - $start1 ) * 1000
141
+				($end1 - $start1) * 1000
142 142
 			);
143 143
 			$this->dataFactory->timing( // not really a timing, but works like one (we want percentiles etc.)
144 144
 				'wikibase.quality.constraints.type.php.success.entities',
145 145
 				$entitiesChecked
146 146
 			);
147 147
 
148
-			return new CachedBool( $isSubclass, Metadata::blank() );
149
-		} catch ( OverflowException $e ) {
150
-			$end1 = microtime( true );
148
+			return new CachedBool($isSubclass, Metadata::blank());
149
+		} catch (OverflowException $e) {
150
+			$end1 = microtime(true);
151 151
 			$this->dataFactory->timing(
152 152
 				'wikibase.quality.constraints.type.php.overflow.timing',
153
-				( $end1 - $start1 ) * 1000
153
+				($end1 - $start1) * 1000
154 154
 			);
155 155
 
156
-			if ( !( $this->sparqlHelper instanceof DummySparqlHelper ) ) {
156
+			if (!($this->sparqlHelper instanceof DummySparqlHelper)) {
157 157
 				$this->dataFactory->increment(
158 158
 					'wikibase.quality.constraints.sparql.typeFallback'
159 159
 				);
160 160
 
161
-				$start2 = microtime( true );
161
+				$start2 = microtime(true);
162 162
 				$hasType = $this->sparqlHelper->hasType(
163 163
 					$comparativeClass->getSerialization(),
164 164
 					$classesToCheck
165 165
 				);
166
-				$end2 = microtime( true );
166
+				$end2 = microtime(true);
167 167
 				$this->dataFactory->timing(
168 168
 					'wikibase.quality.constraints.type.sparql.success.timing',
169
-					( $end2 - $start2 ) * 1000
169
+					($end2 - $start2) * 1000
170 170
 				);
171 171
 
172 172
 				return $hasType;
173 173
 			} else {
174
-				return new CachedBool( false, Metadata::blank() );
174
+				return new CachedBool(false, Metadata::blank());
175 175
 			}
176 176
 		}
177 177
 	}
@@ -189,13 +189,13 @@  discard block
 block discarded – undo
189 189
 	 * @return CachedBool
190 190
 	 * @throws SparqlHelperException if SPARQL is used and the query times out or some other error occurs
191 191
 	 */
192
-	public function hasClassInRelation( StatementList $statements, array $relationIds, array $classesToCheck ) {
192
+	public function hasClassInRelation(StatementList $statements, array $relationIds, array $classesToCheck) {
193 193
 		$metadatas = [];
194 194
 
195
-		foreach ( $this->getStatementsByPropertyIds( $statements, $relationIds ) as $statement ) {
195
+		foreach ($this->getStatementsByPropertyIds($statements, $relationIds) as $statement) {
196 196
 			$mainSnak = $statement->getMainSnak();
197 197
 
198
-			if ( !$this->hasCorrectType( $mainSnak ) ) {
198
+			if (!$this->hasCorrectType($mainSnak)) {
199 199
 				continue;
200 200
 			}
201 201
 			/** @var PropertyValueSnak $mainSnak */
@@ -204,28 +204,28 @@  discard block
 block discarded – undo
204 204
 			$dataValue = $mainSnak->getDataValue();
205 205
 			$comparativeClass = $dataValue->getEntityId();
206 206
 
207
-			if ( in_array( $comparativeClass->getSerialization(), $classesToCheck ) ) {
207
+			if (in_array($comparativeClass->getSerialization(), $classesToCheck)) {
208 208
 				// discard $metadatas, we know this is fresh
209
-				return new CachedBool( true, Metadata::blank() );
209
+				return new CachedBool(true, Metadata::blank());
210 210
 			}
211 211
 
212
-			$result = $this->isSubclassOfWithSparqlFallback( $comparativeClass, $classesToCheck );
212
+			$result = $this->isSubclassOfWithSparqlFallback($comparativeClass, $classesToCheck);
213 213
 			$metadatas[] = $result->getMetadata();
214
-			if ( $result->getBool() ) {
214
+			if ($result->getBool()) {
215 215
 				return new CachedBool(
216 216
 					true,
217
-					Metadata::merge( $metadatas )
217
+					Metadata::merge($metadatas)
218 218
 				);
219 219
 			}
220 220
 		}
221 221
 
222 222
 		return new CachedBool(
223 223
 			false,
224
-			Metadata::merge( $metadatas )
224
+			Metadata::merge($metadatas)
225 225
 		);
226 226
 	}
227 227
 
228
-	private function hasCorrectType( Snak $mainSnak ) {
228
+	private function hasCorrectType(Snak $mainSnak) {
229 229
 		return $mainSnak instanceof PropertyValueSnak
230 230
 			&& $mainSnak->getDataValue()->getType() === 'wikibase-entityid';
231 231
 	}
@@ -242,12 +242,12 @@  discard block
 block discarded – undo
242 242
 	) {
243 243
 		$statementArrays = [];
244 244
 
245
-		foreach ( $propertyIdSerializations as $propertyIdSerialization ) {
246
-			$propertyId = new PropertyId( $propertyIdSerialization );
247
-			$statementArrays[] = $statements->getByPropertyId( $propertyId )->toArray();
245
+		foreach ($propertyIdSerializations as $propertyIdSerialization) {
246
+			$propertyId = new PropertyId($propertyIdSerialization);
247
+			$statementArrays[] = $statements->getByPropertyId($propertyId)->toArray();
248 248
 		}
249 249
 
250
-		return call_user_func_array( 'array_merge', $statementArrays );
250
+		return call_user_func_array('array_merge', $statementArrays);
251 251
 	}
252 252
 
253 253
 	/**
@@ -259,10 +259,10 @@  discard block
 block discarded – undo
259 259
 	 *
260 260
 	 * @return ViolationMessage
261 261
 	 */
262
-	public function getViolationMessage( PropertyId $propertyId, EntityId $entityId, array $classes, $checker, $relation ) {
262
+	public function getViolationMessage(PropertyId $propertyId, EntityId $entityId, array $classes, $checker, $relation) {
263 263
 		$classes = array_map(
264
-			function( $itemIdSerialization ) {
265
-				return new ItemId( $itemIdSerialization );
264
+			function($itemIdSerialization) {
265
+				return new ItemId($itemIdSerialization);
266 266
 			},
267 267
 			$classes
268 268
 		);
@@ -274,10 +274,10 @@  discard block
 block discarded – undo
274 274
 		// wbqc-violation-message-valueType-instance
275 275
 		// wbqc-violation-message-valueType-subclass
276 276
 		// wbqc-violation-message-valueType-instanceOrSubclass
277
-		return ( new ViolationMessage( 'wbqc-violation-message-' . $checker . '-' . $relation ) )
278
-			->withEntityId( $propertyId, Role::CONSTRAINT_PROPERTY )
279
-			->withEntityId( $entityId, Role::SUBJECT )
280
-			->withEntityIdList( $classes, Role::OBJECT );
277
+		return (new ViolationMessage('wbqc-violation-message-'.$checker.'-'.$relation))
278
+			->withEntityId($propertyId, Role::CONSTRAINT_PROPERTY)
279
+			->withEntityId($entityId, Role::SUBJECT)
280
+			->withEntityIdList($classes, Role::OBJECT);
281 281
 	}
282 282
 
283 283
 }
Please login to merge, or discard this patch.
src/ServiceWiring-Wikibase.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -7,13 +7,13 @@
 block discarded – undo
7 7
 use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ExceptionIgnoringEntityLookup;
8 8
 
9 9
 return [
10
-	WikibaseServices::ENTITY_LOOKUP => function( MediaWikiServices $services ) {
10
+	WikibaseServices::ENTITY_LOOKUP => function(MediaWikiServices $services) {
11 11
 		return new ExceptionIgnoringEntityLookup(
12 12
 			WikibaseRepo::getDefaultInstance()->getEntityLookup()
13 13
 		);
14 14
 	},
15 15
 
16
-	WikibaseServices::PROPERTY_DATA_TYPE_LOOKUP => function( MediaWikiServices $services ) {
16
+	WikibaseServices::PROPERTY_DATA_TYPE_LOOKUP => function(MediaWikiServices $services) {
17 17
 		return WikibaseRepo::getDefaultInstance()->getPropertyDataTypeLookup();
18 18
 	},
19 19
 ];
Please login to merge, or discard this patch.
src/ConstraintCheck/Helper/ExceptionIgnoringEntityLookup.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 	 */
22 22
 	private $lookup;
23 23
 
24
-	public function __construct( EntityLookup $lookup ) {
24
+	public function __construct(EntityLookup $lookup) {
25 25
 		$this->lookup = $lookup;
26 26
 	}
27 27
 
@@ -32,10 +32,10 @@  discard block
 block discarded – undo
32 32
 	 * @param EntityId $entityId
33 33
 	 * @return EntityDocument|null
34 34
 	 */
35
-	public function getEntity( EntityId $entityId ) {
35
+	public function getEntity(EntityId $entityId) {
36 36
 		try {
37
-			return $this->lookup->getEntity( $entityId );
38
-		} catch ( EntityLookupException $exception ) {
37
+			return $this->lookup->getEntity($entityId);
38
+		} catch (EntityLookupException $exception) {
39 39
 			return null;
40 40
 		}
41 41
 	}
@@ -48,8 +48,8 @@  discard block
 block discarded – undo
48 48
 	 * @param EntityId $entityId
49 49
 	 * @return bool
50 50
 	 */
51
-	public function hasEntity( EntityId $entityId ) {
52
-		return $this->lookup->hasEntity( $entityId );
51
+	public function hasEntity(EntityId $entityId) {
52
+		return $this->lookup->hasEntity($entityId);
53 53
 	}
54 54
 
55 55
 }
Please login to merge, or discard this patch.