Skip to content

Commit 04833c1

Browse files
lucaswerkmeisterWMDE bot
authored andcommitted
Enable MediaWiki.Arrays.TrailingComma sniff
Enforce trailing commas in multi-line arrays, and no trailing commas in single-line arrays. In one line in FullStatementRdfBuilderTest, the extra comma pushes the line length over the hard limit (140 → 141 characters), so split the array across multiple lines to keep it below the limit. The same thing happens in one line in RdfBuilderTest, so split the DatabaseEntitySource constructor call across multiple lines. Bug: T325532 Change-Id: I184b019ba7ab8b435cd0774cac04011dac4585bd
1 parent a5c52b6 commit 04833c1

23 files changed

+125
-125
lines changed

src/Entity/SerializableEntityId.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ private static function extractSerializationParts( $serialization ) {
101101
return [
102102
is_string( $repoName ) ? $repoName : '',
103103
$prefixRemainder,
104-
$localPart
104+
$localPart,
105105
];
106106
}
107107

src/ReferenceList.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ public function serialize() {
239239
*/
240240
public function __serialize() {
241241
return [
242-
'references' => array_values( $this->references )
242+
'references' => array_values( $this->references ),
243243
];
244244
}
245245

tests/unit/ByPropertyIdArrayTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -372,19 +372,19 @@ public function addProvider() {
372372
[ $c[0], $c[1], $c[3] ],
373373
$c[5],
374374
1,
375-
[ $c[0], $c[1], $c[5], $c[3] ]
375+
[ $c[0], $c[1], $c[5], $c[3] ],
376376
];
377377
$argLists[] = [
378378
[ $c[0], $c[1], $c[5], $c[3] ],
379379
$c[2],
380380
2,
381-
[ $c[0], $c[1], $c[2], $c[3], $c[5] ]
381+
[ $c[0], $c[1], $c[2], $c[3], $c[5] ],
382382
];
383383
$argLists[] = [
384384
[ $c[0], $c[1], $c[2], $c[3], $c[5] ],
385385
$c[4],
386386
null,
387-
[ $c[0], $c[1], $c[2], $c[3], $c[4], $c[5] ]
387+
[ $c[0], $c[1], $c[2], $c[3], $c[4], $c[5] ],
388388
];
389389

390390
return $argLists;

tests/unit/Entity/EntityIdTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,15 @@ public function deserializationCompatibilityProvider(): array {
5959
return [
6060
'v05serialization' => [
6161
new ItemId( 'q123' ),
62-
'C:32:"Wikibase\DataModel\Entity\ItemId":15:{["item","Q123"]}'
62+
'C:32:"Wikibase\DataModel\Entity\ItemId":15:{["item","Q123"]}',
6363
],
6464
'v07serialization' => [
6565
new ItemId( 'q123' ),
66-
'C:32:"Wikibase\DataModel\Entity\ItemId":4:{Q123}'
66+
'C:32:"Wikibase\DataModel\Entity\ItemId":4:{Q123}',
6767
],
6868
'2022-03 PHP 7.4+' => [
6969
new ItemId( 'q123' ),
70-
'O:32:"Wikibase\DataModel\Entity\ItemId":1:{s:13:"serialization";s:4:"Q123";}'
70+
'O:32:"Wikibase\DataModel\Entity\ItemId":1:{s:13:"serialization";s:4:"Q123";}',
7171
],
7272
];
7373
}

tests/unit/Entity/EntityIdValueTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public function provideGetArrayValue() {
8686
[
8787
'entity-type' => 'item',
8888
'numeric-id' => 2147483647,
89-
'id' => 'Q2147483647'
89+
'id' => 'Q2147483647',
9090
],
9191
],
9292
'P31337' => [
@@ -143,27 +143,27 @@ public function provideDeserializationCompatibility() {
143143
return [
144144
'local: Version 0.5 alpha (f5b8b64)' => [
145145
'C:39:"Wikibase\DataModel\Entity\EntityIdValue":14:{["item",31337]}',
146-
$local
146+
$local,
147147
],
148148
'local: Version 7.0 (7fcddfc)' => [
149149
'C:39:"Wikibase\DataModel\Entity\EntityIdValue":'
150150
. '50:{C:32:"Wikibase\DataModel\Entity\ItemId":6:{Q31337}}',
151-
$local
151+
$local,
152152
],
153153
'foreign: Version 7.0 (7fcddfc)' => [
154154
'C:39:"Wikibase\DataModel\Entity\EntityIdValue":'
155155
. '63:{C:43:"Wikibase\DataModel\Entity\NumericPropertyId":8:{foo:P678}}',
156-
$foreign
156+
$foreign,
157157
],
158158
'custom: Version 7.0 (7fcddfc): custom' => [
159159
'C:39:"Wikibase\DataModel\Entity\EntityIdValue":'
160160
. '58:{C:42:"Wikibase\DataModel\Fixtures\CustomEntityId":4:{X567}}',
161-
$custom
161+
$custom,
162162
],
163163
'local 2022-03 PHP 7.4+' => [
164164
'O:39:"Wikibase\DataModel\Entity\EntityIdValue":'
165165
. '1:{s:8:"entityId";O:32:"Wikibase\DataModel\Entity\ItemId":1:{s:13:"serialization";s:6:"Q31337";}}',
166-
$local
166+
$local,
167167
],
168168
];
169169
}

tests/unit/Entity/ItemTest.php

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -77,35 +77,35 @@ public function simpleSiteLinkProvider() {
7777
'enwiki',
7878
'Wikidata',
7979
[
80-
new ItemId( 'Q42' )
80+
new ItemId( 'Q42' ),
8181
]
82-
)
82+
),
8383
];
8484
$argLists[] = [
8585
new SiteLink(
8686
'nlwiki',
8787
'Wikidata'
88-
)
88+
),
8989
];
9090
$argLists[] = [
9191
new SiteLink(
9292
'enwiki',
9393
'Nyan!',
9494
[
9595
new ItemId( 'Q42' ),
96-
new ItemId( 'Q149' )
96+
new ItemId( 'Q149' ),
9797
]
98-
)
98+
),
9999
];
100100
$argLists[] = [
101101
new SiteLink(
102102
'foo bar',
103103
'baz bah',
104104
[
105105
new ItemId( 'Q3' ),
106-
new ItemId( 'Q7' )
106+
new ItemId( 'Q7' ),
107107
]
108-
)
108+
),
109109
];
110110

