Thiemo Mättig (WMDE) has uploaded a new change for review. https://gerrit.wikimedia.org/r/232696
Change subject: Add array type hints to public methods ...................................................................... Add array type hints to public methods Please be careful and double check. I tried hard to look at all usages of these methods. The biggest mistake you can make is to add an "array" type hint when a method is called with an iterator. Both work fine in a foreach loop, but there is no type hint for this. Only a soft "@param array|Traversable" via PHPDoc. Change-Id: I950bffd2a52da7f690d73a795ce4a2a62fb9494d --- M client/includes/DataAccess/SnaksFinder.php M client/includes/DataAccess/StatementTransclusionInteractor.php M client/includes/Hooks/SpecialWatchlistQueryHandler.php M client/includes/RepoLinker.php M repo/includes/ChangeOp/SiteLinkChangeOpFactory.php M repo/includes/Interactors/ItemMergeInteractor.php M repo/includes/Validators/NotEntityIdValidator.php M view/src/ClaimHtmlGenerator.php M view/src/Template/Template.php M view/src/TextInjector.php 10 files changed, 16 insertions(+), 16 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/96/232696/1 diff --git a/client/includes/DataAccess/SnaksFinder.php b/client/includes/DataAccess/SnaksFinder.php index eabdae1..86dc1f3 100644 --- a/client/includes/DataAccess/SnaksFinder.php +++ b/client/includes/DataAccess/SnaksFinder.php @@ -24,7 +24,11 @@ * * @return Snak[] */ - public function findSnaks( StatementListProvider $statementListProvider, PropertyId $propertyId, $acceptableRanks = null ) { + public function findSnaks( + StatementListProvider $statementListProvider, + PropertyId $propertyId, + array $acceptableRanks = null + ) { $statementList = $this->getStatementsWithPropertyId( $statementListProvider, $propertyId ); if ( $acceptableRanks === null ) { return $statementList->getBestStatements()->getMainSnaks(); diff --git a/client/includes/DataAccess/StatementTransclusionInteractor.php b/client/includes/DataAccess/StatementTransclusionInteractor.php index 3c94199..6fe8037 100644 --- a/client/includes/DataAccess/StatementTransclusionInteractor.php +++ b/client/includes/DataAccess/StatementTransclusionInteractor.php @@ -79,7 +79,7 @@ public function render( EntityId $entityId, $propertyLabelOrId, - $acceptableRanks = null + array $acceptableRanks = null ) { try { $entity = $this->entityLookup->getEntity( $entityId ); diff --git a/client/includes/Hooks/SpecialWatchlistQueryHandler.php b/client/includes/Hooks/SpecialWatchlistQueryHandler.php index 77337e1..3cd81e0 100644 --- a/client/includes/Hooks/SpecialWatchlistQueryHandler.php +++ b/client/includes/Hooks/SpecialWatchlistQueryHandler.php @@ -53,7 +53,7 @@ * * @return array */ - public function addWikibaseConditions( WebRequest $request, array $conds, $opts ) { + public function addWikibaseConditions( WebRequest $request, array $conds, FormOptions $opts = null ) { // do not include wikibase changes for activated enhanced watchlist // since we do not support that format yet if ( $this->shouldHideWikibaseChanges( $request, $opts ) ) { diff --git a/client/includes/RepoLinker.php b/client/includes/RepoLinker.php index 586b0a2..9af6f71 100644 --- a/client/includes/RepoLinker.php +++ b/client/includes/RepoLinker.php @@ -103,7 +103,7 @@ * * @return string (html) */ - public function formatLink( $url, $text, $attribs = array() ) { + public function formatLink( $url, $text, array $attribs = array() ) { $attribs['class'] = isset( $attribs['class'] ) ? 'plainlinks ' . $attribs['class'] : 'plainlinks'; diff --git a/repo/includes/ChangeOp/SiteLinkChangeOpFactory.php b/repo/includes/ChangeOp/SiteLinkChangeOpFactory.php index 186fa79..ba17178 100644 --- a/repo/includes/ChangeOp/SiteLinkChangeOpFactory.php +++ b/repo/includes/ChangeOp/SiteLinkChangeOpFactory.php @@ -21,7 +21,7 @@ * @throws InvalidArgumentException * @return ChangeOp */ - public function newSetSiteLinkOp( $siteId, $pageName, $badges = null ) { + public function newSetSiteLinkOp( $siteId, $pageName, array $badges = null ) { return new ChangeOpSiteLink( $siteId, $pageName, $badges ); } diff --git a/repo/includes/Interactors/ItemMergeInteractor.php b/repo/includes/Interactors/ItemMergeInteractor.php index e566e20..e85c158 100644 --- a/repo/includes/Interactors/ItemMergeInteractor.php +++ b/repo/includes/Interactors/ItemMergeInteractor.php @@ -140,7 +140,7 @@ * * @throws ItemMergeException */ - public function mergeItems( ItemId $fromId, ItemId $toId, $ignoreConflicts = array(), $summary = null, $bot = false ) { + public function mergeItems( ItemId $fromId, ItemId $toId, array $ignoreConflicts = array(), $summary = null, $bot = false ) { $this->checkPermissions( $fromId ); $this->checkPermissions( $toId ); diff --git a/repo/includes/Validators/NotEntityIdValidator.php b/repo/includes/Validators/NotEntityIdValidator.php index 029d9b2..6563b4e 100644 --- a/repo/includes/Validators/NotEntityIdValidator.php +++ b/repo/includes/Validators/NotEntityIdValidator.php @@ -41,11 +41,7 @@ * * @throws InvalidArgumentException */ - public function __construct( EntityIdParser $idParser, $errorCode, $forbiddenTypes = null ) { - if ( !is_null( $forbiddenTypes ) && !is_array( $forbiddenTypes ) ) { - throw new InvalidArgumentException( '$forbiddenTypes must be an array' ); - } - + public function __construct( EntityIdParser $idParser, $errorCode, array $forbiddenTypes = null ) { if ( !is_string( $errorCode ) ) { throw new InvalidArgumentException( '$errorCode must be a string' ); } diff --git a/view/src/ClaimHtmlGenerator.php b/view/src/ClaimHtmlGenerator.php index 887e769..3878489 100644 --- a/view/src/ClaimHtmlGenerator.php +++ b/view/src/ClaimHtmlGenerator.php @@ -184,7 +184,7 @@ * * @return string */ - protected function getSnaklistviewHtml( $snaks ) { + protected function getSnaklistviewHtml( array $snaks ) { $snaksHtml = ''; $i = 0; diff --git a/view/src/Template/Template.php b/view/src/Template/Template.php index 8ecb91d..7286878 100644 --- a/view/src/Template/Template.php +++ b/view/src/Template/Template.php @@ -24,11 +24,11 @@ * be sure to escape your params before using this class! * * @param TemplateRegistry $templateRegistry - * @param $key: message key, or array of message keys to try + * @param string|string[] $key message key, or array of message keys to try * and use the first non-empty message for - * @param $params Array message parameters + * @param array $params Array message parameters */ - public function __construct( TemplateRegistry $templateRegistry, $key, $params = array() ) { + public function __construct( TemplateRegistry $templateRegistry, $key, array $params = array() ) { $this->templateRegistry = $templateRegistry; parent::__construct( $key, $params ); } diff --git a/view/src/TextInjector.php b/view/src/TextInjector.php index 80fb7d9..604e228 100644 --- a/view/src/TextInjector.php +++ b/view/src/TextInjector.php @@ -35,7 +35,7 @@ * for use by inject(); a map of string markers associated with * parameter arrays. */ - public function __construct( $markers = array() ) { + public function __construct( array $markers = array() ) { $this->markers = $markers; // idea stolen from Parser class in core -- To view, visit https://gerrit.wikimedia.org/r/232696 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I950bffd2a52da7f690d73a795ce4a2a62fb9494d Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits