Passed
Push — master ( 34770a...32caf2 )
by
unknown
08:08
created
src/Lookup/RedirectResolvingEntityLookup.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	/**
29 29
 	 * @param EntityLookup $lookup The lookup to use
30 30
 	 */
31
-	public function __construct( EntityLookup $lookup ) {
31
+	public function __construct(EntityLookup $lookup) {
32 32
 		$this->lookup = $lookup;
33 33
 	}
34 34
 
@@ -46,11 +46,11 @@  discard block
 block discarded – undo
46 46
 	 * @return EntityDocument|null
47 47
 	 * @throws EntityLookupException
48 48
 	 */
49
-	public function getEntity( EntityId $entityId ) {
49
+	public function getEntity(EntityId $entityId) {
50 50
 		try {
51
-			return $this->lookup->getEntity( $entityId );
52
-		} catch ( UnresolvedEntityRedirectException $ex ) {
53
-			return $this->lookup->getEntity( $ex->getRedirectTargetId() );
51
+			return $this->lookup->getEntity($entityId);
52
+		} catch (UnresolvedEntityRedirectException $ex) {
53
+			return $this->lookup->getEntity($ex->getRedirectTargetId());
54 54
 		}
55 55
 	}
56 56
 
@@ -65,11 +65,11 @@  discard block
 block discarded – undo
65 65
 	 * @return bool
66 66
 	 * @throws EntityLookupException
67 67
 	 */
68
-	public function hasEntity( EntityId $entityId ) {
68
+	public function hasEntity(EntityId $entityId) {
69 69
 		try {
70
-			return $this->lookup->hasEntity( $entityId );
71
-		} catch ( UnresolvedEntityRedirectException $ex ) {
72
-			return $this->lookup->hasEntity( $ex->getRedirectTargetId() );
70
+			return $this->lookup->hasEntity($entityId);
71
+		} catch (UnresolvedEntityRedirectException $ex) {
72
+			return $this->lookup->hasEntity($ex->getRedirectTargetId());
73 73
 		}
74 74
 	}
75 75
 
Please login to merge, or discard this patch.
src/Lookup/LegacyAdapterPropertyLookup.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 
17 17
 	private EntityLookup $lookup;
18 18
 
19
-	public function __construct( EntityLookup $lookup ) {
19
+	public function __construct(EntityLookup $lookup) {
20 20
 		$this->lookup = $lookup;
21 21
 	}
22 22
 
@@ -26,11 +26,11 @@  discard block
 block discarded – undo
26 26
 	 * @return Property|null
27 27
 	 * @throws PropertyLookupException
28 28
 	 */
29
-	public function getPropertyForId( PropertyId $propertyId ) {
29
+	public function getPropertyForId(PropertyId $propertyId) {
30 30
 		try {
31
-			return $this->lookup->getEntity( $propertyId );
32
-		} catch ( EntityLookupException $ex ) {
33
-			throw new PropertyLookupException( $propertyId, $ex->getMessage(), $ex );
31
+			return $this->lookup->getEntity($propertyId);
32
+		} catch (EntityLookupException $ex) {
33
+			throw new PropertyLookupException($propertyId, $ex->getMessage(), $ex);
34 34
 		}
35 35
 	}
36 36
 
Please login to merge, or discard this patch.
src/Lookup/InMemoryDataTypeLookup.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -28,8 +28,8 @@  discard block
 block discarded – undo
28 28
 	 * @return string
29 29
 	 * @throws PropertyDataTypeLookupException
30 30
 	 */
31
-	public function getDataTypeIdForProperty( PropertyId $propertyId ) {
32
-		$this->verifyDataTypeIsSet( $propertyId );
31
+	public function getDataTypeIdForProperty(PropertyId $propertyId) {
32
+		$this->verifyDataTypeIsSet($propertyId);
33 33
 
34 34
 		return $this->dataTypeIds[$propertyId->getSerialization()];
35 35
 	}
@@ -42,8 +42,8 @@  discard block
 block discarded – undo
42 42
 	 *
43 43
 	 * @throws InvalidArgumentException
44 44
 	 */
45
-	public function setDataTypeForProperty( PropertyId $propertyId, $dataTypeId ) {
46
-		$this->verifyDataTypeIdType( $dataTypeId );
45
+	public function setDataTypeForProperty(PropertyId $propertyId, $dataTypeId) {
46
+		$this->verifyDataTypeIdType($dataTypeId);
47 47
 		$this->dataTypeIds[$propertyId->getSerialization()] = $dataTypeId;
48 48
 	}
49 49
 
@@ -52,11 +52,11 @@  discard block
 block discarded – undo
52 52
 	 *
53 53
 	 * @throws PropertyDataTypeLookupException
54 54
 	 */
55
-	private function verifyDataTypeIsSet( PropertyId $propertyId ) {
55
+	private function verifyDataTypeIsSet(PropertyId $propertyId) {
56 56
 		$id = $propertyId->getSerialization();
57 57
 
58
-		if ( !array_key_exists( $id, $this->dataTypeIds ) ) {
59
-			throw new PropertyDataTypeLookupException( $propertyId, "The DataType for property '$id' is not set" );
58
+		if (!array_key_exists($id, $this->dataTypeIds)) {
59
+			throw new PropertyDataTypeLookupException($propertyId, "The DataType for property '$id' is not set");
60 60
 		}
61 61
 	}
62 62
 
@@ -65,9 +65,9 @@  discard block
 block discarded – undo
65 65
 	 *
66 66
 	 * @throws InvalidArgumentException
67 67
 	 */
68
-	private function verifyDataTypeIdType( $dataTypeId ) {
69
-		if ( !is_string( $dataTypeId ) ) {
70
-			throw new InvalidArgumentException( '$dataTypeId must be a string; got ' . get_debug_type( $dataTypeId ) );
68
+	private function verifyDataTypeIdType($dataTypeId) {
69
+		if (!is_string($dataTypeId)) {
70
+			throw new InvalidArgumentException('$dataTypeId must be a string; got ' . get_debug_type($dataTypeId));
71 71
 		}
72 72
 	}
73 73
 
Please login to merge, or discard this patch.
src/Lookup/ItemLookupException.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 	 * @param string|null $message
20 20
 	 * @param Exception|null $previous
21 21
 	 */
22
-	public function __construct( ItemId $itemId, $message = null, ?Exception $previous = null ) {
22
+	public function __construct(ItemId $itemId, $message = null, ?Exception $previous = null) {
23 23
 		parent::__construct(
24 24
 			$itemId,
25 25
 			$message ?: 'Item lookup failed for: ' . $itemId,
@@ -32,8 +32,8 @@  discard block
 block discarded – undo
32 32
 	 */
33 33
 	public function getItemId() {
34 34
 		$itemId = $this->getEntityId();
35
-		if ( !( $itemId instanceof ItemId ) ) {
36
-			throw new LogicException( 'expected $itemId to be of type ItemId' );
35
+		if (!($itemId instanceof ItemId)) {
36
+			throw new LogicException('expected $itemId to be of type ItemId');
37 37
 		}
38 38
 
39 39
 		return $itemId;
Please login to merge, or discard this patch.
src/Lookup/EntityRedirectTargetLookup.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,6 +31,6 @@
 block discarded – undo
31 31
 	 * redirect.
32 32
 	 * @throws EntityRedirectLookupException
33 33
 	 */
34
-	public function getRedirectForEntityId( EntityId $entityId, $forUpdate = '' );
34
+	public function getRedirectForEntityId(EntityId $entityId, $forUpdate = '');
35 35
 
36 36
 }
Please login to merge, or discard this patch.
src/Lookup/EntityLookup.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	 * @return EntityDocument|null
29 29
 	 * @throws EntityLookupException
30 30
 	 */
31
-	public function getEntity( EntityId $entityId );
31
+	public function getEntity(EntityId $entityId);
32 32
 
33 33
 	/**
34 34
 	 * Returns whether the given entity can bee looked up using
@@ -46,6 +46,6 @@  discard block
 block discarded – undo
46 46
 	 * @return bool
47 47
 	 * @throws EntityLookupException
48 48
 	 */
49
-	public function hasEntity( EntityId $entityId );
49
+	public function hasEntity(EntityId $entityId);
50 50
 
51 51
 }
Please login to merge, or discard this patch.
src/Lookup/EntityRetrievingClosestReferencedEntityIdLookup.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -90,32 +90,32 @@  discard block
 block discarded – undo
90 90
 	 * @return EntityId|null Returns null in case none of the target entities are referenced.
91 91
 	 * @throws ReferencedEntityIdLookupException
92 92
 	 */
93
-	public function getReferencedEntityId( EntityId $fromId, PropertyId $propertyId, array $toIds ) {
94
-		if ( !$toIds ) {
93
+	public function getReferencedEntityId(EntityId $fromId, PropertyId $propertyId, array $toIds) {
94
+		if (!$toIds) {
95 95
 			return null;
96 96
 		}
97 97
 
98 98
 		$this->alreadyVisited = [];
99 99
 
100 100
 		$steps = $this->maxDepth + 1; // Add one as checking $fromId already is a step
101
-		$toVisit = [ $fromId ];
101
+		$toVisit = [$fromId];
102 102
 
103
-		while ( $steps-- ) {
104
-			$this->entityPrefetcher->prefetch( $toVisit );
103
+		while ($steps--) {
104
+			$this->entityPrefetcher->prefetch($toVisit);
105 105
 			$toVisitNext = [];
106 106
 
107
-			foreach ( $toVisit as $curId ) {
108
-				$result = $this->processEntityById( $curId, $fromId, $propertyId, $toIds, $toVisitNext );
109
-				if ( $result ) {
107
+			foreach ($toVisit as $curId) {
108
+				$result = $this->processEntityById($curId, $fromId, $propertyId, $toIds, $toVisitNext);
109
+				if ($result) {
110 110
 					return $result;
111 111
 				}
112 112
 			}
113 113
 			// Remove already visited entities
114 114
 			$toVisit = array_unique(
115
-				array_diff( $toVisitNext, array_keys( $this->alreadyVisited ) )
115
+				array_diff($toVisitNext, array_keys($this->alreadyVisited))
116 116
 			);
117 117
 
118
-			if ( !$toVisit ) {
118
+			if (!$toVisit) {
119 119
 				return null;
120 120
 			}
121 121
 		}
@@ -146,16 +146,16 @@  discard block
 block discarded – undo
146 146
 		array $toIds,
147 147
 		array &$toVisit
148 148
 	) {
149
-		$entity = $this->getEntity( $id, $fromId, $propertyId, $toIds );
150
-		if ( !$entity ) {
149
+		$entity = $this->getEntity($id, $fromId, $propertyId, $toIds);
150
+		if (!$entity) {
151 151
 			return null;
152 152
 		}
153 153
 
154
-		$mainSnaks = $this->getMainSnaks( $entity, $propertyId );
154
+		$mainSnaks = $this->getMainSnaks($entity, $propertyId);
155 155
 
156
-		foreach ( $mainSnaks as $mainSnak ) {
157
-			$result = $this->processSnak( $mainSnak, $toVisit, $toIds );
158
-			if ( $result ) {
156
+		foreach ($mainSnaks as $mainSnak) {
157
+			$result = $this->processSnak($mainSnak, $toVisit, $toIds);
158
+			if ($result) {
159 159
 				return $result;
160 160
 			}
161 161
 		}
@@ -171,8 +171,8 @@  discard block
 block discarded – undo
171 171
 	 *
172 172
 	 * @return StatementListProvider|null Null if not applicable.
173 173
 	 */
174
-	private function getEntity( EntityId $id, EntityId $fromId, PropertyId $propertyId, array $toIds ) {
175
-		if ( isset( $this->alreadyVisited[$id->getSerialization()] ) ) {
174
+	private function getEntity(EntityId $id, EntityId $fromId, PropertyId $propertyId, array $toIds) {
175
+		if (isset($this->alreadyVisited[$id->getSerialization()])) {
176 176
 			trigger_error(
177 177
 				'Entity ' . $id->getSerialization() . ' already visited.',
178 178
 				E_USER_WARNING
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 
184 184
 		$this->alreadyVisited[$id->getSerialization()] = true;
185 185
 
186
-		if ( count( $this->alreadyVisited ) > $this->maxEntityVisits ) {
186
+		if (count($this->alreadyVisited) > $this->maxEntityVisits) {
187 187
 			throw new MaxReferencedEntityVisitsExhaustedException(
188 188
 				$fromId,
189 189
 				$propertyId,
@@ -193,12 +193,12 @@  discard block
 block discarded – undo
193 193
 		}
194 194
 
195 195
 		try {
196
-			$entity = $this->entityLookup->getEntity( $id );
197
-		} catch ( EntityLookupException $ex ) {
198
-			throw new ReferencedEntityIdLookupException( $fromId, $propertyId, $toIds, null, $ex );
196
+			$entity = $this->entityLookup->getEntity($id);
197
+		} catch (EntityLookupException $ex) {
198
+			throw new ReferencedEntityIdLookupException($fromId, $propertyId, $toIds, null, $ex);
199 199
 		}
200 200
 
201
-		if ( !( $entity instanceof StatementListProvider ) ) {
201
+		if (!($entity instanceof StatementListProvider)) {
202 202
 			return null;
203 203
 		}
204 204
 
@@ -213,17 +213,17 @@  discard block
 block discarded – undo
213 213
 	 * @param EntityId[] $toIds
214 214
 	 * @return EntityId|null Target id the Snak refers to, null if none.
215 215
 	 */
216
-	private function processSnak( Snak $snak, array &$toVisit, array $toIds ) {
217
-		if ( !( $snak instanceof PropertyValueSnak ) ) {
216
+	private function processSnak(Snak $snak, array &$toVisit, array $toIds) {
217
+		if (!($snak instanceof PropertyValueSnak)) {
218 218
 			return null;
219 219
 		}
220 220
 		$dataValue = $snak->getDataValue();
221
-		if ( !( $dataValue instanceof EntityIdValue ) ) {
221
+		if (!($dataValue instanceof EntityIdValue)) {
222 222
 			return null;
223 223
 		}
224 224
 
225 225
 		$entityId = $dataValue->getEntityId();
226
-		if ( in_array( $entityId, $toIds, false ) ) {
226
+		if (in_array($entityId, $toIds, false)) {
227 227
 			return $entityId;
228 228
 		}
229 229
 
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 	) {
244 244
 		return $statementListProvider
245 245
 			->getStatements()
246
-			->getByPropertyId( $propertyId )
246
+			->getByPropertyId($propertyId)
247 247
 			->getBestStatements()
248 248
 			->getMainSnaks();
249 249
 	}
Please login to merge, or discard this patch.
src/Lookup/ReferencedEntityIdLookupException.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -49,17 +49,17 @@
 block discarded – undo
49 49
 		$this->toIds = $toIds;
50 50
 
51 51
 		$targets = array_map(
52
-			static function ( EntityId $entityId ) {
52
+			static function(EntityId $entityId) {
53 53
 				return $entityId->getSerialization();
54 54
 			},
55 55
 			$toIds
56 56
 		);
57
-		$targets = implode( ', ', $targets );
57
+		$targets = implode(', ', $targets);
58 58
 
59 59
 		$message = $message ?: 'Referenced entity id lookup failed. Tried to find a referenced entity out of ' .
60 60
 			$targets . ' linked from ' . $fromId->getSerialization() . ' via ' . $propertyId->getSerialization();
61 61
 
62
-		parent::__construct( $message, 0, $previous );
62
+		parent::__construct($message, 0, $previous);
63 63
 	}
64 64
 
65 65
 }
Please login to merge, or discard this patch.
src/Lookup/TermLookup.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	 * @throws TermLookupException for entity not found
31 31
 	 * @return string|null
32 32
 	 */
33
-	public function getLabel( EntityId $entityId, $languageCode );
33
+	public function getLabel(EntityId $entityId, $languageCode);
34 34
 
35 35
 	/**
36 36
 	 * Gets all labels of an Entity with the specified EntityId.
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 	 * @throws TermLookupException if the entity was not found (not guaranteed).
46 46
 	 * @return string[] labels, keyed by language.
47 47
 	 */
48
-	public function getLabels( EntityId $entityId, array $languageCodes );
48
+	public function getLabels(EntityId $entityId, array $languageCodes);
49 49
 
50 50
 	/**
51 51
 	 * Gets the description of an Entity with the specified EntityId and language code.
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	 * @throws TermLookupException for entity not found
59 59
 	 * @return string|null
60 60
 	 */
61
-	public function getDescription( EntityId $entityId, $languageCode );
61
+	public function getDescription(EntityId $entityId, $languageCode);
62 62
 
63 63
 	/**
64 64
 	 * Gets all descriptions of an Entity with the specified EntityId.
@@ -74,6 +74,6 @@  discard block
 block discarded – undo
74 74
 	 * @throws TermLookupException if the entity was not found (not guaranteed).
75 75
 	 * @return string[] descriptions, keyed by language.
76 76
 	 */
77
-	public function getDescriptions( EntityId $entityId, array $languageCodes );
77
+	public function getDescriptions(EntityId $entityId, array $languageCodes);
78 78
 
79 79
 }
Please login to merge, or discard this patch.