Addshore has uploaded a new change for review.

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


Change subject: Cleanup lib/includes/serializers
......................................................................

Cleanup lib/includes/serializers

Cleanup all files before starting to look at them.

This commit also splits the Options files into
3 seperate files (one per class)

Change-Id: I776358b0b9dbfcc0b525c8d6aef0a135d2d119b2
---
M lib/WikibaseLib.classes.php
M lib/includes/serializers/AliasSerializer.php
M lib/includes/serializers/ByPropertyListSerializer.php
M lib/includes/serializers/ByPropertyListUnserializer.php
M lib/includes/serializers/ClaimSerializer.php
M lib/includes/serializers/ClaimsSerializer.php
M lib/includes/serializers/DescriptionSerializer.php
A lib/includes/serializers/EntitySerializationOptions.php
M lib/includes/serializers/EntitySerializer.php
M lib/includes/serializers/ItemSerializer.php
M lib/includes/serializers/LabelSerializer.php
A lib/includes/serializers/MultiLangSerializationOptions.php
M lib/includes/serializers/MultilingualSerializer.php
M lib/includes/serializers/PropertySerializer.php
M lib/includes/serializers/ReferenceSerializer.php
M lib/includes/serializers/SerializationOptions.php
M lib/includes/serializers/Serializer.php
M lib/includes/serializers/SerializerFactory.php
M lib/includes/serializers/SerializerObject.php
M lib/includes/serializers/SiteLinkSerializer.php
M lib/includes/serializers/SnakSerializer.php
M lib/includes/serializers/Unserializer.php
22 files changed, 284 insertions(+), 426 deletions(-)


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

diff --git a/lib/WikibaseLib.classes.php b/lib/WikibaseLib.classes.php
index 6fb2bea..cfc1e68 100644
--- a/lib/WikibaseLib.classes.php
+++ b/lib/WikibaseLib.classes.php
@@ -139,9 +139,9 @@
                'Wikibase\Lib\Serializers\PropertySerializer' => 
'includes/serializers/PropertySerializer.php',
                'Wikibase\Lib\Serializers\ReferenceSerializer' => 
'includes/serializers/ReferenceSerializer.php',
                'Wikibase\Lib\Serializers\SerializationOptions' => 
'includes/serializers/SerializationOptions.php',
-               'Wikibase\Lib\Serializers\MultiLangSerializationOptions' => 
'includes/serializers/SerializationOptions.php',
+               'Wikibase\Lib\Serializers\MultiLangSerializationOptions' => 
'includes/serializers/MultiLangSerializationOptions.php',
+               'Wikibase\Lib\Serializers\EntitySerializationOptions' => 
'includes/serializers/EntitySerializationOptions.php',
                'Wikibase\Lib\Serializers\MultilingualSerializer' => 
'includes/serializers/MultilingualSerializer.php',
-               'Wikibase\Lib\Serializers\EntitySerializationOptions' => 
'includes/serializers/SerializationOptions.php',
                'Wikibase\Lib\Serializers\Serializer' => 
'includes/serializers/Serializer.php',
                'Wikibase\Lib\Serializers\SerializerFactory' => 
'includes/serializers/SerializerFactory.php',
                'Wikibase\Lib\Serializers\SerializerObject' => 
'includes/serializers/SerializerObject.php',
diff --git a/lib/includes/serializers/AliasSerializer.php 
b/lib/includes/serializers/AliasSerializer.php
index 8d7058e..5e4b519 100644
--- a/lib/includes/serializers/AliasSerializer.php
+++ b/lib/includes/serializers/AliasSerializer.php
@@ -11,8 +11,6 @@
  *
  * @since 0.4
  *
- * @ingroup WikibaseLib
- *
  * @licence GNU GPL v2+
  * @author Tobias Gritschacher < [email protected] >
  * @author Katie Filbert < [email protected] >
