jenkins-bot has submitted this change and it was merged.

Change subject: Add missing type hints to getters that return mocks
......................................................................


Add missing type hints to getters that return mocks

I found candidates with a pretty complicated regex, searching for
functions that construct and return a mock but do not have a PHPDoc
block. This improves type safety and reduces the number of warnings
analysis tools like PHPStorm report.

Change-Id: I5f9dfae8566e4bd63965dc1b720252d37ba87e4a
---
M client/tests/phpunit/includes/DataAccess/PropertyParserFunction/RunnerTest.php
M lib/tests/phpunit/formatters/PropertyValueSnakFormatterTest.php
M repo/tests/phpunit/includes/Diff/DifferencesSnakVisualizerTest.php
M repo/tests/phpunit/includes/Interactors/TokenCheckInteractorTest.php
M view/tests/phpunit/Module/TemplateModuleTest.php
M view/tests/phpunit/ViewFactoryTest.php
6 files changed, 38 insertions(+), 3 deletions(-)

Approvals:
  JanZerebecki: Looks good to me, approved
  jenkins-bot: Verified



diff --git 
a/client/tests/phpunit/includes/DataAccess/PropertyParserFunction/RunnerTest.php
 
b/client/tests/phpunit/includes/DataAccess/PropertyParserFunction/RunnerTest.php
index 8a69602..7bd9345 100644
--- 
a/client/tests/phpunit/includes/DataAccess/PropertyParserFunction/RunnerTest.php
+++ 
b/client/tests/phpunit/includes/DataAccess/PropertyParserFunction/RunnerTest.php
@@ -180,6 +180,11 @@
                return new RestrictedEntityLookup( $this->getMock( 
EntityLookup::class ), 200 );
        }
 
+       /**
+        * @param ItemId $itemId
+        *
+        * @return SiteLinkLookup
+        */
        private function getSiteLinkLookup( ItemId $itemId ) {
                $siteLinkLookup = $this->getMockBuilder( SiteLinkLookup::class )
                        ->getMock();
diff --git a/lib/tests/phpunit/formatters/PropertyValueSnakFormatterTest.php 
b/lib/tests/phpunit/formatters/PropertyValueSnakFormatterTest.php
index cf24c53..b610c7d 100644
--- a/lib/tests/phpunit/formatters/PropertyValueSnakFormatterTest.php
+++ b/lib/tests/phpunit/formatters/PropertyValueSnakFormatterTest.php
@@ -130,6 +130,11 @@
                $this->assertRegExp( $expected, $actual );
        }
 