111111
return $argLists;
@@ -120,13 +120,13 @@ public function simpleSiteLinksProvider() {
120120

121121
$argLists[] = [
122122
new SiteLink( 'enwiki', 'Wikidata' ),
123-
new SiteLink( 'nlwiki', 'Wikidata', [ new ItemId( 'Q3' ) ] )
123+
new SiteLink( 'nlwiki', 'Wikidata', [ new ItemId( 'Q3' ) ] ),
124124
];
125125

126126
$argLists[] = [
127127
new SiteLink( 'enwiki', 'Wikidata' ),
128128
new SiteLink( 'nlwiki', 'Wikidata' ),
129-
new SiteLink( 'foo bar', 'baz bah', [ new ItemId( 'Q2' ) ] )
129+
new SiteLink( 'foo bar', 'baz bah', [ new ItemId( 'Q2' ) ] ),
130130
];
131131

132132
return $argLists;
@@ -618,10 +618,10 @@ public function testWhenTermsAreSet_getFingerprintReturnsFingerprintWithTerms()
618618
new Term( 'en', 'foo' ),
619619
] ),
620620
new TermList( [
621-
new Term( 'en', 'foo bar' )
621+
new Term( 'en', 'foo bar' ),
622622
] ),
623623
new AliasGroupList( [
624-
new AliasGroup( 'en', [ 'foo', 'bar' ] )
624+
new AliasGroup( 'en', [ 'foo', 'bar' ] ),
625625
] )
626626
),
627627
$entity->getFingerprint()
@@ -653,10 +653,10 @@ public function testWhenSettingFingerprint_getFingerprintReturnsIt() {
653653
new Term( 'en', 'english label' ),
654654
] ),
655655
new TermList( [
656-
new Term( 'en', 'english description' )
656+
new Term( 'en', 'english description' ),
657657
] ),
658658
new AliasGroupList( [
659-
new AliasGroup( 'en', [ 'first en alias', 'second en alias' ] )
659+
new AliasGroup( 'en', [ 'first en alias', 'second en alias' ] ),
660660
] )
661661
);
662662

