Skip to content

Commit fa18665

Browse files
committed
Add function documentation to private functions
Bug: T330644 Depends-On: I2914498869ee8dbee20ca8196ac70b7b70e83b44 Depends-On: I69fb434d5840af45977d0fbc8026faab274e3866 Depends-On: I9db4e5fa87a6d84300c5f9f4e3eddf497ec31739 Change-Id: I1c42b94b1b6683b78b2b4d326bdbecc3353935d3
1 parent ea14c33 commit fa18665

36 files changed

+170
-1
lines changed

.phpcs.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?xml version="1.0"?>
22
<ruleset>
33
<rule ref="./vendor/mediawiki/mediawiki-codesniffer/MediaWiki">
4-
<exclude name="MediaWiki.Commenting.FunctionComment.MissingDocumentationPrivate" />
54
<exclude name="MediaWiki.Commenting.FunctionComment.MissingDocumentationProtected" />
65
<exclude name="MediaWiki.Commenting.FunctionComment.MissingDocumentationPublic" />
76
<exclude name="MediaWiki.Commenting.FunctionComment.MissingParamTag" />

data-access/src/EntitySourceDefinitionsConfigParser.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,10 @@ private function validateDatabaseSourceConfigFields( $sourceData, $sourceName )
126126
}
127127
}
128128

