File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55* Removed ` Claims ` class (deprecated since 1.0)
66* Removed ` getClaims ` and ` setClaims ` from ` Entity ` , ` Item ` and ` Property ` (deprecated since 1.0)
77* Removed ` ReferenceList::removeDuplicates `
8- * ` ReferenceList ` no longer derives from ` SplObjectStorage ` , though still implements ` Countable `
9- * ` ReferenceList ` now implements ` IteratorAggregate ` and has a ` toArray ` method
8+ * ` ReferenceList ` no longer derives from ` SplObjectStorage ` , though still implements ` Countable ` and ` Traversable `
9+ * ` ReferenceList ` now implements ` IteratorAggregate `
10+ * ` ReferenceList::addReference ` now throws an ` InvalidArgumentException ` for negative indices
1011* Removed ` HashableObjectStorage `
1112* ` Entity ` no longer implements ` Comparable `
1213* Added ` EntityDocument::equals `
Original file line number Diff line number Diff line change @@ -126,7 +126,7 @@ public function hasReference( Reference $reference ) {
126126 */
127127 public function indexOf ( Reference $ reference ) {
128128 foreach ( $ this ->references as $ index => $ ref ) {
129- if ( $ ref-> equals ( $ reference ) ) {
129+ if ( $ ref === $ reference ) {
130130 return $ index ;
131131 }
132132 }
@@ -283,13 +283,4 @@ public function getIterator() {
283283 return new ArrayIterator ( $ this ->references );
284284 }
285285
286- /**
287- * @since 5.0
288- *
289- * @return Reference[]
290- */
291- public function toArray () {
292- return $ this ->references ;
293- }
294-
295286}
Original file line number Diff line number Diff line change @@ -191,6 +191,17 @@ public function testAddReferenceAtIndexZero() {
191191 $ this ->assertSameReferenceOrder ( $ expectedList , $ references );
192192 }
193193
194+ public function testAddReferenceAtNegativeIndex () {
195+ $ reference1 = new Reference ( array ( new PropertyNoValueSnak ( 1 ) ) );
196+ $ reference2 = new Reference ( array ( new PropertyNoValueSnak ( 2 ) ) );
197+ $ reference3 = new Reference ( array ( new PropertyNoValueSnak ( 3 ) ) );
198+
199+ $ references = new ReferenceList ( array ( $ reference1 , $ reference2 ) );
200+
201+ $ this ->setExpectedException ( 'InvalidArgumentException ' );
202+ $ references ->addReference ( $ reference3 , -1 );
203+ }
204+
194205 public function testGivenEmptyReference_addReferenceDoesNotAdd () {
195206 $ reference1 = new Reference ( array ( new PropertyNoValueSnak ( 1 ) ) );
196207 $ reference2 = new Reference ( array ( new PropertyNoValueSnak ( 2 ) ) );
You can’t perform that action at this time.
0 commit comments