Skip to content

Commit 4f02fa4

Browse files
thiemowmdeWMDE bot
authored andcommitted
Drop reimplementations of is_iterable() & iterator_to_array()
Especially the SimpleCacheWithBagOStuff class is unnecessarily complex for no obvious reason. iterator_to_array() apparently exists since PHP 5.1. is_iterable() exists since PHP 7.1. Note the int/string validation was done twice before. This is all very well covered by PHPUnit tests. Pretty much guaranteed everything behaves exactly as before. Change-Id: I9fe716ab438ac27cd9af12e91275705ae796bde3
1 parent 2daf33f commit 4f02fa4

5 files changed

Lines changed: 5 additions & 5 deletions

File tree

src/ByPropertyIdArray.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class ByPropertyIdArray extends ArrayObject {
6161
* @throws InvalidArgumentException
6262
*/
6363
public function __construct( $input = null ) {
64-
if ( is_object( $input ) && !( $input instanceof Traversable ) ) {
64+
if ( $input && !is_iterable( $input ) ) {
6565
throw new InvalidArgumentException( '$input must be an array, Traversable or null' );
6666
}
6767

src/Internal/MapValueHasher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function __construct( $holdOrderIntoAccount = false ) {
3232
* @throws InvalidArgumentException
3333
*/
3434
public function hash( $map ) {
35-
if ( !is_array( $map ) && !( $map instanceof Traversable ) ) {
35+
if ( !is_iterable( $map ) ) {
3636
throw new InvalidArgumentException( '$map must be an array or an instance of Traversable' );
3737
}
3838

src/ReferenceList.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class ReferenceList implements Countable, IteratorAggregate, Serializable {
3737
* @throws InvalidArgumentException
3838
*/
3939
public function __construct( $references = [] ) {
40-
if ( !is_array( $references ) && !( $references instanceof Traversable ) ) {
40+
if ( !is_iterable( $references ) ) {
4141
throw new InvalidArgumentException( '$references must be an array or an instance of Traversable' );
4242
}
4343

src/SiteLinkList.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class SiteLinkList implements IteratorAggregate, Countable {
3535
* @throws InvalidArgumentException
3636
*/
3737
public function __construct( /* iterable */ $siteLinks = [] ) {
38-
if ( !is_array( $siteLinks ) && !( $siteLinks instanceof Traversable ) ) {
38+
if ( !is_iterable( $siteLinks ) ) {
3939
throw new InvalidArgumentException( '$siteLinks must be iterable' );
4040
}
4141

src/Snak/SnakList.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class SnakList extends ArrayObject {
3737
* @throws InvalidArgumentException
3838
*/
3939
public function __construct( $snaks = [] ) {
40-
if ( !is_array( $snaks ) && !( $snaks instanceof Traversable ) ) {
40+
if ( !is_iterable( $snaks ) ) {
4141
throw new InvalidArgumentException( '$snaks must be an array or an instance of Traversable' );
4242
}
4343

0 commit comments

Comments
 (0)