Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/402888 )

Change subject: Don’t use `self` reference in type hint
......................................................................

Don’t use `self` reference in type hint

The change of EntityContent::getDiff’s first parameter from
EntityContent to self makes the tests fail on PHP7 [1] (which is not
part of our pre-merge integration builds). I’m not sure why, but I
suspect that PHPUnit’s mocking framework, when instructed to create a
mock of ItemContent (a subclass of EntityContent), produces the
following signature:

    class Mock_ItemContent_somehash {
        public function getDiff( self $toContent ) {
            // ...
        }
    }

If PHPUnit doesn’t resolve the `self` in EntityContent::getDiff to the
EntityContent class name, then `self` in the fake mocked class refers to
the fake mocked class, not EntityContent, resulting in an error due to
the incompatible signature.

This should probably considered a PHPUnit bug, but for the time being I
think we just need to work around it. (Our version of PHPUnit is ancient
due to MediaWiki’s support for old PHP versions, so this bug might well
be fixed in newer versions already.)

[1]: 
https://travis-ci.org/wikimedia/mediawiki-extensions-Wikibase/jobs/326482650

Change-Id: Ie261567b840d600a1a7dd7246f0d45e83ebf8c34
---
M repo/includes/Content/EntityContent.php
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/88/402888/1

diff --git a/repo/includes/Content/EntityContent.php 
b/repo/includes/Content/EntityContent.php
index b858d23..2063739 100644
--- a/repo/includes/Content/EntityContent.php
+++ b/repo/includes/Content/EntityContent.php
@@ -538,7 +538,7 @@
         *
         * @return EntityContentDiff
         */
-       public function getDiff( self $toContent ) {
+       public function getDiff( EntityContent $toContent ) {
                $fromContent = $this;
 
                $differ = new MapDiffer();

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie261567b840d600a1a7dd7246f0d45e83ebf8c34
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) <lucas.werkmeis...@wikimedia.de>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to