From c3b03f74f55344400422c706d8ad48764023e9ef Mon Sep 17 00:00:00 2001 From: Lucas Werkmeister Date: Wed, 30 Aug 2017 16:14:24 +0200 Subject: [PATCH] Remove deprecated options to use snak hashes This follows through with the deprecation of the separate options in 4f558c9, leaving only the single unified option behind to control whether snak hashes of any kind are included or not. --- RELEASE-NOTES.md | 8 +++++ src/SerializerFactory.php | 46 ++++------------------------ tests/unit/SerializerFactoryTest.php | 11 ------- 3 files changed, 14 insertions(+), 51 deletions(-) diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index cac04649..bb1c42aa 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -1,5 +1,13 @@ # Wikibase DataModel Serialization release notes +## 3.0.0 (dev) + +* Removed the deprecated `SerializerFactory` options + `OPTION_SERIALIZE_MAIN_SNAKS_WITHOUT_HASH`, + `OPTION_SERIALIZE_QUALIFIER_SNAKS_WITHOUT_HASH` and + `OPTION_SERIALIZE_REFERENCE_SNAKS_WITHOUT_HASH` + (use `OPTION_SERIALIZE_SNAKS_WITHOUT_HASH` instead) + ## 2.7.0 (2018-03-28) * Fixed `AliasGroupListDeserializer` and `TermListDeserializer` misbehaving when confronted with diff --git a/src/SerializerFactory.php b/src/SerializerFactory.php index d91827c8..d048f797 100644 --- a/src/SerializerFactory.php +++ b/src/SerializerFactory.php @@ -36,29 +36,11 @@ class SerializerFactory { const OPTION_DEFAULT = 0; /** @since 1.2.0 */ const OPTION_OBJECTS_FOR_MAPS = 1; - /** - * @since 1.7.0 - * @deprecated since 2.5 use OPTION_SERIALIZE_SNAKS_WITHOUT_HASH - */ - const OPTION_SERIALIZE_MAIN_SNAKS_WITHOUT_HASH = 2; - /** - * @since 1.7.0 - * @deprecated since 2.5 use OPTION_SERIALIZE_SNAKS_WITHOUT_HASH - */ - const OPTION_SERIALIZE_QUALIFIER_SNAKS_WITHOUT_HASH = 4; - /** - * @since 1.7.0 - * @deprecated since 2.5 use OPTION_SERIALIZE_SNAKS_WITHOUT_HASH - */ - const OPTION_SERIALIZE_REFERENCE_SNAKS_WITHOUT_HASH = 8; /** * Omit hashes when serializing snaks. * @since 2.5.0 */ - const OPTION_SERIALIZE_SNAKS_WITHOUT_HASH = 14; /* = - self::OPTION_SERIALIZE_MAIN_SNAKS_WITHOUT_HASH | - self::OPTION_SERIALIZE_QUALIFIER_SNAKS_WITHOUT_HASH | - self::OPTION_SERIALIZE_REFERENCE_SNAKS_WITHOUT_HASH; */ + const OPTION_SERIALIZE_SNAKS_WITHOUT_HASH = 2; /** * @var int @@ -95,22 +77,8 @@ private function shouldUseObjectsForMaps() { /** * @return bool */ - private function shouldSerializeMainSnaksWithHash() { - return !(bool)( $this->options & self::OPTION_SERIALIZE_MAIN_SNAKS_WITHOUT_HASH ); - } - - /** - * @return bool - */ - private function shouldSerializeQualifierSnaksWithHash() { - return !(bool)( $this->options & self::OPTION_SERIALIZE_QUALIFIER_SNAKS_WITHOUT_HASH ); - } - - /** - * @return bool - */ - private function shouldSerializeReferenceSnaksWithHash() { - return !(bool)( $this->options & self::OPTION_SERIALIZE_REFERENCE_SNAKS_WITHOUT_HASH ); + private function shouldSerializeSnaksWithHash() { + return !(bool)( $this->options & self::OPTION_SERIALIZE_SNAKS_WITHOUT_HASH ); } /** @@ -190,8 +158,8 @@ public function newStatementListSerializer() { */ public function newStatementSerializer() { return new StatementSerializer( - $this->newSnakSerializer( $this->shouldSerializeMainSnaksWithHash() ), - $this->newSnakListSerializer( $this->shouldSerializeQualifierSnaksWithHash() ), + $this->newSnakSerializer( $this->shouldSerializeSnaksWithHash() ), + $this->newSnakListSerializer( $this->shouldSerializeSnaksWithHash() ), $this->newReferencesSerializer() ); } @@ -212,9 +180,7 @@ public function newReferencesSerializer() { */ public function newReferenceSerializer() { return new ReferenceSerializer( - $this->newSnakListSerializer( - $this->shouldSerializeReferenceSnaksWithHash() - ) + $this->newSnakListSerializer( $this->shouldSerializeSnaksWithHash() ) ); } diff --git a/tests/unit/SerializerFactoryTest.php b/tests/unit/SerializerFactoryTest.php index 20eed129..391c1a1a 100644 --- a/tests/unit/SerializerFactoryTest.php +++ b/tests/unit/SerializerFactoryTest.php @@ -159,15 +159,4 @@ public function testNewAliasGroupListSerializer() { ); } - public function testSerializeSnaksWithoutHashConstant() { - $this->assertSame( - // expected: - SerializerFactory::OPTION_SERIALIZE_MAIN_SNAKS_WITHOUT_HASH | - SerializerFactory::OPTION_SERIALIZE_QUALIFIER_SNAKS_WITHOUT_HASH | - SerializerFactory::OPTION_SERIALIZE_REFERENCE_SNAKS_WITHOUT_HASH, - // actual: - SerializerFactory::OPTION_SERIALIZE_SNAKS_WITHOUT_HASH - ); - } - }