Skip to content

Commit

Permalink
Merge pull request #170 from JeroenDeDauw/suchclass
Browse files Browse the repository at this point in the history
Use ::class to ref classes
  • Loading branch information
JeroenDeDauw authored Jun 17, 2016
2 parents da0ece6 + a0913d0 commit 92f7690
Show file tree
Hide file tree
Showing 13 changed files with 54 additions and 38 deletions.
31 changes: 21 additions & 10 deletions Maps.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@
* @author Jeroen De Dauw < [email protected] >
*/

use DataValues\Geo\Parsers\GeoCoordinateParser;
use Maps\CircleParser;
use Maps\DistanceParser;
use Maps\ImageOverlayParser;
use Maps\LineParser;
use Maps\LocationParser;
use Maps\PolygonParser;
use Maps\RectangleParser;
use Maps\ServiceParam;
use Maps\WmsOverlayParser;

if ( !defined( 'MEDIAWIKI' ) ) {
die( 'Not an entry point.' );
}
Expand Down Expand Up @@ -189,42 +200,42 @@
}

$GLOBALS['wgParamDefinitions']['coordinate'] = [
'string-parser' => 'DataValues\Geo\Parsers\GeoCoordinateParser',
'string-parser' => GeoCoordinateParser::class,
];

$GLOBALS['wgParamDefinitions']['mappingservice'] = [
'definition'=> 'Maps\ServiceParam',
'definition'=> ServiceParam::class,
];

$GLOBALS['wgParamDefinitions']['mapslocation'] = [
'string-parser' => 'Maps\LocationParser',
'string-parser' => LocationParser::class,
];

$GLOBALS['wgParamDefinitions']['mapsline'] = [
'string-parser' => 'Maps\LineParser',
'string-parser' => LineParser::class,
];

$GLOBALS['wgParamDefinitions']['mapscircle'] = [
'string-parser' => 'Maps\CircleParser',
'string-parser' => CircleParser::class,
];

$GLOBALS['wgParamDefinitions']['mapsrectangle'] = [
'string-parser' => 'Maps\RectangleParser',
'string-parser' => RectangleParser::class,
];

$GLOBALS['wgParamDefinitions']['mapspolygon'] = [
'string-parser' => 'Maps\PolygonParser',
'string-parser' => PolygonParser::class,
];

$GLOBALS['wgParamDefinitions']['distance'] = [
'string-parser' => 'Maps\DistanceParser',
'string-parser' => DistanceParser::class,
];

$GLOBALS['wgParamDefinitions']['wmsoverlay'] = [
'string-parser' => 'Maps\WmsOverlayParser',
'string-parser' => WmsOverlayParser::class,
];

$GLOBALS['wgParamDefinitions']['mapsimageoverlay'] = [
'string-parser' => 'Maps\ImageOverlayParser',
'string-parser' => ImageOverlayParser::class,
];
} );
14 changes: 7 additions & 7 deletions includes/services/GoogleMaps3/GoogleMaps3.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

/**
* This group contains all Google Maps v3 related files of the Maps extension.
*
*
* @defgroup MapsGoogleMaps3 Google Maps v3
*/