+       /**
+        * @param string $value
+        *
+        * @return ValueFormatter
+        */
        private function getMockFormatter( $value ) {
                $formatter = $this->getMock( ValueFormatter::class );
                $formatter->expects( $this->any() )
diff --git a/repo/tests/phpunit/includes/Diff/DifferencesSnakVisualizerTest.php 
b/repo/tests/phpunit/includes/Diff/DifferencesSnakVisualizerTest.php
index e26d435..b6dd39e 100644
--- a/repo/tests/phpunit/includes/Diff/DifferencesSnakVisualizerTest.php
+++ b/repo/tests/phpunit/includes/Diff/DifferencesSnakVisualizerTest.php
@@ -25,6 +25,12 @@
  */
 class DifferencesSnakVisualizerTest extends MediaWikiTestCase {
 
+       /**
+        * @param string $returnValue
+        * @param string $format
+        *
+        * @return SnakFormatter
+        */
        public function newSnakFormatter( $returnValue = '<i>SNAK</i>', $format 
= SnakFormatter::FORMAT_HTML ) {
                $instance = $this->getMock( SnakFormatter::class );
                $instance->expects( $this->any() )
diff --git 
a/repo/tests/phpunit/includes/Interactors/TokenCheckInteractorTest.php 
b/repo/tests/phpunit/includes/Interactors/TokenCheckInteractorTest.php
index 85bff2b..1f5b296 100644
--- a/repo/tests/phpunit/includes/Interactors/TokenCheckInteractorTest.php
+++ b/repo/tests/phpunit/includes/Interactors/TokenCheckInteractorTest.php
@@ -2,6 +2,8 @@
 
 namespace Wikibase\Test\Interactors;
 
+use FauxRequest;
+use PHPUnit_Framework_TestCase;
 use User;
 use Wikibase\Repo\Interactors\TokenCheckException;
 use Wikibase\Repo\Interactors\TokenCheckInteractor;
@@ -18,8 +20,11 @@
  * @license GPL-2.0+
  * @author Daniel Kinzler
  */
-class TokenCheckInteractorTest extends \PHPUnit_Framework_TestCase {
+class TokenCheckInteractorTest extends PHPUnit_Framework_TestCase {
 
+       /**
+        * @return User
+        */
        private function getMockUser() {
                $user = $this->getMockBuilder( User::class )
                        ->disableOriginalConstructor()
@@ -41,7 +46,7 @@
                );
 
                $user = $this->getMockUser();
-               $request = new \FauxRequest( $data, true );
+               $request = new FauxRequest( $data, true );
 
                $checker = new TokenCheckInteractor( $user );
                $checker->checkRequestToken( $request, 'tokentest' );
@@ -61,7 +66,7 @@
         * @dataProvider tokenFailureProvider
         */
        public function testCheckToken_failure( $data, $wasPosted, $expected ) {
-               $request = new \FauxRequest( $data, $wasPosted );
+               $request = new FauxRequest( $data, $wasPosted );
 
                $user = $this->getMockUser();
                $checker = new TokenCheckInteractor( $user );
diff --git a/view/tests/phpunit/Module/TemplateModuleTest.php 
b/view/tests/phpunit/Module/TemplateModuleTest.php
index 3a3fab9..cf853af 100644
--- a/view/tests/phpunit/Module/TemplateModuleTest.php
+++ b/view/tests/phpunit/Module/TemplateModuleTest.php
@@ -52,6 +52,9 @@
                $this->assertNotEquals( $oldSummary['mtime'], 
$newSummary['mtime'] );
        }
 
+       /**
+        * @return ResourceLoaderContext
+        */
        private function getResourceLoaderContext() {
                $context = $this->getMockBuilder( ResourceLoaderContext::class )
                        ->disableOriginalConstructor()
diff --git a/view/tests/phpunit/ViewFactoryTest.php 
b/view/tests/phpunit/ViewFactoryTest.php
index 3451736..ff43c8d 100644
--- a/view/tests/phpunit/ViewFactoryTest.php
+++ b/view/tests/phpunit/ViewFactoryTest.php
@@ -145,6 +145,11 @@
                $this->assertInstanceOf( EntityTermsView::class, 
$entityTermsView );
        }
 
+       /**
+        * @param string $format
+        *
+        * @return EntityIdFormatterFactory
+        */
        private function getEntityIdFormatterFactory( $format ) {
                $entityIdFormatter = $this->getMock( EntityIdFormatter::class );
 
@@ -161,6 +166,9 @@
                return $formatterFactory;
        }
 
+       /**
+        * @return HtmlSnakFormatterFactory
+        */
        private function getSnakFormatterFactory() {
                $snakFormatter = $this->getMock( SnakFormatter::class );
 
@@ -177,6 +185,9 @@
                return $snakFormatterFactory;
        }
 
+       /**
+        * @return SiteStore
+        */
        private function getSiteStore() {
                $siteStore = $this->getMock( SiteStore::class );
 

-- 
To view, visit https://gerrit.wikimedia.org/r/279317
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I5f9dfae8566e4bd63965dc1b720252d37ba87e4a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Hoo man <[email protected]>
Gerrit-Reviewer: JanZerebecki <[email protected]>
Gerrit-Reviewer: Jonas Kress (WMDE) <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to