Skip to content

Commit 01d3de9

Browse files
authored
Merge pull request #744 from wmde/classFeature
Make use of the …::class feature
2 parents fbb68a2 + 56650be commit 01d3de9

32 files changed

Lines changed: 94 additions & 71 deletions

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"irc": "irc://irc.freenode.net/wikidata"
2424
},
2525
"require": {
26-
"php": ">=5.5.0",
26+
"php": ">=5.5.9",
2727
"data-values/data-values": "~0.1|~1.0",
2828
"wikimedia/assert": "~0.2.2"
2929
},

src/Snak/SnakList.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function __construct( $snaks = [] ) {
4444
* @return string
4545
*/
4646
public function getObjectType() {
47-
return 'Wikibase\DataModel\Snak\Snak';
47+
return Snak::class;
4848
}
4949

5050
/**

tests/fixtures/HashArrayWithoutDuplicates.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Wikibase\DataModel\Fixtures;
44

5+
use Hashable;
56
use Wikibase\DataModel\HashArray;
67

78
/**
@@ -11,7 +12,7 @@
1112
class HashArrayWithoutDuplicates extends HashArray {
1213

1314
public function getObjectType() {
14-
return '\Hashable';
15+
return Hashable::class;
1516
}
1617

1718
}

tests/unit/ByPropertyIdArrayTest.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@
44

55
use ArrayObject;
66
use DataValues\StringValue;
7+
use InvalidArgumentException;
8+
use OutOfBoundsException;
79
use PHPUnit_Framework_TestCase;
810
use ReflectionClass;
911
use ReflectionMethod;
12+
use RuntimeException;
1013
use stdClass;
1114
use Wikibase\DataModel\ByPropertyIdArray;
1215
use Wikibase\DataModel\Entity\PropertyId;
@@ -39,7 +42,7 @@ public function testGivenNonTraversableObject_constructorDoesNotCastObjectToArra
3942
$object = new stdClass();
4043
$object->property = true;
4144

42-
$this->setExpectedException( 'InvalidArgumentException' );
45+
$this->setExpectedException( InvalidArgumentException::class );
4346
new ByPropertyIdArray( $object );
4447
}
4548

@@ -67,7 +70,7 @@ public function testArrayObjectNotConstructedFromObject() {
6770
* @return ReflectionMethod
6871
*/
6972
protected static function getMethod( $methodName ) {
70-
$class = new ReflectionClass( 'Wikibase\DataModel\ByPropertyIdArray' );
73+
$class = new ReflectionClass( ByPropertyIdArray::class );
7174
$method = $class->getMethod( $methodName );
7275
$method->setAccessible( true );
7376
return $method;
@@ -209,22 +212,22 @@ public function testGetByNotSetIdThrowsException() {
209212
$indexedArray = new ByPropertyIdArray();
210213
$indexedArray->buildIndex();
211214

212-
$this->setExpectedException( 'OutOfBoundsException' );
215+
$this->setExpectedException( OutOfBoundsException::class );
213216

214217
$indexedArray->getByPropertyId( new PropertyId( 'P9000' ) );
215218
}
216219

217220
public function testNotBuildExceptionIsThrownForByPropertyId() {
218221
$indexedArray = new ByPropertyIdArray();
219222

220-
$this->setExpectedException( 'RuntimeException' );
223+
$this->setExpectedException( RuntimeException::class );
221224
$indexedArray->getByPropertyId( new PropertyId( 'P9000' ) );
222225
}
223226

224227
public function testNotBuildExceptionIsThrownForGetPropertyIds() {
225228
$indexedArray = new ByPropertyIdArray();
226229

227-
$this->setExpectedException( 'RuntimeException' );
230+
$this->setExpectedException( RuntimeException::class );
228231
$indexedArray->getPropertyIds();
229232
}
230233

@@ -341,7 +344,7 @@ public function testMoveThrowingOutOfBoundsExceptionIfObjectNotPresent() {
341344
$indexedArray = new ByPropertyIdArray( $statements );
342345
$indexedArray->buildIndex();
343346

344-
$this->setExpectedException( 'OutOfBoundsException' );
347+
$this->setExpectedException( OutOfBoundsException::class );
345348

346349
$indexedArray->moveObjectToIndex( new Statement( new PropertyNoValueSnak( new PropertyId( 'P9999' ) ) ), 0 );
347350
}
@@ -351,7 +354,7 @@ public function testMoveThrowingOutOfBoundsExceptionOnInvalidIndex() {
351354
$indexedArray = new ByPropertyIdArray( $statements );
352355
$indexedArray->buildIndex();
353356

354-
$this->setExpectedException( 'OutOfBoundsException' );
357+
$this->setExpectedException( OutOfBoundsException::class );
355358

356359
$indexedArray->moveObjectToIndex( $statements[0], 9999 );
357360
}

tests/unit/Entity/BasicEntityIdParserTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Wikibase\DataModel\Entity\BasicEntityIdParser;
66
use Wikibase\DataModel\Entity\EntityId;
7+
use Wikibase\DataModel\Entity\EntityIdParsingException;
78
use Wikibase\DataModel\Entity\ItemId;
89
use Wikibase\DataModel\Entity\PropertyId;
910

@@ -41,7 +42,7 @@ public function entityIdProvider() {
4142
public function testCannotParseInvalidId( $invalidIdSerialization ) {
4243
$parser = new BasicEntityIdParser();
4344

44-
$this->setExpectedException( 'Wikibase\DataModel\Entity\EntityIdParsingException' );
45+
$this->setExpectedException( EntityIdParsingException::class );
4546
$parser->parse( $invalidIdSerialization );
4647
}
4748

tests/unit/Entity/DispatchingEntityIdParserTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Wikibase\DataModel\Entity\BasicEntityIdParser;
66
use Wikibase\DataModel\Entity\DispatchingEntityIdParser;
77
use Wikibase\DataModel\Entity\EntityId;
8+
use Wikibase\DataModel\Entity\EntityIdParsingException;
89
use Wikibase\DataModel\Entity\ItemId;
910
use Wikibase\DataModel\Entity\PropertyId;
1011

@@ -50,7 +51,7 @@ public function entityIdProvider() {
5051
public function testCannotParseInvalidId( $invalidIdSerialization ) {
5152
$parser = $this->getBasicParser();
5253

53-
$this->setExpectedException( 'Wikibase\DataModel\Entity\EntityIdParsingException' );
54+
$this->setExpectedException( EntityIdParsingException::class );
5455
$parser->parse( $invalidIdSerialization );
5556
}
5657

@@ -74,7 +75,7 @@ public function invalidIdSerializationProvider() {
7475
public function testCannotParseWithoutBuilders() {
7576
$parser = new DispatchingEntityIdParser( [] );
7677

77-
$this->setExpectedException( 'Wikibase\DataModel\Entity\EntityIdParsingException' );
78+
$this->setExpectedException( EntityIdParsingException::class );
7879
$parser->parse( 'Q1' );
7980
}
8081

tests/unit/Entity/EntityIdValueTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Wikibase\DataModel\Tests\Entity;
44

5+
use DataValues\IllegalValueException;
56
use PHPUnit_Framework_TestCase;
67
use Wikibase\DataModel\Entity\EntityId;
78
use Wikibase\DataModel\Entity\EntityIdValue;
@@ -200,7 +201,7 @@ public function validArrayProvider() {
200201
* @dataProvider invalidArrayProvider
201202
*/
202203
public function testCannotDeserializeInvalidSerialization( $invalidArray ) {
203-
$this->setExpectedException( 'DataValues\IllegalValueException' );
204+
$this->setExpectedException( IllegalValueException::class );
204205

205206
EntityIdValue::newFromArray( $invalidArray );
206207
}

tests/unit/Entity/EntityRedirectTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Wikibase\DataModel\Tests\Entity;
44

5+
use InvalidArgumentException;
56
use Wikibase\DataModel\Entity\EntityRedirect;
67
use Wikibase\DataModel\Entity\ItemId;
78
use Wikibase\DataModel\Entity\PropertyId;
@@ -28,7 +29,7 @@ public function testConstruction() {
2829
}
2930

3031
public function testConstruction_baseType() {
31-
$this->setExpectedException( 'InvalidArgumentException' );
32+
$this->setExpectedException( InvalidArgumentException::class );
3233

3334
$entityId = new ItemId( 'Q123' );
3435
$targetId = new PropertyId( 'P345' );

tests/unit/Entity/ItemIdParserTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Wikibase\DataModel\Tests\Entity;
44

55
use PHPUnit_Framework_TestCase;
6+
use Wikibase\DataModel\Entity\EntityIdParsingException;
67
use Wikibase\DataModel\Entity\ItemId;
78
use Wikibase\DataModel\Entity\ItemIdParser;
89

@@ -37,7 +38,7 @@ public function entityIdProvider() {
3738
public function testCannotParseInvalidId( $invalidIdSerialization ) {
3839
$parser = new ItemIdParser();
3940

40-
$this->setExpectedException( 'Wikibase\DataModel\Entity\EntityIdParsingException' );
41+
$this->setExpectedException( EntityIdParsingException::class );
4142
$parser->parse( $invalidIdSerialization );
4243
}
4344

tests/unit/Entity/ItemIdSetTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Wikibase\DataModel\Tests\Entity;
44

5+
use Traversable;
56
use Wikibase\DataModel\Entity\ItemId;
67
use Wikibase\DataModel\Entity\ItemIdSet;
78

@@ -18,7 +19,7 @@ class ItemIdSetTest extends \PHPUnit_Framework_TestCase {
1819

1920
public function testGetIterator() {
2021
$set = new ItemIdSet();
21-
$this->assertInstanceOf( 'Traversable', $set->getIterator() );
22+
$this->assertInstanceOf( Traversable::class, $set->getIterator() );
2223
}
2324

2425
/**

0 commit comments

Comments
 (0)