registration: Improve error message if a non-array attribute is set
authorKunal Mehta <legoktm@gmail.com>
Tue, 16 Jun 2015 23:08:44 +0000 (16:08 -0700)
committerKunal Mehta <legoktm@gmail.com>
Tue, 16 Jun 2015 23:08:44 +0000 (16:08 -0700)
Otherwise array_merge_recursive() will trigger a confusing and unhelpful
warning.

Bug: T102523
Change-Id: I7e4778cb7552fe93a08f315c9888ec64322e2501

includes/registration/ExtensionProcessor.php

index 0a09ff5..273e9ef 100644 (file)
@@ -290,10 +290,14 @@ class ExtensionProcessor implements Processor {
 
        /**
         * @param string $name
-        * @param mixed $value
+        * @param array $value
         * @param array &$array
+        * @throws InvalidArgumentException
         */
        protected function storeToArray( $name, $value, &$array ) {
+               if ( !is_array( $value ) ) {
+                       throw new InvalidArgumentException( "The value for '$name' should be an array" );
+               }
                if ( isset( $array[$name] ) ) {
                        $array[$name] = array_merge_recursive( $array[$name], $value );
                } else {