Skip to content

Commit

Permalink
Merge "view,data-access: Use type-declaration on undocumented private…
Browse files Browse the repository at this point in the history
… functions"
  • Loading branch information
jenkins-bot authored and Gerrit Code Review committed Jan 31, 2025
2 parents a3f39ca + fff910c commit 31311da
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 15 deletions.
2 changes: 1 addition & 1 deletion data-access/src/EntitySourceDefinitionsConfigParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ private function assertConfigArrayWellFormed( array $sourceConfig ) {
}
}

private function validateDatabaseSourceConfigFields( $sourceData, $sourceName ) {
private function validateDatabaseSourceConfigFields( array $sourceData, string $sourceName ) {
if ( !is_string( $sourceData['repoDatabase'] ) && $sourceData['repoDatabase'] !== false ) {
throw new InvalidArgumentException(
'Symbolic database name of entity source "' . $sourceName . '" should be a string or false.'
Expand Down
4 changes: 2 additions & 2 deletions data-access/tests/phpunit/FakePrefetchingTermLookup.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ private function bufferFakeTermsForEntities( array $entityIds, array $termTypes,
}
}

private function bufferNonAliasTerm( EntityId $id, $type, $lang ) {
private function bufferNonAliasTerm( EntityId $id, string $type, string $lang ) {
$this->buffer[$id->getSerialization()][$type][$lang] = $this->generateFakeTerm( $id, $type, $lang );
}

private function bufferAliasTerms( EntityId $id, $type, $lang ) {
private function bufferAliasTerms( EntityId $id, string $type, string $lang ) {
$this->buffer[$id->getSerialization()][$type][$lang] = [];
$this->buffer[$id->getSerialization()][$type][$lang][] = $this->generateFakeTerm( $id, $type, $lang, 1 );
$this->buffer[$id->getSerialization()][$type][$lang][] = $this->generateFakeTerm( $id, $type, $lang, 2 );
Expand Down
4 changes: 2 additions & 2 deletions data-access/tests/phpunit/InMemoryPrefetchingTermLookup.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ private function bufferStubTermsForEntities( array $entityIds, array $termTypes,
}
}

private function bufferNonAliasTerm( EntityId $id, $type, $lang ) {
private function bufferNonAliasTerm( EntityId $id, string $type, string $lang ) {
$this->buffer[$id->getSerialization()][$type][$lang] = $this->getFromEntityData( $id, $type, $lang );
}

private function getFromEntityData( EntityId $id, $type, $lang ): ?string {
private function getFromEntityData( EntityId $id, string $type, string $lang ): ?string {
if ( !array_key_exists( $id->getSerialization(), $this->entityData ) ) {
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion view/src/StatementHtmlGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ private function getHtmlForReferences( ReferenceList $referenceList ) {
return $this->wrapInListview( $referencesHtml );
}

private function wrapInListview( $listviewContent ) {
private function wrapInListview( string $listviewContent ): string {
if ( $listviewContent !== '' ) {
return $this->templateFactory->render( 'wikibase-listview', $listviewContent );
} else {
Expand Down
20 changes: 13 additions & 7 deletions view/src/Termbox/Renderer/TermboxRemoteRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function getContent( EntityId $entityId, $revision, $language, $editLink,
return $request->getContent();
}

private function reportFailureOfRequest( $message, ?Exception $exception = null ) {
private function reportFailureOfRequest( string $message, ?Exception $exception = null ) {
$context = [
'errormessage' => $message,
'class' => __CLASS__,
Expand All @@ -99,7 +99,13 @@ private function reportFailureOfRequest( $message, ?Exception $exception = null
$this->stats->increment( 'wikibase.view.TermboxRemoteRenderer.requestError' );
}

private function formatUrl( EntityId $entityId, $revision, $language, $editLink, TermLanguageFallbackChain $preferredLanguages ) {
private function formatUrl(
EntityId $entityId,
int $revision,
string $language,
string $editLink,
TermLanguageFallbackChain $preferredLanguages
): string {
if ( !$this->ssrServerUrl ) {
throw new TermboxNoRemoteRendererException( 'Termbox SSR server URL not configured' );
}
Expand All @@ -109,11 +115,11 @@ private function formatUrl( EntityId $entityId, $revision, $language, $editLink,

private function getRequestParams(
EntityId $entityId,
$revision,
$language,
$editLink,
int $revision,
string $language,
string $editLink,
TermLanguageFallbackChain $preferredLanguages
) {
): array {
return [
'entity' => $entityId->getSerialization(),
'revision' => $revision,
Expand All @@ -123,7 +129,7 @@ private function getRequestParams(
];
}

private function getLanguageCodes( TermLanguageFallbackChain $preferredLanguages ) {
private function getLanguageCodes( TermLanguageFallbackChain $preferredLanguages ): array {
return array_map( function ( LanguageWithConversion $language ) {
return $language->getLanguageCode();
}, $preferredLanguages->getFallbackChain() );
Expand Down
2 changes: 1 addition & 1 deletion view/src/TermsListView.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ private function getDescriptionView( TermList $listOfDescriptionTerms, string $l
);
}

private function getMulDescriptionView() {
private function getMulDescriptionView(): string {
return $this->templateFactory->render(
'wikibase-descriptionview-mul',
htmlspecialchars( $this->textProvider->get( 'wikibase-description-not-applicable' ), ENT_QUOTES ),
Expand Down
2 changes: 1 addition & 1 deletion view/src/ToolbarEditSectionGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private function getHtmlForEditSection(
);
}

private function getToolbarContainer( $content ) {
private function getToolbarContainer( string $content ): string {
return '<wb:sectionedit>'
. $this->templateFactory->render( 'wikibase-toolbar-container', $content )
. '</wb:sectionedit>';
Expand Down

0 comments on commit 31311da

Please # to comment.