Skip to content

Commit 94f7b23

Browse files
committed
Merge pull request #546 from wmde/iteratorArrays
Add workaround type hints to getIterator implementations
2 parents b7d8c67 + ab9cde3 commit 94f7b23

5 files changed

Lines changed: 14 additions & 8 deletions

File tree

src/Entity/ItemIdSet.php

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

33
namespace Wikibase\DataModel\Entity;
44

5+
use ArrayIterator;
56
use Comparable;
67
use Countable;
78
use InvalidArgumentException;
@@ -51,10 +52,10 @@ public function count() {
5152
/**
5253
* @see IteratorAggregate::getIterator
5354
*
54-
* @return Traversable
55+
* @return Traversable|ItemId[]
5556
*/
5657
public function getIterator() {
57-
return new \ArrayIterator( $this->ids );
58+
return new ArrayIterator( $this->ids );
5859
}
5960

6061
/**

src/Statement/StatementByGuidMap.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
*/
2424
class StatementByGuidMap implements IteratorAggregate, Countable {
2525

26+
/**
27+
* @var Statement[]
28+
*/
2629
private $statements = array();
2730

2831
/**
@@ -104,7 +107,7 @@ public function count() {
104107
* The iterator has the GUIDs of the statements as keys.
105108
*
106109
* @see IteratorAggregate::getIterator
107-
* @return Traversable
110+
* @return Traversable|Statement[]
108111
*/
109112
public function getIterator() {
110113
return new ArrayIterator( $this->statements );

src/Statement/StatementList.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ public function getMainSnaks() {
224224
}
225225

226226
/**
227-
* @return Traversable
227+
* @return Traversable|Statement[]
228228
*/
229229
public function getIterator() {
230230
return new ArrayIterator( $this->statements );

src/Term/AliasGroupList.php

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

33
namespace Wikibase\DataModel\Term;
44

5+
use ArrayIterator;
56
use Countable;
67
use InvalidArgumentException;
78
use IteratorAggregate;
@@ -51,10 +52,10 @@ public function count() {
5152

5253
/**
5354
* @see IteratorAggregate::getIterator
54-
* @return Traversable
55+
* @return Traversable|AliasGroup[]
5556
*/
5657
public function getIterator() {
57-
return new \ArrayIterator( $this->groups );
58+
return new ArrayIterator( $this->groups );
5859
}
5960

6061
/**

src/Term/TermList.php

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

33
namespace Wikibase\DataModel\Term;
44

5+
use ArrayIterator;
56
use Comparable;
67
use Countable;
78
use InvalidArgumentException;
@@ -64,10 +65,10 @@ public function toTextArray() {
6465

6566
/**
6667
* @see IteratorAggregate::getIterator
67-
* @return Traversable
68+
* @return Traversable|Term[]
6869
*/
6970
public function getIterator() {
70-
return new \ArrayIterator( $this->terms );
71+
return new ArrayIterator( $this->terms );
7172
}
7273

7374
/**

0 commit comments

Comments
 (0)