Addshore has uploaded a new change for review.

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


Change subject: Cleanup lib/Validators
......................................................................

Cleanup lib/Validators

Change-Id: Iad47d841489e565eaa8e82b143684c2bb22f47e1
---
M lib/includes/Validators/CompositeValidator.php
M lib/includes/Validators/DataFieldValidator.php
M lib/includes/Validators/DataValueValidator.php
M lib/includes/Validators/EntityExistsValidator.php
M lib/includes/Validators/EntityIdValidator.php
M lib/includes/Validators/NumberRangeValidator.php
M lib/includes/Validators/NumberValidator.php
M lib/includes/Validators/RegexValidator.php
M lib/includes/Validators/StringLengthValidator.php
M lib/includes/Validators/TypeValidator.php
M lib/includes/Validators/UrlSchemeValidators.php
M lib/includes/Validators/UrlValidator.php
M lib/includes/Validators/ValidatorErrorLocalizer.php
13 files changed, 56 insertions(+), 281 deletions(-)


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

diff --git a/lib/includes/Validators/CompositeValidator.php 
b/lib/includes/Validators/CompositeValidator.php
index 19d08a4..693b927 100644
--- a/lib/includes/Validators/CompositeValidator.php
+++ b/lib/includes/Validators/CompositeValidator.php
@@ -1,50 +1,19 @@
 <?php
- /**
- *
- * Copyright © 10.06.13 by the authors listed below.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- * @license GPL 2+
- * @file
- *
- * @author Daniel Kinzler
- */
-
 
 namespace Wikibase\Validators;
 
-
 use DataTypes\DataTypeFactory;
-use DataValues\DataValue;
+use InvalidArgumentException;
 use ValueValidators\Result;
 use ValueValidators\ValueValidator;
 use Wikibase\Claim;