/**
* This file holds the hook and initialization for the Google Maps v3 service.
* This file holds the hook and initialization for the Google Maps v3 service.
*
* @licence GNU GPL v2+
* @author Jeroen De Dauw < [email protected] >
Expand Down Expand Up @@ -105,23 +105,23 @@
} );

/**
* Initialization function for the Google Maps v3 service.
*
* Initialization function for the Google Maps v3 service.
*
* @since 0.6.3
* @ingroup MapsGoogleMaps3
*
*
* @return boolean true
*/
function efMapsInitGoogleMaps3() {
global $wgAutoloadClasses;

$wgAutoloadClasses['MapsGoogleMaps3'] = __DIR__ . '/Maps_GoogleMaps3.php';

MapsMappingServices::registerService( 'googlemaps3', 'MapsGoogleMaps3' );
MapsMappingServices::registerService( 'googlemaps3', MapsGoogleMaps3::class );

// TODO: kill below code
$googleMaps = MapsMappingServices::getServiceInstance( 'googlemaps3' );
$googleMaps->addFeature( 'display_map', 'MapsDisplayMapRenderer' );
$googleMaps->addFeature( 'display_map', MapsDisplayMapRenderer::class );

return true;
}
4 changes: 2 additions & 2 deletions includes/services/Leaflet/Leaflet.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ function efMapsInitLeaflet() {

$wgAutoloadClasses['MapsLeaflet'] = __DIR__ . '/Maps_Leaflet.php';

MapsMappingServices::registerService( 'leaflet', 'MapsLeaflet' );
MapsMappingServices::registerService( 'leaflet', MapsLeaflet::class );
$leafletMaps = MapsMappingServices::getServiceInstance( 'leaflet' );
$leafletMaps->addFeature( 'display_map', 'MapsDisplayMapRenderer' );
$leafletMaps->addFeature( 'display_map', MapsDisplayMapRenderer::class );

return true;
}
12 changes: 6 additions & 6 deletions includes/services/OpenLayers/OpenLayers.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

/**
* This group contains all OpenLayers related files of the Maps extension.
*
*
* @defgroup MapsOpenLayers OpenLayers
*/

/**
* This file holds the hook and initialization for the OpenLayers service.
* This file holds the hook and initialization for the OpenLayers service.
*
* @licence GNU GPL v2+
* @author Jeroen De Dauw < [email protected] >
Expand Down Expand Up @@ -53,11 +53,11 @@
} );

function efMapsInitOpenLayers() {
MapsMappingServices::registerService(
MapsMappingServices::registerService(
'openlayers',
'MapsOpenLayers',
[ 'display_map' => 'MapsDisplayMapRenderer' ]
MapsOpenLayers::class,
[ 'display_map' => MapsDisplayMapRenderer::class ]
);

return true;
}
3 changes: 2 additions & 1 deletion tests/phpunit/ElementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use DataValues\Geo\Values\LatLongValue;
use Maps\Element;
use Maps\ElementOptions;
use Maps\Elements\Circle;
use Maps\Elements\ImageOverlay;
use Maps\Elements\Line;
Expand Down Expand Up @@ -67,7 +68,7 @@ public function testSetOptions( Element $element ) {
* @param Element $element
*/
public function testGetOptions( Element $element ) {
$this->assertInstanceOf( '\Maps\ElementOptions', $element->getOptions() );
$this->assertInstanceOf( ElementOptions::class , $element->getOptions() );
}

}
6 changes: 4 additions & 2 deletions tests/phpunit/elements/BaseElementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

namespace Maps\Tests\Elements;

use InvalidArgumentException;
use Maps\Element;
use Maps\ElementOptions;

/**
* Base class for unit tests classes for the Maps\BaseElement deriving objects.
Expand Down Expand Up @@ -75,7 +77,7 @@ public function testGivenValidArguments_constructorDoesNotThrowException() {
* @since 3.0
*/
public function testGivenInvalidArguments_constructorThrowsException() {
$this->setExpectedException( 'InvalidArgumentException' );
$this->setExpectedException( InvalidArgumentException::class );
call_user_func_array( [ $this, 'newInstance' ], func_get_args() );
}