@@ -673,7 +673,7 @@ public function testGetLabels() {
673673

674674
$this->assertEquals(
675675
new TermList( [
676-
new Term( 'en', 'foo' )
676+
new Term( 'en', 'foo' ),
677677
] ),
678678
$item->getLabels()
679679
);
@@ -685,7 +685,7 @@ public function testGetDescriptions() {
685685

686686
$this->assertEquals(
687687
new TermList( [
688-
new Term( 'en', 'foo bar' )
688+
new Term( 'en', 'foo bar' ),
689689
] ),
690690
$item->getDescriptions()
691691
);
@@ -697,7 +697,7 @@ public function testGetAliasGroups() {
697697

698698
$this->assertEquals(
699699
new AliasGroupList( [
700-
new AliasGroup( 'en', [ 'foo', 'bar' ] )
700+
new AliasGroup( 'en', [ 'foo', 'bar' ] ),
701701
] ),
702702
$item->getAliasGroups()
703703
);
@@ -744,7 +744,7 @@ public function testClear( Item $item ) {
744744

745745
public function clearableProvider() {
746746
return [
747-
'empty' => [ new Item( new ItemId( 'Q23' ) ), ],
747+
'empty' => [ new Item( new ItemId( 'Q23' ) ) ],
748748
'with fingerprint' => [
749749
new Item(
750750
new ItemId( 'Q42' ),
@@ -756,16 +756,16 @@ public function clearableProvider() {
756756
new ItemId( 'Q123' ),
757757
null,
758758
new SiteLinkList( [ new SiteLink( 'enwiki', 'Wikidata' ) ] )
759-
)
759+
),
760760
],
761761
'with statement' => [
762762
new Item(
763763
new ItemId( 'Q321' ),
764764
null,
765765
null,
766766
new StatementList( $this->newStatement() )
767-
)
768-
]
767+
),
768+
],
769769
];
770770
}
771771

tests/unit/Entity/PropertyTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -492,10 +492,10 @@ public function testWhenTermsAreSet_getFingerprintReturnsFingerprintWithTerms()
492492
new Term( 'en', 'foo' ),
493493
] ),
494494
new TermList( [
495-
new Term( 'en', 'foo bar' )
495+
new Term( 'en', 'foo bar' ),
496496
] ),
497497
new AliasGroupList( [
498-
new AliasGroup( 'en', [ 'foo', 'bar' ] )
498+
new AliasGroup( 'en', [ 'foo', 'bar' ] ),
499499
] )
500500
),
501501
$entity->getFingerprint()
@@ -527,10 +527,10 @@ public function testWhenSettingFingerprint_getFingerprintReturnsIt() {
527527
new Term( 'en', 'english label' ),
528528
] ),
529529
new TermList( [
530-
new Term( 'en', 'english description' )
530+
new Term( 'en', 'english description' ),
531531
] ),
532532
new AliasGroupList( [
533-
new AliasGroup( 'en', [ 'first en alias', 'second en alias' ] )
533+
new AliasGroup( 'en', [ 'first en alias', 'second en alias' ] ),
534534
] )
535535
);
536536

@@ -547,7 +547,7 @@ public function testGetLabels() {
547547

548548
$this->assertEquals(
549549
new TermList( [
550-
new Term( 'en', 'foo' )
550+
new Term( 'en', 'foo' ),
551551
] ),
552552
$property->getLabels()
553553
);
@@ -559,7 +559,7 @@ public function testGetDescriptions() {
559559

560560
$this->assertEquals(
561561
new TermList( [
562-
new Term( 'en', 'foo bar' )
562+
new Term( 'en', 'foo bar' ),
563563
] ),
564564
$property->getDescriptions()
565565
);
@@ -571,7 +571,7 @@ public function testGetAliasGroups() {
571571

572572
$this->assertEquals(
573573
new AliasGroupList( [
574-
new AliasGroup( 'en', [ 'foo', 'bar' ] )
574+
new AliasGroup( 'en', [ 'foo', 'bar' ] ),
575575
] ),
576576
$property->getAliasGroups()
577577
);
@@ -643,7 +643,7 @@ public function clearableProvider() {
643643
null,
644644
'wikibase-entityid',
645645
$this->newNonEmptyStatementList()
646-
)
646+
),
647647
],
648648
];
649649
}

tests/unit/ReferenceListTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ public function testGivenAnArrayOfSnaks_addNewReferenceAddsThem() {
481481
$snaks = [
482482
new PropertyNoValueSnak( 1 ),
483483
new PropertyNoValueSnak( 3 ),
484-
new PropertyNoValueSnak( 2 )
484+
new PropertyNoValueSnak( 2 ),
485485
];
486486

487487
$references->addNewReference( $snaks );

tests/unit/ReferenceTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function snakListProvider() {
3535
$snakLists[] = new SnakList( [
3636
new PropertyValueSnak( new NumericPropertyId( 'P1' ), new StringValue( 'a' ) ),
3737
new PropertySomeValueSnak( new NumericPropertyId( 'P2' ) ),
38-
new PropertyNoValueSnak( new NumericPropertyId( 'P3' ) )
38+
new PropertyNoValueSnak( new NumericPropertyId( 'P3' ) ),
3939
] );
4040

4141
$argLists = [];
@@ -136,7 +136,7 @@ public function unorderedReferenceProvider() {
136136
new PropertyValueSnak( $ids[0], new StringValue( 'a' ) ),
137137
new PropertySomeValueSnak( $ids[0] ),
138138
new PropertyNoValueSnak( $ids[1] ),
139-
] )
139+
] ),
140140
],
141141
[
142142
new SnakList( [

0 commit comments

Comments
 (0)