129+
/**
130+
* @param int|string $namespaceAndSlot
131+
* @return array{0:int,1:string}
132+
*/
129133
private static function splitNamespaceAndSlot( $namespaceAndSlot ) {
130134
if ( is_int( $namespaceAndSlot ) ) {
131135
return [ $namespaceAndSlot, SlotRecord::MAIN ];

data-access/src/SourceAndTypeDispatchingPrefetchingTermLookup.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ public function getPrefetchedTerm( EntityId $entityId, $termType, $languageCode
6161
)->getPrefetchedTerm( $entityId, $termType, $languageCode );
6262
}
6363

64+
/**
65+
* @return PrefetchingTermLookup
66+
*/
6467
private function getLookupForEntitySourceAndType( EntitySource $source, string $type ) {
6568
return $this->dispatcher->getServiceForSourceAndType( $source->getSourceName(), $type, [ $source ] );
6669
}

lib/includes/ServiceBySourceAndTypeDispatcher.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ public function __construct( string $type, array $callbacks ) {
4040
$this->serviceType = $type;
4141
}
4242

43+
/**
44+
* @return mixed
45+
*/
4346
private function createService( string $sourceName, string $entityType, array $args = [] ) {
4447
if ( isset( $this->callbacks[$sourceName][$entityType] ) ) {
4548
$this->services[$sourceName][$entityType] = $this->callbacks[$sourceName][$entityType]( ...$args );

lib/includes/ServiceByTypeDispatcher.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ public function getServiceForType( string $entityType, array $callbackArgs = []
5959
return $this->services[$entityType] ?? $this->createService( $entityType, $callbackArgs );
6060
}
6161

62+
/**
63+
* @return mixed
64+
*/
6265
private function createService( string $entityType, array $args = [] ) {
6366
$this->services[$entityType] = $this->callbacks[$entityType]( ...$args );
6467

lib/includes/SimpleCacheWithBagOStuff.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ private function assertKeysAreValid( array $keys ): void {
231231
}
232232

233233
/**
234+
* @param string $key
234235
* @throws CacheInvalidArgumentException
235236
*/
236237
private function assertKeyIsValid( $key ): void {
@@ -314,6 +315,10 @@ private function normalizeTtl( $ttl ) {
314315
throw new CacheInvalidArgumentException( "Invalid TTL: `null|int|\DateInterval` expected, `$type` given" );
315316
}
316317

318+
/**
319+
* @param mixed $value
320+
* @return string|false
321+
*/
317322
private function serialize( $value ) {
318323
$dataToStore = serialize( $value );
319324

lib/includes/Store/CachingPrefetchingTermLookup.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,9 @@ private function getPrefetchedTermsFromLookup(
240240
return $terms;
241241
}
242242

243+
/**
244+
* @return string|string[]|false|null
245+
*/
243246
private function getTermFromLookup( EntityId $entity, string $termType, string $language ) {
244247
if ( $termType === TermTypes::TYPE_LABEL || $termType === TermTypes::TYPE_DESCRIPTION ) {
245248
return $this->lookup->getPrefetchedTerm( $entity, $termType, $language );
@@ -308,6 +311,9 @@ private function getCacheKey( EntityId $id, string $language, string $termType )
308311
return $this->buildCacheKey( $resolutionResult[1], $resolutionResult[0], $language, $termType );
309312
}
310313

314+
/**
315+
* @return string|false|null
316+
*/
311317
private function getBufferedOrCachedEntry( EntityId $entityId, string $termType, string $languageCode ) {
312318
// Check if it's prefetched already.
313319
$prefetchedTerm = $this->getPrefetchedTerm( $entityId, $termType, $languageCode );

lib/packages/wikibase/changes/src/ItemChange.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ private function getDiffFromSiteLinkChangesPerWiki( array $change ): Diff {
4949
}
5050
}
5151

52+
/**
53+
* @param mixed $obj
54+
*/
5255
private function logWarning( $obj ) {
5356
// This shouldn't happen, but we should be robust against corrupt, incomplete
5457
// or obsolete instances in the database, etc.

lib/packages/wikibase/data-model-serialization/src/Deserializers/AliasGroupListDeserializer.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ private function deserializeAliasGroup( array $serialization, $languageCode ) {
7171
return new AliasGroup( (string)$languageCode, $aliases );
7272
}
7373

74+
/**
75+
* @param array $serialization
76+
* @param string $requestedLanguage
77+
*/
7478
private function assertIsValidAliasSerialization( $serialization, $requestedLanguage ) {
7579
if ( !is_array( $serialization ) ) {
7680
throw new DeserializationException( 'Term serializations must be arrays' );
@@ -86,6 +90,10 @@ private function assertIsValidAliasSerialization( $serialization, $requestedLang
8690
$this->assertRequestedAndActualLanguageMatch( $serialization, $requestedLanguage );
8791
}
8892

93+
/**
94+
* @param array $array
95+
* @param string $attributeName
96+
*/
8997
private function requireAttribute( array $array, $attributeName ) {
9098
if ( !array_key_exists( $attributeName, $array ) ) {
9199
throw new MissingAttributeException(
@@ -94,6 +102,10 @@ private function requireAttribute( array $array, $attributeName ) {
94102
}
95103
}
96104

105+
/**
106+
* @param array $array
107+
* @param string $key
108+
*/
97109
private function assertNotAttribute( array $array, $key ) {
98110
if ( array_key_exists( $key, $array ) ) {
99111
throw new InvalidAttributeException(
@@ -104,6 +116,10 @@ private function assertNotAttribute( array $array, $key ) {
104116
}
105117
}
106118

119+
/**
120+
* @param array $serialization
121+
* @param string $requestedLanguage
122+
*/
107123
private function assertRequestedAndActualLanguageMatch(
108124
array $serialization,
109125
$requestedLanguage
@@ -117,10 +133,19 @@ private function assertRequestedAndActualLanguageMatch(
117133
}
118134
}
119135

136+
/**
137+
* @param array $array
138+
* @param string $attributeName
139+
*/
120140
private function assertAttributeIsArray( array $array, $attributeName ) {
121141
$this->assertAttributeInternalType( $array, $attributeName, 'array' );
122142
}
123143

144+
/**
145+
* @param array $array
146+
* @param string $attributeName
147+
* @param string $internalType
148+
*/
124149
private function assertAttributeInternalType( array $array, $attributeName, $internalType ) {
125150
if ( gettype( $array[$attributeName] ) !== $internalType ) {
126151
throw new InvalidAttributeException(

lib/packages/wikibase/data-model-serialization/src/Deserializers/ReferenceDeserializer.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ public function isDeserializerFor( $serialization ) {
3737
return $this->isValidSerialization( $serialization );
3838
}
3939

40+
/**
41+
* @param mixed $serialization
42+
*/
4043
private function isValidSerialization( $serialization ): bool {
4144
return is_array( $serialization ) && array_key_exists( 'snaks', $serialization );
4245
}

lib/packages/wikibase/data-model-serialization/src/Deserializers/SiteLinkDeserializer.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ private function getDeserializeBadges( array $serialization ): array {
6666
return $badges;
6767
}
6868

69+
/**
70+
* @param string $serialization
71+
*/
6972
private function deserializeItemId( $serialization ): ItemId {
7073
$itemId = $this->entityIdDeserializer->deserialize( $serialization );
7174

@@ -80,6 +83,9 @@ private function deserializeItemId( $serialization ): ItemId {
8083
return $itemId;
8184
}
8285

86+
/**
87+
* @param array $serialization
88+
*/
8389
private function assertBadgesIsArray( $serialization ) {
8490
if ( !is_array( $serialization['badges'] ) ) {
8591
throw new InvalidAttributeException(
@@ -90,11 +96,18 @@ private function assertBadgesIsArray( $serialization ) {
9096
}
9197
}
9298

99+
/**
100+
* @param array $serialization
101+
*/
93102
private function assertCanDeserialize( $serialization ) {
94103
$this->requireAttribute( $serialization, 'site' );
95104
$this->requireAttribute( $serialization, 'title' );
96105
}
97106

107+
/**
108+
* @param array $serialization
109+
* @param string $attribute
110+
*/
98111
private function requireAttribute( $serialization, $attribute ) {
99112
if ( !is_array( $serialization ) || !array_key_exists( $attribute, $serialization ) ) {
100113
throw new MissingAttributeException( $attribute );

lib/packages/wikibase/data-model-serialization/src/Deserializers/SnakDeserializer.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ private function deserializeDataValue( PropertyId $propertyId, array $serializat
137137
}
138138
}
139139

140+
/**
141+
* @param array $serialization
142+
*/
140143
private function assertValidDataValue( $serialization ): void {
141144
if ( !is_array( $serialization ) || !array_key_exists( DataValueDeserializer::TYPE_KEY, $serialization ) ) {
142145
throw new MissingTypeException( 'Not an array or missing the key "' . DataValueDeserializer::TYPE_KEY . '"' );
@@ -184,6 +187,9 @@ private function deserializePropertyId( string $serialization ): PropertyId {
184187
);
185188
}
186189

190+
/**
191+
* @param array $serialization
192+
*/
187193
private function assertCanDeserialize( $serialization ): void {
188194
if ( !is_array( $serialization ) ) {
189195
throw new DeserializationException( 'The snak serialization should be an array' );

lib/packages/wikibase/data-model-serialization/src/Deserializers/TermDeserializer.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ private function assertCanDeserialize( $serialization ) {
5555
$this->assertAttributeIsString( $serialization, 'value' );
5656
}
5757

58+
/**
59+
* @param array $array
60+
* @param string $attributeName
61+
*/
5862
private function assertAttributeIsString( array $array, $attributeName ) {
5963
if ( !is_string( $array[$attributeName] ) ) {
6064
throw new InvalidAttributeException(

lib/packages/wikibase/data-model-serialization/src/Deserializers/TermListDeserializer.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ private function getDeserialized( array $serialization ) {
6262
return $termList;
6363
}
6464

65+
/**
66+
* @param array $serialization
67+
* @param string $requestedLanguage
68+
*/
6569
private function assertRequestedAndActualLanguageMatch(
6670
array $serialization,
6771
$requestedLanguage
@@ -75,6 +79,10 @@ private function assertRequestedAndActualLanguageMatch(
7579
}
7680
}
7781

82+
/**
83+
* @param array $array
84+
* @param string $attributeName
85+
*/
7886
private function assertAttributeIsArray( array $array, $attributeName ) {
7987
if ( !is_array( $array[$attributeName] ) ) {
8088
throw new InvalidAttributeException(

lib/packages/wikibase/data-model-serialization/src/Serializers/AliasGroupListSerializer.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ public function serialize( $object ) {
3333
return $this->serializeMap( $this->generateSerializedArrayRepresentation( $object ) );
3434
}
3535

36+
/**
37+
* @param AliasGroupList $object
38+
*/
3639
private function assertIsSerializerFor( $object ) {
3740
if ( !( $object instanceof AliasGroupList ) ) {
3841
throw new UnsupportedObjectException(

lib/packages/wikibase/data-model-serialization/src/Serializers/AliasGroupSerializer.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ public function serialize( $object ) {
2727
return $this->getSerialized( $object );
2828
}
2929

30+
/**
31+
* @param AliasGroup $object
32+
*/
3033
private function assertIsSerializerFor( $object ) {
3134
if ( !( $object instanceof AliasGroup ) ) {
3235
throw new UnsupportedObjectException(

lib/packages/wikibase/data-model-serialization/src/Serializers/TermListSerializer.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ public function serialize( $object ) {
3737
return $this->serializeMap( $this->generateSerializedArrayRepresentation( $object ) );
3838
}
3939

40+
/**
41+
* @param TermList $object
42+
*/
4043
private function assertIsSerializerFor( $object ) {
4144
if ( !( $object instanceof TermList ) ) {
4245
throw new UnsupportedObjectException(

lib/packages/wikibase/data-model-serialization/src/Serializers/TermSerializer.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ public function serialize( $object ) {
2525
return $this->getSerialized( $object );
2626
}
2727

28+
/**
29+
* @param Term $object
30+
*/
2831
private function assertIsSerializerFor( $object ) {
2932
if ( !( $object instanceof Term ) ) {
3033
throw new UnsupportedObjectException(

lib/packages/wikibase/data-model-serialization/src/Serializers/TypedSnakSerializer.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ public function serialize( $object ) {
3838
return $this->getSerialized( $object );
3939
}
4040

41+
/**
42+
* @param TypedSnak $object
43+
*/
4144
private function assertIsSerializerFor( $object ) {
4245
if ( !( $object instanceof TypedSnak ) ) {
4346
throw new UnsupportedObjectException(

lib/packages/wikibase/data-model-services/src/ByPropertyIdGrouper.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ public function __construct( $propertyIdProviders ) {
3333
$this->indexPropertyIdProviders( $propertyIdProviders );
3434
}
3535

36+
/**
37+
* @param PropertyIdProvider[]|Traversable $propertyIdProviders
38+
*/
3639
private function assertArePropertyIdProviders( $propertyIdProviders ) {
3740
if ( !is_iterable( $propertyIdProviders ) ) {
3841
throw new InvalidArgumentException( '$propertyIdProviders must be an array or an instance of Traversable' );

lib/packages/wikibase/data-model/src/Entity/ItemId.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ public function __construct( $idSerialization ) {
2626
parent::__construct( strtoupper( $idSerialization ) );
2727
}
2828

29+
/**
30+
* @param string $idSerialization
31+
*/
2932
private function assertValidIdFormat( $idSerialization ) {
3033
if ( !is_string( $idSerialization ) ) {
3134
throw new InvalidArgumentException( '$idSerialization must be a string' );

lib/packages/wikibase/data-model/src/Entity/NumericPropertyId.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ public function __construct( $idSerialization ) {
2222
parent::__construct( strtoupper( $idSerialization ) );
2323
}
2424

25+
/**
26+
* @param string $idSerialization
27+
*/
2528
private function assertValidIdFormat( $idSerialization ) {
2629
if ( !is_string( $idSerialization ) ) {
2730
throw new InvalidArgumentException( '$idSerialization must be a string' );

lib/packages/wikibase/data-model/src/Entity/SerializableEntityId.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ public function __construct( $serialization ) {
2525
$this->serialization = self::normalizeIdSerialization( $serialization );
2626
}
2727

28+
/**
29+
* @param string $serialization
30+
*/
2831
private static function assertValidSerialization( $serialization ) {
2932
if ( !is_string( $serialization ) ) {
3033
throw new InvalidArgumentException( '$serialization must be a string' );

lib/packages/wikibase/data-model/src/Statement/StatementByGuidMap.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ public function hasStatementWithGuid( $statementGuid ) {
6464
return array_key_exists( $statementGuid, $this->statements );
6565
}
6666

67+
/**
68+
* @param string $statementGuid
69+
*/
6770
private function assertIsStatementGuid( $statementGuid ) {
6871
if ( !is_string( $statementGuid ) ) {
6972
throw new InvalidArgumentException( '$statementGuid needs to be a string' );

lib/packages/wikibase/internal-serialization/src/Deserializers/LegacyEntityIdDeserializer.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ public function deserialize( $serialization ) {
4141
}
4242
}
4343

44+
/**
45+
* @param array $serialization
46+
*/
4447
private function isLegacyFormat( $serialization ): bool {
4548
return is_array( $serialization ) && count( $serialization ) == 2
4649
&& array_key_exists( 0, $serialization ) && array_key_exists( 1, $serialization );

lib/packages/wikibase/internal-serialization/src/Deserializers/LegacyItemDeserializer.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ private function getStatement( array $claimSerialization ) {
126126
return $this->statementDeserializer->deserialize( $statementSerialization );
127127
}
128128

129+
/**
130+
* @param array $value
131+
*/
129132
private function assertClaimValueIsArray( $value ) {
130133
if ( !is_array( $value ) ) {
131134
throw new DeserializationException( 'Claim serialization must be an array.' );

0 commit comments

Comments
 (0)