Expand All @@ -84,7 +86,7 @@ public function testGivenInvalidArguments_constructorThrowsException() {
* @param Element $element
*/
public function testGetOptions( Element $element ) {
$this->assertInstanceOf( '\Maps\ElementOptions', $element->getOptions() );
$this->assertInstanceOf( ElementOptions::class, $element->getOptions() );
}

}
2 changes: 1 addition & 1 deletion tests/phpunit/elements/CircleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class CircleTest extends BaseElementTest {
* @return string
*/
public function getClass() {
return 'Maps\Elements\Circle';
return Circle::class;
}

public function validConstructorProvider() {
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/elements/ImageOverlayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ImageOverlayTest extends RectangleTest {
* @return string
*/
public function getClass() {
return 'Maps\Elements\ImageOverlay';
return ImageOverlay::class;
}

public function validConstructorProvider() {
Expand Down
4 changes: 2 additions & 2 deletions tests/phpunit/elements/LineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class LineTest extends BaseElementTest {
* @return string
*/
public function getClass() {
return 'Maps\Elements\Line';
return Line::class;
}

public function validConstructorProvider() {
Expand Down Expand Up @@ -65,7 +65,7 @@ public function testGetLineCoordinates( Line $line, array $arguments ) {
$this->assertEquals( count( $arguments[0] ), count( $coordinates ) );

foreach ( $coordinates as $geoCoordinate ) {
$this->assertInstanceOf( 'DataValues\LatLongValue', $geoCoordinate );
$this->assertInstanceOf( LatLongValue::class, $geoCoordinate );
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/elements/PolygonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class PolygonTest extends LineTest {
* @return string
*/
public function getClass() {
return 'Maps\Elements\Polygon';
return Polygon::class;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/elements/RectangleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class RectangleTest extends BaseElementTest {
* @return string
*/
public function getClass() {
return 'Maps\Elements\Rectangle';
return Rectangle::class;
}

public function validConstructorProvider() {
Expand Down
5 changes: 3 additions & 2 deletions tests/phpunit/parsers/CircleParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use DataValues\Geo\Values\LatLongValue;
use Maps\CircleParser;
use Maps\Elements\Circle;

/**
* @covers Maps\CircleParser
Expand All @@ -22,7 +23,7 @@ public function testGivenCoordinateAndRadius_parserReturnsCircle() {

$circle = $parser->parse( '57.421,23.90625:32684.605182' );

$this->assertInstanceOf( 'Maps\Elements\Circle', $circle );
$this->assertInstanceOf( Circle::class, $circle );

$expectedLatLong = new LatLongValue( 57.421, 23.90625 );
$this->assertTrue( $expectedLatLong->equals( $circle->getCircleCentre() ) );
Expand All @@ -35,7 +36,7 @@ public function testGivenTitleAndText_circleHasProvidedMetaData() {

$circle = $parser->parse( '57.421,23.90625:32684.605182~title~text' );

$this->assertInstanceOf( 'Maps\Elements\Circle', $circle );
$this->assertInstanceOf( Circle::class, $circle );

$this->assertEquals( 'title', $circle->getTitle() );
$this->assertEquals( 'text', $circle->getText() );
Expand Down
5 changes: 3 additions & 2 deletions tests/phpunit/parsers/RectlangleParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Maps\Test;

use DataValues\Geo\Values\LatLongValue;
use Maps\Elements\Rectangle;
use Maps\RectangleParser;

/**
Expand All @@ -22,7 +23,7 @@ public function testGivenBoundingBox_parserReturnsRectangle() {

$rectangle = $parser->parse( '51.8357775,33.83789:46,23.37890625' );

$this->assertInstanceOf( 'Maps\Elements\Rectangle', $rectangle );
$this->assertInstanceOf( Rectangle::class, $rectangle );

$expectedNorthEast = new LatLongValue( 51.8357775, 33.83789 );
$this->assertTrue( $expectedNorthEast->equals( $rectangle->getRectangleNorthEast() ) );
Expand All @@ -36,7 +37,7 @@ public function testGivenTitleAndText_rectangleHasProvidedMetaData() {

$rectangle = $parser->parse( "51.8357775,33.83789:46,23.37890625~I'm a square~of doom" );

$this->assertInstanceOf( 'Maps\Elements\Rectangle', $rectangle );
$this->assertInstanceOf( Rectangle::class, $rectangle );

$this->assertEquals( "I'm a square", $rectangle->getTitle() );
$this->assertEquals( 'of doom', $rectangle->getText() );
Expand Down

0 comments on commit 92f7690

Please sign in to comment.