-use Wikibase\Lib\PropertyDataTypeLookup;
-use Wikibase\PropertyValueSnak;
-use Wikibase\Reference;
-use Wikibase\References;
-use Wikibase\Snak;
-use Wikibase\Statement;
 
 /**
  * A CompositeValidator uses a list of sub-validators to validate the data.
  * It does not implement any validation logic directly.
  *
- * @package Wikibase\Validators
+ * @license GPL 2+
+ * @author Daniel Kinzler
  */
 class CompositeValidator implements ValueValidator {
 
@@ -73,8 +42,8 @@
         *
         * @param mixed $value The value to validate
         *
-        * @return \ValueValidators\Result
-        * @throws \InvalidArgumentException
+        * @return Result
+        * @throws InvalidArgumentException
         */
        public function validate( $value ) {
                $result = Result::newSuccess();
diff --git a/lib/includes/Validators/DataFieldValidator.php 
b/lib/includes/Validators/DataFieldValidator.php
index ed825aa..2128bf9 100644
--- a/lib/includes/Validators/DataFieldValidator.php
+++ b/lib/includes/Validators/DataFieldValidator.php
@@ -1,7 +1,7 @@
 <?php
+
 namespace Wikibase\Validators;
 
-use DataValues\DataValue;
 use DataValues\IllegalValueException;
 use InvalidArgumentException;
 use ValueValidators\Result;
diff --git a/lib/includes/Validators/DataValueValidator.php 
b/lib/includes/Validators/DataValueValidator.php
index 040281d..0e1eaad 100644
--- a/lib/includes/Validators/DataValueValidator.php
+++ b/lib/includes/Validators/DataValueValidator.php
@@ -1,41 +1,18 @@
 <?php
- /**
- *
- * Copyright © 10.06.13 by the authors listed below.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- * @license GPL 2+
- * @file
- *
- * @author Daniel Kinzler
- */
-
 
 namespace Wikibase\Validators;
 
-
 use DataValues\DataValue;
+use InvalidArgumentException;
+use ValueValidators\Result;
 use ValueValidators\ValueValidator;
 
 /**
  * The DataValueValidator class allows the validation of the plain value
  * of a simple DataValues object based on the DataValue's array representation.
  *
- * @package Wikibase\Validators
+ * @license GPL 2+
+ * @author Daniel Kinzler
  */
 class DataValueValidator implements ValueValidator {
 
@@ -47,7 +24,7 @@
        /**
         * @param ValueValidator $validator The validator to apply to the given 
field
         *
-        * @throws \InvalidArgumentException
+        * @throws InvalidArgumentException
         */
        public function __construct( ValueValidator $validator ) {
                $this->validator = $validator;
@@ -58,12 +35,12 @@
         *
         * @param DataValue $value The value to validate
         *
-        * @return \ValueValidators\Result
-        * @throws \InvalidArgumentException
+        * @return Result
+        * @throws InvalidArgumentException
         */
        public function validate( $value ) {
                if ( !( $value instanceof DataValue ) ) {
-                       throw new \InvalidArgumentException( 'DataValue 
expected' );
+                       throw new InvalidArgumentException( 'DataValue 
expected' );
                }
 
                $arrayValue = $value->getArrayValue();
diff --git a/lib/includes/Validators/EntityExistsValidator.php 
b/lib/includes/Validators/EntityExistsValidator.php
index 5092e4e..4133860 100644
--- a/lib/includes/Validators/EntityExistsValidator.php
+++ b/lib/includes/Validators/EntityExistsValidator.php
@@ -2,6 +2,7 @@
 
 namespace Wikibase\Validators;
 
+use InvalidArgumentException;
 use ValueValidators\Error;
 use ValueValidators\Result;
 use ValueValidators\ValueValidator;
@@ -13,11 +14,7 @@
  * EntityExistsValidator checks that a given entity exists.
  *
  * @license GPL 2+
- * @file
- *
  * @author Daniel Kinzler
- *
- * @package Wikibase\Validators
  */
 class EntityExistsValidator implements ValueValidator {
 
@@ -38,8 +35,8 @@
         *
         * @param EntityIdValue|EntityId $value The ID to validate
         *
-        * @return \ValueValidators\Result
-        * @throws \InvalidArgumentException
+        * @return Result
+        * @throws InvalidArgumentException
         */
        public function validate( $value ) {
                if ( $value instanceof EntityIdValue ) {
@@ -47,7 +44,7 @@
                }
 
                if ( !( $value instanceof EntityId ) ) {
-                       throw new \InvalidArgumentException( "Expected an 
EntityId object" );
+                       throw new InvalidArgumentException( "Expected an 
EntityId object" );
                }
 
                if ( !$this->lookup->hasEntity( $value ) ) {
diff --git a/lib/includes/Validators/EntityIdValidator.php 
b/lib/includes/Validators/EntityIdValidator.php
index 0b71835..b30579e 100644
--- a/lib/includes/Validators/EntityIdValidator.php
+++ b/lib/includes/Validators/EntityIdValidator.php
@@ -1,33 +1,8 @@
 <?php
- /**
- *
- * Copyright © 10.06.13 by the authors listed below.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- * @license GPL 2+
- * @file
- *
- * @author Daniel Kinzler
- */
-
 
 namespace Wikibase\Validators;
 
-
+use InvalidArgumentException;
 use ValueParsers\ParseException;
 use ValueValidators\Error;
 use ValueValidators\Result;
@@ -38,7 +13,8 @@
 /**
  * EntityIdValidator checks that an entity ID string is well formed and refers 
to the right type of entity.
  *
- * @package Wikibase\Validators
+ * @license GPL 2+
+ * @author Daniel Kinzler
  */
 class EntityIdValidator implements ValueValidator {
 
@@ -66,8 +42,8 @@
         *
         * @param string $value The value to validate
         *
-        * @return \ValueValidators\Result
-        * @throws \InvalidArgumentException
+        * @return Result
+        * @throws InvalidArgumentException
         */
        public function validate( $value ) {
                try {
diff --git a/lib/includes/Validators/NumberRangeValidator.php 
b/lib/includes/Validators/NumberRangeValidator.php
index 4ece070..257d1d3 100644
--- a/lib/includes/Validators/NumberRangeValidator.php
+++ b/lib/includes/Validators/NumberRangeValidator.php
@@ -2,6 +2,7 @@
 
 namespace Wikibase\Validators;
 
+use InvalidArgumentException;
 use ValueValidators\Error;
 use ValueValidators\Result;
 use ValueValidators\ValueValidator;
@@ -43,8 +44,8 @@
         *
         * @param string $value The value to validate
         *
-        * @return \ValueValidators\Result
-        * @throws \InvalidArgumentException
+        * @return Result
+        * @throws InvalidArgumentException
         */
        public function validate( $value ) {
                if ( $value < $this->min ) {
diff --git a/lib/includes/Validators/NumberValidator.php 
b/lib/includes/Validators/NumberValidator.php
index 85442a0..6ff25cf 100644
--- a/lib/includes/Validators/NumberValidator.php
+++ b/lib/includes/Validators/NumberValidator.php
@@ -1,13 +1,13 @@
 <?php
 namespace Wikibase\Validators;
 
+use InvalidArgumentException;
 use ValueValidators\Error;
 use ValueValidators\Result;
 use ValueValidators\ValueValidator;
 
 /**
  * @license GPL 2+
- *
  * @author Katie Filbert < [email protected] >
  */
 class NumberValidator implements ValueValidator {
diff --git a/lib/includes/Validators/RegexValidator.php 
b/lib/includes/Validators/RegexValidator.php
index 9def8d8..7239826 100644
--- a/lib/includes/Validators/RegexValidator.php
+++ b/lib/includes/Validators/RegexValidator.php
@@ -1,33 +1,8 @@
 <?php
- /**
- *
- * Copyright © 10.06.13 by the authors listed below.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- * @license GPL 2+
- * @file
- *
- * @author Daniel Kinzler
- */
-
 
 namespace Wikibase\Validators;
 
-
+use InvalidArgumentException;
 use ValueValidators\Error;
 use ValueValidators\Result;
 use ValueValidators\ValueValidator;
@@ -35,7 +10,8 @@
 /**
  * RegexValidator checks a string against a regular expression.
  *
- * @package Wikibase\Validators
+ * @license GPL 2+
+ * @author Daniel Kinzler
  */
 class RegexValidator implements ValueValidator {
 
@@ -71,8 +47,8 @@
         *
         * @param string $value The value to validate
         *
-        * @return \ValueValidators\Result
-        * @throws \InvalidArgumentException
+        * @return Result
+        * @throws InvalidArgumentException
         */
        public function validate( $value ) {
                $match = preg_match( $this->expression, $value );
diff --git a/lib/includes/Validators/StringLengthValidator.php 
b/lib/includes/Validators/StringLengthValidator.php
index 2e9acb6..1b84ad4 100644
--- a/lib/includes/Validators/StringLengthValidator.php
+++ b/lib/includes/Validators/StringLengthValidator.php
@@ -1,33 +1,8 @@
 <?php
- /**
- *
- * Copyright © 10.06.13 by the authors listed below.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- * @license GPL 2+
- * @file
- *
- * @author Daniel Kinzler
- */
-
 
 namespace Wikibase\Validators;
 
-
+use InvalidArgumentException;
 use ValueValidators\Error;
 use ValueValidators\Result;
 use ValueValidators\ValueValidator;
@@ -35,7 +10,8 @@
 /**
  * StringLengthValidator checks a string's length
  *
- * @package Wikibase\Validators
+ * @license GPL 2+
+ * @author Daniel Kinzler
  */
 class StringLengthValidator implements ValueValidator {
 
@@ -75,8 +51,8 @@
         *
         * @param string $value The value to validate
         *
-        * @return \ValueValidators\Result
-        * @throws \InvalidArgumentException
+        * @return Result
+        * @throws InvalidArgumentException
         */
        public function validate( $value ) {
                $length = call_user_func( $this->measure, $value );
diff --git a/lib/includes/Validators/TypeValidator.php 
b/lib/includes/Validators/TypeValidator.php
index 152f3ad..471e1fc 100644
--- a/lib/includes/Validators/TypeValidator.php
+++ b/lib/includes/Validators/TypeValidator.php
@@ -1,33 +1,8 @@
 <?php
- /**
- *
- * Copyright © 10.06.13 by the authors listed below.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- * @license GPL 2+
- * @file
- *
- * @author Daniel Kinzler
- */
-
 
 namespace Wikibase\Validators;
 
-
+use InvalidArgumentException;
 use ValueValidators\Error;
 use ValueValidators\Result;
 use ValueValidators\ValueValidator;
@@ -35,7 +10,8 @@
 /**
  * TypeValidator checks a value's data type.
  *
- * @package Wikibase\Validators
+ * @license GPL 2+
+ * @author Daniel Kinzler
  */
 class TypeValidator implements ValueValidator {
 
@@ -49,7 +25,7 @@
         *
         * @param string $type A PHP type name or a class name.
         *
-        * @throws \InvalidArgumentException
+        * @throws InvalidArgumentException
         */
        public function __construct( $type ) {
                $this->type = $type;
@@ -60,8 +36,8 @@
         *
         * @param mixed $value The value to validate
         *
-        * @return \ValueValidators\Result
-        * @throws \InvalidArgumentException
+        * @return Result
+        * @throws InvalidArgumentException
         */
        public function validate( $value ) {
                $type = gettype( $value );
diff --git a/lib/includes/Validators/UrlSchemeValidators.php 
b/lib/includes/Validators/UrlSchemeValidators.php
index 5d51c2f..156917f 100644
--- a/lib/includes/Validators/UrlSchemeValidators.php
+++ b/lib/includes/Validators/UrlSchemeValidators.php
@@ -1,32 +1,6 @@
 <?php
- /**
- *
- * Copyright © 10.06.13 by the authors listed below.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- * @license GPL 2+
- * @file
- *
- * @author Daniel Kinzler
- */
-
 
 namespace Wikibase\Validators;
-
 
 use Parser;
 use ValueValidators\ValueValidator;
@@ -35,7 +9,8 @@
  * UrlSchemeValidators is a collection of validators for some commonly used 
URL schemes.
  * This is intended for conveniently supplying a map of validators to 
UrlValidator.
  *
- * @package Wikibase\Validators
+ * @license GPL 2+
+ * @author Daniel Kinzler
  */
 class UrlSchemeValidators {
 
diff --git a/lib/includes/Validators/UrlValidator.php 
b/lib/includes/Validators/UrlValidator.php
index 1452916..fad8395 100644
--- a/lib/includes/Validators/UrlValidator.php
+++ b/lib/includes/Validators/UrlValidator.php
@@ -1,33 +1,8 @@
 <?php
- /**
- *
- * Copyright © 10.06.13 by the authors listed below.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- * @license GPL 2+
- * @file
- *
- * @author Daniel Kinzler
- */
-
 
 namespace Wikibase\Validators;
 
-
+use InvalidArgumentException;
 use ValueValidators\Error;
 use ValueValidators\Result;
 use ValueValidators\ValueValidator;
@@ -35,7 +10,8 @@
 /**
  * UrlValidator checks URLs based on sub-validators for each scheme.
  *
- * @package Wikibase\Validators
+ * @license GPL 2+
+ * @author Daniel Kinzler
  */
 class UrlValidator implements ValueValidator {
 
@@ -52,16 +28,16 @@
         *        other schemes. You may want to use UrlSchemaValidators to 
create the
         *        respective validators conveniently.
         *
-        * @throws \InvalidArgumentException
+        * @throws InvalidArgumentException
         */
        public function __construct( array $schemes ) {
                foreach ( $schemes as $scheme => $validator ) {
                        if ( !is_string( $scheme ) ) {
-                               throw new \InvalidArgumentException( 'The keys 
in $scheme must be strings (scheme names).' );
+                               throw new InvalidArgumentException( 'The keys 
in $scheme must be strings (scheme names).' );
                        }
 
                        if ( !is_object( $validator ) || !( $validator 
instanceof ValueValidator ) ) {
-                               throw new \InvalidArgumentException( 'The 
values in $scheme must be instances of ValueValidator.' );
+                               throw new InvalidArgumentException( 'The values 
in $scheme must be instances of ValueValidator.' );
                        }
                }
 
@@ -73,8 +49,8 @@
         *
         * @param mixed $value The value to validate
         *
-        * @return \ValueValidators\Result
-        * @throws \InvalidArgumentException
+        * @return Result
+        * @throws InvalidArgumentException
         */
        public function validate( $value ) {
                // See RFC 3986, section-3.1.
diff --git a/lib/includes/Validators/ValidatorErrorLocalizer.php 
b/lib/includes/Validators/ValidatorErrorLocalizer.php
index 7989940..45e77c0 100644
--- a/lib/includes/Validators/ValidatorErrorLocalizer.php
+++ b/lib/includes/Validators/ValidatorErrorLocalizer.php
@@ -1,38 +1,14 @@
 <?php
- /**
- *
- * Copyright © 20.06.13 by the authors listed below.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- * @license GPL 2+
- * @file
- *
- * @author Daniel Kinzler
- */
-
 
 namespace Wikibase\Validators;
-
 
 use ValueValidators\Error;
 
 /**
  * Class ValidatorErrorLocalizer
- * @package Wikibase\Validators
+ *
+ * @license GPL 2+
+ * @author Daniel Kinzler
  */
 class ValidatorErrorLocalizer {
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iad47d841489e565eaa8e82b143684c2bb22f47e1
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Addshore <[email protected]>

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

Reply via email to