Thiemo Mättig (WMDE) has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/188359

Change subject: Inline type checks in ExceptionLocalizer classes
......................................................................

Inline type checks in ExceptionLocalizer classes

You could argue that this change introduces code duplication.
Problem is that the way this was implemented caused code
analysis tools (e.g. PHPStorm) to complain about undeclared
methods (that only exist in the subclasses).

Change-Id: If0e218296773ca05083db9906a04bf888255cdbf
---
M lib/includes/Localizer/MessageExceptionLocalizer.php
M lib/includes/Localizer/ParseExceptionLocalizer.php
M repo/includes/Localizer/ChangeOpValidationExceptionLocalizer.php
3 files changed, 9 insertions(+), 6 deletions(-)


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

diff --git a/lib/includes/Localizer/MessageExceptionLocalizer.php 
b/lib/includes/Localizer/MessageExceptionLocalizer.php
index be98467..c71e27c0 100644
--- a/lib/includes/Localizer/MessageExceptionLocalizer.php
+++ b/lib/includes/Localizer/MessageExceptionLocalizer.php
@@ -23,8 +23,8 @@
         * @throws InvalidArgumentException
         */
        public function getExceptionMessage( Exception $exception ) {
-               if ( !$this->hasExceptionMessage( $exception ) ) {
-                       throw new InvalidArgumentException( '$exception is not 
a MessageException.' );
+               if ( !( $exception instanceof MessageException ) ) {
+                       throw new InvalidArgumentException( '$exception must be 
a MessageException' );
                }
 
                $key = $exception->getKey();
@@ -44,4 +44,5 @@
        public function hasExceptionMessage( Exception $exception ) {
                return $exception instanceof MessageException;
        }
+
 }
diff --git a/lib/includes/Localizer/ParseExceptionLocalizer.php 
b/lib/includes/Localizer/ParseExceptionLocalizer.php
index dc2dc99..3bdea75 100644
--- a/lib/includes/Localizer/ParseExceptionLocalizer.php
+++ b/lib/includes/Localizer/ParseExceptionLocalizer.php
@@ -25,8 +25,8 @@
         * @throws InvalidArgumentException
         */
        public function getExceptionMessage( Exception $exception ) {
-               if ( !$this->hasExceptionMessage( $exception ) ) {
-                       throw new InvalidArgumentException( '$exception is not 
a ParseException' );
+               if ( !( $exception instanceof ParseException ) ) {
+                       throw new InvalidArgumentException( '$exception must be 
a ParseException' );
                }
 
                $baseKey = 'wikibase-parse-error';
@@ -64,4 +64,5 @@
        public function hasExceptionMessage( Exception $exception ) {
                return $exception instanceof ParseException;
        }
+
 }
diff --git a/repo/includes/Localizer/ChangeOpValidationExceptionLocalizer.php 
b/repo/includes/Localizer/ChangeOpValidationExceptionLocalizer.php
index 7d1377a..50dd265 100644
--- a/repo/includes/Localizer/ChangeOpValidationExceptionLocalizer.php
+++ b/repo/includes/Localizer/ChangeOpValidationExceptionLocalizer.php
@@ -38,8 +38,8 @@
         * @return Message
         */
        public function getExceptionMessage( Exception $exception ) {
-               if ( !$this->hasExceptionMessage( $exception ) ) {
-                       throw new InvalidArgumentException( '$exception is not 
a ChangeOpValidationException.' );
+               if ( !( $exception instanceof ChangeOpValidationException ) ) {
+                       throw new InvalidArgumentException( '$exception must be 
a ChangeOpValidationException' );
                }
 
                $result = $exception->getValidationResult();
@@ -62,4 +62,5 @@
        public function hasExceptionMessage( Exception $exception ) {
                return $exception instanceof ChangeOpValidationException;
        }
+
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: If0e218296773ca05083db9906a04bf888255cdbf
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <[email protected]>

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

Reply via email to