jenkins-bot has submitted this change and it was merged.
Change subject: New Wikidata Build - 2014/11/11
......................................................................
New Wikidata Build - 2014/11/11
Change-Id: I0c71d54a00fa400d13ac5badeaedf8ba8d46be63
---
M WikibaseClient.settings.php
M WikibaseRepo.settings.php
M composer.lock
M extensions/PropertySuggester/PropertySuggester.php
M extensions/PropertySuggester/README.md
M extensions/PropertySuggester/modules/ext.PropertySuggester.EntitySelector.js
M extensions/Wikibase/client/includes/WikibaseClient.php
M extensions/Wikibase/client/tests/phpunit/includes/WikibaseClientTest.php
M extensions/Wikibase/lib/i18n/he.json
A extensions/Wikibase/lib/includes/store/EntityInfoTermLookup.php
M extensions/Wikibase/lib/includes/store/TermLookup.php
A extensions/Wikibase/lib/tests/phpunit/store/EntityInfoTermLookupTest.php
M extensions/Wikibase/lib/tests/phpunit/store/EntityTermLookupTest.php
M vendor/autoload.php
M vendor/composer/autoload_classmap.php
M vendor/composer/autoload_real.php
M vendor/composer/installed.json
M vendor/wikibase/data-model/RELEASE-NOTES.md
M vendor/wikibase/data-model/WikibaseDataModel.php
M vendor/wikibase/data-model/composer.json
M vendor/wikibase/data-model/src/ByPropertyIdArray.php
M vendor/wikibase/data-model/src/ByPropertyIdGrouper.php
M vendor/wikibase/data-model/src/Claim/Claim.php
M vendor/wikibase/data-model/src/Claim/ClaimGuid.php
M vendor/wikibase/data-model/src/Claim/ClaimGuidParser.php
M vendor/wikibase/data-model/src/Claim/ClaimList.php
M vendor/wikibase/data-model/src/Claim/Claims.php
M vendor/wikibase/data-model/src/Entity/Diff/ItemDiffer.php
M vendor/wikibase/data-model/src/Entity/Diff/ItemPatcher.php
M vendor/wikibase/data-model/src/Entity/Diff/PropertyDiffer.php
M vendor/wikibase/data-model/src/Entity/Diff/PropertyPatcher.php
M vendor/wikibase/data-model/src/Entity/DispatchingEntityIdParser.php
M vendor/wikibase/data-model/src/Entity/Entity.php
M vendor/wikibase/data-model/src/Entity/EntityIdValue.php
M vendor/wikibase/data-model/src/Entity/InMemoryDataTypeLookup.php
M vendor/wikibase/data-model/src/Entity/Item.php
M vendor/wikibase/data-model/src/Entity/ItemId.php
M vendor/wikibase/data-model/src/Entity/ItemIdSet.php
M vendor/wikibase/data-model/src/Entity/Property.php
M vendor/wikibase/data-model/src/Entity/PropertyId.php
M vendor/wikibase/data-model/src/HashArray.php
M vendor/wikibase/data-model/src/Internal/MapValueHasher.php
M vendor/wikibase/data-model/src/Reference.php
M vendor/wikibase/data-model/src/ReferenceList.php
M vendor/wikibase/data-model/src/SiteLink.php
M vendor/wikibase/data-model/src/SiteLinkList.php
M vendor/wikibase/data-model/src/Snak/PropertyNoValueSnak.php
M vendor/wikibase/data-model/src/Snak/PropertySomeValueSnak.php
M vendor/wikibase/data-model/src/Snak/PropertyValueSnak.php
M vendor/wikibase/data-model/src/Snak/Snak.php
M vendor/wikibase/data-model/src/Snak/SnakObject.php
M vendor/wikibase/data-model/src/Statement/Statement.php
M vendor/wikibase/data-model/src/Statement/StatementList.php
M vendor/wikibase/data-model/src/Statement/StatementListDiffer.php
A vendor/wikibase/data-model/src/StatementListProvider.php
M vendor/wikibase/data-model/src/Term/AliasGroup.php
M vendor/wikibase/data-model/src/Term/AliasGroupList.php
M vendor/wikibase/data-model/src/Term/Term.php
M vendor/wikibase/data-model/src/Term/TermList.php
M vendor/wikibase/data-model/tests/unit/Entity/PropertyNotFoundExceptionTest.php
M vendor/wikibase/data-model/tests/unit/Statement/StatementListDifferTest.php
M vendor/wikibase/data-model/tests/unit/Statement/StatementTest.php
62 files changed, 583 insertions(+), 282 deletions(-)
Approvals:
Tobias Gritschacher: Looks good to me, approved
jenkins-bot: Verified
diff --git a/WikibaseClient.settings.php b/WikibaseClient.settings.php
index 42bbcb2..3f2723c 100644
--- a/WikibaseClient.settings.php
+++ b/WikibaseClient.settings.php
@@ -1,2 +1,2 @@
<?php
-$wgWBClientSettings["sharedCacheKeyPrefix"] = "wikibase:WBL/1415608596";
\ No newline at end of file
+$wgWBClientSettings["sharedCacheKeyPrefix"] = "wikibase:WBL/1415705197";
\ No newline at end of file
diff --git a/WikibaseRepo.settings.php b/WikibaseRepo.settings.php
index 034be32..0326233 100644
--- a/WikibaseRepo.settings.php
+++ b/WikibaseRepo.settings.php
@@ -1,2 +1,2 @@
<?php
-$wgWBRepoSettings["sharedCacheKeyPrefix"] = "wikibase:WBL/1415608596";
\ No newline at end of file
+$wgWBRepoSettings["sharedCacheKeyPrefix"] = "wikibase:WBL/1415705197";
\ No newline at end of file
diff --git a/composer.lock b/composer.lock
index d169986..ef3d711 100644
--- a/composer.lock
+++ b/composer.lock
@@ -743,16 +743,16 @@
},
{
"name": "propertysuggester/property-suggester",
- "version": "1.1.4",
+ "version": "1.1.5",
"source": {
"type": "git",
"url": "https://github.com/Wikidata-lib/PropertySuggester.git",
- "reference": "c8cdc7061b8a44e021eb2b3a98e83ff1cd18787e"
+ "reference": "0d106a6cb2e30a34cdec2e0eda52cca66a479733"
},
"dist": {
"type": "zip",
- "url":
"https://api.github.com/repos/Wikidata-lib/PropertySuggester/zipball/c8cdc7061b8a44e021eb2b3a98e83ff1cd18787e",
- "reference": "c8cdc7061b8a44e021eb2b3a98e83ff1cd18787e",
+ "url":
"https://api.github.com/repos/Wikidata-lib/PropertySuggester/zipball/0d106a6cb2e30a34cdec2e0eda52cca66a479733",
+ "reference": "0d106a6cb2e30a34cdec2e0eda52cca66a479733",
"shasum": ""
},
"require": {
@@ -784,7 +784,7 @@
"wikibase",
"wikidata"
],
- "time": "2014-10-22 13:21:31"
+ "time": "2014-11-10 15:13:08"
},
{
"name": "serialization/serialization",
@@ -891,16 +891,16 @@
},
{
"name": "wikibase/data-model",
- "version": "2.1.1",
+ "version": "2.2.0",
"source": {
"type": "git",
"url": "https://github.com/wmde/WikibaseDataModel.git",
- "reference": "ddb7d18bcd8ed835d3ebdfc20c7a22e0df4049e6"
+ "reference": "5077367f7585615a583cbe291c868ca8ffbd1faa"
},
"dist": {
"type": "zip",
- "url":
"https://api.github.com/repos/wmde/WikibaseDataModel/zipball/ddb7d18bcd8ed835d3ebdfc20c7a22e0df4049e6",
- "reference": "ddb7d18bcd8ed835d3ebdfc20c7a22e0df4049e6",
+ "url":
"https://api.github.com/repos/wmde/WikibaseDataModel/zipball/5077367f7585615a583cbe291c868ca8ffbd1faa",
+ "reference": "5077367f7585615a583cbe291c868ca8ffbd1faa",
"shasum": ""
},
"require": {
@@ -914,7 +914,7 @@
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "2.1.x-dev"
+ "dev-master": "2.2.x-dev"
}
},
"autoload": {
@@ -944,7 +944,7 @@
"wikibase",
"wikidata"
],
- "time": "2014-10-28 13:04:15"
+ "time": "2014-11-10 16:30:27"
},
{
"name": "wikibase/data-model-javascript",
@@ -1185,12 +1185,12 @@
"source": {
"type": "git",
"url":
"https://github.com/wikimedia/mediawiki-extensions-Wikibase.git",
- "reference": "dab7bb5af4a00c25b12c235924899a73a0e0b8c9"
+ "reference": "e88d9cce5d56570182820734a3887e3de424df12"
},
"dist": {
"type": "zip",
- "url":
"https://api.github.com/repos/wikimedia/mediawiki-extensions-Wikibase/zipball/dab7bb5af4a00c25b12c235924899a73a0e0b8c9",
- "reference": "dab7bb5af4a00c25b12c235924899a73a0e0b8c9",
+ "url":
"https://api.github.com/repos/wikimedia/mediawiki-extensions-Wikibase/zipball/e88d9cce5d56570182820734a3887e3de424df12",
+ "reference": "e88d9cce5d56570182820734a3887e3de424df12",
"shasum": ""
},
"require": {
@@ -1256,7 +1256,7 @@
"wikibaserepo",
"wikidata"
],
- "time": "2014-11-09 20:55:23"
+ "time": "2014-11-11 10:28:38"
},
{
"name": "wikibase/wikimedia-badges",
diff --git a/extensions/PropertySuggester/PropertySuggester.php
b/extensions/PropertySuggester/PropertySuggester.php
index 1f33c30..162ba97 100644
--- a/extensions/PropertySuggester/PropertySuggester.php
+++ b/extensions/PropertySuggester/PropertySuggester.php
@@ -9,7 +9,7 @@
return;
}
-define( 'PropertySuggester_VERSION', '1.1.4' );
+define( 'PropertySuggester_VERSION', '1.1.5' );
if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) {
require_once __DIR__ . '/vendor/autoload.php';
diff --git a/extensions/PropertySuggester/README.md
b/extensions/PropertySuggester/README.md
index ebf2ada..8668f6f 100644
--- a/extensions/PropertySuggester/README.md
+++ b/extensions/PropertySuggester/README.md
@@ -44,6 +44,9 @@
## Release notes
+### 1.1.5 (2014-11-10)
+* Adjust to new version of DataModel JavaScript
+
### 1.1.4 (2014-10-22)
* Replace usage of Wikibase\NamespaceUtils for compatibility with Wikibase
Repo.
diff --git
a/extensions/PropertySuggester/modules/ext.PropertySuggester.EntitySelector.js
b/extensions/PropertySuggester/modules/ext.PropertySuggester.EntitySelector.js
index 09d72ad..ec386d2 100644
---
a/extensions/PropertySuggester/modules/ext.PropertySuggester.EntitySelector.js
+++
b/extensions/PropertySuggester/modules/ext.PropertySuggester.EntitySelector.js
@@ -105,7 +105,7 @@
}
var statement = $statementView.length > 0 ?
$statementView.data( 'statementview' ).option( 'value' ) : null;
if( statement ) {
- return statement.getMainSnak().getPropertyId();
+ return
statement.getClaim().getMainSnak().getPropertyId();
} else {
return null;
}
diff --git a/extensions/Wikibase/client/includes/WikibaseClient.php
b/extensions/Wikibase/client/includes/WikibaseClient.php
index 6ece070..5161ee8 100644
--- a/extensions/Wikibase/client/includes/WikibaseClient.php
+++ b/extensions/Wikibase/client/includes/WikibaseClient.php
@@ -42,7 +42,6 @@
use Wikibase\Lib\OutputFormatValueFormatterFactory;
use Wikibase\Lib\PropertyInfoDataTypeLookup;
use Wikibase\Lib\Serializers\ForbiddenSerializer;
-use Wikibase\Lib\SnakFormatter;
use Wikibase\Lib\Store\EntityContentDataCodec;
use Wikibase\Lib\Store\EntityLookup;
use Wikibase\Lib\WikibaseDataTypeBuilders;
@@ -216,18 +215,6 @@
}
return $this->propertyDataTypeLookup;
- }
-
- /**
- * @since 0.4
- *
- * @param string $format The desired format, use
SnakFormatter::FORMAT_XXX
- * @param FormatterOptions $options
- *
- * @return SnakFormatter
- */
- public function newSnakFormatter( $format =
SnakFormatter::FORMAT_PLAIN, FormatterOptions $options ) {
- return $this->getSnakFormatterFactory()->getSnakFormatter(
$format, $options );
}
/**
diff --git
a/extensions/Wikibase/client/tests/phpunit/includes/WikibaseClientTest.php
b/extensions/Wikibase/client/tests/phpunit/includes/WikibaseClientTest.php
index f93292b..3c83767 100644
--- a/extensions/Wikibase/client/tests/phpunit/includes/WikibaseClientTest.php
+++ b/extensions/Wikibase/client/tests/phpunit/includes/WikibaseClientTest.php
@@ -8,7 +8,6 @@
use ValueFormatters\FormatterOptions;
use Wikibase\Client\WikibaseClient;
use Wikibase\DataModel\Entity\Item;
-use Wikibase\Lib\SnakFormatter;
use Wikibase\SettingsArray;
/**
@@ -38,14 +37,6 @@
public function testGetPropertyDataTypeLookupReturnType() {
$returnValue =
$this->getDefaultInstance()->getPropertyDataTypeLookup();
$this->assertInstanceOf(
'Wikibase\DataModel\Entity\PropertyDataTypeLookup', $returnValue );
- }
-
- public function testNewSnakFormatterReturnType() {
- $returnValue = $this->getDefaultInstance()->newSnakFormatter(
- SnakFormatter::FORMAT_PLAIN,
- new FormatterOptions()
- );
- $this->assertInstanceOf( 'Wikibase\Lib\SnakFormatter',
$returnValue );
}
public function testGetStringNormalizerReturnType() {
diff --git a/extensions/Wikibase/lib/i18n/he.json
b/extensions/Wikibase/lib/i18n/he.json
index d2f6dd4..33cf191 100644
--- a/extensions/Wikibase/lib/i18n/he.json
+++ b/extensions/Wikibase/lib/i18n/he.json
@@ -2,7 +2,8 @@
"@metadata": {
"authors": [
"Amire80",
- "Yona b"
+ "Yona b",
+ "Guycn2"
]
},
"wikibase-lib-desc": "הפעולות המשותפות להרחבות Wikibase ו־Wikibase
Client",
@@ -31,12 +32,7 @@
"wikibase-error-remove-timeout": "יש לנו קשיים טכניים. לא ניתן להשלים
את ההסרה שלך.",
"wikibase-error-autocomplete-connection": "לא ניתן לבצע שאילתה מתוך
ה־API של האתר. נא לנסות שוב מאוחר יותר.",
"wikibase-error-autocomplete-response": "השרת ענה: $1",
- "wikibase-error-ui-client-error": "החיבור לדף הלקוח נכשל. נא לנסות שוב
מאוחר יותר.",
"wikibase-error-ui-no-external-page": "הערך שהוזן לא נמצא באתר המתאים.",
- "wikibase-error-ui-cant-edit": "אין לך הרשאה לבצע את הפעולה הזאת.",
- "wikibase-error-ui-no-permissions": "אין לך מספיק הרשאות לבצע את הפעולה
הזאת.",
- "wikibase-error-ui-link-exists": "אין לך אפשרות לקשר לדף הזה כי פריט
אחר כבר מקשר אליו.",
- "wikibase-error-ui-session-failure": "השיחה שלך פגה. נא להיכנס שוב.",
"wikibase-error-ui-edit-conflict": "אירעה התנגשות עריכה. נא לרענן את
הדף ולשמור מחדש.",
"wikibase-quantitydetails-amount": "כמות",
"wikibase-quantitydetails-upperbound": "גבול עליון",
@@ -58,7 +54,7 @@
"wikibase-parse-error-entity-id": "מזהה הישות אינו תקין.",
"wikibase-parse-error-quantity": "ערך הכמות אינו תקין.",
"wikibase-parse-error-time": "ערך הזמן אינו תקין.",
- "wikibase-replicationnote": "יש לשים לב לכך שייקח מספר דקות עד
שהשינויים יוצגו בכל אתרי הוויקי",
+ "wikibase-replicationnote": "יש לשים לב שייתכן שייקח מספר דקות עד
שהשינויים יוצגו בכל אתרי הוויקי.",
"wikibase-sitelinks-wikipedia": "דפי ויקיפדיה שמקושרים לפריט הזה",
"wikibase-sitelinks-sitename-columnheading": "שפה",
"wikibase-sitelinks-sitename-columnheading-special": "אתר",
@@ -84,8 +80,6 @@
"wikibase-validator-bad-value-type": "סוג הערך $1 אינו נכון, זה היה
אמור להיות $2",
"wikibase-validator-bad-url": "כתובת URL בלתי־תקינה: $1",
"wikibase-validator-bad-url-scheme": "סכמת URL לא נתמכת: $1",
- "wikibase-validator-bad-http-url": "כתובת URL של HTTP בלתי־תקינה: $1",
- "wikibase-validator-bad-mailto-url": "כתובת URL של mailto בלתי־תקינה:
$1",
"wikibase-validator-unknown-unit": "יחידה בלתי־ידועה: $1",
"wikibase-validator-not-allowed": "ערך בלתי־תקין: $1",
"datatypes-type-wikibase-item": "פריט",
diff --git a/extensions/Wikibase/lib/includes/store/EntityInfoTermLookup.php
b/extensions/Wikibase/lib/includes/store/EntityInfoTermLookup.php
new file mode 100644
index 0000000..bc2d677
--- /dev/null
+++ b/extensions/Wikibase/lib/includes/store/EntityInfoTermLookup.php
@@ -0,0 +1,145 @@
+<?php
+
+namespace Wikibase\Lib\Store;
+
+use OutOfBoundsException;
+use Wikibase\DataModel\Entity\EntityId;
+
+/**
+ * TermLookup based on plain array data structures.
+ * This allows term lookups to be performed directly on prefetched data,
+ * such as the data structured generated by EntityInfoBuilder.
+ *
+ * @see EntityInfoBuilder
+ *
+ * @since 0.5
+ *
+ * @licence GNU GPL v2+
+ * @author Daniel Kinzler
+ */
+class EntityInfoTermLookup implements TermLookup {
+
+ /**
+ * @var array
+ */
+ private $entityRecords;
+
+ /**
+ * @param array $entityRecords An array of entity records, as returned
+ * by EntityInfoBuilder::getEntityInfo.
+ */
+ public function __construct( array $entityRecords ) {
+ $this->entityRecords = $entityRecords;
+ }
+
+ /**
+ * @param EntityId $entityId
+ * @param string $field
+ * @param string $languageCode
+ *
+ * @return string|null
+ * @throws OutOfBoundsException
+ */
+ private function getValue( EntityId $entityId, $field, $languageCode ) {
+ $id = $entityId->getSerialization();
+
+ if ( !isset( $this->entityRecords[$id] ) ) {
+ throw new OutOfBoundsException( 'No terms known for
entity ' . $id );
+ }
+
+ if ( !isset( $this->entityRecords[$id][$field] ) ) {
+ throw new OutOfBoundsException( 'No ' . $field . '
known for entity ' . $id );
+ }
+
+ if ( !isset( $this->entityRecords[$id][$field][$languageCode] )
) {
+ throw new OutOfBoundsException( 'No ' . $field . '
known in ' . $languageCode . ' for entity ' . $id );
+ }
+
+ $value = $this->entityRecords[$id][$field][$languageCode];
+
+ if ( is_array( $value ) ) {
+ // $value may be a record with "language" and "value"
fields.
+ $value = $value['value'];
+ }
+
+ return $value;
+ }
+
+ /**
+ * @param EntityId $entityId
+ * @param string $field
+ *
+ * @return string[]
+ */
+ private function getLanguageToValueMapping( EntityId $entityId, $field
) {
+ $id = $entityId->getSerialization();
+
+ if ( !isset( $this->entityRecords[$id] ) ) {
+ return array();
+ }
+
+ if ( !isset( $this->entityRecords[$id][$field] ) ) {
+ return array();
+ }
+
+ $values = array();
+
+ foreach ( $this->entityRecords[$id][$field] as $languageCode =>
$value ) {
+ if ( is_array( $value ) ) {
+ // $value may be a record with "language" and
"value" fields.
+ $value = $value['value'];
+ }
+
+ $values[$languageCode] = $value;
+ }
+
+ return $values;
+ }
+
+ /**
+ * Gets the label of an Entity with the specified EntityId and language
code.
+ *
+ * @param EntityId $entityId
+ * @param string $languageCode
+ *
+ * @return string
+ */
+ public function getLabel( EntityId $entityId, $languageCode ) {
+ return $this->getValue( $entityId, 'labels', $languageCode );
+ }
+
+ /**
+ * Gets all labels of an Entity with the specified EntityId.
+ *
+ * @param EntityId $entityId
+ *
+ * @return string[]
+ */
+ public function getLabels( EntityId $entityId ) {
+ return $this->getLanguageToValueMapping( $entityId, 'labels' );
+ }
+
+ /**
+ * Gets the description of an Entity with the specified EntityId and
language code.
+ *
+ * @param EntityId $entityId
+ * @param string $languageCode
+ *
+ * @return string
+ */
+ public function getDescription( EntityId $entityId, $languageCode ) {
+ return $this->getValue( $entityId, 'descriptions',
$languageCode );
+ }
+
+ /**
+ * Gets all descriptions of an Entity with the specified EntityId.
+ *
+ * @param EntityId $entityId
+ *
+ * @return string[]
+ */
+ public function getDescriptions( EntityId $entityId ) {
+ return $this->getLanguageToValueMapping( $entityId,
'descriptions' );
+ }
+
+}
diff --git a/extensions/Wikibase/lib/includes/store/TermLookup.php
b/extensions/Wikibase/lib/includes/store/TermLookup.php
index 067fe35..4c1b065 100644
--- a/extensions/Wikibase/lib/includes/store/TermLookup.php
+++ b/extensions/Wikibase/lib/includes/store/TermLookup.php
@@ -23,6 +23,7 @@
* @throws OutOfBoundsException for label not found
* @throws StorageException for Entity not found
* @return string
+ * @throws OutOfBoundsException if no such label was found
*/
public function getLabel( EntityId $entityId, $languageCode );
@@ -32,7 +33,7 @@
* @param EntityId $entityId
*
* @throws StorageException for Entity not found
- * @return string[]
+ * @return string[] labels, keyed by language.
*/
public function getLabels( EntityId $entityId );
@@ -45,6 +46,7 @@
* @throws OutOfBoundsException for description not found
* @throws StorageException for Entity not found
* @return string
+ * @throws OutOfBoundsException if no such description was found
*/
public function getDescription( EntityId $entityId, $languageCode );
@@ -54,7 +56,7 @@
* @param EntityId $entityId
*
* @throws StorageException for Entity not found
- * @return string[]
+ * @return string[] descriptions, keyed by language.
*/
public function getDescriptions( EntityId $entityId );
diff --git
a/extensions/Wikibase/lib/tests/phpunit/store/EntityInfoTermLookupTest.php
b/extensions/Wikibase/lib/tests/phpunit/store/EntityInfoTermLookupTest.php
new file mode 100644
index 0000000..8a74e10
--- /dev/null
+++ b/extensions/Wikibase/lib/tests/phpunit/store/EntityInfoTermLookupTest.php
@@ -0,0 +1,125 @@
+<?php
+
+namespace Wikibase\Test;
+
+use Wikibase\DataModel\Entity\EntityId;
+use Wikibase\DataModel\Entity\ItemId;
+use Wikibase\Lib\Store\EntityInfoTermLookup;
+
+/**
+ * @covers Wikibase\Lib\Store\EntityInfoTermLookup
+ *
+ * @licence GNU GPL v2+
+ * @author Katie Filbert
+ * @author Daniel Kinzler
+ */
+class EntityInfoTermLookupTest extends \MediaWikiTestCase {
+
+ public function testGetLabel() {
+ $termLookup = $this->getEntityInfoTermLookup();
+
+ $label = $termLookup->getLabel( new ItemId( 'Q116' ), 'en' );
+ $this->assertEquals( 'New York City', $label );
+ }
+
+ public function testGetLabel_notFoundThrowsException() {
+ $termLookup = $this->getEntityInfoTermLookup();
+
+ $this->setExpectedException( 'OutOfBoundsException' );
+ $termLookup->getLabel( new ItemId( 'Q120' ), 'en' );
+ }
+
+ /**
+ * @dataProvider getLabelsProvider
+ */
+ public function testGetLabels( $expected, EntityId $entityId ) {
+ $termLookup = $this->getEntityInfoTermLookup();
+
+ $labels = $termLookup->getLabels( $entityId );
+ $this->assertEquals( $expected, $labels );
+ }
+
+ public function getLabelsProvider() {
+ return array(
+ array(
+ array( 'en' => 'New York City', 'es' => 'Nueva
York' ),
+ new ItemId( 'Q116' )
+ ),
+ array(
+ array(),
+ new ItemId( 'Q120' )
+ )
+ );
+ }
+
+ public function testGetDescription() {
+ $termLookup = $this->getEntityInfoTermLookup();
+
+ $description = $termLookup->getDescription( new ItemId( 'Q116'
), 'de' );
+ $expected = 'Metropole an der Ostküste der Vereinigten Staaten';
+
+ $this->assertEquals( $expected, $description );
+ }
+
+ public function testGetDescription_notFoundThrowsException() {
+ $termLookup = $this->getEntityInfoTermLookup();
+
+ $this->setExpectedException( 'OutOfBoundsException' );
+ $termLookup->getDescription( new ItemId( 'Q90000' ), 'fr' );
+ }
+
+ /**
+ * @dataProvider getDescriptionsProvider
+ */
+ public function getDescriptions( $expected, EntityId $entityId ) {
+ $termLookup = $this->getEntityInfoTermLookup();
+
+ $descriptions = $termLookup->getDescriptions( $entityId );
+ $this->assertEquals( $expected, $descriptions );
+ }
+
+ public function getDescriptionsProvider() {
+ return array(
+ array(
+ array(
+ 'de' => 'Metropole an der Ostküste der
Vereinigten Staaten',
+ 'en' => 'largest city in New York and
the United States of America',
+ ),
+ new ItemId( 'Q116' )
+ ),
+ array(
+ array(),
+ new ItemId( 'Q90001' )
+ )
+ );
+ }
+
+ private function getEntityInfoTermLookup() {
+ $entityInfo = $this->makeEntityInfo();
+ return new EntityInfoTermLookup( $entityInfo );
+ }
+
+ private function makeEntityInfo() {
+ $entityInfo = array(
+ 'Q116' => array(
+ 'labels' => array(
+ 'en' => array( 'language' => 'en',
'value' => 'New York City' ),
+ 'es' => 'Nueva York', // terse form
also supported
+ ),
+ 'descriptions' => array(
+ 'en' => array( 'language' => 'en',
'value' => 'largest city in New York and the United States of America' ),
+ 'de' => array( 'language' => 'de',
'value' => 'Metropole an der Ostküste der Vereinigten Staaten' ),
+ ),
+ ),
+
+ 'Q117' => array(
+ 'labels' => array(
+ 'de' => array( 'language' => 'de',
'value' => 'Berlin' ),
+ ),
+ ),
+ );
+
+ return $entityInfo;
+ }
+
+}
diff --git
a/extensions/Wikibase/lib/tests/phpunit/store/EntityTermLookupTest.php
b/extensions/Wikibase/lib/tests/phpunit/store/EntityTermLookupTest.php
index c237da9..f1236b8 100644
--- a/extensions/Wikibase/lib/tests/phpunit/store/EntityTermLookupTest.php
+++ b/extensions/Wikibase/lib/tests/phpunit/store/EntityTermLookupTest.php
@@ -6,6 +6,12 @@
use Wikibase\DataModel\Entity\ItemId;
use Wikibase\Lib\Store\EntityTermLookup;
+/**
+ * @covers Wikibase\Lib\Store\EntityTermLookup
+ *
+ * @licence GNU GPL v2+
+ * @author Katie Filbert
+ */
class EntityTermLookupTest extends \MediaWikiTestCase {
public function testGetLabel() {
diff --git a/vendor/autoload.php b/vendor/autoload.php
index 912457a..0f7bba6 100644
--- a/vendor/autoload.php
+++ b/vendor/autoload.php
@@ -4,4 +4,4 @@
require_once __DIR__ . '/composer' . '/autoload_real.php';
-return ComposerAutoloaderInitc03c5367b04efb09b1008931ac5a6d08::getLoader();
+return ComposerAutoloaderInit4f772306d798bbc71934c9c46e1cb4b9::getLoader();
diff --git a/vendor/composer/autoload_classmap.php
b/vendor/composer/autoload_classmap.php
index a098546..ed9689f 100644
--- a/vendor/composer/autoload_classmap.php
+++ b/vendor/composer/autoload_classmap.php
@@ -458,6 +458,7 @@
'Wikibase\\DataModel\\Snak\\SnakRole' => $vendorDir .
'/wikibase/data-model/src/Snak/SnakRole.php',
'Wikibase\\DataModel\\Snak\\Snaks' => $vendorDir .
'/wikibase/data-model/src/Snak/Snaks.php',
'Wikibase\\DataModel\\Snak\\TypedSnak' => $vendorDir .
'/wikibase/data-model/src/Snak/TypedSnak.php',
+ 'Wikibase\\DataModel\\StatementListProvider' => $vendorDir .
'/wikibase/data-model/src/StatementListProvider.php',
'Wikibase\\DataModel\\Statement\\BestStatementsFinder' => $vendorDir .
'/wikibase/data-model/src/Statement/BestStatementsFinder.php',
'Wikibase\\DataModel\\Statement\\Statement' => $vendorDir .
'/wikibase/data-model/src/Statement/Statement.php',
'Wikibase\\DataModel\\Statement\\StatementList' => $vendorDir .
'/wikibase/data-model/src/Statement/StatementList.php',
@@ -607,6 +608,7 @@
'Wikibase\\Lib\\Store\\EntityContentDataCodec' => $baseDir .
'/extensions/Wikibase/lib/includes/store/EntityContentDataCodec.php',
'Wikibase\\Lib\\Store\\EntityInfoBuilder' => $baseDir .
'/extensions/Wikibase/lib/includes/store/EntityInfoBuilder.php',
'Wikibase\\Lib\\Store\\EntityInfoBuilderFactory' => $baseDir .
'/extensions/Wikibase/lib/includes/store/EntityInfoBuilderFactory.php',
+ 'Wikibase\\Lib\\Store\\EntityInfoTermLookup' => $baseDir .
'/extensions/Wikibase/lib/includes/store/EntityInfoTermLookup.php',
'Wikibase\\Lib\\Store\\EntityLookup' => $baseDir .
'/extensions/Wikibase/lib/includes/store/EntityLookup.php',
'Wikibase\\Lib\\Store\\EntityRedirect' => $baseDir .
'/extensions/Wikibase/lib/includes/store/EntityRedirect.php',
'Wikibase\\Lib\\Store\\EntityRedirectResolvingDecorator' => $baseDir .
'/extensions/Wikibase/lib/includes/store/EntityRedirectResolvingDecorator.php',
@@ -920,6 +922,7 @@
'Wikibase\\Test\\EntityIdLinkFormatterTest' => $baseDir .
'/extensions/Wikibase/lib/tests/phpunit/formatters/EntityIdLinkFormatterTest.php',
'Wikibase\\Test\\EntityIdTitleFormatterTest' => $baseDir .
'/extensions/Wikibase/lib/tests/phpunit/formatters/EntityIdTitleFormatterTest.php',
'Wikibase\\Test\\EntityInfoBuilderTest' => $baseDir .
'/extensions/Wikibase/lib/tests/phpunit/store/EntityInfoBuilderTest.php',
+ 'Wikibase\\Test\\EntityInfoTermLookupTest' => $baseDir .
'/extensions/Wikibase/lib/tests/phpunit/store/EntityInfoTermLookupTest.php',
'Wikibase\\Test\\EntityModificationTestHelper' => $baseDir .
'/extensions/Wikibase/repo/tests/phpunit/includes/EntityModificationTestHelper.php',
'Wikibase\\Test\\EntityNamespaceLookupTest' => $baseDir .
'/extensions/Wikibase/repo/tests/phpunit/includes/EntityNamespaceLookupTest.php',
'Wikibase\\Test\\EntityParserOutputGeneratorTest' => $baseDir .
'/extensions/Wikibase/repo/tests/phpunit/includes/EntityParserOutputGeneratorTest.php',
diff --git a/vendor/composer/autoload_real.php
b/vendor/composer/autoload_real.php
index f03e13a..370859b 100644
--- a/vendor/composer/autoload_real.php
+++ b/vendor/composer/autoload_real.php
@@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
-class ComposerAutoloaderInitc03c5367b04efb09b1008931ac5a6d08
+class ComposerAutoloaderInit4f772306d798bbc71934c9c46e1cb4b9
{
private static $loader;
@@ -19,9 +19,9 @@
return self::$loader;
}
-
spl_autoload_register(array('ComposerAutoloaderInitc03c5367b04efb09b1008931ac5a6d08',
'loadClassLoader'), true, true);
+
spl_autoload_register(array('ComposerAutoloaderInit4f772306d798bbc71934c9c46e1cb4b9',
'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
-
spl_autoload_unregister(array('ComposerAutoloaderInitc03c5367b04efb09b1008931ac5a6d08',
'loadClassLoader'));
+
spl_autoload_unregister(array('ComposerAutoloaderInit4f772306d798bbc71934c9c46e1cb4b9',
'loadClassLoader'));
$map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) {
@@ -42,14 +42,14 @@
$includeFiles = require __DIR__ . '/autoload_files.php';
foreach ($includeFiles as $file) {
- composerRequirec03c5367b04efb09b1008931ac5a6d08($file);
+ composerRequire4f772306d798bbc71934c9c46e1cb4b9($file);
}
return $loader;
}
}
-function composerRequirec03c5367b04efb09b1008931ac5a6d08($file)
+function composerRequire4f772306d798bbc71934c9c46e1cb4b9($file)
{
require $file;
}
diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json
index 8ac0a57..86e2eab 100644
--- a/vendor/composer/installed.json
+++ b/vendor/composer/installed.json
@@ -682,17 +682,17 @@
},
{
"name": "wikibase/data-model",
- "version": "2.1.1",
- "version_normalized": "2.1.1.0",
+ "version": "2.2.0",
+ "version_normalized": "2.2.0.0",
"source": {
"type": "git",
"url": "https://github.com/wmde/WikibaseDataModel.git",
- "reference": "ddb7d18bcd8ed835d3ebdfc20c7a22e0df4049e6"
+ "reference": "5077367f7585615a583cbe291c868ca8ffbd1faa"
},
"dist": {
"type": "zip",
- "url":
"https://api.github.com/repos/wmde/WikibaseDataModel/zipball/ddb7d18bcd8ed835d3ebdfc20c7a22e0df4049e6",
- "reference": "ddb7d18bcd8ed835d3ebdfc20c7a22e0df4049e6",
+ "url":
"https://api.github.com/repos/wmde/WikibaseDataModel/zipball/5077367f7585615a583cbe291c868ca8ffbd1faa",
+ "reference": "5077367f7585615a583cbe291c868ca8ffbd1faa",
"shasum": ""
},
"require": {
@@ -703,11 +703,11 @@
"require-dev": {
"whatthejeff/nyancat-phpunit-resultprinter": "~1.2"
},
- "time": "2014-10-28 13:04:15",
+ "time": "2014-11-10 16:30:27",
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "2.1.x-dev"
+ "dev-master": "2.2.x-dev"
}
},
"installation-source": "dist",
@@ -1127,12 +1127,12 @@
"source": {
"type": "git",
"url":
"https://github.com/wikimedia/mediawiki-extensions-Wikibase.git",
- "reference": "dab7bb5af4a00c25b12c235924899a73a0e0b8c9"
+ "reference": "e88d9cce5d56570182820734a3887e3de424df12"
},
"dist": {
"type": "zip",
- "url":
"https://api.github.com/repos/wikimedia/mediawiki-extensions-Wikibase/zipball/dab7bb5af4a00c25b12c235924899a73a0e0b8c9",
- "reference": "dab7bb5af4a00c25b12c235924899a73a0e0b8c9",
+ "url":
"https://api.github.com/repos/wikimedia/mediawiki-extensions-Wikibase/zipball/e88d9cce5d56570182820734a3887e3de424df12",
+ "reference": "e88d9cce5d56570182820734a3887e3de424df12",
"shasum": ""
},
"require": {
@@ -1159,7 +1159,7 @@
"conflict": {
"mediawiki/mediawiki": "<1.23"
},
- "time": "2014-11-09 20:55:23",
+ "time": "2014-11-11 10:28:38",
"type": "mediawiki-extension",
"installation-source": "dist",
"autoload": {
@@ -1304,17 +1304,17 @@
},
{
"name": "propertysuggester/property-suggester",
- "version": "1.1.4",
- "version_normalized": "1.1.4.0",
+ "version": "1.1.5",
+ "version_normalized": "1.1.5.0",
"source": {
"type": "git",
"url": "https://github.com/Wikidata-lib/PropertySuggester.git",
- "reference": "c8cdc7061b8a44e021eb2b3a98e83ff1cd18787e"
+ "reference": "0d106a6cb2e30a34cdec2e0eda52cca66a479733"
},
"dist": {
"type": "zip",
- "url":
"https://api.github.com/repos/Wikidata-lib/PropertySuggester/zipball/c8cdc7061b8a44e021eb2b3a98e83ff1cd18787e",
- "reference": "c8cdc7061b8a44e021eb2b3a98e83ff1cd18787e",
+ "url":
"https://api.github.com/repos/Wikidata-lib/PropertySuggester/zipball/0d106a6cb2e30a34cdec2e0eda52cca66a479733",
+ "reference": "0d106a6cb2e30a34cdec2e0eda52cca66a479733",
"shasum": ""
},
"require": {
@@ -1324,7 +1324,7 @@
"phpunit/phpunit": "3.7.*",
"satooshi/php-coveralls": "dev-master"
},
- "time": "2014-10-22 13:21:31",
+ "time": "2014-11-10 15:13:08",
"type": "mediawiki-extension",
"installation-source": "dist",
"autoload": {
diff --git a/vendor/wikibase/data-model/RELEASE-NOTES.md
b/vendor/wikibase/data-model/RELEASE-NOTES.md
index a900fb1..847e9ab 100644
--- a/vendor/wikibase/data-model/RELEASE-NOTES.md
+++ b/vendor/wikibase/data-model/RELEASE-NOTES.md
@@ -1,5 +1,11 @@
# Wikibase DataModel release notes
+## Version 2.2.0 (2014-11-10)
+
+* `Item` and `Property` now implement `StatementListProvider`
+* Introduced the `StatementListProvider` interface for classes containing a
`StatementList`
+* Added rank comparison to `Statement::equals`
+
## Version 2.1.0 (2014-10-27)
* `ReferenceList` now implements `Serializable`
diff --git a/vendor/wikibase/data-model/WikibaseDataModel.php
b/vendor/wikibase/data-model/WikibaseDataModel.php
index 2a2e1e2..e318bdf 100644
--- a/vendor/wikibase/data-model/WikibaseDataModel.php
+++ b/vendor/wikibase/data-model/WikibaseDataModel.php
@@ -12,7 +12,7 @@
return 1;
}
-define( 'WIKIBASE_DATAMODEL_VERSION', '2.1.1' );
+define( 'WIKIBASE_DATAMODEL_VERSION', '2.2.0' );
if ( defined( 'MEDIAWIKI' ) ) {
call_user_func( function() {
diff --git a/vendor/wikibase/data-model/composer.json
b/vendor/wikibase/data-model/composer.json
index ceb79d1..b59893c 100644
--- a/vendor/wikibase/data-model/composer.json
+++ b/vendor/wikibase/data-model/composer.json
@@ -38,7 +38,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "2.1.x-dev"
+ "dev-master": "2.2.x-dev"
}
}
}
diff --git a/vendor/wikibase/data-model/src/ByPropertyIdArray.php
b/vendor/wikibase/data-model/src/ByPropertyIdArray.php
index 1b55fbf..280801b 100644
--- a/vendor/wikibase/data-model/src/ByPropertyIdArray.php
+++ b/vendor/wikibase/data-model/src/ByPropertyIdArray.php
@@ -122,7 +122,7 @@
$this->assertIndexIsBuild();
if ( !( array_key_exists( $propertyId->getSerialization(),
$this->byId ) ) ) {
- throw new OutOfBoundsException( 'Property id array key
does not exist.' );
+ throw new OutOfBoundsException( 'Object with propertyId
"' . $propertyId->getSerialization() . '" not found' );
}
return $this->byId[$propertyId->getSerialization()];
diff --git a/vendor/wikibase/data-model/src/ByPropertyIdGrouper.php
b/vendor/wikibase/data-model/src/ByPropertyIdGrouper.php
index de76723..25832c0 100644
--- a/vendor/wikibase/data-model/src/ByPropertyIdGrouper.php
+++ b/vendor/wikibase/data-model/src/ByPropertyIdGrouper.php
@@ -33,12 +33,12 @@
private function assertArePropertyIdProviders( $propertyIdProviders ) {
if ( !is_array( $propertyIdProviders ) && !(
$propertyIdProviders instanceof Traversable ) ) {
- throw new InvalidArgumentException(
'$propertyIdProviders should be an array or a Traversable' );
+ throw new InvalidArgumentException(
'$propertyIdProviders must be an array or an instance of Traversable' );
}
foreach ( $propertyIdProviders as $propertyIdProvider ) {
if ( !( $propertyIdProvider instanceof
PropertyIdProvider ) ) {
- throw new InvalidArgumentException( 'All
elements need implement PropertyIdProvider' );
+ throw new InvalidArgumentException( 'Every
element in $propertyIdProviders must be an instance of PropertyIdProvider' );
}
}
}
@@ -89,7 +89,7 @@
$idSerialization = $propertyId->getSerialization();
if ( !isset( $this->byPropertyId[$idSerialization] ) ) {
- throw new OutOfBoundsException( 'Property id does not
exist.' );
+ throw new OutOfBoundsException( 'PropertyIdProvider
with propertyId "' . $idSerialization . '" not found' );
}
return $this->byPropertyId[$idSerialization];
diff --git a/vendor/wikibase/data-model/src/Claim/Claim.php
b/vendor/wikibase/data-model/src/Claim/Claim.php
index 25aa950..f158c62 100644
--- a/vendor/wikibase/data-model/src/Claim/Claim.php
+++ b/vendor/wikibase/data-model/src/Claim/Claim.php
@@ -14,7 +14,7 @@
/**
* Class that represents a single Wikibase claim.
- * See https://meta.wikimedia.org/wiki/Wikidata/Data_model#Statements
+ * See https://www.mediawiki.org/wiki/Wikibase/DataModel#Statements
*
* @since 0.4 (as 'ClaimObject' and interface 'Claim' since 0.1)
*
@@ -164,7 +164,7 @@
*/
public function setGuid( $guid ) {
if ( !is_string( $guid ) && $guid !== null ) {
- throw new InvalidArgumentException( 'Can only set the
GUID to string values or null' );
+ throw new InvalidArgumentException( '$guid must be a
string or null; got ' . gettype( $guid ) );
}
$this->guid = $guid;
@@ -193,11 +193,11 @@
* @return Snak[]
*/
public function getAllSnaks() {
- $snaks = array();
+ $snaks = array( $this->mainSnak );
- $snaks[] = $this->getMainSnak();
- $qualifiers = $this->getQualifiers();
- $snaks = array_merge( $snaks, iterator_to_array( $qualifiers )
);
+ foreach( $this->qualifiers as $qualifier ) {
+ $snaks[] = $qualifier;
+ }
return $snaks;
}
diff --git a/vendor/wikibase/data-model/src/Claim/ClaimGuid.php
b/vendor/wikibase/data-model/src/Claim/ClaimGuid.php
index c810ec3..3312d59 100644
--- a/vendor/wikibase/data-model/src/Claim/ClaimGuid.php
+++ b/vendor/wikibase/data-model/src/Claim/ClaimGuid.php
@@ -30,10 +30,10 @@
*/
public function __construct( $entityId, $guid ) {
if( !$entityId instanceof EntityId ){
- throw new InvalidArgumentException( '$entityId needs to
be an EntityId' );
+ throw new InvalidArgumentException( '$entityId must be
an instance of EntityId' );
}
if( !is_string( $guid ) ){
- throw new InvalidArgumentException( '$guid needs to be
a string' );
+ throw new InvalidArgumentException( '$guid must be a
string; got ' . gettype( $guid ) );
}
$this->serialization = $entityId->getSerialization() .
self::SEPARATOR . $guid;
diff --git a/vendor/wikibase/data-model/src/Claim/ClaimGuidParser.php
b/vendor/wikibase/data-model/src/Claim/ClaimGuidParser.php
index 5797f93..e2f2434 100644
--- a/vendor/wikibase/data-model/src/Claim/ClaimGuidParser.php
+++ b/vendor/wikibase/data-model/src/Claim/ClaimGuidParser.php
@@ -32,7 +32,7 @@
*/
public function parse( $serialization ) {
if ( !is_string( $serialization ) ) {
- throw new ClaimGuidParsingException( '$serialization
needs to be a string' );
+ throw new ClaimGuidParsingException( '$serialization
must be a string; got ' . gettype( $serialization ) );
}
$keyParts = explode( ClaimGuid::SEPARATOR, $serialization );
@@ -44,4 +44,4 @@
return new ClaimGuid( $this->entityIdParser->parse(
$keyParts[0] ), $keyParts[1] );
}
-}
\ No newline at end of file
+}
diff --git a/vendor/wikibase/data-model/src/Claim/ClaimList.php
b/vendor/wikibase/data-model/src/Claim/ClaimList.php
index 850af35..ded25ab 100644
--- a/vendor/wikibase/data-model/src/Claim/ClaimList.php
+++ b/vendor/wikibase/data-model/src/Claim/ClaimList.php
@@ -35,7 +35,7 @@
}
if ( !is_array( $claims ) ) {
- throw new InvalidArgumentException( '$claims should be
an array' );
+ throw new InvalidArgumentException( '$claims must be an
array; got ' . gettype( $claims ) );
}
$this->claims = $claims;
diff --git a/vendor/wikibase/data-model/src/Claim/Claims.php
b/vendor/wikibase/data-model/src/Claim/Claims.php
index c889032..ad5208e 100644
--- a/vendor/wikibase/data-model/src/Claim/Claims.php
+++ b/vendor/wikibase/data-model/src/Claim/Claims.php
@@ -38,7 +38,7 @@
if ( $input !== null ) {
if ( !is_array( $input ) && !( $input instanceof
Traversable ) ) {
- throw new InvalidArgumentException( '$input
must be traversable' );
+ throw new InvalidArgumentException( '$input
must be an array or an instance of Traversable' );
}
foreach ( $input as $claim ) {
@@ -55,7 +55,7 @@
*/
private function getGuidKey( $guid ) {
if ( !is_string( $guid ) ) {
- throw new InvalidArgumentException( 'Expected a GUID
string' );
+ throw new InvalidArgumentException( '$guid must be a
string; got ' . gettype( $guid ) );
}
$key = strtoupper( $guid );
@@ -93,7 +93,7 @@
*/
public function addClaim( Claim $claim, $index = null ) {
if ( !is_null( $index ) && !is_integer( $index ) ) {
- throw new InvalidArgumentException( 'Index needs to be
null or an integer value' );
+ throw new InvalidArgumentException( '$index must be an
integer or null; got ' . gettype( $index ) );
} else if ( is_null( $index ) || $index >= count( $this ) ) {
$this[] = $claim;
} else {
@@ -269,7 +269,7 @@
*/
public function offsetSet( $guid, $claim ) {
if ( !( $claim instanceof Claim ) ) {
- throw new InvalidArgumentException( 'Expected a Claim
instance' );
+ throw new InvalidArgumentException( '$claim must be an
instance of Claim' );
}
$claimKey = $this->getClaimKey( $claim );
diff --git a/vendor/wikibase/data-model/src/Entity/Diff/ItemDiffer.php
b/vendor/wikibase/data-model/src/Entity/Diff/ItemDiffer.php
index 7f4dd36..dada5a3 100644
--- a/vendor/wikibase/data-model/src/Entity/Diff/ItemDiffer.php
+++ b/vendor/wikibase/data-model/src/Entity/Diff/ItemDiffer.php
@@ -58,7 +58,7 @@
private function assertIsItem( EntityDocument $item ) {
if ( !( $item instanceof Item ) ) {
- throw new InvalidArgumentException( 'All entities need
to be items' );
+ throw new InvalidArgumentException( '$item must be an
instance of Item' );
}
}
diff --git a/vendor/wikibase/data-model/src/Entity/Diff/ItemPatcher.php
b/vendor/wikibase/data-model/src/Entity/Diff/ItemPatcher.php
index ce171c3..4bcd32d 100644
--- a/vendor/wikibase/data-model/src/Entity/Diff/ItemPatcher.php
+++ b/vendor/wikibase/data-model/src/Entity/Diff/ItemPatcher.php
@@ -60,7 +60,7 @@
private function assertIsItem( EntityDocument $item ) {
if ( !( $item instanceof Item ) ) {
- throw new InvalidArgumentException( 'All entities need
to be items' );
+ throw new InvalidArgumentException( '$item must be an
instance of Item' );
}
}
diff --git a/vendor/wikibase/data-model/src/Entity/Diff/PropertyDiffer.php
b/vendor/wikibase/data-model/src/Entity/Diff/PropertyDiffer.php
index 249a316..ad88b18 100644
--- a/vendor/wikibase/data-model/src/Entity/Diff/PropertyDiffer.php
+++ b/vendor/wikibase/data-model/src/Entity/Diff/PropertyDiffer.php
@@ -55,9 +55,9 @@
return $this->diffProperties( $from, $to );
}
- private function assertIsProperty( EntityDocument $item ) {
- if ( !( $item instanceof Property ) ) {
- throw new InvalidArgumentException( 'All entities need
to be properties' );
+ private function assertIsProperty( EntityDocument $property ) {
+ if ( !( $property instanceof Property ) ) {
+ throw new InvalidArgumentException( '$property must be
an instance of Property' );
}
}
@@ -76,12 +76,12 @@
return $this->recursiveMapDiffer->doDiff( $from, $to );
}
- private function toDiffArray( Property $item ) {
+ private function toDiffArray( Property $property ) {
$array = array();
- $array['aliases'] = $item->getAllAliases();
- $array['label'] = $item->getLabels();
- $array['description'] = $item->getDescriptions();
+ $array['aliases'] = $property->getAllAliases();
+ $array['label'] = $property->getLabels();
+ $array['description'] = $property->getDescriptions();
return $array;
}
@@ -116,4 +116,4 @@
return new EntityDiff( $diffOps );
}
-}
\ No newline at end of file
+}
diff --git a/vendor/wikibase/data-model/src/Entity/Diff/PropertyPatcher.php
b/vendor/wikibase/data-model/src/Entity/Diff/PropertyPatcher.php
index 16274f3..9825197 100644
--- a/vendor/wikibase/data-model/src/Entity/Diff/PropertyPatcher.php
+++ b/vendor/wikibase/data-model/src/Entity/Diff/PropertyPatcher.php
@@ -54,7 +54,7 @@
private function assertIsProperty( EntityDocument $property ) {
if ( !( $property instanceof Property ) ) {
- throw new InvalidArgumentException( 'All entities need
to be properties' );
+ throw new InvalidArgumentException( '$property must be
an instance of Property' );
}
}
diff --git
a/vendor/wikibase/data-model/src/Entity/DispatchingEntityIdParser.php
b/vendor/wikibase/data-model/src/Entity/DispatchingEntityIdParser.php
index f2c7255..a49b94a 100644
--- a/vendor/wikibase/data-model/src/Entity/DispatchingEntityIdParser.php
+++ b/vendor/wikibase/data-model/src/Entity/DispatchingEntityIdParser.php
@@ -55,7 +55,7 @@
*/
private function assertIdIsString( $idSerialization ) {
if ( !is_string( $idSerialization ) ) {
- throw new EntityIdParsingException( 'Entity id
serializations need to be strings' );
+ throw new EntityIdParsingException( '$idSerialization
must be a string; got ' . gettype( $idSerialization ) );
}
}
diff --git a/vendor/wikibase/data-model/src/Entity/Entity.php
b/vendor/wikibase/data-model/src/Entity/Entity.php
index a4fe462..cb02a6c 100644
--- a/vendor/wikibase/data-model/src/Entity/Entity.php
+++ b/vendor/wikibase/data-model/src/Entity/Entity.php
@@ -19,7 +19,7 @@
/**
* Represents a single Wikibase entity.
- * See https://meta.wikimedia.org/wiki/Wikidata/Data_model#Values
+ * See https://www.mediawiki.org/wiki/Wikibase/DataModel#Values
*
* @deprecated since 1.0 - do not type hint against Entity. See
* https://lists.wikimedia.org/pipermail/wikidata-tech/2014-June/000489.html
@@ -446,11 +446,12 @@
* @return Snak[]
*/
public function getAllSnaks() {
- $claims = $this->getClaims();
$snaks = array();
- foreach ( $claims as $claim ) {
- $snaks = array_merge( $snaks, $claim->getAllSnaks() );
+ foreach ( $this->getClaims() as $claim ) {
+ foreach( $claim->getAllSnaks() as $snak ) {
+ $snaks[] = $snak;
+ }
}
return $snaks;
diff --git a/vendor/wikibase/data-model/src/Entity/EntityIdValue.php
b/vendor/wikibase/data-model/src/Entity/EntityIdValue.php
index e7594fb..8135953 100644
--- a/vendor/wikibase/data-model/src/Entity/EntityIdValue.php
+++ b/vendor/wikibase/data-model/src/Entity/EntityIdValue.php
@@ -140,7 +140,7 @@
*/
public static function newFromArray( $data ) {
if ( !is_array( $data ) ) {
- throw new IllegalValueException( "array expected" );
+ throw new IllegalValueException( '$data must be an
array; got ' . gettype( $data ) );
}
if ( !array_key_exists( 'entity-type', $data ) ) {
diff --git a/vendor/wikibase/data-model/src/Entity/InMemoryDataTypeLookup.php
b/vendor/wikibase/data-model/src/Entity/InMemoryDataTypeLookup.php
index 64822c2..245cdbb 100644
--- a/vendor/wikibase/data-model/src/Entity/InMemoryDataTypeLookup.php
+++ b/vendor/wikibase/data-model/src/Entity/InMemoryDataTypeLookup.php
@@ -53,7 +53,7 @@
private function verifyDataTypeIdType( $dataTypeId ) {
if ( !is_string( $dataTypeId ) ) {
- throw new InvalidArgumentException( '$dataTypeId needs
to be a string' );
+ throw new InvalidArgumentException( '$dataTypeId must
be a string; got ' . gettype( $dataTypeId ) );
}
}
diff --git a/vendor/wikibase/data-model/src/Entity/Item.php
b/vendor/wikibase/data-model/src/Entity/Item.php
index 381433e..1279b42 100644
--- a/vendor/wikibase/data-model/src/Entity/Item.php
+++ b/vendor/wikibase/data-model/src/Entity/Item.php
@@ -2,10 +2,6 @@
namespace Wikibase\DataModel\Entity;
-use Diff\Comparer\CallbackComparer;
-use Diff\DiffOp\Diff\Diff;
-use Diff\Patcher\ListPatcher;
-use Diff\Patcher\MapPatcher;
use InvalidArgumentException;
use OutOfBoundsException;
use Wikibase\DataModel\Claim\Claim;
@@ -15,18 +11,19 @@
use Wikibase\DataModel\Snak\Snak;
use Wikibase\DataModel\Statement\Statement;
use Wikibase\DataModel\Statement\StatementList;
+use Wikibase\DataModel\StatementListProvider;
use Wikibase\DataModel\Term\Fingerprint;
/**
* Represents a single Wikibase item.
- * See https://meta.wikimedia.org/wiki/Wikidata/Data_model#Items
+ * See https://www.mediawiki.org/wiki/Wikibase/DataModel#Items
*
* @since 0.1
*
* @licence GNU GPL v2+
* @author Jeroen De Dauw < [email protected] >
*/
-class Item extends Entity {
+class Item extends Entity implements StatementListProvider {
const ENTITY_TYPE = 'item';
@@ -71,11 +68,8 @@
else if ( is_integer( $id ) ) {
$this->id = ItemId::newFromNumber( $id );
}
- else if ( $id instanceof EntityId ) {
- $this->id = new ItemId( $id->getSerialization() );
- }
else {
- throw new InvalidArgumentException( __METHOD__ . ' only
accepts ItemId, integer and null' );
+ throw new InvalidArgumentException( '$id must be an
instance of ItemId, an integer, or null' );
}
}
@@ -252,7 +246,7 @@
*/
public function addClaim( Claim $statement ) {
if ( !( $statement instanceof Statement ) ) {
- throw new InvalidArgumentException( 'Claims are not
supported any more, use Statements.' );
+ throw new InvalidArgumentException( '$statement must be
an instance of Statement' );
} elseif ( $statement->getGuid() === null ) {
throw new InvalidArgumentException( 'Can\'t add a Claim
without a GUID.' );
}
diff --git a/vendor/wikibase/data-model/src/Entity/ItemId.php
b/vendor/wikibase/data-model/src/Entity/ItemId.php
index 0820ac5..fb68444 100644
--- a/vendor/wikibase/data-model/src/Entity/ItemId.php
+++ b/vendor/wikibase/data-model/src/Entity/ItemId.php
@@ -26,11 +26,11 @@
private function assertValidIdFormat( $idSerialization ) {
if ( !is_string( $idSerialization ) ) {
- throw new InvalidArgumentException( 'The id
serialization needs to be a string.' );
+ throw new InvalidArgumentException( '$idSerialization
must be a string; got ' . gettype( $idSerialization ) );
}
if ( !preg_match( self::PATTERN, $idSerialization ) ) {
- throw new InvalidArgumentException( 'Invalid ItemId
serialization provided.' );
+ throw new InvalidArgumentException( '$idSerialization
must match ' . self::PATTERN );
}
}
@@ -80,7 +80,7 @@
*/
public static function newFromNumber( $numericId ) {
if ( !is_numeric( $numericId ) ) {
- throw new InvalidArgumentException( '$number needs to
be numeric.' );
+ throw new InvalidArgumentException( '$numericId must be
numeric' );
}
return new self( 'Q' . $numericId );
diff --git a/vendor/wikibase/data-model/src/Entity/ItemIdSet.php
b/vendor/wikibase/data-model/src/Entity/ItemIdSet.php
index 0780928..2af338e 100644
--- a/vendor/wikibase/data-model/src/Entity/ItemIdSet.php
+++ b/vendor/wikibase/data-model/src/Entity/ItemIdSet.php
@@ -31,7 +31,7 @@
public function __construct( array $ids = array() ) {
foreach ( $ids as $id ) {
if ( !( $id instanceof ItemId ) ) {
- throw new InvalidArgumentException( 'ItemIdSet
can only contain instances of ItemId' );
+ throw new InvalidArgumentException( 'Every
element in $ids must be an instance of ItemId' );
}
$this->ids[$id->getNumericId()] = $id;
diff --git a/vendor/wikibase/data-model/src/Entity/Property.php
b/vendor/wikibase/data-model/src/Entity/Property.php
index d458a68..61a8718 100644
--- a/vendor/wikibase/data-model/src/Entity/Property.php
+++ b/vendor/wikibase/data-model/src/Entity/Property.php
@@ -5,17 +5,18 @@
use InvalidArgumentException;
use Wikibase\DataModel\Statement\StatementList;
use Wikibase\DataModel\Term\Fingerprint;
+use Wikibase\DataModel\StatementListProvider;
/**
* Represents a single Wikibase property.
- * See https://meta.wikimedia.org/wiki/Wikidata/Data_model#Properties
+ * See https://www.mediawiki.org/wiki/Wikibase/DataModel#Properties
*
* @since 0.1
*
* @licence GNU GPL v2+
* @author Jeroen De Dauw < [email protected] >
*/
-class Property extends Entity {
+class Property extends Entity implements StatementListProvider {
const ENTITY_TYPE = 'property';
@@ -60,11 +61,8 @@
else if ( is_integer( $id ) ) {
$this->id = PropertyId::newFromNumber( $id );
}
- else if ( $id instanceof EntityId ) {
- $this->id = new PropertyId( $id->getSerialization() );
- }
else {
- throw new InvalidArgumentException( __METHOD__ . ' only
accepts PropertyId, integer and null' );
+ throw new InvalidArgumentException( '$id must be an
instance of PropertyId, an integer, or null' );
}
}
@@ -86,7 +84,7 @@
*/
public function setDataTypeId( $dataTypeId ) {
if ( !is_string( $dataTypeId ) ) {
- throw new InvalidArgumentException( '$dataTypeId needs
to be a string' );
+ throw new InvalidArgumentException( '$dataTypeId must
be a string; got ' . gettype( $dataTypeId ) );
}
$this->dataTypeId = $dataTypeId;
diff --git a/vendor/wikibase/data-model/src/Entity/PropertyId.php
b/vendor/wikibase/data-model/src/Entity/PropertyId.php
index d76831b..e697e9e 100644
--- a/vendor/wikibase/data-model/src/Entity/PropertyId.php
+++ b/vendor/wikibase/data-model/src/Entity/PropertyId.php
@@ -26,11 +26,11 @@
private function assertValidIdFormat( $idSerialization ) {
if ( !is_string( $idSerialization ) ) {
- throw new InvalidArgumentException( 'The id
serialization needs to be a string.' );
+ throw new InvalidArgumentException( '$idSerialization
must be a string; got ' . gettype( $idSerialization ) );
}
if ( !preg_match( self::PATTERN, $idSerialization ) ) {
- throw new InvalidArgumentException( 'Invalid PropertyId
serialization provided.' );
+ throw new InvalidArgumentException( '$idSerialization
must match ' . self::PATTERN );
}
}
@@ -80,7 +80,7 @@
*/
public static function newFromNumber( $numericId ) {
if ( !is_numeric( $numericId ) ) {
- throw new InvalidArgumentException( '$number needs to
be numeric.' );
+ throw new InvalidArgumentException( '$numericId must be
numeric' );
}
return new self( 'P' . $numericId );
diff --git a/vendor/wikibase/data-model/src/HashArray.php
b/vendor/wikibase/data-model/src/HashArray.php
index 80af972..3aa345f 100644
--- a/vendor/wikibase/data-model/src/HashArray.php
+++ b/vendor/wikibase/data-model/src/HashArray.php
@@ -414,10 +414,7 @@
if ( !$this->hasValidType( $value ) ) {
$type = is_object( $value ) ? get_class( $value ) :
gettype( $value );
- throw new InvalidArgumentException(
- 'Can only add ' . $this->getObjectType() . '
implementing objects to ' . get_called_class() . ', ' .
- 'but got a ' . $type . ' instead'
- );
+ throw new InvalidArgumentException( '$value must be an
instance of ' . $this->getObjectType() . '; got ' . $type );
}
if ( is_null( $index ) ) {
diff --git a/vendor/wikibase/data-model/src/Internal/MapValueHasher.php
b/vendor/wikibase/data-model/src/Internal/MapValueHasher.php
index 46a672d..cb69eaf 100644
--- a/vendor/wikibase/data-model/src/Internal/MapValueHasher.php
+++ b/vendor/wikibase/data-model/src/Internal/MapValueHasher.php
@@ -34,7 +34,7 @@
*/
public function hash( $map ) {
if ( !is_array( $map ) && !( $map instanceof Traversable ) ) {
- throw new InvalidArgumentException( 'MapHasher::hash
only accepts Traversable objects (including arrays)' );
+ throw new InvalidArgumentException( '$map must be an
array or an instance of Traversable' );
}
$hashes = array();
diff --git a/vendor/wikibase/data-model/src/Reference.php
b/vendor/wikibase/data-model/src/Reference.php
index e15c8ce..cffdcb0 100644
--- a/vendor/wikibase/data-model/src/Reference.php
+++ b/vendor/wikibase/data-model/src/Reference.php
@@ -9,7 +9,7 @@
/**
* Object that represents a single Wikibase reference.
- * See https://meta.wikimedia.org/wiki/Wikidata/Data_model#ReferenceRecords
+ * See https://www.mediawiki.org/wiki/Wikibase/DataModel#ReferenceRecords
*
* @since 0.1, instantiable since 0.4
*
@@ -40,7 +40,7 @@
$this->snaks = new SnakList( $snaks );
}
else {
- throw new InvalidArgumentException();
+ throw new InvalidArgumentException( '$snaks must be an
instance of Snaks, an array of instances of Snak, or null' );
}
}
diff --git a/vendor/wikibase/data-model/src/ReferenceList.php
b/vendor/wikibase/data-model/src/ReferenceList.php
index 0cdc6ac..b6b43be 100644
--- a/vendor/wikibase/data-model/src/ReferenceList.php
+++ b/vendor/wikibase/data-model/src/ReferenceList.php
@@ -36,7 +36,7 @@
*/
public function addReference( Reference $reference, $index = null ) {
if( !is_null( $index ) && !is_integer( $index ) ) {
- throw new InvalidArgumentException( 'Index needs to be
an integer value' );
+ throw new InvalidArgumentException( '$index must be an
integer or null; got ' . gettype( $index ) );
} else if ( is_null( $index ) || $index >= count( $this ) ) {
// Append object to the end of the reference list.
$this->attach( $reference );
diff --git a/vendor/wikibase/data-model/src/SiteLink.php
b/vendor/wikibase/data-model/src/SiteLink.php
index fafb2d4..848462d 100644
--- a/vendor/wikibase/data-model/src/SiteLink.php
+++ b/vendor/wikibase/data-model/src/SiteLink.php
@@ -38,11 +38,11 @@
*/
public function __construct( $siteId, $pageName, $badges = null ) {
if ( !is_string( $siteId ) ) {
- throw new InvalidArgumentException( '$siteId needs to
be a string' );
+ throw new InvalidArgumentException( '$siteId must be a
string; got ' . gettype( $siteId ) );
}
if ( !is_string( $pageName ) ) {
- throw new InvalidArgumentException( '$pageName needs to
be a string' );
+ throw new InvalidArgumentException( '$pageName must be
a string; got ' . gettype( $pageName ) );
}
$this->siteId = $siteId;
@@ -56,7 +56,7 @@
} elseif ( is_array( $badges ) ) {
$badges = new ItemIdSet( $badges );
} elseif ( !( $badges instanceof ItemIdSet ) ) {
- throw new InvalidArgumentException( '$badges needs to
be ItemIdSet, ItemId[] or null' );
+ throw new InvalidArgumentException( '$badges must be an
instance of ItemIdSet, an array of instances of ItemId, or null' );
}
$this->badges = $badges;
diff --git a/vendor/wikibase/data-model/src/SiteLinkList.php
b/vendor/wikibase/data-model/src/SiteLinkList.php
index d4ac7c4..154be02 100644
--- a/vendor/wikibase/data-model/src/SiteLinkList.php
+++ b/vendor/wikibase/data-model/src/SiteLinkList.php
@@ -33,7 +33,7 @@
public function __construct( array $siteLinks = array() ) {
foreach ( $siteLinks as $siteLink ) {
if ( !( $siteLink instanceof SiteLink ) ) {
- throw new InvalidArgumentException(
'SiteLinkList only accepts SiteLink objects' );
+ throw new InvalidArgumentException( 'Every
element of $siteLinks must be an instance of SiteLink' );
}
$this->addSiteLink( $siteLink );
@@ -98,7 +98,7 @@
*/
public function getBySiteId( $siteId ) {
if ( !$this->hasLinkWithSiteId( $siteId ) ) {
- throw new OutOfBoundsException( 'No SiteLink with site
id: ' . $siteId );
+ throw new OutOfBoundsException( 'SiteLink with siteId
"' . $siteId . '" not found' );
}
return $this->siteLinks[$siteId];
@@ -114,7 +114,7 @@
*/
public function hasLinkWithSiteId( $siteId ) {
if ( !is_string( $siteId ) ) {
- throw new InvalidArgumentException( '$siteId should be
a string' );
+ throw new InvalidArgumentException( '$siteId must be a
string; got ' . gettype( $siteId ) );
}
return array_key_exists( $siteId, $this->siteLinks );
@@ -154,7 +154,7 @@
*/
public function removeLinkWithSiteId( $siteId ) {
if ( !is_string( $siteId ) ) {
- throw new InvalidArgumentException( '$siteId should be
a string' );
+ throw new InvalidArgumentException( '$siteId must be a
string; got ' . gettype( $siteId ) );
}
unset( $this->siteLinks[$siteId] );
diff --git a/vendor/wikibase/data-model/src/Snak/PropertyNoValueSnak.php
b/vendor/wikibase/data-model/src/Snak/PropertyNoValueSnak.php
index 5d707d5..909ee5b 100644
--- a/vendor/wikibase/data-model/src/Snak/PropertyNoValueSnak.php
+++ b/vendor/wikibase/data-model/src/Snak/PropertyNoValueSnak.php
@@ -4,7 +4,7 @@
/**
* Class representing a property no value snak.
- * See https://meta.wikimedia.org/wiki/Wikidata/Data_model#PropertyNoValueSnak
+ * See https://www.mediawiki.org/wiki/Wikibase/DataModel#PropertyNoValueSnak
*
* @since 0.1
*
diff --git a/vendor/wikibase/data-model/src/Snak/PropertySomeValueSnak.php
b/vendor/wikibase/data-model/src/Snak/PropertySomeValueSnak.php
index 23b3ff0..2499e02 100644
--- a/vendor/wikibase/data-model/src/Snak/PropertySomeValueSnak.php
+++ b/vendor/wikibase/data-model/src/Snak/PropertySomeValueSnak.php
@@ -4,7 +4,7 @@
/**
* Class representing a property some value snak.
- * See https://meta.wikimedia.org/wiki/Wikidata/Data_model#PropertyNoValueSnak
+ * See https://www.mediawiki.org/wiki/Wikibase/DataModel#PropertyNoValueSnak
*
* @since 0.1
*
diff --git a/vendor/wikibase/data-model/src/Snak/PropertyValueSnak.php
b/vendor/wikibase/data-model/src/Snak/PropertyValueSnak.php
index 8785f93..7ec7225 100644
--- a/vendor/wikibase/data-model/src/Snak/PropertyValueSnak.php
+++ b/vendor/wikibase/data-model/src/Snak/PropertyValueSnak.php
@@ -8,7 +8,7 @@
/**
* Class representing a property value snak.
- * See https://meta.wikimedia.org/wiki/Wikidata/Data_model#PropertyValueSnak
+ * See https://www.mediawiki.org/wiki/Wikibase/DataModel#PropertyValueSnak
*
* @since 0.1
*
diff --git a/vendor/wikibase/data-model/src/Snak/Snak.php
b/vendor/wikibase/data-model/src/Snak/Snak.php
index 6048b30..dd32481 100644
--- a/vendor/wikibase/data-model/src/Snak/Snak.php
+++ b/vendor/wikibase/data-model/src/Snak/Snak.php
@@ -10,7 +10,7 @@
/**
* Interface for objects that represent a single Wikibase snak.
- * See https://meta.wikimedia.org/wiki/Wikidata/Data_model#Snaks
+ * See https://www.mediawiki.org/wiki/Wikibase/DataModel#Snaks
*
* @since 0.1
*
diff --git a/vendor/wikibase/data-model/src/Snak/SnakObject.php
b/vendor/wikibase/data-model/src/Snak/SnakObject.php
index 4ecd774..bb812ea 100644
--- a/vendor/wikibase/data-model/src/Snak/SnakObject.php
+++ b/vendor/wikibase/data-model/src/Snak/SnakObject.php
@@ -9,7 +9,7 @@
/**
* Base class for snaks.
- * See https://meta.wikimedia.org/wiki/Wikidata/Data_model#Snaks
+ * See https://www.mediawiki.org/wiki/Wikibase/DataModel#Snaks
*
* @since 0.1
*
@@ -41,11 +41,11 @@
}
if ( !$propertyId instanceof EntityId ) {
- throw new InvalidArgumentException( '$propertyId should
be a PropertyId' );
+ throw new InvalidArgumentException( '$propertyId must
be an instance of EntityId' );
}
if ( $propertyId->getEntityType() !== Property::ENTITY_TYPE ) {
- throw new InvalidArgumentException( 'The $propertyId of
a property snak can only be an ID of a Property object' );
+ throw new InvalidArgumentException( '$propertyId must
have an entityType of ' . Property::ENTITY_TYPE );
}
if ( !( $propertyId instanceof PropertyId ) ) {
diff --git a/vendor/wikibase/data-model/src/Statement/Statement.php
b/vendor/wikibase/data-model/src/Statement/Statement.php
index 8d4b5cc..a1dd41d 100644
--- a/vendor/wikibase/data-model/src/Statement/Statement.php
+++ b/vendor/wikibase/data-model/src/Statement/Statement.php
@@ -11,7 +11,7 @@
/**
* Class representing a Wikibase statement.
- * See https://meta.wikimedia.org/wiki/Wikidata/Data_model#Statements
+ * See https://www.mediawiki.org/wiki/Wikibase/DataModel#Statements
*
* @since 0.1
*
@@ -41,7 +41,7 @@
private $rank = self::RANK_NORMAL;
/**
- * @since 0.1
+ * @since 2.0
*
* @param Claim $claim
* @param ReferenceList|null $references
@@ -145,8 +145,9 @@
/* @var Reference $reference */
foreach( $this->getReferences() as $reference ) {
- $referenceSnaks = $reference->getSnaks();
- $snaks = array_merge( $snaks, iterator_to_array(
$referenceSnaks ) );
+ foreach( $reference->getSnaks() as $referenceSnak ) {
+ $snaks[] = $referenceSnak;
+ }
}
return $snaks;
@@ -167,6 +168,7 @@
}
return $this->claimFieldsEqual( $target )
+ && $this->rank === $target->getRank()
&& $this->references->equals( $target->references );
}
diff --git a/vendor/wikibase/data-model/src/Statement/StatementList.php
b/vendor/wikibase/data-model/src/Statement/StatementList.php
index f3d2334..bfadc27 100644
--- a/vendor/wikibase/data-model/src/Statement/StatementList.php
+++ b/vendor/wikibase/data-model/src/Statement/StatementList.php
@@ -51,12 +51,12 @@
private function assertAreStatements( $statements ) {
if ( !is_array( $statements ) && !( $statements instanceof
Traversable ) ) {
- throw new InvalidArgumentException( '$statements should
be an array or a Traversable' );
+ throw new InvalidArgumentException( '$statements must
be an array or an instance of Traversable' );
}
foreach ( $statements as $statement ) {
if ( !( $statement instanceof Statement ) ) {
- throw new InvalidArgumentException( 'All
elements need to be of type Statement' );
+ throw new InvalidArgumentException( 'Every
element in $statements must be an instance of Statement' );
}
}
}
@@ -138,9 +138,13 @@
*/
public function getAllSnaks() {
$snaks = array();
+
foreach ( $this->statements as $statement ) {
- $snaks = array_merge( $snaks, $statement->getAllSnaks()
);
+ foreach( $statement->getAllSnaks() as $snak ) {
+ $snaks[] = $snak;
+ }
}
+
return $snaks;
}
diff --git a/vendor/wikibase/data-model/src/Statement/StatementListDiffer.php
b/vendor/wikibase/data-model/src/Statement/StatementListDiffer.php
index 167c527..3213b41 100644
--- a/vendor/wikibase/data-model/src/Statement/StatementListDiffer.php
+++ b/vendor/wikibase/data-model/src/Statement/StatementListDiffer.php
@@ -4,13 +4,7 @@
use Diff\Differ\MapDiffer;
use Diff\DiffOp\Diff\Diff;
-use Diff\DiffOp\DiffOp;
-use Diff\DiffOp\DiffOpAdd;
-use Diff\DiffOp\DiffOpChange;
-use Diff\DiffOp\DiffOpRemove;
use UnexpectedValueException;
-use Wikibase\DataModel\Claim\Claim;
-use Wikibase\DataModel\Claim\Claims;
/**
* @since 1.0
@@ -30,48 +24,36 @@
* @throws UnexpectedValueException
*/
public function getDiff( StatementList $fromStatements, StatementList
$toStatements ) {
- $differ = new MapDiffer();
- $fromStatements = new Claims( $fromStatements->toArray() );
- $toStatements = new Claims( $toStatements->toArray() );
-
- $hashDifferences = $differ->doDiff(
- $fromStatements->getHashes(),
- $toStatements->getHashes()
+ return new Diff(
+ $this->newDiffer()->doDiff(
+ $this->toDiffArray( $fromStatements ),
+ $this->toDiffArray( $toStatements )
+ ),
+ true
);
-
- $diff = new Diff( array(), true );
-
- foreach ( $hashDifferences as $guid => $diffOp ) {
- $diff[$guid] = $this->getDiffOp( $diffOp, $guid,
$toStatements, $fromStatements );
- }
-
- return $diff;
}
- private function getDiffOp( DiffOp $diffOp, $guid, Claims $toClaims,
Claims $fromClaims ) {
- if ( $diffOp instanceof DiffOpChange ) {
- $oldClaim = $fromClaims->getClaimWithGuid( $guid );
- $newClaim = $toClaims->getClaimWithGuid( $guid );
+ private function newDiffer() {
+ $differ = new MapDiffer();
- if ( !( $oldClaim instanceof Claim
- && $newClaim instanceof Claim
- && $oldClaim->getGuid() ===
$newClaim->getGuid() ) ) {
- throw new UnexpectedValueException( 'Invalid
operands' );
- }
+ $differ->setComparisonCallback( function( Statement
$fromStatement, Statement $toStatement ) {
+ return $fromStatement->equals( $toStatement );
+ } );
- return new DiffOpChange( $oldClaim, $newClaim );
+ return $differ;
+ }
+
+ private function toDiffArray( StatementList $statementList ) {
+ $statementArray = array();
+
+ /**
+ * @var Statement $statement
+ */
+ foreach ( $statementList as $statement ) {
+ $statementArray[$statement->getGuid()] = $statement;
}
- elseif ( $diffOp instanceof DiffOpAdd ) {
- $claim = $toClaims->getClaimWithGuid( $guid );
- return new DiffOpAdd( $claim );
- }
- elseif ( $diffOp instanceof DiffOpRemove ) {
- $claim = $fromClaims->getClaimWithGuid( $guid );
- return new DiffOpRemove( $claim );
- }
- else {
- throw new UnexpectedValueException( 'Invalid DiffOp
type cannot be handled' );
- }
+
+ return $statementArray;
}
}
diff --git a/vendor/wikibase/data-model/src/StatementListProvider.php
b/vendor/wikibase/data-model/src/StatementListProvider.php
new file mode 100644
index 0000000..d9de9b0
--- /dev/null
+++ b/vendor/wikibase/data-model/src/StatementListProvider.php
@@ -0,0 +1,22 @@
+<?php
+
+namespace Wikibase\DataModel;
+
+use Wikibase\DataModel\Statement\StatementList;
+
+/**
+ * Interface for classes that contain a StatementList.
+ *
+ * @since 2.2.0
+ *
+ * @license GNU GPL v2+
+ * @author Marius Hoch < [email protected] >
+ */
+interface StatementListProvider {
+
+ /**
+ * @return StatementList
+ */
+ public function getStatements();
+
+}
diff --git a/vendor/wikibase/data-model/src/Term/AliasGroup.php
b/vendor/wikibase/data-model/src/Term/AliasGroup.php
index 6e0b137..addc0ed 100644
--- a/vendor/wikibase/data-model/src/Term/AliasGroup.php
+++ b/vendor/wikibase/data-model/src/Term/AliasGroup.php
@@ -34,7 +34,7 @@
private function setLanguageCode( $languageCode ) {
if ( !is_string( $languageCode ) ) {
- throw new InvalidArgumentException( '$languageCode
needs to be a string' );
+ throw new InvalidArgumentException( '$languageCode must
be a string; got ' . gettype( $languageCode ) );
}
$this->languageCode = $languageCode;
@@ -43,7 +43,7 @@
private function setAliases( array $aliases ) {
foreach ( $aliases as $alias ) {
if ( !is_string( $alias ) ) {
- throw new InvalidArgumentException( 'All
elements in $aliases need to be strings' );
+ throw new InvalidArgumentException( 'Every
element in $aliases must be a string; found ' . gettype( $alias ) );
}
}
diff --git a/vendor/wikibase/data-model/src/Term/AliasGroupList.php
b/vendor/wikibase/data-model/src/Term/AliasGroupList.php
index 54b9c64..213a395 100644
--- a/vendor/wikibase/data-model/src/Term/AliasGroupList.php
+++ b/vendor/wikibase/data-model/src/Term/AliasGroupList.php
@@ -34,7 +34,7 @@
public function __construct( array $aliasGroups = array() ) {
foreach ( $aliasGroups as $aliasGroup ) {
if ( !( $aliasGroup instanceof AliasGroup ) ) {
- throw new InvalidArgumentException(
'AliasGroupList can only contain AliasGroup instances' );
+ throw new InvalidArgumentException( 'Every
element in $aliasGroups must be an instance of AliasGroup' );
}
$this->setGroup( $aliasGroup );
@@ -68,9 +68,7 @@
$this->assertIsLanguageCode( $languageCode );
if ( !array_key_exists( $languageCode, $this->groups ) ) {
- throw new OutOfBoundsException(
- 'There is no AliasGroup with language code "' .
$languageCode . '" in the list'
- );
+ throw new OutOfBoundsException( 'AliasGroup with
languageCode "' . $languageCode . '" not found' );
}
return $this->groups[$languageCode];
@@ -87,7 +85,7 @@
private function assertIsLanguageCode( $languageCode ) {
if ( !is_string( $languageCode ) ) {
- throw new InvalidArgumentException( '$languageCode
should be a string' );
+ throw new InvalidArgumentException( '$languageCode must
be a string; got ' . gettype( $languageCode ) );
}
}
diff --git a/vendor/wikibase/data-model/src/Term/Term.php
b/vendor/wikibase/data-model/src/Term/Term.php
index 37eca26..7e0a39c 100644
--- a/vendor/wikibase/data-model/src/Term/Term.php
+++ b/vendor/wikibase/data-model/src/Term/Term.php
@@ -26,11 +26,11 @@
*/
public function __construct( $languageCode, $text ) {
if ( !is_string( $languageCode ) ) {
- throw new InvalidArgumentException( '$languageCode
should be a string' );
+ throw new InvalidArgumentException( '$languageCode must
be a string; got ' . gettype( $languageCode ) );
}
if ( !is_string( $text ) ) {
- throw new InvalidArgumentException( '$text should be a
string' );
+ throw new InvalidArgumentException( '$text must be a
string; got ' . gettype( $text ) );
}
$this->languageCode = $languageCode;
diff --git a/vendor/wikibase/data-model/src/Term/TermList.php
b/vendor/wikibase/data-model/src/Term/TermList.php
index 7fd9607..918c172 100644
--- a/vendor/wikibase/data-model/src/Term/TermList.php
+++ b/vendor/wikibase/data-model/src/Term/TermList.php
@@ -32,7 +32,7 @@
public function __construct( array $terms = array() ) {
foreach ( $terms as $term ) {
if ( !( $term instanceof Term ) ) {
- throw new InvalidArgumentException( 'TermList
can only contain instances of Term' );
+ throw new InvalidArgumentException( 'Every
element in $terms must be an instance of Term' );
}
$this->terms[$term->getLanguageCode()] = $term;
@@ -81,9 +81,7 @@
$this->assertIsLanguageCode( $languageCode );
if ( !array_key_exists( $languageCode, $this->terms ) ) {
- throw new OutOfBoundsException(
- 'There is no Term with language code "' .
$languageCode . '" in the list'
- );
+ throw new OutOfBoundsException( 'Term with languageCode
"' . $languageCode . '" not found' );
}
return $this->terms[$languageCode];
@@ -101,7 +99,7 @@
private function assertIsLanguageCode( $languageCode ) {
if ( !is_string( $languageCode ) ) {
- throw new InvalidArgumentException( '$languageCode
should be a string' );
+ throw new InvalidArgumentException( '$languageCode must
be a string; got ' . gettype( $languageCode ) );
}
}
diff --git
a/vendor/wikibase/data-model/tests/unit/Entity/PropertyNotFoundExceptionTest.php
b/vendor/wikibase/data-model/tests/unit/Entity/PropertyNotFoundExceptionTest.php
index 179699c..c76bf0e 100644
---
a/vendor/wikibase/data-model/tests/unit/Entity/PropertyNotFoundExceptionTest.php
+++
b/vendor/wikibase/data-model/tests/unit/Entity/PropertyNotFoundExceptionTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Wikibase\Lib\Test;
+namespace Wikibase\Test\Entity;
use Wikibase\DataModel\Entity\PropertyId;
use Wikibase\DataModel\Entity\PropertyNotFoundException;
diff --git
a/vendor/wikibase/data-model/tests/unit/Statement/StatementListDifferTest.php
b/vendor/wikibase/data-model/tests/unit/Statement/StatementListDifferTest.php
index 0492ef3..2ac9d5d 100644
---
a/vendor/wikibase/data-model/tests/unit/Statement/StatementListDifferTest.php
+++
b/vendor/wikibase/data-model/tests/unit/Statement/StatementListDifferTest.php
@@ -2,19 +2,19 @@
namespace Wikibase\Test;
+use DataValues\StringValue;
use Diff\DiffOp\Diff\Diff;
use Diff\DiffOp\DiffOpAdd;
use Diff\DiffOp\DiffOpChange;
use Diff\DiffOp\DiffOpRemove;
+use Wikibase\DataModel\Claim\Claim;
+use Wikibase\DataModel\Snak\PropertyValueSnak;
+use Wikibase\DataModel\Statement\Statement;
use Wikibase\DataModel\Statement\StatementList;
use Wikibase\DataModel\Statement\StatementListDiffer;
/**
* @covers Wikibase\DataModel\Statement\StatementListDiffer
- *
- * @group Wikibase
- * @group WikibaseDataModel
- * @group WikibaseClaim
*
* @licence GNU GPL v2+
* @author Jeroen De Dauw < [email protected] >
@@ -25,101 +25,92 @@
$this->assertResultsInDiff( new StatementList(), new
StatementList(), new Diff() );
}
- private function assertResultsInDiff( StatementList $fromClaims,
StatementList $toClaims, Diff $diff ) {
+ private function assertResultsInDiff( StatementList $fromStatements,
StatementList $toStatements, Diff $diff ) {
$differ = new StatementListDiffer();
- $actual = $differ->getDiff( $fromClaims, $toClaims );
+ $actual = $differ->getDiff( $fromStatements, $toStatements );
$this->assertEquals( $diff, $actual );
}
public function testGivenTwoIdenticalLists_diffIsEmpty() {
- $claims = new StatementList( array(
- $this->getStubStatement( 'zero', 'first' ),
- $this->getStubStatement( 'one', 'second' ),
+ $statements = new StatementList( array(
+ $this->getNewStatement( 'zero', 'first' ),
+ $this->getNewStatement( 'one', 'second' ),
) );
- $this->assertResultsInDiff( $claims, $claims, new Diff() );
+ $this->assertResultsInDiff( $statements, $statements, new
Diff() );
}
- private function getStubStatement( $guid, $hash ) {
- $claim = $this->getMockBuilder(
'Wikibase\DataModel\Statement\Statement' )
- ->disableOriginalConstructor()->getMock();
-
- $claim->expects( $this->any() )
- ->method( 'getGuid' )
- ->will( $this->returnValue( $guid ) );
-
- $claim->expects( $this->any() )
- ->method( 'getHash' )
- ->will( $this->returnValue( $hash ) );
-
- return $claim;
+ private function getNewStatement( $guid, $hash ) {
+ $statement = new Statement( new Claim( new PropertyValueSnak(
1, new StringValue( $hash ) ) ) );
+ $statement->setGuid( $guid );
+ return $statement;
}
- public function testGivenToListWithExtraClaim_additionOperationInDiff()
{
- $fromClaims = new StatementList( array(
- $this->getStubStatement( 'zero', 'first' ),
- $this->getStubStatement( 'one', 'second' ),
+ public function
testGivenToListWithExtraStatement_additionOperationInDiff() {
+ $fromStatements = new StatementList( array(
+ $this->getNewStatement( 'zero', 'first' ),
+ $this->getNewStatement( 'one', 'second' ),
) );
- $toClaims = new StatementList( array(
- $this->getStubStatement( 'zero', 'first' ),
- $this->getStubStatement( 'two', 'third' ),
- $this->getStubStatement( 'one', 'second' ),
+ $toStatements = new StatementList( array(
+ $this->getNewStatement( 'zero', 'first' ),
+ $this->getNewStatement( 'two', 'third' ),
+ $this->getNewStatement( 'one', 'second' ),
) );
$diff = new Diff( array(
- 'two' => new DiffOpAdd( $this->getStubStatement( 'two',
'third' ) ),
+ 'two' => new DiffOpAdd( $this->getNewStatement( 'two',
'third' ) ),
) );
- $this->assertResultsInDiff( $fromClaims, $toClaims, $diff );
+ $this->assertResultsInDiff( $fromStatements, $toStatements,
$diff );
}
- public function testGivenToListWithLessClaims_removalOperationsInDiff()
{
- $fromClaims = new StatementList( array(
- $this->getStubStatement( 'zero', 'first' ),
- $this->getStubStatement( 'one', 'second' ),
- $this->getStubStatement( 'two', 'third' ),
+ public function
testGivenToListWithLessStatements_removalOperationsInDiff() {
+ $fromStatements = new StatementList( array(
+ $this->getNewStatement( 'zero', 'first' ),
+ $this->getNewStatement( 'one', 'second' ),
+ $this->getNewStatement( 'two', 'third' ),
) );
- $toClaims = new StatementList( array(
- $this->getStubStatement( 'one', 'second' ),
+ $toStatements = new StatementList( array(
+ $this->getNewStatement( 'one', 'second' ),
) );
$diff = new Diff( array(
- 'zero' => new DiffOpRemove( $this->getStubStatement(
'zero', 'first' ) ),
- 'two' => new DiffOpRemove( $this->getStubStatement(
'zero', 'third' ) ),
+ 'zero' => new DiffOpRemove( $this->getNewStatement(
'zero', 'first' ) ),
+ 'two' => new DiffOpRemove( $this->getNewStatement(
'two', 'third' ) ),
) );
- $this->assertResultsInDiff( $fromClaims, $toClaims, $diff );
+ $this->assertResultsInDiff( $fromStatements, $toStatements,
$diff );
}
- public function testGivenListWithChangedClaims_changeOperationsInDiff()
{
- $fromClaims = new StatementList( array(
- $this->getStubStatement( 'zero', 'first' ),
- $this->getStubStatement( 'one', 'second' ),
- $this->getStubStatement( 'two', 'third' ),
+ public function
testGivenListWithChangedStatements_changeOperationsInDiff() {
+ $fromStatements = new StatementList( array(
+ $this->getNewStatement( 'zero', 'first' ),
+ $this->getNewStatement( 'one', 'second' ),
+ $this->getNewStatement( 'two', 'third' ),
) );
- $toClaims = new StatementList( array(
- $this->getStubStatement( 'zero', 'FIRST' ),
- $this->getStubStatement( 'one', 'second' ),
- $this->getStubStatement( 'two', 'THIRD' ),
+ $toStatements = new StatementList( array(
+ $this->getNewStatement( 'zero', 'FIRST' ),
+ $this->getNewStatement( 'one', 'second' ),
+ $this->getNewStatement( 'two', 'THIRD' ),
) );
$diff = new Diff( array(
'zero' => new DiffOpChange(
- $this->getStubStatement( 'zero',
'first' ),
- $this->getStubStatement( 'zero',
'FIRST' )
+ $this->getNewStatement( 'zero', 'first'
),
+ $this->getNewStatement( 'zero', 'FIRST'
)
),
'two' => new DiffOpChange(
- $this->getStubStatement( 'zero',
'third' ),
- $this->getStubStatement( 'zero',
'THIRD' )
+ $this->getNewStatement( 'two', 'third'
),
+ $this->getNewStatement( 'two', 'THIRD' )
),
) );
- $this->assertResultsInDiff( $fromClaims, $toClaims, $diff );
+ $this->assertResultsInDiff( $fromStatements, $toStatements,
$diff );
}
}
diff --git a/vendor/wikibase/data-model/tests/unit/Statement/StatementTest.php
b/vendor/wikibase/data-model/tests/unit/Statement/StatementTest.php
index 0df7ed5..45a09c5 100644
--- a/vendor/wikibase/data-model/tests/unit/Statement/StatementTest.php
+++ b/vendor/wikibase/data-model/tests/unit/Statement/StatementTest.php
@@ -367,4 +367,56 @@
$this->assertSame( $qualifiers, $claim->getQualifiers() );
}
+ public function testEquals() {
+ $statement = $this->newStatement();
+ $target = $this->newStatement();
+
+ $this->assertTrue( $statement->equals( $target ) );
+ }
+
+ /**
+ * @dataProvider notEqualsProvider
+ */
+ public function testNotEquals( Statement $statement, Statement $target,
$message ) {
+ $this->assertFalse( $statement->equals( $target ), $message );
+ }
+
+ public function notEqualsProvider() {
+ $statement = $this->newStatement();
+
+ $statementWithoutQualifiers = $this->newStatement();
+ $statementWithoutQualifiers->getClaim()->setQualifiers( new
SnakList() );
+
+ $statementWithoutReferences = $this->newStatement();
+ $statementWithoutReferences->setReferences( new ReferenceList()
);
+
+ $statementWithPreferredRank = $this->newStatement();
+ $statementWithPreferredRank->setRank( Statement::RANK_PREFERRED
);
+
+ $statementMainSnakNotEqual = $this->newStatement();
+ $statementMainSnakNotEqual->setClaim(
+ new Claim( new PropertyNoValueSnak( 9000 ) )
+ );
+
+ return array(
+ array( $statement, $statementWithoutQualifiers,
'qualifiers not equal' ),
+ array( $statement, $statementWithoutReferences,
'references not equal' ),
+ array( $statement, $statementWithPreferredRank, 'rank
not equal' ),
+ array( $statement, $statementMainSnakNotEqual, 'main
snak not equal' )
+ );
+ }
+
+ private function newStatement() {
+ $qualifiers = new SnakList( array( new PropertyNoValueSnak( 23
) ) );
+
+ $statement = new Statement(
+ new Claim( new PropertyNoValueSnak( 42 ), $qualifiers ),
+ new ReferenceList( array( new PropertyNoValueSnak( 1337
) ) )
+ );
+
+ $statement->setRank( Statement::RANK_NORMAL );
+
+ return $statement;
+ }
+
}
--
To view, visit https://gerrit.wikimedia.org/r/172526
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I0c71d54a00fa400d13ac5badeaedf8ba8d46be63
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikidata
Gerrit-Branch: master
Gerrit-Owner: Tobias Gritschacher <[email protected]>
Gerrit-Reviewer: Addshore <[email protected]>
Gerrit-Reviewer: Aude <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: Tobias Gritschacher <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits