Skip to content

Commit 3e88cf0

Browse files
committed
Remove unused HashArray::rebuildIndices and indicesAreUpToDate
1 parent 3441060 commit 3e88cf0

3 files changed

Lines changed: 0 additions & 85 deletions

File tree

src/HashArray.php

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -334,49 +334,6 @@ public function removeDuplicates() {
334334
}
335335
}
336336

337-
/**
338-
* Returns if the hash indices are up to date.
339-
* For an HashArray with immutable objects this should always be the case.
340-
* For one with mutable objects it's the responsibility of the mutating code
341-
* to keep the indices up to date (see class documentation) and thus possible
342-
* this has not been done since the last update, thus causing a state where
343-
* one or more indices are out of date.
344-
*
345-
* @since 0.4
346-
*
347-
* @return bool
348-
*/
349-
public function indicesAreUpToDate() {
350-
foreach ( $this->offsetHashes as $hash => $offsets ) {
351-
$offsets = (array)$offsets;
352-
353-
foreach ( $offsets as $offset ) {
354-
/** @var Hashable[] $this */
355-
if ( $this[$offset]->getHash() !== $hash ) {
356-
return false;
357-
}
358-
}
359-
}
360-
361-
return true;
362-
}
363-
364-
/**
365-
* Removes and adds all elements, ensuring the indices are up to date.
366-
*
367-
* @since 0.4
368-
*/
369-
public function rebuildIndices() {
370-
$hashables = iterator_to_array( $this );
371-
372-
$this->offsetHashes = [];
373-
374-
foreach ( $hashables as $offset => $hashable ) {
375-
$this->offsetUnset( $offset );
376-
$this->offsetSet( $offset, $hashable );
377-
}
378-
}
379-
380337
/**
381338
* @see ArrayObject::append
382339
*

tests/unit/HashArray/HashArrayWithDuplicatesTest.php

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use Hashable;
66
use Wikibase\DataModel\Fixtures\HashArrayElement;
7-
use Wikibase\DataModel\Fixtures\MutableHashable;
87
use Wikibase\DataModel\HashArray;
98

109
/**
@@ -117,24 +116,4 @@ public function testGetHash( HashArray $array ) {
117116
);
118117
}
119118

120-
/**
121-
* @dataProvider instanceProvider
122-
* @param HashArray $array
123-
*/
124-
public function testIndicesAreUpToDate( HashArray $array ) {
125-
$this->assertInternalType( 'boolean', $array->indicesAreUpToDate() );
126-
127-
$mutable = new MutableHashable();
128-
129-
$array->addElement( $mutable );
130-
131-
$mutable->text = '~[,,_,,]:3';
132-
133-
$this->assertFalse( $array->indicesAreUpToDate() );
134-
135-
$array->rebuildIndices();
136-
137-
$this->assertTrue( $array->indicesAreUpToDate() );
138-
}
139-
140119
}

tests/unit/HashArray/HashArrayWithoutDuplicatesTest.php

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace Wikibase\DataModel\Tests\HashArray;
44

55
use Wikibase\DataModel\Fixtures\HashArrayElement;
6-
use Wikibase\DataModel\Fixtures\MutableHashable;
76
use Wikibase\DataModel\HashArray;
87

98
/**
@@ -114,24 +113,4 @@ public function testGetHash( HashArray $array ) {
114113
}
115114
}
116115

117-
/**
118-
* @dataProvider instanceProvider
119-
* @param HashArray $array
120-
*/
121-
public function testIndicesAreUpToDate( HashArray $array ) {
122-
$this->assertInternalType( 'boolean', $array->indicesAreUpToDate() );
123-
124-
$mutable = new MutableHashable();
125-
126-
$array->addElement( $mutable );
127-
128-
$mutable->text = '~[,,_,,]:3';
129-
130-
$this->assertFalse( $array->indicesAreUpToDate() );
131-
132-
$array->rebuildIndices();
133-
134-
$this->assertTrue( $array->indicesAreUpToDate() );
135-
}
136-
137116
}

0 commit comments

Comments
 (0)