jenkins-bot has submitted this change and it was merged.
Change subject: Removing PHP 5.3 support
......................................................................
Removing PHP 5.3 support
Change-Id: I8e787e75bfe9b17d46cb90b64ce0d51077a88af9
---
M GeoData.i18n.magic.php
M GeoData.i18n.php
M GeoData.php
M includes/Coord.php
M includes/CoordinatesOutput.php
M includes/CoordinatesParserFunction.php
M includes/GeoData.body.php
M includes/Globe.php
M includes/Hooks.php
M includes/Searcher.php
M includes/api/ApiQueryCoordinates.php
M includes/api/ApiQueryGeoSearch.php
M includes/api/ApiQueryGeoSearchDb.php
M includes/api/ApiQueryGeoSearchElastic.php
M load-test.php
M maintenance/updateIndexGranularity.php
M tests/BoundingBoxTest.php
M tests/CoordTest.php
M tests/GeoDataMathTest.php
M tests/GeoSearchTest.php
M tests/MiscGeoDataTest.php
M tests/ParseCoordTest.php
M tests/TagTest.php
23 files changed, 347 insertions(+), 347 deletions(-)
Approvals:
Yurik: Looks good to me, approved
jenkins-bot: Verified
diff --git a/GeoData.i18n.magic.php b/GeoData.i18n.magic.php
index ad7984a..e5e28b7 100644
--- a/GeoData.i18n.magic.php
+++ b/GeoData.i18n.magic.php
@@ -1,15 +1,15 @@
<?php
-$magicWords = array();
+$magicWords = [];
/**
* English
*/
-$magicWords = array();
+$magicWords = [];
/** English (English) */
-$magicWords['en'] = array(
- 'coordinates' => array( 0, 'coordinates' ),
- 'primary' => array( 0, 'primary' ),
-);
+$magicWords['en'] = [
+ 'coordinates' => [ 0, 'coordinates' ],
+ 'primary' => [ 0, 'primary' ],
+];
diff --git a/GeoData.i18n.php b/GeoData.i18n.php
index 41b33d3..ce9e12e 100644
--- a/GeoData.i18n.php
+++ b/GeoData.i18n.php
@@ -10,10 +10,10 @@
*
* This shim maintains compatibility back to MediaWiki 1.17.
*/
-$messages = array();
+$messages = [];
if ( !function_exists( 'wfJsonI18nShim948fecf94b1b10d6' ) ) {
function wfJsonI18nShim948fecf94b1b10d6( $cache, $code, &$cachedData ) {
- $codeSequence = array_merge( array( $code ),
$cachedData['fallbackSequence'] );
+ $codeSequence = array_merge( [ $code ],
$cachedData['fallbackSequence'] );
foreach ( $codeSequence as $csCode ) {
$fileName = dirname( __FILE__ ) . "/i18n/$csCode.json";
if ( is_readable( $fileName ) ) {
diff --git a/GeoData.php b/GeoData.php
index 47b723c..3b27b16 100644
--- a/GeoData.php
+++ b/GeoData.php
@@ -3,14 +3,14 @@
* GeoData extension. Initial author Max Semenik
* License: WTFPL 2.0
*/
-$wgExtensionCredits['other'][] = array(
+$wgExtensionCredits['other'][] = [
'path' => __FILE__,
'name' => 'GeoData',
- 'author' => array( 'Max Semenik' ),
+ 'author' => [ 'Max Semenik' ],
'url' => 'https://www.mediawiki.org/wiki/Extension:GeoData',
'descriptionmsg' => 'geodata-desc',
'license-name' => 'WTFPL',
-);
+];
$dir = __DIR__;
@@ -87,7 +87,7 @@
/**
* Conversion table type --> dim
*/
-$wgTypeToDim = array(
+$wgTypeToDim = [
'country' => 1000000,
'satellite' => 1000000,
'state' => 300000,
@@ -108,7 +108,7 @@
'pass' => 1000,
'camera' => 1000,
'landmark' => 1000,
-);
+];
/**
* Default value of dim if it is unknown
@@ -118,19 +118,19 @@
/**
* Description of globes. Allows to extend or override the defaults from
Globe.php
*/
-$wgGlobes = array(
+$wgGlobes = [
/*
Example definition:
- 'saraksh' => array(
+ 'saraksh' => [
// Range of latitudes
- 'lon' => array( -180, 180 ),
+ 'lon' => [ -180, 180 ],
// What sign should N degrees east have?
'east' => -1,
// Radius in metres. If omitted, no distance calculation will
be possible on this globe
'radius' => 12345678.9,
- ),
+ ],
*/
-);
+];
/**
* Controls what GeoData should do when it encounters some problem.
@@ -139,11 +139,11 @@
* - fail - Consider the tag invalid, display message and add tracking
category
* - none - Do nothing
*/
-$wgGeoDataWarningLevel = array(
+$wgGeoDataWarningLevel = [
'unknown type' => 'track',
'unknown globe' => 'none',
'invalid region' => 'track',
-);
+];
/**
* How many gt_(lat|lon)_int units per degree
@@ -160,7 +160,7 @@
* Specifies which information about page's primary coordinate is added to
global JS variable wgCoordinates.
* Setting it to false or empty array will disable wgCoordinates.
*/
-$wgGeoDataInJS = array( 'lat', 'lon' );
+$wgGeoDataInJS = [ 'lat', 'lon' ];
/**
* Enables the use of GeoData as a CirrusSearch plugin for indexing.
diff --git a/includes/Coord.php b/includes/Coord.php
index a3a8243..73d7e9c 100644
--- a/includes/Coord.php
+++ b/includes/Coord.php
@@ -124,7 +124,7 @@
*/
public function getRow( $pageId ) {
global $wgGeoDataIndexGranularity, $wgGeoDataBackend;
- $row = array( 'gt_page_id' => $pageId );
+ $row = [ 'gt_page_id' => $pageId ];
foreach ( self::$fieldMapping as $field => $column ) {
$row[$column] = $this->$field;
}
@@ -140,14 +140,14 @@
* @return array
*/
public function getAsArray() {
- $result = array();
+ $result = [];
foreach ( self::getFields() as $field ) {
$result[$field] = $this->$field;
}
return $result;
}
- private static $fieldMapping = array(
+ private static $fieldMapping = [
'id' => 'gt_id',
'lat' => 'gt_lat',
'lon' => 'gt_lon',
@@ -158,7 +158,7 @@
'name' => 'gt_name',
'country' => 'gt_country',
'region' => 'gt_region',
- );
+ ];
public static function getFieldMapping() {
return self::$fieldMapping;
diff --git a/includes/CoordinatesOutput.php b/includes/CoordinatesOutput.php
index d1a0d10..da8685f 100644
--- a/includes/CoordinatesOutput.php
+++ b/includes/CoordinatesOutput.php
@@ -10,7 +10,7 @@
class CoordinatesOutput {
public $limitExceeded = false;
private $primary = false,
- $secondary = array();
+ $secondary = [];
public function getCount() {
return count( $this->secondary ) + ( $this->primary ? 1 : 0 );
diff --git a/includes/CoordinatesParserFunction.php
b/includes/CoordinatesParserFunction.php
index 94fbfa2..1061002 100644
--- a/includes/CoordinatesParserFunction.php
+++ b/includes/CoordinatesParserFunction.php
@@ -24,8 +24,8 @@
*/
private $output;
- private $named = array(),
- $unnamed = array();
+ private $named = [],
+ $unnamed = [];
/** @var Globe */
private $globe;
@@ -46,8 +46,8 @@
$this->output->geoData = new CoordinatesOutput();
}
- $this->unnamed = array();
- $this->named = array();
+ $this->unnamed = [];
+ $this->named = [];
$this->parseArgs( $frame, $args );
$this->processArgs();
$status = self::parseCoordinates( $this->unnamed, $this->globe
);
@@ -69,7 +69,7 @@
return '';
}
- return array( "<span class=\"error\">{$errorText}</span>",
'noparse' => false );
+ return [ "<span class=\"error\">{$errorText}</span>", 'noparse'
=> false ];
}
/**
@@ -210,7 +210,7 @@
}
private function parseGeoHackArgs( $str ) {
- $result = array();
+ $result = [];
$str = str_replace( '_', ' ', $str ); // per GeoHack docs,
spaces and underscores are equivalent
$parts = explode( ' ', $str );
foreach ( $parts as $arg ) {
@@ -264,8 +264,8 @@
* @return Status Operation status, in case of success its value is a
Coord object
*/
public static function parseCoordinates( $parts, Globe $globe ) {
- $latSuffixes = array( 'N' => 1, 'S' => -1 );
- $lonSuffixes = array( 'E' => $globe->getEastSign(), 'W' =>
-$globe->getEastSign() );
+ $latSuffixes = [ 'N' => 1, 'S' => -1 ];
+ $lonSuffixes = [ 'E' => $globe->getEastSign(), 'W' =>
-$globe->getEastSign() ];
$count = count( $parts );
if ( !is_array( $parts ) || $count < 2 || $count > 8 || (
$count % 2 ) ) {
diff --git a/includes/GeoData.body.php b/includes/GeoData.body.php
index 640f2a1..f51a52c 100644
--- a/includes/GeoData.body.php
+++ b/includes/GeoData.body.php
@@ -31,7 +31,7 @@
* @return Coord|bool Coordinates or false
*/
public static function getPageCoordinates( Title $title ) {
- $coords = self::getAllCoordinates( $title->getArticleID(),
array( 'gt_primary' => 1 ) );
+ $coords = self::getAllCoordinates( $title->getArticleID(), [
'gt_primary' => 1 ] );
if ( $coords ) {
return $coords[0];
}
@@ -46,11 +46,11 @@
* @param int $dbType Database to select from DM_MASTER or DB_SLAVE
* @return Coord[]
*/
- public static function getAllCoordinates( $pageId, $conds = array(),
$dbType = DB_SLAVE ) {
+ public static function getAllCoordinates( $pageId, $conds = [], $dbType
= DB_SLAVE ) {
$db = wfGetDB( $dbType );
$conds['gt_page_id'] = $pageId;
$res = $db->select( 'geo_tags', Coord::getColumns(), $conds,
__METHOD__ );
- $coords = array();
+ $coords = [];
foreach ( $res as $row ) {
$coords[] = Coord::newFromRow( $row );
}
diff --git a/includes/Globe.php b/includes/Globe.php
index 1ce1fe4..c44e474 100644
--- a/includes/Globe.php
+++ b/includes/Globe.php
@@ -49,18 +49,18 @@
private static function getData() {
global $wgGlobes;
- static $data = array();
+ static $data = [];
if ( $data ) {
return $data;
}
- $earth = array( 'lon' => array( -180, 180 ), 'east' => +1 );
- $east360 = array( 'lon' => array( 0, 360 ), 'east' => +1 );
- $west360 = array( 'lon' => array( 0, 360 ), 'east' => -1 );
+ $earth = [ 'lon' => [ -180, 180 ], 'east' => +1 ];
+ $east360 = [ 'lon' => [ 0, 360 ], 'east' => +1 ];
+ $west360 = [ 'lon' => [ 0, 360 ], 'east' => -1 ];
// Coordinate systems mostly taken from
http://planetarynames.wr.usgs.gov/TargetCoordinates
- $data = array(
- 'earth' => $earth + array( 'radius' =>
Math::EARTH_RADIUS ),
+ $data = [
+ 'earth' => $earth + [ 'radius' => Math::EARTH_RADIUS ],
'mercury' => $west360,
'venus' => $east360,
'moon' => $earth,
@@ -89,7 +89,7 @@
'oberon' => $east360,
'triton' => $east360,
'pluto' => $east360, // ???
- );
+ ];
$data = $wgGlobes + $data;
diff --git a/includes/Hooks.php b/includes/Hooks.php
index bcf382f..ef527eb 100644
--- a/includes/Hooks.php
+++ b/includes/Hooks.php
@@ -41,7 +41,7 @@
} else {
$updater->addExtensionTable(
'geo_tags', "$dir/../sql/db-backed.sql" );
}
- $updater->addExtensionUpdate( array(
'GeoData\Hooks::upgradeToDecimal' ) );
+ $updater->addExtensionUpdate( [
'GeoData\Hooks::upgradeToDecimal' ] );
break;
default:
throw new MWException( 'GeoData extension
currently supports only MySQL and SQLite' );
@@ -82,7 +82,7 @@
*/
public static function onParserFirstCallInit( &$parser ) {
$parser->setFunctionHook( 'coordinates',
- array( new CoordinatesParserFunction( $parser ),
'coordinates' ),
+ [ new CoordinatesParserFunction( $parser ),
'coordinates' ],
Parser::SFH_OBJECT_ARGS
);
}
@@ -98,7 +98,7 @@
*/
public static function onArticleDeleteComplete( &$article, User &$user,
$reason, $id ) {
$dbw = wfGetDB( DB_MASTER );
- $dbw->delete( 'geo_tags', array( 'gt_page_id' => $id ),
__METHOD__ );
+ $dbw->delete( 'geo_tags', [ 'gt_page_id' => $id ], __METHOD__ );
}
/**
@@ -109,7 +109,7 @@
*/
public static function onLinksUpdate( &$linksUpdate ) {
$out = $linksUpdate->getParserOutput();
- $data = array();
+ $data = [];
$coordFromMetadata = self::getCoordinatesIfFile(
$linksUpdate->getTitle() );
if ( isset( $out->geoData ) ) {
/** @var CoordinatesOutput $geoData */
@@ -158,13 +158,13 @@
$dbw = wfGetDB( DB_MASTER );
if ( $wgGeoDataBackend == 'db' && !count( $coords ) ) {
- $dbw->delete( 'geo_tags', array( 'gt_page_id' =>
$pageId ), __METHOD__ );
+ $dbw->delete( 'geo_tags', [ 'gt_page_id' => $pageId ],
__METHOD__ );
return;
}
- $prevCoords = GeoData::getAllCoordinates( $pageId, array(),
DB_MASTER );
- $add = array();
- $delete = array();
+ $prevCoords = GeoData::getAllCoordinates( $pageId, [],
DB_MASTER );
+ $add = [];
+ $delete = [];
$primary = ( isset( $coords[0] ) && $coords[0]->primary ) ?
$coords[0] : null;
foreach ( $prevCoords as $old ) {
$delete[$old->id] = $old;
@@ -189,7 +189,7 @@
if ( count( $delete ) ) {
$deleteIds = array_keys( $delete );
- $dbw->delete( 'geo_tags', array( 'gt_id' => $deleteIds
), __METHOD__ );
+ $dbw->delete( 'geo_tags', [ 'gt_id' => $deleteIds ],
__METHOD__ );
}
if ( count( $add ) ) {
$dbw->insert( 'geo_tags', $add, __METHOD__ );
@@ -229,7 +229,7 @@
if ( !$coord ) {
return;
}
- $result = array();
+ $result = [];
foreach ( $wgGeoDataInJS as $param ) {
if ( isset( $coord->$param ) ) {
$result[$param] = $coord->$param;
@@ -254,27 +254,27 @@
}
$pageConfig = $config['page'];
- $pageConfig['properties']['coordinates'] = array(
+ $pageConfig['properties']['coordinates'] = [
'type' => 'nested',
- 'properties' => array(
- 'coord' => array(
+ 'properties' => [
+ 'coord' => [
'type' => 'geo_point',
'lat_lon' => true,
- ),
- 'globe' => array( 'type' => 'string', 'index'
=> 'not_analyzed' ),
- 'primary' => array( 'type' => 'boolean' ),
- 'dim' => array( 'type' => 'float' ),
- 'type' => array( 'type' => 'string', 'index' =>
'not_analyzed' ),
- 'name' => array( 'type' => 'string', 'index' =>
'no' ),
- 'country' => array( 'type' => 'string', 'index'
=> 'not_analyzed' ),
- 'region' => array( 'type' => 'string', 'index'
=> 'not_analyzed' ),
- ),
- );
+ ],
+ 'globe' => [ 'type' => 'string', 'index' =>
'not_analyzed' ],
+ 'primary' => [ 'type' => 'boolean' ],
+ 'dim' => [ 'type' => 'float' ],
+ 'type' => [ 'type' => 'string', 'index' =>
'not_analyzed' ],
+ 'name' => [ 'type' => 'string', 'index' => 'no'
],
+ 'country' => [ 'type' => 'string', 'index' =>
'not_analyzed' ],
+ 'region' => [ 'type' => 'string', 'index' =>
'not_analyzed' ],
+ ],
+ ];
if ( $wgGeoDataCoordinatesCompression ) {
-
$pageConfig['properties']['coordinates']['properties']['coord']['fielddata'] =
array(
+
$pageConfig['properties']['coordinates']['properties']['coord']['fielddata'] = [
'format' => 'compressed',
'precision' => $wgGeoDataCoordinatesCompression,
- );
+ ];
}
$config['page'] = $pageConfig;
}
@@ -299,11 +299,11 @@
return;
}
- $coords = array();
+ $coords = [];
/** @var Coord $coord */
foreach ( $parserOutput->geoData->getAll() as $coord ) {
$arr = $coord->getAsArray();
- $arr['coord'] = array( 'lat' => $coord->lat, 'lon' =>
$coord->lon );
+ $arr['coord'] = [ 'lat' => $coord->lat, 'lon' =>
$coord->lon ];
unset( $arr['id'] );
unset( $arr['lat'] );
unset( $arr['lon'] );
diff --git a/includes/Searcher.php b/includes/Searcher.php
index cee6e8a..ce6d3bc 100644
--- a/includes/Searcher.php
+++ b/includes/Searcher.php
@@ -34,7 +34,7 @@
$search = $pageType->createSearch( $query );
try {
- $this->start( "performing $queryType", array(
'queryType' => $queryType ) );
+ $this->start( "performing $queryType", [ 'queryType' =>
$queryType ] );
$result = $search->search();
$this->success();
} catch ( ExceptionInterface $ex ) {
diff --git a/includes/api/ApiQueryCoordinates.php
b/includes/api/ApiQueryCoordinates.php
index 000165d..8816057 100644
--- a/includes/api/ApiQueryCoordinates.php
+++ b/includes/api/ApiQueryCoordinates.php
@@ -25,7 +25,7 @@
$params = $this->extractRequestParams();
$from = $this->getFromCoord( $params );
$this->addTables( 'geo_tags' );
- $this->addFields( array( 'gt_id', 'gt_page_id', 'gt_lat',
'gt_lon', 'gt_primary', 'gt_globe' ) );
+ $this->addFields( [ 'gt_id', 'gt_page_id', 'gt_lat', 'gt_lon',
'gt_primary', 'gt_globe' ] );
$mapping = Coord::getFieldMapping();
foreach( $params['prop'] as $prop ) {
if ( isset( $mapping[$prop] ) ) {
@@ -34,7 +34,7 @@
}
$this->addWhereFld( 'gt_page_id', array_keys( $titles ) );
$primary = $params['primary'];
- $this->addWhereIf( array( 'gt_primary' => intval( $primary ===
'primary' ) ), $primary !== 'all' );
+ $this->addWhereIf( [ 'gt_primary' => intval( $primary ===
'primary' ) ], $primary !== 'all' );
if ( isset( $params['continue'] ) ) {
$parts = explode( '|', $params['continue'] );
@@ -51,7 +51,7 @@
$this->addOption( 'USE INDEX', 'gt_page_id' );
}
- $this->addOption( 'ORDER BY', array( 'gt_page_id', 'gt_id' ) );
+ $this->addOption( 'ORDER BY', [ 'gt_page_id', 'gt_id' ] );
$this->addOption( 'LIMIT', $params['limit'] + 1 );
$res = $this->select( __METHOD__ );
@@ -62,10 +62,10 @@
$this->setContinueEnumParameter( 'continue',
$row->gt_page_id . '|' . $row->gt_id );
break;
}
- $vals = array(
+ $vals = [
'lat' => floatval( $row->gt_lat ),
'lon' => floatval( $row->gt_lon ),
- );
+ ];
if ( $row->gt_primary ) {
$vals['primary'] = '';
}
@@ -124,47 +124,47 @@
}
public function getAllowedParams() {
- return array(
- 'limit' => array(
+ return [
+ 'limit' => [
ApiBase::PARAM_DFLT => 10,
ApiBase::PARAM_TYPE => 'limit',
ApiBase::PARAM_MIN => 1,
ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1,
ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2
- ),
- 'continue' => array(
+ ],
+ 'continue' => [
ApiBase::PARAM_TYPE => 'string',
ApiBase::PARAM_HELP_MSG =>
'api-help-param-continue',
- ),
- 'prop' => array(
- ApiBase::PARAM_TYPE => array( 'type', 'name',
'dim', 'country', 'region', 'globe' ),
+ ],
+ 'prop' => [
+ ApiBase::PARAM_TYPE => [ 'type', 'name', 'dim',
'country', 'region', 'globe' ],
ApiBase::PARAM_DFLT => 'globe',
ApiBase::PARAM_ISMULTI => true,
- ),
- 'primary' => array(
- ApiBase::PARAM_TYPE => array( 'primary',
'secondary', 'all' ),
+ ],
+ 'primary' => [
+ ApiBase::PARAM_TYPE => [ 'primary',
'secondary', 'all' ],
ApiBase::PARAM_DFLT => 'primary',
- ),
- 'distancefrompoint' => array(
+ ],
+ 'distancefrompoint' => [
ApiBase::PARAM_TYPE => 'string',
- ApiBase::PARAM_HELP_MSG_APPEND => array(
+ ApiBase::PARAM_HELP_MSG_APPEND => [
'geodata-api-help-coordinates-format',
- ),
- ),
- 'distancefrompage' => array(
+ ],
+ ],
+ 'distancefrompage' => [
ApiBase::PARAM_TYPE => 'string',
- ),
- );
+ ],
+ ];
}
/**
* @see ApiBase::getExamplesMessages()
*/
protected function getExamplesMessages() {
- return array(
+ return [
'action=query&prop=coordinates&titles=Main%20Page'
=> 'apihelp-query+coordinates-example-1',
- );
+ ];
}
public function getHelpUrls() {
diff --git a/includes/api/ApiQueryGeoSearch.php
b/includes/api/ApiQueryGeoSearch.php
index 4530a3a..a175676 100644
--- a/includes/api/ApiQueryGeoSearch.php
+++ b/includes/api/ApiQueryGeoSearch.php
@@ -108,7 +108,7 @@
$this->addTables( 'page' );
// retrieve some fields only if page set needs them
if ( is_null( $resultPageSet ) ) {
- $this->addFields( array( 'page_id', 'page_namespace',
'page_title' ) );
+ $this->addFields( [ 'page_id', 'page_namespace',
'page_title' ] );
} else {
$this->addFields( WikiPage::selectFields() );
}
@@ -117,7 +117,7 @@
$this->radius = intval( $params['radius'] );
if ( is_null( $resultPageSet ) ) {
- $this->getResult()->addIndexedTagName( array( 'query',
$this->getModuleName() ),
+ $this->getResult()->addIndexedTagName( [ 'query',
$this->getModuleName() ],
$this->getModulePrefix()
);
}
@@ -125,59 +125,59 @@
public function getAllowedParams() {
global $wgMaxGeoSearchRadius, $wgDefaultGlobe, $wgGeoDataDebug;
- $params = array (
- 'coord' => array(
+ $params = [
+ 'coord' => [
ApiBase::PARAM_TYPE => 'string',
- ApiBase::PARAM_HELP_MSG_APPEND => array(
+ ApiBase::PARAM_HELP_MSG_APPEND => [
'geodata-api-help-coordinates-format',
- ),
- ),
- 'page' => array(
+ ],
+ ],
+ 'page' => [
ApiBase::PARAM_TYPE => 'string',
- ),
- 'bbox' => array(
+ ],
+ 'bbox' => [
ApiBase::PARAM_TYPE => 'string',
- ),
- 'radius' => array(
+ ],
+ 'radius' => [
ApiBase::PARAM_TYPE => 'integer',
ApiBase::PARAM_MIN => self::MIN_RADIUS,
ApiBase::PARAM_MAX => $wgMaxGeoSearchRadius,
ApiBase::PARAM_RANGE_ENFORCE => true,
- ),
- 'maxdim' => array(
+ ],
+ 'maxdim' => [
ApiBase::PARAM_TYPE => 'integer',
- ),
- 'limit' => array(
+ ],
+ 'limit' => [
ApiBase::PARAM_DFLT => 10,
ApiBase::PARAM_TYPE => 'limit',
ApiBase::PARAM_MIN => 1,
ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1,
ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2
- ),
+ ],
// @todo: globe selection disabled until we have a real
use case
- 'globe' => array(
+ 'globe' => [
ApiBase::PARAM_TYPE => (array)$wgDefaultGlobe,
ApiBase::PARAM_DFLT => $wgDefaultGlobe,
- ),
- 'namespace' => array(
+ ],
+ 'namespace' => [
ApiBase::PARAM_TYPE => 'namespace',
ApiBase::PARAM_DFLT => NS_MAIN,
ApiBase::PARAM_ISMULTI => true,
- ),
- 'prop' => array(
- ApiBase::PARAM_TYPE => array( 'type', 'name',
'dim', 'country', 'region', 'globe' ),
+ ],
+ 'prop' => [
+ ApiBase::PARAM_TYPE => [ 'type', 'name', 'dim',
'country', 'region', 'globe' ],
ApiBase::PARAM_DFLT => 'globe',
ApiBase::PARAM_ISMULTI => true,
- ),
- 'primary' => array(
- ApiBase::PARAM_TYPE => array( 'primary',
'secondary', 'all' ),
+ ],
+ 'primary' => [
+ ApiBase::PARAM_TYPE => [ 'primary',
'secondary', 'all' ],
ApiBase::PARAM_DFLT => 'primary',
- ),
- );
+ ],
+ ];
if ( $wgGeoDataDebug ) {
- $params['debug'] = array(
+ $params['debug'] = [
ApiBase::PARAM_TYPE => 'boolean',
- );
+ ];
}
return $params;
}
@@ -186,12 +186,12 @@
* @see ApiBase::getExamplesMessages()
*/
protected function getExamplesMessages() {
- return array(
+ return [
'action=query&list=geosearch&gsradius=10000&gscoord=37.786971|-122.399677'
=> 'apihelp-query+geosearch-example-1',
'action=query&list=geosearch&gsbbox=37.8|-122.3|37.7|-122.4'
=> 'apihelp-query+geosearch-example-2',
- );
+ ];
}
public function getHelpUrls() {
diff --git a/includes/api/ApiQueryGeoSearchDb.php
b/includes/api/ApiQueryGeoSearchDb.php
index e6b88af..e20446f 100644
--- a/includes/api/ApiQueryGeoSearchDb.php
+++ b/includes/api/ApiQueryGeoSearchDb.php
@@ -20,7 +20,7 @@
$params = $this->extractRequestParams();
$this->addTables( 'geo_tags' );
- $this->addFields( array( 'gt_lat', 'gt_lon', 'gt_primary' ) );
+ $this->addFields( [ 'gt_lat', 'gt_lon', 'gt_primary' ] );
$mapping = Coord::getFieldMapping();
foreach( $params['prop'] as $prop ) {
if ( isset( $mapping[$prop] ) ) {
@@ -36,7 +36,7 @@
$this->addWhere( 'gt_dim < ' . intval(
$params['maxdim'] ) );
}
$primary = $params['primary'];
- $this->addWhereIf( array( 'gt_primary' => intval( $primary ===
'primary' ) ), $primary !== 'all' );
+ $this->addWhereIf( [ 'gt_primary' => intval( $primary ===
'primary' ) ], $primary !== 'all' );
$this->addCoordFilter();
@@ -44,7 +44,7 @@
$res = $this->select( __METHOD__ );
- $rows = array();
+ $rows = [];
foreach ( $res as $row ) {
$row->dist = Math::distance( $this->coord->lat,
$this->coord->lon, $row->gt_lat, $row->gt_lon );
$rows[] = $row;
@@ -63,14 +63,14 @@
}
if ( is_null( $resultPageSet ) ) {
$title = Title::newFromRow( $row );
- $vals = array(
+ $vals = [
'pageid' => intval( $row->page_id ),
'ns' => intval( $title->getNamespace()
),
'title' => $title->getPrefixedText(),
'lat' => floatval( $row->gt_lat ),
'lon' => floatval( $row->gt_lon ),
'dist' => round( $row->dist, 1 ),
- );
+ ];
if ( $row->gt_primary ) {
$vals['primary'] = '';
}
@@ -83,7 +83,7 @@
}
}
}
- $fit = $result->addValue( array( 'query',
$this->getModuleName() ), null, $vals );
+ $fit = $result->addValue( [ 'query',
$this->getModuleName() ], null, $vals );
if ( !$fit ) {
break;
}
@@ -104,7 +104,7 @@
} else {
$this->addWhereRange( 'gt_lon', 'newer', $bbox->lon1,
$bbox->lon2, false );
}
- $this->addOption( 'USE INDEX', array( 'geo_tags' =>
'gt_spatial' ) );
+ $this->addOption( 'USE INDEX', [ 'geo_tags' => 'gt_spatial' ] );
}
/**
diff --git a/includes/api/ApiQueryGeoSearchElastic.php
b/includes/api/ApiQueryGeoSearchElastic.php
index aa8dabf..5ab80c6 100644
--- a/includes/api/ApiQueryGeoSearchElastic.php
+++ b/includes/api/ApiQueryGeoSearchElastic.php
@@ -26,30 +26,30 @@
$bools = new \Elastica\Filter\BoolFilter();
if ( $this->idToExclude ) {
- $bools->addMustNot( new \Elastica\Filter\Term( array(
'_id' => $this->idToExclude ) ) );
+ $bools->addMustNot( new \Elastica\Filter\Term( [ '_id'
=> $this->idToExclude ] ) );
}
// Only Earth is supported
- $bools->addMust( new \Elastica\Filter\Term( array(
'coordinates.globe' => 'earth' ) ) );
+ $bools->addMust( new \Elastica\Filter\Term( [
'coordinates.globe' => 'earth' ] ) );
if ( isset( $params['maxdim'] ) ) {
$bools->addMust( new \Elastica\Filter\Range(
'coordinates.dim',
- array( 'to' => $params['maxdim'] ) ) );
+ [ 'to' => $params['maxdim'] ] ) );
}
$primary = $params['primary'];
if ( $primary !== 'all' ) {
- $bools->addMust( new \Elastica\Filter\Term( array(
+ $bools->addMust( new \Elastica\Filter\Term( [
'coordinates.primary' => intval(
$primary === 'primary' )
- ) ) );
+ ] ) );
}
if ( $this->bbox ) {
- $distanceFilter = new \Elastica\Filter\GeoBoundingBox(
'coordinates.coord', array(
- array( 'lat' => $this->bbox->lat1,
'lon' => $this->bbox->lon1 ),
- array( 'lat' => $this->bbox->lat2,
'lon' => $this->bbox->lon2 ),
- ) );
+ $distanceFilter = new \Elastica\Filter\GeoBoundingBox(
'coordinates.coord', [
+ [ 'lat' => $this->bbox->lat1, 'lon' =>
$this->bbox->lon1 ],
+ [ 'lat' => $this->bbox->lat2, 'lon' =>
$this->bbox->lon2 ],
+ ] );
} else {
$distanceFilter =
new \Elastica\Filter\GeoDistance(
'coordinates.coord',
- array( 'lat' => $this->coord->lat,
'lon' => $this->coord->lon ),
+ [ 'lat' => $this->coord->lat, 'lon' =>
$this->coord->lon ],
$this->radius . 'm' );
if ( $wgGeoDataIndexLatLon ) {
$distanceFilter->setOptimizeBbox( 'indexed' );
@@ -59,7 +59,7 @@
$query = new \Elastica\Query();
$fields =
array_map( function ( $prop ) { return
"coordinates.$prop"; },
- array_merge( array( 'coord', 'primary' ),
$params['prop'] ) );
+ array_merge( [ 'coord', 'primary' ],
$params['prop'] ) );
$query->setParam( '_source', $fields );
$filter = new \Elastica\Filter\BoolAnd();
$filter->addFilter( $bools );
@@ -76,16 +76,16 @@
$query->setPostFilter( $nested );
}
- $query->addSort( array(
- '_geo_distance' => array(
- 'coordinates.coord' => array(
+ $query->addSort( [
+ '_geo_distance' => [
+ 'coordinates.coord' => [
'lat' => $this->coord->lat,
'lon' => $this->coord->lon
- ),
+ ],
'order' => 'asc',
'unit' => 'm'
- )
- ) );
+ ]
+ ] );
$query->setSize( $params['limit'] );
$searcher = new Searcher( $this->getUser() );
@@ -101,8 +101,8 @@
if ( !isset( $data['hits']['hits'] ) ) {
$this->dieDebug( __METHOD__, 'Unexpected result set
returned by Elasticsearch' );
}
- $ids = array();
- $coordinates = array();
+ $ids = [];
+ $coordinates = [];
foreach ( $data['hits']['hits'] as $page ) {
$id = $page['_id'];
foreach ( $page['_source']['coordinates'] as
$coordArray ) {
@@ -125,10 +125,10 @@
if ( !count( $coordinates ) ) {
return; // No results, no point in doing anything else
}
- $this->addWhere( array( 'page_id' => array_keys( $ids ) ) );
+ $this->addWhere( [ 'page_id' => array_keys( $ids ) ] );
$this->addTables( 'page' );
if ( is_null( $resultPageSet ) ) {
- $this->addFields( array( 'page_id', 'page_title',
'page_namespace' ) );
+ $this->addFields( [ 'page_id', 'page_title',
'page_namespace' ] );
} else {
$this->addFields( $resultPageSet->getPageTableFields()
);
}
@@ -136,7 +136,7 @@
$res = $this->select( __METHOD__ );
if ( is_null( $resultPageSet ) ) {
- $titles = array();
+ $titles = [];
foreach ( $res as $row ) {
$titles[$row->page_id] = Title::newFromRow(
$row );
}
@@ -154,14 +154,14 @@
}
/** @var Title $title */
$title = $titles[$id];
- $vals = array(
+ $vals = [
'pageid' => intval( $coord->pageId ),
'ns' => intval( $title->getNamespace()
),
'title' => $title->getPrefixedText(),
'lat' => floatval( $coord->lat ),
'lon' => floatval( $coord->lon ),
'dist' => round( $coord->distance, 1 ),
- );
+ ];
if ( $coord->primary ) {
$vals['primary'] = '';
@@ -172,7 +172,7 @@
$vals[$prop] = $coord->$prop;
}
}
- $fit = $result->addValue( array( 'query',
$this->getModuleName() ), null, $vals );
+ $fit = $result->addValue( [ 'query',
$this->getModuleName() ], null, $vals );
if ( !$fit ) {
break;
}
@@ -234,7 +234,7 @@
*/
private function addDebugInfo( \Elastica\ResultSet $resultSet ) {
$ti = $resultSet->getResponse()->getTransferInfo();
- $neededData = array(
+ $neededData = [
'url',
'total_time',
'namelookup_time',
@@ -244,8 +244,8 @@
'size_download',
'starttransfer_time',
'redirect_time',
- );
- $debug = array();
+ ];
+ $debug = [];
foreach ( $neededData as $name ) {
if ( isset( $ti[$name] ) ) {
$debug[$name] = $ti[$name];
diff --git a/load-test.php b/load-test.php
index c6491be..cbbf7c3 100644
--- a/load-test.php
+++ b/load-test.php
@@ -5,7 +5,7 @@
}
$site = 'http://localhost/w/api.php';
-$times = array();
+$times = [];
echo "Load-testing $site with GeoData requests, press Ctrl+Break to stop...\n";
diff --git a/maintenance/updateIndexGranularity.php
b/maintenance/updateIndexGranularity.php
index 77d2de3..0c83a39 100644
--- a/maintenance/updateIndexGranularity.php
+++ b/maintenance/updateIndexGranularity.php
@@ -23,24 +23,24 @@
$id = 0;
$dbw = wfGetDB( DB_MASTER );
do {
- $ids = array();
+ $ids = [];
$this->beginTransaction( $dbw, __METHOD__ );
$res = $dbw->select( 'geo_tags', 'gt_id',
- array( "gt_id > $id" ),
+ [ "gt_id > $id" ],
__METHOD__,
- array( 'LIMIT' => self::BATCH_SIZE )
+ [ 'LIMIT' => self::BATCH_SIZE ]
);
foreach ( $res as $row ) {
$id = $row->gt_id;
$ids[] = $id;
}
$dbw->update( 'geo_tags',
- array(
+ [
"gt_lat_int = ROUND(gt_lat *
$wgGeoDataIndexGranularity)",
"gt_lon_int = ROUND(gt_lon *
$wgGeoDataIndexGranularity)"
- ),
- array( 'gt_id' => $ids ),
+ ],
+ [ 'gt_id' => $ids ],
__METHOD__
);
$this->commitTransaction( $dbw, __METHOD__ );
diff --git a/tests/BoundingBoxTest.php b/tests/BoundingBoxTest.php
index af3b014..4cbdc2e 100644
--- a/tests/BoundingBoxTest.php
+++ b/tests/BoundingBoxTest.php
@@ -17,11 +17,11 @@
}
public function provideCenter() {
- return array(
- array( 15, 15, 10, 10, 20, 20 ),
- array( 15, -180, 10, 175, 20, -175 ),
- array( 15, -170, 10, 175, 20, -155 ),
- array( 15, 170, 10, 155, 20, -175 ),
- );
+ return [
+ [ 15, 15, 10, 10, 20, 20 ],
+ [ 15, -180, 10, 175, 20, -175 ],
+ [ 15, -170, 10, 175, 20, -155 ],
+ [ 15, 170, 10, 155, 20, -175 ],
+ ];
}
}
\ No newline at end of file
diff --git a/tests/CoordTest.php b/tests/CoordTest.php
index fa30757..0328f12 100644
--- a/tests/CoordTest.php
+++ b/tests/CoordTest.php
@@ -24,16 +24,16 @@
}
public function getEqualsCases() {
- return array(
- array( new Coord( 10, 20 ), new Coord( 10, 20 ), true,
'Basic equality' ),
- array( new Coord( 10, 20 ), new Coord( 0, 0 ), false,
'Basic inequality' ),
- array( new Coord( 10, 20, 'endor' ), new Coord( 10, 20,
'endor' ), true, 'Equality with globe set' ),
- array( new Coord( 10, 20, 'earth' ), new Coord( 10, 20,
'moon' ), false, 'Inequality due to globe' ),
- array( new Coord( 10, 20, 'yavin' ), new Coord( 0, 0,
'yavin' ), false, 'Inequality with globes equal' ),
- array( new Coord( 10, 20 ), new Coord( 10, 20.1 ),
false, 'Precision 1' ),
- array( new Coord( 10, 20 ), new Coord( 10, 20.0000001
), true, 'Precision 2' ),
- array( new Coord( 10, 20 ), null, false, 'Comparison
with null' ),
- );
+ return [
+ [ new Coord( 10, 20 ), new Coord( 10, 20 ), true,
'Basic equality' ],
+ [ new Coord( 10, 20 ), new Coord( 0, 0 ), false, 'Basic
inequality' ],
+ [ new Coord( 10, 20, 'endor' ), new Coord( 10, 20,
'endor' ), true, 'Equality with globe set' ],
+ [ new Coord( 10, 20, 'earth' ), new Coord( 10, 20,
'moon' ), false, 'Inequality due to globe' ],
+ [ new Coord( 10, 20, 'yavin' ), new Coord( 0, 0,
'yavin' ), false, 'Inequality with globes equal' ],
+ [ new Coord( 10, 20 ), new Coord( 10, 20.1 ), false,
'Precision 1' ],
+ [ new Coord( 10, 20 ), new Coord( 10, 20.0000001 ),
true, 'Precision 2' ],
+ [ new Coord( 10, 20 ), null, false, 'Comparison with
null' ],
+ ];
}
public function testBboxAround() {
@@ -54,11 +54,11 @@
}
public function provideGlobeObj() {
- return array(
- array( null, new Globe( 'earth' ) ),
- array( 'earth', new Globe( 'earth' ) ),
- array( 'moon', new Globe( 'moon' ) ),
- array( 'something nonexistent', new Globe( 'something
nonexistent' ) ),
- );
+ return [
+ [ null, new Globe( 'earth' ) ],
+ [ 'earth', new Globe( 'earth' ) ],
+ [ 'moon', new Globe( 'moon' ) ],
+ [ 'something nonexistent', new Globe( 'something
nonexistent' ) ],
+ ];
}
}
\ No newline at end of file
diff --git a/tests/GeoDataMathTest.php b/tests/GeoDataMathTest.php
index ed5e0b5..ea7c385 100644
--- a/tests/GeoDataMathTest.php
+++ b/tests/GeoDataMathTest.php
@@ -15,13 +15,13 @@
}
public function getDistanceData() {
- return array(
+ return [
// just run against a few values from teh internets...
- array( 55.75, 37.6167, 59.95, 30.3167, 635000, 'Moscow
to St. Bumtown' ),
- array( 51.5, -0.1167, 52.35, 4.9167, 357520, 'London to
Amsterdam' ),
- array( 40.7142, -74.0064, 37.775, -122.418, 4125910,
'New York to San Francisco' ),
- array( 0, 179, 0, -179, 222390, 'Wrap around zero' ),
- );
+ [ 55.75, 37.6167, 59.95, 30.3167, 635000, 'Moscow to
St. Bumtown' ],
+ [ 51.5, -0.1167, 52.35, 4.9167, 357520, 'London to
Amsterdam' ],
+ [ 40.7142, -74.0064, 37.775, -122.418, 4125910, 'New
York to San Francisco' ],
+ [ 0, 179, 0, -179, 222390, 'Wrap around zero' ],
+ ];
}
/**
@@ -37,11 +37,11 @@
}
public function getRectData() {
- return array(
- array( 180 ),
- array( -180 ),
- array( 179.95 ),
- array( -179.95 ),
- );
+ return [
+ [ 180 ],
+ [ -180 ],
+ [ 179.95 ],
+ [ -179.95 ],
+ ];
}
}
diff --git a/tests/GeoSearchTest.php b/tests/GeoSearchTest.php
index 93c3ade..523a90f 100644
--- a/tests/GeoSearchTest.php
+++ b/tests/GeoSearchTest.php
@@ -7,12 +7,12 @@
*/
class GeoSearchTest extends MediaWikiTestCase {
public function setUp() {
- $this->setMwGlobals( 'wgAPIListModules', array( 'geosearch' =>
'MockApiQueryGeoSearch' ) );
+ $this->setMwGlobals( 'wgAPIListModules', [ 'geosearch' =>
'MockApiQueryGeoSearch' ] );
parent::setUp();
}
private function request( array $params ) {
- $params += array( 'action' => 'query', 'list' => 'geosearch' );
+ $params += [ 'action' => 'query', 'list' => 'geosearch' ];
$request = new FauxRequest( $params );
$api = new ApiMain( $request );
@@ -28,12 +28,12 @@
}
public function provideRequiredParams() {
- return array(
- array( array(), 'coord, page or bbox are required' ),
- array( array( 'gscoord' => '1|2', 'gspage' => 'foo' ),
'Must have only one of coord, page or bbox' ),
- array( array( 'gsbbox' => '10|170|-10|-170' ), 'Fail if
bounding box is too big' ),
- array( array( 'gsbbox' => '10|170|10|170' ), 'Fail if
bounding box is too small' ),
- );
+ return [
+ [ [], 'coord, page or bbox are required' ],
+ [ [ 'gscoord' => '1|2', 'gspage' => 'foo' ], 'Must have
only one of coord, page or bbox' ],
+ [ [ 'gsbbox' => '10|170|-10|-170' ], 'Fail if bounding
box is too big' ],
+ [ [ 'gsbbox' => '10|170|10|170' ], 'Fail if bounding
box is too small' ],
+ ];
}
}
diff --git a/tests/MiscGeoDataTest.php b/tests/MiscGeoDataTest.php
index 676bcec..d585a31 100644
--- a/tests/MiscGeoDataTest.php
+++ b/tests/MiscGeoDataTest.php
@@ -14,10 +14,10 @@
}
public function getIntRangeData() {
- return array(
- array( 37.697, 37.877, array( 377, 378, 379 ) ),
- array( 9.99, 10.01, array( 100 ) ),
- array( 179.9, -179.9, array( -1800, -1799, 1799, 1800 )
)
- );
+ return [
+ [ 37.697, 37.877, [ 377, 378, 379 ] ],
+ [ 9.99, 10.01, [ 100 ] ],
+ [ 179.9, -179.9, [ -1800, -1799, 1799, 1800 ] ]
+ ];
}
}
diff --git a/tests/ParseCoordTest.php b/tests/ParseCoordTest.php
index 0858aac..cdd5f98 100644
--- a/tests/ParseCoordTest.php
+++ b/tests/ParseCoordTest.php
@@ -28,64 +28,64 @@
}
public function getCases() {
- return array(
+ return [
// basics
- array( array( 0, 0 ), new Coord( 0, 0 ) ),
- array( array( 75, 25 ), new Coord( 75, 25 ) ),
- array( array( '20.0', '-15.5' ), new Coord( 20, -15.5 )
),
- array( array( -20, 30, 40, 45 ), new Coord( -20.5,
40.75 ) ),
- array( array( 20, 30, 40, 40, 45, 55 ), new Coord(
20.511111111111, 40.765277777778 ) ),
+ [ [ 0, 0 ], new Coord( 0, 0 ) ],
+ [ [ 75, 25 ], new Coord( 75, 25 ) ],
+ [ [ '20.0', '-15.5' ], new Coord( 20, -15.5 ) ],
+ [ [ -20, 30, 40, 45 ], new Coord( -20.5, 40.75 ) ],
+ [ [ 20, 30, 40, 40, 45, 55 ], new Coord(
20.511111111111, 40.765277777778 ) ],
// NESW
- array( array( 20.1, 'N', 30, 'E' ), new Coord( 20.1, 30
) ),
- array( array( 20, 'N', 30.5, 'W' ), new Coord( 20,
-30.5 ) ),
- array( array( 20, 'S', 30, 'E' ), new Coord( -20, 30 )
),
- array( array( 20, 'S', 30, 'W' ), new Coord( -20, -30 )
),
- array( array( 20, 30, 40, 'S', 40, 45, 55, 'E' ), new
Coord( -20.511111111111, 40.765277777778 ) ),
- array( array( 20, 30, 40, 'N', 40, 45, 55, 'W' ), new
Coord( 20.511111111111, -40.765277777778 ) ),
- array( array( 20, 'E', 30, 'W' ), false ),
- array( array( 20, 'S', 30, 'N' ), false ),
- array( array( -20, 'S', 30, 'E' ), false ),
- array( array( 20, 'S', -30, 'W' ), false ),
+ [ [ 20.1, 'N', 30, 'E' ], new Coord( 20.1, 30 ) ],
+ [ [ 20, 'N', 30.5, 'W' ], new Coord( 20, -30.5 ) ],
+ [ [ 20, 'S', 30, 'E' ], new Coord( -20, 30 ) ],
+ [ [ 20, 'S', 30, 'W' ], new Coord( -20, -30 ) ],
+ [ [ 20, 30, 40, 'S', 40, 45, 55, 'E' ], new Coord(
-20.511111111111, 40.765277777778 ) ],
+ [ [ 20, 30, 40, 'N', 40, 45, 55, 'W' ], new Coord(
20.511111111111, -40.765277777778 ) ],
+ [ [ 20, 'E', 30, 'W' ], false ],
+ [ [ 20, 'S', 30, 'N' ], false ],
+ [ [ -20, 'S', 30, 'E' ], false ],
+ [ [ 20, 'S', -30, 'W' ], false ],
// wrong number of parameters
- array( array(), false ),
- array( array( 1 ), false ),
- array( array( 1, 2, 3 ), false ),
- array( array( 1, 2, 3, 4, 5 ), false ),
- array( array( 1, 2, 3, 4, 5, 6, 7 ), false ),
- array( array( 1, 2, 3, 4, 5, 6, 7, 8, 9 ), false ),
- array( array( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ), false ),
+ [ [], false ],
+ [ [ 1 ], false ],
+ [ [ 1, 2, 3 ], false ],
+ [ [ 1, 2, 3, 4, 5 ], false ],
+ [ [ 1, 2, 3, 4, 5, 6, 7 ], false ],
+ [ [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ], false ],
+ [ [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], false ],
// unbalanced NESW
- array( array( 'N', 'E' ), false ),
- array( array( 12, 'N', 'E' ), false ),
- array( array( 'N', 15, 'E' ), false ),
- array( array( 1, 2, 3, 'N', 1, 'E' ), false ),
- array( array( 1, 2, 3, 'N', 'E' ), false ),
- array( array( 1, 2, 3, 'N', 1, 'E' ), false ),
- array( array( 1, 2, 3, 'N', 1, 2, 'E' ), false ),
+ [ [ 'N', 'E' ], false ],
+ [ [ 12, 'N', 'E' ], false ],
+ [ [ 'N', 15, 'E' ], false ],
+ [ [ 1, 2, 3, 'N', 1, 'E' ], false ],
+ [ [ 1, 2, 3, 'N', 'E' ], false ],
+ [ [ 1, 2, 3, 'N', 1, 'E' ], false ],
+ [ [ 1, 2, 3, 'N', 1, 2, 'E' ], false ],
// Fractional numbers inconsistency
- array( array( 1, 2.1, 3, 1, 2, 3 ), false ),
- array( array( 1, 2.1, 3.2, 1, 2, 3 ), false ),
- array( array( 1.00000001, 2.1, 3.2, 1, 2, 3 ), false ),
- array( array( 1.00000001, 2.1, 3, 1, 2, 3 ), false ),
- array( array( 1.00000001, 2, 3, 1, 2, 3 ), false ),
+ [ [ 1, 2.1, 3, 1, 2, 3 ], false ],
+ [ [ 1, 2.1, 3.2, 1, 2, 3 ], false ],
+ [ [ 1.00000001, 2.1, 3.2, 1, 2, 3 ], false ],
+ [ [ 1.00000001, 2.1, 3, 1, 2, 3 ], false ],
+ [ [ 1.00000001, 2, 3, 1, 2, 3 ], false ],
// only the last component of the coordinate should be
non-integer
- array( array( 10.5, 1, 20, 0 ), false ),
- array( array( 10, 30.5, 1, 20, 0, 0 ), false ),
+ [ [ 10.5, 1, 20, 0 ], false ],
+ [ [ 10, 30.5, 1, 20, 0, 0 ], false ],
// Exception per
https://phabricator.wikimedia.org/T50488
- array( array( 1.5, 0, 2.5, 0 ), new Coord( 1.5, 2.5 ) ),
- array( array( 1, 2.5, 0, 3, 4.5, 0 ), new Coord(
1.0416666666667, 3.075 ) ),
+ [ [ 1.5, 0, 2.5, 0 ], new Coord( 1.5, 2.5 ) ],
+ [ [ 1, 2.5, 0, 3, 4.5, 0 ], new Coord( 1.0416666666667,
3.075 ) ],
// coordinate validation (Earth)
- array( array( -90, 180 ), new Coord( -90, 180 ) ),
- array( array( 90.0000001, -180.00000001 ), false ),
- array( array( 90, 1, 180, 0 ), false ),
- array( array( 10, -1, 20, 0 ), false ),
- array( array( 25, 60, 10, 0 ), false ),
- array( array( 25, 0, 0, 10, 0, 60 ), false ),
+ [ [ -90, 180 ], new Coord( -90, 180 ) ],
+ [ [ 90.0000001, -180.00000001 ], false ],
+ [ [ 90, 1, 180, 0 ], false ],
+ [ [ 10, -1, 20, 0 ], false ],
+ [ [ 25, 60, 10, 0 ], false ],
+ [ [ 25, 0, 0, 10, 0, 60 ], false ],
// coordinate validation and normalisation (non-Earth)
- array( array( 10, 20 ), new Coord( 10, 20, 'mars' ),
'mars' ),
- array( array( 110, 20 ), false, 'mars' ),
- array( array( 47, 0, 'S', 355, 3, 'W' ), new Coord(
-47, 4.95, 'mars' ), 'mars' ), // Asimov Crater
- array( array( 68, 'S', 357, 'E' ), new Coord( -68, 357,
'venus' ), 'venus' ), // Quetzalpetlatl Corona
- );
+ [ [ 10, 20 ], new Coord( 10, 20, 'mars' ), 'mars' ],
+ [ [ 110, 20 ], false, 'mars' ],
+ [ [ 47, 0, 'S', 355, 3, 'W' ], new Coord( -47, 4.95,
'mars' ), 'mars' ], // Asimov Crater
+ [ [ 68, 'S', 357, 'E' ], new Coord( -68, 357, 'venus'
), 'venus' ], // Quetzalpetlatl Corona
+ ];
}
}
\ No newline at end of file
diff --git a/tests/TagTest.php b/tests/TagTest.php
index b187fce..0a53e19 100644
--- a/tests/TagTest.php
+++ b/tests/TagTest.php
@@ -64,128 +64,128 @@
}
public function getLooseData() {
- return array(
+ return [
// Basics
- array(
+ [
'{{#coordinates: 10|20|primary}}',
- array( 'lat' => 10, 'lon' => 20, 'globe' =>
'earth', 'primary' => true ),
- ),
- array(
+ [ 'lat' => 10, 'lon' => 20, 'globe' => 'earth',
'primary' => true ],
+ ],
+ [
'{{#coordinates: 100|20|primary}}',
false,
- ),
- array(
+ ],
+ [
'{{#coordinates: 10|2000|primary}}',
false,
- ),
- array(
+ ],
+ [
'{{#coordinates: 10| primary |
20}}',
- array( 'lat' => 10, 'lon' => 20, 'globe' =>
'earth', 'primary' => true ),
- ),
- array( // empty parameter instead of primary
+ [ 'lat' => 10, 'lon' => 20, 'globe' => 'earth',
'primary' => true ],
+ ],
+ [ // empty parameter instead of primary
'{{#coordinates: 10 | | 20 }}',
- array( 'lat' => 10, 'lon' => 20, 'globe' =>
'earth', 'primary' => false ),
- ),
- array(
+ [ 'lat' => 10, 'lon' => 20, 'globe' => 'earth',
'primary' => false ],
+ ],
+ [
'{{#coordinates: primary|10|20}}',
- array( 'lat' => 10, 'lon' => 20, 'globe' =>
'earth', 'primary' => true ),
- ),
+ [ 'lat' => 10, 'lon' => 20, 'globe' => 'earth',
'primary' => true ],
+ ],
// type
- array(
+ [
'{{#coordinates: 10|20|type:city}}',
- array( 'lat' => 10, 'lon' => 20, 'globe' =>
'earth', 'type' => 'city' ),
- ),
- array(
+ [ 'lat' => 10, 'lon' => 20, 'globe' => 'earth',
'type' => 'city' ],
+ ],
+ [
'{{#coordinates: 10|20|type:city(666)}}',
- array( 'lat' => 10, 'lon' => 20, 'globe' =>
'earth', 'type' => 'city' ),
- ),
+ [ 'lat' => 10, 'lon' => 20, 'globe' => 'earth',
'type' => 'city' ],
+ ],
// Other geohack params
- array(
+ [
'{{#coordinates: 10|20}}',
- array( 'lat' => 10, 'lon' => 20, 'globe' =>
'earth', 'dim' => 1000 ),
- ),
- array(
+ [ 'lat' => 10, 'lon' => 20, 'globe' => 'earth',
'dim' => 1000 ],
+ ],
+ [
'{{#coordinates:10|20|globe:Moon
dim:10_region:RU-mos}}',
- array( 'lat' => 10, 'lon' => 20, 'globe' =>
'moon', 'country' => 'RU', 'region' => 'MOS', 'dim' => 10 ),
- ),
- array(
+ [ 'lat' => 10, 'lon' => 20, 'globe' => 'moon',
'country' => 'RU', 'region' => 'MOS', 'dim' => 10 ],
+ ],
+ [
'{{#coordinates:10|20|globe:Moon
dim:10_region:RU}}',
- array( 'lat' => 10, 'lon' => 20, 'globe' =>
'moon', 'country' => 'RU', 'dim' => 10 ),
- ),
- array(
+ [ 'lat' => 10, 'lon' => 20, 'globe' => 'moon',
'country' => 'RU', 'dim' => 10 ],
+ ],
+ [
'{{#coordinates: 10|20|_dim:3Km_}}',
- array( 'lat' => 10, 'lon' => 20, 'globe' =>
'earth', 'dim' => 3000 ),
- ),
- array(
+ [ 'lat' => 10, 'lon' => 20, 'globe' => 'earth',
'dim' => 3000 ],
+ ],
+ [
'{{#coordinates: 10|20|foo:bar dim:100m}}',
- array( 'lat' => 10, 'lon' => 20, 'globe' =>
'earth', 'dim' => 100 ),
- ),
- array(
+ [ 'lat' => 10, 'lon' => 20, 'globe' => 'earth',
'dim' => 100 ],
+ ],
+ [
'{{#coordinates: 10|20|dim:-300}}',
- array( 'lat' => 10, 'lon' => 20, 'globe' =>
'earth', 'dim' => 1000 ),
- ),
- array(
+ [ 'lat' => 10, 'lon' => 20, 'globe' => 'earth',
'dim' => 1000 ],
+ ],
+ [
'{{#coordinates: 10|20|dim:-10km}}',
- array( 'lat' => 10, 'lon' => 20, 'globe' =>
'earth', 'dim' => 1000 ),
- ),
- array(
+ [ 'lat' => 10, 'lon' => 20, 'globe' => 'earth',
'dim' => 1000 ],
+ ],
+ [
'{{#coordinates: 10|20|dim:1L}}',
- array( 'lat' => 10, 'lon' => 20, 'globe' =>
'earth', 'dim' => 1000 ),
- ),
+ [ 'lat' => 10, 'lon' => 20, 'globe' => 'earth',
'dim' => 1000 ],
+ ],
// dim fallbacks
- array(
+ [
'{{#coordinates: 10|20|type:city}}',
- array( 'lat' => 10, 'lon' => 20, 'globe' =>
'earth', 'type' => 'city', 'dim' => 10000 ),
- ),
- array(
+ [ 'lat' => 10, 'lon' => 20, 'globe' => 'earth',
'type' => 'city', 'dim' => 10000 ],
+ ],
+ [
'{{#coordinates: 10|20|type:city(2000)}}',
- array( 'lat' => 10, 'lon' => 20, 'globe' =>
'earth', 'type' => 'city', 'dim' => 10000 ),
- ),
- array(
+ [ 'lat' => 10, 'lon' => 20, 'globe' => 'earth',
'type' => 'city', 'dim' => 10000 ],
+ ],
+ [
'{{#coordinates: 10|20|type:lulz}}',
- array( 'lat' => 10, 'lon' => 20, 'globe' =>
'earth', 'type' => 'lulz', 'dim' => 1000 ),
- ),
- array(
+ [ 'lat' => 10, 'lon' => 20, 'globe' => 'earth',
'type' => 'lulz', 'dim' => 1000 ],
+ ],
+ [
'{{#coordinates: 10|20|scale:50000}}',
- array( 'lat' => 10, 'lon' => 20, 'globe' =>
'earth', 'dim' => 5000 ),
- ),
+ [ 'lat' => 10, 'lon' => 20, 'globe' => 'earth',
'dim' => 5000 ],
+ ],
// https://phabricator.wikimedia.org/T48181
- array(
+ [
'{{#coordinates: 2.5|3,5}}',
- array( 'lat' => 2.5, 'lon' => 3.5 ),
+ [ 'lat' => 2.5, 'lon' => 3.5 ],
'de',
- ),
+ ],
// https://phabricator.wikimedia.org/T49090
- array(
+ [
'{{#coordinates: -3.29237|-60.624889|globe=}}',
- array( 'lat' => -3.29237, 'lon' => -60.624889,
'globe' => 'earth' ),
- ),
+ [ 'lat' => -3.29237, 'lon' => -60.624889,
'globe' => 'earth' ],
+ ],
// Lowercase type
- array(
+ [
'{{#coordinates: 10|20|type:sOmEtHiNg}}',
- array( 'lat' => 10, 'lon' => 20, 'globe' =>
'earth', 'type' => 'something' ),
- ),
- );
+ [ 'lat' => 10, 'lon' => 20, 'globe' => 'earth',
'type' => 'something' ],
+ ],
+ ];
}
public function getStrictData() {
- return array(
- array(
+ return [
+ [
'{{#coordinates:10|20|globe:Moon
dim:10_region:RUS-MOS}}',
false,
- ),
- array(
+ ],
+ [
'{{#coordinates:10|20|globe:Moon
dim:10_region:RU-}}',
false,
- ),
- array(
+ ],
+ [
'{{#coordinates:10|20|globe:Moon
dim:10|region=RU-longvalue}}',
false,
- ),
- array(
+ ],
+ [
'{{#coordinates:10|20|globe:Moon
dim:10_region:РУ-МОС}}',
false,
- ),
- );
+ ],
+ ];
}
}
--
To view, visit https://gerrit.wikimedia.org/r/262681
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I8e787e75bfe9b17d46cb90b64ce0d51077a88af9
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/GeoData
Gerrit-Branch: master
Gerrit-Owner: MaxSem <[email protected]>
Gerrit-Reviewer: Yurik <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits