Thiemo Mättig (WMDE) has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/316315

Change subject: Add Traversable as a pseudo-type
......................................................................

Add Traversable as a pseudo-type

This is a resubmission of https://github.com/wikimedia/Assert/pull/13
first reported as https://github.com/wikimedia/Assert/issues/5

Change-Id: If2c80f5e5460d6b4de3bc4668b6c9f4cd19af921
---
M src/Assert.php
M tests/phpunit/AssertTest.php
2 files changed, 6 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/libs/Assert 
refs/changes/15/316315/1

diff --git a/src/Assert.php b/src/Assert.php
index 77dccd3..7f6e6c6 100644
--- a/src/Assert.php
+++ b/src/Assert.php
@@ -15,6 +15,7 @@
  *
  * @license MIT
  * @author Daniel Kinzler
+ * @author Thiemo Mättig
  * @copyright Wikimedia Deutschland e.V.
  */
 class Assert {
@@ -182,6 +183,10 @@
                        return true;
                }
 
+               if ( is_array( $value ) && in_array( 'Traversable', 
$allowedTypes ) ) {
+                       return true;
+               }
+
                return false;
        }
 
diff --git a/tests/phpunit/AssertTest.php b/tests/phpunit/AssertTest.php
index 5b68b31..4391983 100644
--- a/tests/phpunit/AssertTest.php
+++ b/tests/phpunit/AssertTest.php
@@ -65,6 +65,7 @@
                        } ),
 
                        'Traversable' => array( 'Traversable', new 
ArrayObject() ),
+                       'Traversable array' => array( 'Traversable', array() ),
                );
        }
 

-- 
To view, visit https://gerrit.wikimedia.org/r/316315
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If2c80f5e5460d6b4de3bc4668b6c9f4cd19af921
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/libs/Assert
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to