Ori.livneh has uploaded a new change for review.

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

Change subject: stop using wikimedia/assert
......................................................................

stop using wikimedia/assert

In XHProf profiles of Wikimedia edit requests, Wikimedia\Assert\Assert::hasType
has ranks somewhere between second and fourth place when sorting function calls
by exclusive CPU time. Replace it with a simple is_array() check and stop
verifying the type of each of the array's values.

Change-Id: I5a7a9f25912f4f1d8d2c274237999718bc8e68dd
---
M composer.json
M src/Reader/Hash.php
M tests/Reader/HashTest.php
3 files changed, 6 insertions(+), 18 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/cdb refs/changes/81/291581/1

diff --git a/composer.json b/composer.json
index f6c7fb7..bf54635 100644
--- a/composer.json
+++ b/composer.json
@@ -26,8 +26,7 @@
                ]
        },
        "require": {
-               "php": ">=5.3.2",
-               "wikimedia/assert": "~0.2.2"
+               "php": ">=5.3.2"
        },
        "require-dev": {
                "jakub-onderka/php-parallel-lint": "0.9",
diff --git a/src/Reader/Hash.php b/src/Reader/Hash.php
index 3010305..36bbc3b 100644
--- a/src/Reader/Hash.php
+++ b/src/Reader/Hash.php
@@ -52,9 +52,9 @@
         * @param string[] $data An associative PHP array.
         */
        public function __construct( $data ) {
-               Assert::parameterType( 'array', $data, '$data' );
-               Assert::parameterElementType( 'string', $data, '$data' );
-
+               if ( !is_array( $data ) ) {
+                       throw new \InvalidArgumentException( __METHOD__ . ': 
"$data" must be an array.' );
+               }
                $this->data = $data;
        }
 
diff --git a/tests/Reader/HashTest.php b/tests/Reader/HashTest.php
index bab34e7..70401fa 100644
--- a/tests/Reader/HashTest.php
+++ b/tests/Reader/HashTest.php
@@ -9,20 +9,9 @@
  */
 class HashTest extends \PHPUnit_Framework_TestCase {
 
-       public function provideConstructor_fail() {
-               return array(
-                       array( 'Foo' ),
-                       array( array( "x" => 1, "y" => 2 ) ),
-               );
-       }
-
-       /**
-        * @dataProvider provideConstructor_fail
-        */
-       public function testConstructor_fail( $data ) {
+       public function testConstructor_fail() {
                $this->setExpectedException( 'InvalidArgumentException' );
-
-               new Hash( $data );
+               new Hash( 'not an array' );
        }
 
        public function testClose() {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5a7a9f25912f4f1d8d2c274237999718bc8e68dd
Gerrit-PatchSet: 1
Gerrit-Project: cdb
Gerrit-Branch: master
Gerrit-Owner: Ori.livneh <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to