diff --git a/lib/includes/serializers/ByPropertyListSerializer.php 
b/lib/includes/serializers/ByPropertyListSerializer.php
index d14629a..9de1176 100644
--- a/lib/includes/serializers/ByPropertyListSerializer.php
+++ b/lib/includes/serializers/ByPropertyListSerializer.php
@@ -5,7 +5,6 @@
 use Traversable;
 use InvalidArgumentException;
 use Wikibase\ByPropertyIdArray;
-use Wikibase\DataModel\Entity\PropertyId;
 
 /**
  * Serializer for Traversable objects that need to be grouped
@@ -27,9 +26,6 @@
  * http://www.gnu.org/copyleft/gpl.html
  *
  * @since 0.2
- *
- * @file
- * @ingroup WikibaseLib
  *
  * @licence GNU GPL v2+
  * @author Jeroen De Dauw < [email protected] >
diff --git a/lib/includes/serializers/ByPropertyListUnserializer.php 
b/lib/includes/serializers/ByPropertyListUnserializer.php
index ca99b9e..8e91fa2 100644
--- a/lib/includes/serializers/ByPropertyListUnserializer.php
+++ b/lib/includes/serializers/ByPropertyListUnserializer.php
@@ -26,9 +26,6 @@
  *
  * @since 0.4
  *
- * @file
- * @ingroup WikibaseLib
- *
  * @licence GNU GPL v2+
  * @author Jeroen De Dauw < [email protected] >
  */
diff --git a/lib/includes/serializers/ClaimSerializer.php 
b/lib/includes/serializers/ClaimSerializer.php
index be5019f..e7bf013 100644
--- a/lib/includes/serializers/ClaimSerializer.php
+++ b/lib/includes/serializers/ClaimSerializer.php
@@ -14,8 +14,6 @@
  *
  * @since 0.2
  *
- * @ingroup WikibaseLib
- *
  * @licence GNU GPL v2+
  * @author Jeroen De Dauw < [email protected] >
  */
diff --git a/lib/includes/serializers/ClaimsSerializer.php 
b/lib/includes/serializers/ClaimsSerializer.php
index 68dd4d8..d6f4f0f 100644
--- a/lib/includes/serializers/ClaimsSerializer.php
+++ b/lib/includes/serializers/ClaimsSerializer.php
@@ -13,8 +13,6 @@
  *
  * @since 0.3
  *
- * @ingroup WikibaseLib
- *
  * @licence GNU GPL v2+
  * @author Jeroen De Dauw < [email protected] >
  */
diff --git a/lib/includes/serializers/DescriptionSerializer.php 
b/lib/includes/serializers/DescriptionSerializer.php
index 8be3a66..c11b3e2 100644
--- a/lib/includes/serializers/DescriptionSerializer.php
+++ b/lib/includes/serializers/DescriptionSerializer.php
@@ -11,8 +11,6 @@
  *
  * @since 0.4
  *
- * @ingroup WikibaseLib
- *
  * @licence GNU GPL v2+
  * @author Tobias Gritschacher < [email protected] >
  * @author Katie Filbert < [email protected] >
