jenkins-bot has submitted this change and it was merged.
Change subject: Reordered GeoCoordinateValue constructor parameters
......................................................................
Reordered GeoCoordinateValue constructor parameters
Moved "precision" parameter to before the globe.
Change-Id: Ie70b8624ce3726fc1703cb4fc11abdf7ac0b2b3d
---
M DataValues/includes/values/GeoCoordinateValue.php
M DataValues/tests/phpunit/includes/values/GeoCoordinateValueTest.php
M ValueParsers/tests/phpunit/api/ApiParseValueTest.php
3 files changed, 42 insertions(+), 41 deletions(-)
Approvals:
Tobias Gritschacher: Looks good to me, approved
jenkins-bot: Verified
diff --git a/DataValues/includes/values/GeoCoordinateValue.php
b/DataValues/includes/values/GeoCoordinateValue.php
index bbfa5bd..8a494df 100644
--- a/DataValues/includes/values/GeoCoordinateValue.php
+++ b/DataValues/includes/values/GeoCoordinateValue.php
@@ -58,15 +58,6 @@
protected $altitude;
/**
- * The globe on which the location resides.
- *
- * @since 0.1
- *
- * @var string|null
- */
- protected $globe;
-
- /**
* The precision of the coordinate.
*
* @since 0.1
@@ -76,17 +67,26 @@
protected $precision;
/**
+ * The globe on which the location resides.
+ *
+ * @since 0.1
+ *
+ * @var string|null
+ */
+ protected $globe;
+
+ /**
* @since 0.1
*
* @param float|int $latitude
* @param float|int $longitude
* @param float|int|null $altitude
+ * param float|int|null $precision
* @param string|null $globe
- * @param float|int|null $precision
*
* @throws IllegalValueException
*/
- public function __construct( $latitude, $longitude, $altitude = null,
$globe = 'http://www.wikidata.org/entity/Q2', $precision = null ) {
+ public function __construct( $latitude, $longitude, $altitude = null,
$precision = null, $globe = 'http://www.wikidata.org/entity/Q2' ) {
// TODO: validate those values!
if ( is_int( $latitude ) ) {
$latitude = (float)$latitude;
@@ -127,8 +127,8 @@
$this->latitude = $latitude;
$this->longitude = $longitude;
$this->altitude = $altitude;
- $this->globe = $globe;
$this->precision = $precision;
+ $this->globe = $globe;
}
/**
@@ -153,8 +153,8 @@
* @throws IllegalValueException
*/
public function unserialize( $value ) {
- list( $latitude, $longitude, $altitude, $globe, $precision ) =
json_decode( $value );
- $this->__construct( $latitude, $longitude, $altitude, $globe,
$precision );
+ list( $latitude, $longitude, $altitude, $precision, $globe ) =
json_decode( $value );
+ $this->__construct( $latitude, $longitude, $altitude,
$precision, $globe );
}
/**
@@ -225,17 +225,6 @@
}
/**
- * Returns the globe on which the location resides.
- *
- * @since 0.1
- *
- * @return string|null
- */
- public function getGlobe() {
- return $this->globe;
- }
-
- /**
* Returns the precision of the coordinate.
*
* TODO: Introduce some constants holding the different precisions and
document. Sync with JS.
@@ -250,6 +239,17 @@
}
/**
+ * Returns the globe on which the location resides.
+ *
+ * @since 0.1
+ *
+ * @return string|null
+ */
+ public function getGlobe() {
+ return $this->globe;
+ }
+
+ /**
* @see DataValue::getArrayValue
*
* @since 0.1
@@ -261,8 +261,8 @@
'latitude' => $this->latitude,
'longitude' => $this->longitude,
'altitude' => $this->altitude,
+ 'precision' => $this->precision,
'globe' => $this->globe,
- 'precision' => $this->precision
);
}
@@ -281,8 +281,8 @@
$data['latitude'],
$data['longitude'],
$data['altitude'],
- $data['globe'],
- $data['precision']
+ $data['precision'],
+ $data['globe']
);
}
diff --git
a/DataValues/tests/phpunit/includes/values/GeoCoordinateValueTest.php
b/DataValues/tests/phpunit/includes/values/GeoCoordinateValueTest.php
index 4e48050..33a3d4a 100644
--- a/DataValues/tests/phpunit/includes/values/GeoCoordinateValueTest.php
+++ b/DataValues/tests/phpunit/includes/values/GeoCoordinateValueTest.php
@@ -111,20 +111,20 @@
$argLists[] = array( false, 42, 4.2, 'foo' );
// #42
- $argLists[] = array( true, 42, 4.2, 9000.1,
'http://www.wikidata.org/entity/Q2' );
- $argLists[] = array( true, 42, 4.2, 9000.1, null );
- $argLists[] = array( true, 4.2, 42, 9000.1, 'terminus' );
- $argLists[] = array( true, 4.2, 42, 0, "Schar's World" );
- $argLists[] = array( true, -42, -4.2, -9000.1, 'coruscant' );
+ $argLists[] = array( true, 42, 4.2, 9000.1, null,
'http://www.wikidata.org/entity/Q2' );
+ $argLists[] = array( true, 42, 4.2, 9000.1, null, null );
+ $argLists[] = array( true, 4.2, 42, 9000.1, null, 'terminus' );
+ $argLists[] = array( true, 4.2, 42, 0, null, "Schar's World" );
+ $argLists[] = array( true, -42, -4.2, -9000.1, null,
'coruscant' );
// #47
- $argLists[] = array( false, 42, 4.2, 9000.1, false );
- $argLists[] = array( false, 42, 4.2, 9000.1, true );
- $argLists[] = array( false, 42, 4.2, 9000.1, 42 );
- $argLists[] = array( false, 42, 4.2, 9000.1, 4.2 );
- $argLists[] = array( false, 42, 4.2, 9000.1, -1 );
- $argLists[] = array( false, 42, 4.2, 9000.1, 0 );
- $argLists[] = array( false, 42, 4.2, 9000.1, array() );
+ $argLists[] = array( false, 42, 4.2, 9000.1, null, false );
+ $argLists[] = array( false, 42, 4.2, 9000.1, null, true );
+ $argLists[] = array( false, 42, 4.2, 9000.1, null, 42 );
+ $argLists[] = array( false, 42, 4.2, 9000.1, null, 4.2 );
+ $argLists[] = array( false, 42, 4.2, 9000.1, null, -1 );
+ $argLists[] = array( false, 42, 4.2, 9000.1, null, 0 );
+ $argLists[] = array( false, 42, 4.2, 9000.1, null, array() );
return $argLists;
}
@@ -176,7 +176,7 @@
* @param array $arguments
*/
public function testGetGlobe( GeoCoordinateValue $geoCoord, array
$arguments ) {
- $expected = array_key_exists( 3, $arguments ) ? $arguments[3] :
'http://www.wikidata.org/entity/Q2';
+ $expected = array_key_exists( 4, $arguments ) ? $arguments[4] :
'http://www.wikidata.org/entity/Q2';
$actual = $geoCoord->getGlobe();
$this->assertTrue(
diff --git a/ValueParsers/tests/phpunit/api/ApiParseValueTest.php
b/ValueParsers/tests/phpunit/api/ApiParseValueTest.php
index 98f8297..c974b1b 100644
--- a/ValueParsers/tests/phpunit/api/ApiParseValueTest.php
+++ b/ValueParsers/tests/phpunit/api/ApiParseValueTest.php
@@ -62,6 +62,7 @@
$this->assertArrayHasKey( 'latitude', $value, 'value
has latitude key' );
$this->assertArrayHasKey( 'longitude', $value, 'value
has longitude key' );
$this->assertArrayHasKey( 'altitude', $value, 'value
has altitude key' );
+ $this->assertArrayHasKey( 'precision', $value, 'value
has precision key' );
$this->assertArrayHasKey( 'globe', $value, 'value has
globe key' );
}
}
--
To view, visit https://gerrit.wikimedia.org/r/67975
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ie70b8624ce3726fc1703cb4fc11abdf7ac0b2b3d
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/DataValues
Gerrit-Branch: master
Gerrit-Owner: Henning Snater <[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