Skip to content

Commit fb41c80

Browse files
authored
Merge pull request #829 from wmde/phpcs
Update wikibase/wikibase-codesniffer to 1.2.0
2 parents 3fcd2d3 + 06092ea commit fb41c80

28 files changed

Lines changed: 86 additions & 71 deletions

.phpcs.xml

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

55
<rule ref="Generic.Files.LineLength">
66
<properties>
7-
<property name="lineLimit" value="115" />
7+
<property name="lineLimit" value="120" />
88
</properties>
99
</rule>
1010

RELEASE-NOTES.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Wikibase DataModel release notes
22

3+
## Version 9.6.0 (development)
4+
5+
* `ReferenceList::addNewReference()`, `Statement::addNewReference()` and the `StatementList` constructor
6+
supported being called with a variadic argument list, with a single array argument,
7+
or (in the case of `StatementList`) with a single `Traversable` argument.
8+
The latter two forms are now deprecated (though they still work);
9+
please update your code:
10+
for instance, change `->addNewReference( [ $x, $y ] )` to `->addNewReference( $x, $y )`,
11+
and `->addNewReference( $snaks )` to `->addNewReference( ...$snaks )`.
12+
313
## Version 9.5.1 (2020-06-03)
414

515
* Updated release notes

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"ockcyp/covers-validator": "~1.1",
3636
"phpmd/phpmd": "~2.6",
3737
"phpunit/phpunit": "~8.0",
38-
"wikibase/wikibase-codesniffer": "~1.1.0"
38+
"wikibase/wikibase-codesniffer": "~1.2.0"
3939
},
4040
"autoload": {
4141
"psr-4": {

src/ReferenceList.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,15 @@ public function addReference( Reference $reference, $index = null ) {
9090
/**
9191
* @since 1.1
9292
*
93-
* @param Snak[]|Snak $snaks
94-
* @param Snak [$snak2,...]
93+
* @param Snak ...$snaks
94+
* (passing a single Snak[] is still supported but deprecated)
9595
*
9696
* @throws InvalidArgumentException
9797
*/
98-
public function addNewReference( $snaks = [] /*...*/ ) {
99-
if ( $snaks instanceof Snak ) {
100-
$snaks = func_get_args();
98+
public function addNewReference( ...$snaks ) {
99+
if ( count( $snaks ) === 1 && is_array( $snaks[0] ) ) {
100+
// TODO stop supporting this
101+
$snaks = $snaks[0];
101102
}
102103

103104
$this->addReference( new Reference( $snaks ) );

src/Statement/Statement.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,14 +175,15 @@ public function setReferences( ReferenceList $references ) {
175175
/**
176176
* @since 2.0
177177
*
178-
* @param Snak[]|Snak $snaks
179-
* @param Snak [$snak2,...]
178+
* @param Snak ...$snaks
179+
* (passing a single Snak[] is still supported but deprecated)
180180
*
181181
* @throws InvalidArgumentException
182182
*/
183-
public function addNewReference( $snaks = [] /*...*/ ) {
184-
if ( $snaks instanceof Snak ) {
185-
$snaks = func_get_args();
183+
public function addNewReference( ...$snaks ) {
184+
if ( count( $snaks ) === 1 && is_array( $snaks[0] ) ) {
185+
// TODO stop supporting this
186+
$snaks = $snaks[0];
186187
}
187188

188189
$this->references->addNewReference( $snaks );

src/Statement/StatementList.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,17 @@ class StatementList implements IteratorAggregate, Comparable, Countable {
3636
private $statements = [];
3737

3838
/**
39-
* @param Statement[]|Traversable|Statement $statements
40-
* @param Statement [$statement2,...]
39+
* @param Statement ...$statements
40+
* (passing a single Statement[] or Traversable is still supported but deprecated)
4141
*
4242
* @throws InvalidArgumentException
4343
*/
44-
public function __construct( $statements = [] /*...*/ ) {
45-
if ( $statements instanceof Statement ) {
46-
$statements = func_get_args();
44+
public function __construct( ...$statements ) {
45+
if ( count( $statements ) === 1 && (
46+
is_array( $statements[0] ) || $statements[0] instanceof Traversable
47+
) ) {
48+
// TODO stop supporting this
49+
$statements = $statements[0];
4750
}
4851

4952
if ( !is_array( $statements ) && !( $statements instanceof Traversable ) ) {

tests/unit/Entity/EntityIdTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function testSerializationStability() {
7272
$serialization = 'C:32:"Wikibase\DataModel\Entity\ItemId":4:{Q123}';
7373
$id = new ItemId( 'q123' );
7474

75-
$this->assertEquals(
75+
$this->assertSame(
7676
serialize( $id ),
7777
$serialization
7878
);

tests/unit/Entity/EntityIdValueTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function instanceProvider() {
6262
* @dataProvider instanceProvider
6363
*/
6464
public function testGetType( EntityIdValue $id ) {
65-
$this->assertEquals( 'wikibase-entityid', $id->getType() );
65+
$this->assertSame( 'wikibase-entityid', $id->getType() );
6666
}
6767

6868
/**

tests/unit/Entity/EntityRedirectTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ public function equalsProvider() {
8080
* @param bool $expected
8181
*/
8282
public function testEquals( EntityRedirect $a, $b, $expected ) {
83-
$this->assertEquals( $expected, $a->equals( $b ), '$a->equals( $b )' );
83+
$this->assertSame( $expected, $a->equals( $b ), '$a->equals( $b )' );
8484

8585
if ( $b instanceof EntityRedirect ) {
86-
$this->assertEquals( $expected, $b->equals( $a ), '$b->equals( $a )' );
86+
$this->assertSame( $expected, $b->equals( $a ), '$b->equals( $a )' );
8787
}
8888
}
8989

tests/unit/Entity/ItemIdSetTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function testGetIterator() {
2727
*/
2828
public function testGetSerializations( array $itemIds, array $expected ) {
2929
$set = new ItemIdSet( $itemIds );
30-
$this->assertEquals( $expected, $set->getSerializations() );
30+
$this->assertSame( $expected, $set->getSerializations() );
3131
}
3232

3333
public function serializationsProvider() {
@@ -48,7 +48,7 @@ public function testGivenSetWithTwoItems_countReturnsTwo() {
4848
new ItemId( 'Q1' ),
4949
new ItemId( 'Q2' ),
5050
] );
51-
$this->assertEquals( 2, $set->count() );
51+
$this->assertSame( 2, $set->count() );
5252
}
5353

5454
public function testGivenNotSetId_hasReturnsFalse() {

0 commit comments

Comments
 (0)