diff --git a/lib/includes/serializers/EntitySerializationOptions.php 
b/lib/includes/serializers/EntitySerializationOptions.php
new file mode 100644
index 0000000..0376cdd
--- /dev/null
+++ b/lib/includes/serializers/EntitySerializationOptions.php
@@ -0,0 +1,149 @@
+<?php
+
+namespace Wikibase\Lib\Serializers;
+
+use InvalidArgumentException;
+
+/**
+ * Options for Entity serializers.
+ *
+ * @since 0.2
+ *
+ * @licence GNU GPL v2+
+ * @author Jeroen De Dauw < [email protected] >
+ */
+class EntitySerializationOptions extends MultiLangSerializationOptions {
+
+       const SORT_ASC = 'ascending';
+       const SORT_DESC = 'descending';
+       const SORT_NONE = 'none';
+
+       /**
+        * The optional properties of the entity that should be included in the 
serialization.
+        *
+        * @since 0.2
+        *
+        * @var array of string
+        */
+       protected $props = array(
+               'aliases',
+               'descriptions',
+               'labels',
+               'claims',
+               // TODO: the following properties are not part of all entities, 
listing them here is not nice
+               'datatype', // property specific
+               'sitelinks', // item specific
+       );
+
+       /**
+        * Names of fields to sort on.
+        *
+        * @since 0.2
+        *
+        * @var array
+        */
+       protected $sortFields = array();
+
+       /**
+        * The direction the result should be sorted in.
+        *
+        * @since 0.2
+        *
+        * @var string Element of the EntitySerializationOptions::SORT_ enum
+        */
+       protected $sortDirection = self::SORT_NONE;
+
+       /**
+        * Sets the optional properties of the entity that should be included 
in the serialization.
+        *
+        * @since 0.2
+        *
+        * @param array $props
+        */
+       public function setProps( array $props ) {
+               $this->props = $props;
+       }
+
+       /**
+        * Gets the optional properties of the entity that should be included 
in the serialization.
+        *
+        * @since 0.2
+        *
+        * @return array
+        */
+       public function getProps() {
+               return $this->props;
+       }
+
+       /**
+        * Adds a prop to the list of optionally included elements of the 
entity.
+        *
+        * @since 0.3
+        *
+        * @param string $name
+        */
+       public function addProp( $name ) {
+               $this->props[] = $name;
+       }
+
+       /**
+        * Removes a prop from the list of optionally included elements of the 
entity.
+        *
+        * @since 0.4
+        *
+        * @param string $name
+        */
+       public function removeProp ( $name ) {
+               $this->props = array_diff( $this->props, array( $name ) );
+       }
+
+       /**
+        * Sets the names of fields to sort on.
+        *
+        * @since 0.2
+        *
+        * @param array $sortFields
+        */
+       public function setSortFields( array $sortFields ) {
+               $this->sortFields = $sortFields;
+       }
+
+       /**
+        * Returns the names of fields to sort on.
+        *
+        * @since 0.2
+        *
+        * @return array
+        */
+       public function getSortFields() {
+               return $this->sortFields;
+       }
+
+       /**
+        * Sets the direction the result should be sorted in.
+        *
+        * @since 0.2
+        *
+        * @param string $sortDirection Element of the 
EntitySerializationOptions::SORT_ enum
+        * @throws InvalidArgumentException
+        */
+       public function setSortDirection( $sortDirection ) {
+               if ( !in_array( $sortDirection, array( self::SORT_ASC, 
self::SORT_DESC, self::SORT_NONE ) ) ) {
+                       throw new InvalidArgumentException( 'Invalid sort 
direction provided' );
+               }
+
+               $this->sortDirection = $sortDirection;
+       }
+
+       /**
+        * Returns the direction the result should be sorted in.
+        *
+        * @since 0.2
+        *
+        * @return string Element of the EntitySerializationOptions::SORT_ enum
+        */
+       public function getSortDirection() {
+               return $this->sortDirection;
+       }
+
+}
diff --git a/lib/includes/serializers/EntitySerializer.php 
b/lib/includes/serializers/EntitySerializer.php
index f1fee81..61e2f08 100644
--- a/lib/includes/serializers/EntitySerializer.php
+++ b/lib/includes/serializers/EntitySerializer.php
@@ -4,7 +4,6 @@
 
 use InvalidArgumentException;
 use Wikibase\DataModel\Entity\BasicEntityIdParser;
-use Wikibase\DataModel\Entity\EntityIdValue;
 use Wikibase\Entity;
 use Wikibase\EntityFactory;
 
diff --git a/lib/includes/serializers/ItemSerializer.php 
b/lib/includes/serializers/ItemSerializer.php
index 7cc9703..99847ab 100644
--- a/lib/includes/serializers/ItemSerializer.php
+++ b/lib/includes/serializers/ItemSerializer.php
@@ -2,7 +2,7 @@
 namespace Wikibase\Lib\Serializers;
 
 use InvalidArgumentException;
-use Wikibase\DataModel\SimpleSiteLink;
+use SiteSQLStore;
 use Wikibase\Entity;
 use Wikibase\Item;
 
@@ -12,8 +12,6 @@
  * See docs/json.wiki for details of the format.
  *
  * @since 0.2
- *
- * @ingroup WikibaseLib
  *
  * @licence GNU GPL v2+
  * @author Jeroen De Dauw < [email protected] >
@@ -26,7 +24,7 @@
        /**
         * @since 0.4
         *
-        * @var \SiteSQLStore
+        * @var SiteSQLStore
         */
        protected $siteStore;
 
@@ -36,10 +34,11 @@
         * @since 0.4
         *
         * @param EntitySerializationOptions $options
+        * @param SiteSQLStore $siteStore
         */
-       public function __construct( EntitySerializationOptions $options, 
\SiteSQLStore $siteStore = null ) {
+       public function __construct( EntitySerializationOptions $options, 
SiteSQLStore $siteStore = null ) {
                if ( $siteStore === null ) {
-                       $this->siteStore = \SiteSQLStore::newInstance();
+                       $this->siteStore = SiteSQLStore::newInstance();
                } else {
                        $this->siteStore = $siteStore;
                }
diff --git a/lib/includes/serializers/LabelSerializer.php 
b/lib/includes/serializers/LabelSerializer.php
index 3d965a1..7baab49 100644
--- a/lib/includes/serializers/LabelSerializer.php
+++ b/lib/includes/serializers/LabelSerializer.php
@@ -11,8 +11,6 @@
  *
  * @since 0.4
  *
- * @ingroup WikibaseLib
- *
  * @licence GNU GPL v2+
  * @author Tobias Gritschacher < [email protected] >
  * @author Katie Filbert < [email protected] >
@@ -39,6 +37,7 @@
         * @since 0.4
         *
         * @param MultiLangSerializationOptions $options
+        * @param MultilingualSerializer $multilingualSerializer
         */
        public function __construct( MultiLangSerializationOptions $options = 
null,
                MultilingualSerializer $multilingualSerializer = null
diff --git a/lib/includes/serializers/MultiLangSerializationOptions.php 
b/lib/includes/serializers/MultiLangSerializationOptions.php
new file mode 100644
index 0000000..cb1f3c0
--- /dev/null
+++ b/lib/includes/serializers/MultiLangSerializationOptions.php
@@ -0,0 +1,122 @@
+<?php
+
+namespace Wikibase\Lib\Serializers;
+
+use Wikibase\LanguageFallbackChainFactory;
+
+/**
+ * Options for MultiLang Serializers.
+ *
+ * @since 0.4
+ *
+ * @licence GNU GPL v2+
+ * @author Jeroen De Dauw < [email protected] >
+ * @author Tobias Gritschacher < [email protected] >
+ */
+class MultiLangSerializationOptions extends SerializationOptions {
+
+       /**
+        * The language info array of the languages for which internationalized 
data (ie descriptions) should be returned.
+        * Or null for no restriction.
+        *
+        * Array keys are language codes (may include pseudo ones to identify 
some given fallback chains); values are
+        * LanguageFallbackChain objects (plain code inputs are constructed 
into language chains with a single language).
+        *
+        * @since 0.4
+        *
+        * @var null|array as described above
+        */
+       protected $languages = null;
+
+       /**
+        * Used to create LanguageFallbackChain objects when the old style 
array-of-strings argument is used in setLanguage().
+        *
+        * @var LanguageFallbackChainFactory
+        */
+       protected $languageFallbackChainFactory;
+
+       /**
+        * Sets the language codes or language fallback chains of the languages 
for which internationalized data
+        * (ie descriptions) should be returned.
+        *
+        * @since 0.2
+        *
+        * @param array|null $languages array of strings (back compat, as 
language codes)
+        *                     or LanguageFallbackChain objects (requested 
language codes as keys, to identify chains)
+        */
+       public function setLanguages( array $languages = null ) {
+               if ( $languages === null ) {
+                       $this->languages = null;
+
+                       return;
+               }
+
+               $this->languages = array();
+
+               foreach ( $languages as $languageCode => $languageFallbackChain 
) {
+                       // back-compat
+                       if ( is_numeric( $languageCode ) ) {
+                               $languageCode = $languageFallbackChain;
+                               $languageFallbackChain = 
$this->getLanguageFallbackChainFactory()->newFromLanguageCode(
+                                       $languageCode, 
LanguageFallbackChainFactory::FALLBACK_SELF
+                               );
+                       }
+
+                       $this->languages[$languageCode] = 
$languageFallbackChain;
+               }
+       }
+
+       /**
+        * Gets the language codes of the languages for which internationalized 
data (ie descriptions) should be returned.
+        *
+        * @since 0.2
+        *
+        * @return array|null
+        */
+       public function getLanguages() {
+               if ( $this->languages === null ) {
+                       return null;
+               } else {
+                       return array_keys( $this->languages );
+               }
+       }
+
+       /**
+        * Gets an associative array with language codes as keys and their 
fallback chains as values, or null.
+        *
+        * @since 0.4
+        *
+        * @return array|null
+        */
+       public function getLanguageFallbackChains() {
+               return $this->languages;
+       }
+
+       /**
+        * Get the language fallback chain factory previously set, or a new one 
if none was set.
+        *
+        * @since 0.4
+        *
+        * @return LanguageFallbackChainFactory
+        */
+       public function getLanguageFallbackChainFactory() {
+               if ( $this->languageFallbackChainFactory === null ) {
+                       $this->languageFallbackChainFactory = new 
LanguageFallbackChainFactory();
+               }
+
+               return $this->languageFallbackChainFactory;
+       }
+
+       /**
+        * Set language fallback chain factory and return the previously set 
one.
+        *
+        * @since 0.4
+        *
+        * @param LanguageFallbackChainFactory $factory
+        *
+        * @return LanguageFallbackChainFactory|null
+        */
+       public function setLanguageFallbackChainFactory( 
LanguageFallbackChainFactory $factory ) {
+               return wfSetVar( $this->languageFallbackChainFactory, $factory 
);
+       }
+}
\ No newline at end of file
diff --git a/lib/includes/serializers/MultilingualSerializer.php 
b/lib/includes/serializers/MultilingualSerializer.php
index 5db2070..ccb23a5 100644
--- a/lib/includes/serializers/MultilingualSerializer.php
+++ b/lib/includes/serializers/MultilingualSerializer.php
@@ -5,25 +5,7 @@
 /**
  * Multilingual serializer, for serializer of labels and descriptions.
  *
- * 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
- *
  * @since 0.4
- *
- * @file
- * @ingroup WikibaseLib
  *
  * @licence GNU GPL v2+
  */
diff --git a/lib/includes/serializers/PropertySerializer.php 
b/lib/includes/serializers/PropertySerializer.php
index 8af26e5..ccc42b1 100644
--- a/lib/includes/serializers/PropertySerializer.php
+++ b/lib/includes/serializers/PropertySerializer.php
@@ -13,8 +13,6 @@
  *
  * @since 0.3
  *
- * @ingroup WikibaseLib
- *
  * @licence GNU GPL v2+
  * @author Jeroen De Dauw < [email protected] >
  * @author Katie Filbert < [email protected] >
diff --git a/lib/includes/serializers/ReferenceSerializer.php 
b/lib/includes/serializers/ReferenceSerializer.php
index aa92cbf..e0d47ea 100644
--- a/lib/includes/serializers/ReferenceSerializer.php
+++ b/lib/includes/serializers/ReferenceSerializer.php
@@ -13,8 +13,6 @@
  *
  * @since 0.3
  *
- * @ingroup Wikibase
- *
  * @licence GNU GPL v2+
  * @author Jeroen De Dauw < [email protected] >
  */
diff --git a/lib/includes/serializers/SerializationOptions.php 
b/lib/includes/serializers/SerializationOptions.php
index a17a7fa..ee95d37 100644
--- a/lib/includes/serializers/SerializationOptions.php
+++ b/lib/includes/serializers/SerializationOptions.php
@@ -3,8 +3,6 @@
 namespace Wikibase\Lib\Serializers;
 
 use InvalidArgumentException;
-use ValueFormatters\ValueFormatter;
-use Wikibase\LanguageFallbackChainFactory;
 
 /**
  * Options for Serializer objects.
@@ -115,300 +113,4 @@
 
                $this->idKeyMode = $mode;
        }
-}
-
-/**
- * Options for MultiLang Serializers.
- *
- * 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
- *
- * @since 0.4
- *
- * @file
- * @ingroup WikibaseLib
- *
- * @licence GNU GPL v2+
- * @author Jeroen De Dauw < [email protected] >
- * @author Jeroen De Dauw < [email protected] >
- */
-class MultiLangSerializationOptions extends SerializationOptions {
-       /**
-        * The language info array of the languages for which internationalized 
data (ie descriptions) should be returned.
-        * Or null for no restriction.
-        *
-        * Array keys are language codes (may include pseudo ones to identify 
some given fallback chains); values are
-        * LanguageFallbackChain objects (plain code inputs are constructed 
into language chains with a single language).
-        *
-        * @since 0.4
-        *
-        * @var null|array as described above
-        */
-       protected $languages = null;
-
-       /**
-        * Used to create LanguageFallbackChain objects when the old style 
array-of-strings argument is used in setLanguage().
-        *
-        * @var LanguageFallbackChainFactory
-        */
-       protected $languageFallbackChainFactory;
-
-       /**
-        * Sets the language codes or language fallback chains of the languages 
for which internationalized data
-        * (ie descriptions) should be returned.
-        *
-        * @since 0.2
-        *
-        * @param array|null $languages array of strings (back compat, as 
language codes)
-        *                     or LanguageFallbackChain objects (requested 
language codes as keys, to identify chains)
-        */
-       public function setLanguages( array $languages = null ) {
-               if ( $languages === null ) {
-                       $this->languages = null;
-
-                       return;
-               }
-
-               $this->languages = array();
-
-               foreach ( $languages as $languageCode => $languageFallbackChain 
) {
-                       // back-compat
-                       if ( is_numeric( $languageCode ) ) {
-                               $languageCode = $languageFallbackChain;
-                               $languageFallbackChain = 
$this->getLanguageFallbackChainFactory()->newFromLanguageCode(
-                                       $languageCode, 
LanguageFallbackChainFactory::FALLBACK_SELF
-                               );
-                       }
-
-                       $this->languages[$languageCode] = 
$languageFallbackChain;
-               }
-       }
-
-       /**
-        * Gets the language codes of the languages for which internationalized 
data (ie descriptions) should be returned.
-        *
-        * @since 0.2
-        *
-        * @return array|null
-        */
-       public function getLanguages() {
-               if ( $this->languages === null ) {
-                       return null;
-               } else {
-                       return array_keys( $this->languages );
-               }
-       }
-
-       /**
-        * Gets an associative array with language codes as keys and their 
fallback chains as values, or null.
-        *
-        * @since 0.4
-        *
-        * @return array|null
-        */
-       public function getLanguageFallbackChains() {
-               return $this->languages;
-       }
-
-       /**
-        * Get the language fallback chain factory previously set, or a new one 
if none was set.
-        *
-        * @since 0.4
-        *
-        * @return LanguageFallbackChainFactory
-        */
-       public function getLanguageFallbackChainFactory() {
-               if ( $this->languageFallbackChainFactory === null ) {
-                       $this->languageFallbackChainFactory = new 
LanguageFallbackChainFactory();
-               }
-
-               return $this->languageFallbackChainFactory;
-       }
-
-       /**
-        * Set language fallback chain factory and return the previously set 
one.
-        *
-        * @since 0.4
-        *
-        * @param LanguageFallbackChainFactory $factory
-        *
-        * @return LanguageFallbackChainFactory|null
-        */
-       public function setLanguageFallbackChainFactory( 
LanguageFallbackChainFactory $factory ) {
-               return wfSetVar( $this->languageFallbackChainFactory, $factory 
);
-       }
-}
-
-/**
- * Options for Entity serializers.
- *
- * 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
- *
- * @since 0.2
- *
- * @file
- * @ingroup WikibaseLib
- *
- * @licence GNU GPL v2+
- * @author Jeroen De Dauw < [email protected] >
- */
-class EntitySerializationOptions extends MultiLangSerializationOptions {
-
-       const SORT_ASC = 'ascending';
-       const SORT_DESC = 'descending';
-       const SORT_NONE = 'none';
-
-       /**
-        * The optional properties of the entity that should be included in the 
serialization.
-        *
-        * @since 0.2
-        *
-        * @var array of string
-        */
-       protected $props = array(
-               'aliases',
-               'descriptions',
-               'labels',
-               'claims',
-               // TODO: the following properties are not part of all entities, 
listing them here is not nice
-               'datatype', // property specific
-               'sitelinks', // item specific
-       );
-
-       /**
-        * Names of fields to sort on.
-        *
-        * @since 0.2
-        *
-        * @var array
-        */
-       protected $sortFields = array();
-
-       /**
-        * The direction the result should be sorted in.
-        *
-        * @since 0.2
-        *
-        * @var string Element of the EntitySerializationOptions::SORT_ enum
-        */
-       protected $sortDirection = self::SORT_NONE;
-
-       /**
-        * Sets the optional properties of the entity that should be included 
in the serialization.
-        *
-        * @since 0.2
-        *
-        * @param array $props
-        */
-       public function setProps( array $props ) {
-               $this->props = $props;
-       }
-
-       /**
-        * Gets the optional properties of the entity that should be included 
in the serialization.
-        *
-        * @since 0.2
-        *
-        * @return array
-        */
-       public function getProps() {
-               return $this->props;
-       }
-
-       /**
-        * Adds a prop to the list of optionally included elements of the 
entity.
-        *
-        * @since 0.3
-        *
-        * @param string $name
-        */
-       public function addProp( $name ) {
-               $this->props[] = $name;
-       }
-
-       /**
-        * Removes a prop from the list of optionally included elements of the 
entity.
-        *
-        * @since 0.4
-        *
-        * @param string $name
-        */
-       public function removeProp ( $name ) {
-               $this->props = array_diff( $this->props, array( $name ) );
-       }
-
-       /**
-        * Sets the names of fields to sort on.
-        *
-        * @since 0.2
-        *
-        * @param array $sortFields
-        */
-       public function setSortFields( array $sortFields ) {
-               $this->sortFields = $sortFields;
-       }
-
-       /**
-        * Returns the names of fields to sort on.
-        *
-        * @since 0.2
-        *
-        * @return array
-        */
-       public function getSortFields() {
-               return $this->sortFields;
-       }
-
-       /**
-        * Sets the direction the result should be sorted in.
-        *
-        * @since 0.2
-        *
-        * @param string $sortDirection Element of the 
EntitySerializationOptions::SORT_ enum
-        * @throws InvalidArgumentException
-        */
-       public function setSortDirection( $sortDirection ) {
-               if ( !in_array( $sortDirection, array( self::SORT_ASC, 
self::SORT_DESC, self::SORT_NONE ) ) ) {
-                       throw new InvalidArgumentException( 'Invalid sort 
direction provided' );
-               }
-
-               $this->sortDirection = $sortDirection;
-       }
-
-       /**
-        * Returns the direction the result should be sorted in.
-        *
-        * @since 0.2
-        *
-        * @return string Element of the EntitySerializationOptions::SORT_ enum
-        */
-       public function getSortDirection() {
-               return $this->sortDirection;
-       }
-
-}
+}
\ No newline at end of file
diff --git a/lib/includes/serializers/Serializer.php 
b/lib/includes/serializers/Serializer.php
index 3a4d091..802b236 100644
--- a/lib/includes/serializers/Serializer.php
+++ b/lib/includes/serializers/Serializer.php
@@ -11,25 +11,7 @@
  * for conciseness and can contain a lot of redundant info, and are thus often 
not
  * ideal for serialization for internal storage.
  *
- * 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
- *
  * @since 0.3
- *
- * @file
- * @ingroup WikibaseLib
  *
  * @licence GNU GPL v2+
  * @author Jeroen De Dauw < [email protected] >
diff --git a/lib/includes/serializers/SerializerFactory.php 
b/lib/includes/serializers/SerializerFactory.php
index 6f222ea..57f3f06 100644
--- a/lib/includes/serializers/SerializerFactory.php
+++ b/lib/includes/serializers/SerializerFactory.php
@@ -8,25 +8,7 @@
 /**
  * Factory for constructing Serializer and Unserializer objects.
  *
- * 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
- *
  * @since 0.4
- *
- * @file
- * @ingroup WikibaseLib
  *
  * @licence GNU GPL v2+
  * @author Jeroen De Dauw < [email protected] >
@@ -99,8 +81,9 @@
 
        /**
         * @param string $entityType
+        * @param SerializationOptions $options
         *
-        * @throws OutOfBoundsException
+        * @throws InvalidArgumentException
         * @return Unserializer
         */
        public function newUnserializerForEntity( $entityType, $options ) {
diff --git a/lib/includes/serializers/SerializerObject.php 
b/lib/includes/serializers/SerializerObject.php
index 6913485..bf79545 100644
--- a/lib/includes/serializers/SerializerObject.php
+++ b/lib/includes/serializers/SerializerObject.php
@@ -5,27 +5,9 @@
 /**
  * Base class for ApiSerializers.
  *
- * 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
- *
  * TODO: change to PDO like options as done in ValueParsers
  *
  * @since 0.3
- *
- * @file
- * @ingroup WikibaseLib
  *
  * @licence GNU GPL v2+
  * @author Jeroen De Dauw < [email protected] >
diff --git a/lib/includes/serializers/SiteLinkSerializer.php 
b/lib/includes/serializers/SiteLinkSerializer.php
index d789dc2..3df7720 100644
--- a/lib/includes/serializers/SiteLinkSerializer.php
+++ b/lib/includes/serializers/SiteLinkSerializer.php
@@ -16,8 +16,6 @@
  *
  * @since 0.4
  *
- * @ingroup WikibaseLib
- *
  * @licence GNU GPL v2+
  * @author Jeroen De Dauw < [email protected] >
  * @author John Erling Blad < [email protected] >
@@ -62,10 +60,10 @@
         *
         * @since 0.4
         *
-        * @param array $sitelinks
+        * @param array $siteLinks
         *
-        * @return array
         * @throws InvalidArgumentException
+        * @return array
         */
        final public function getSerialized( $siteLinks ) {
                if ( !is_array( $siteLinks ) ) {
diff --git a/lib/includes/serializers/SnakSerializer.php 
b/lib/includes/serializers/SnakSerializer.php
index 0e23b6c..d65866d 100644
--- a/lib/includes/serializers/SnakSerializer.php
+++ b/lib/includes/serializers/SnakSerializer.php
@@ -13,8 +13,6 @@
  *
  * @since 0.2
  *
- * @ingroup WikibaseLib
- *
  * @licence GNU GPL v2+
  * @author Jeroen De Dauw < [email protected] >
  */
diff --git a/lib/includes/serializers/Unserializer.php 
b/lib/includes/serializers/Unserializer.php
index ee26d40..620271d 100644
--- a/lib/includes/serializers/Unserializer.php
+++ b/lib/includes/serializers/Unserializer.php
@@ -5,25 +5,7 @@
 /**
  * Interface for service objects doing unserialization.
  *
- * 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
- *
  * @since 0.4
- *
- * @file
- * @ingroup WikibaseLib
  *
  * @licence GNU GPL v2+
  * @author Jeroen De Dauw < [email protected] >

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I776358b0b9dbfcc0b525c8d6aef0a135d2d119b2
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