public static function getOptions($userSpecified, $defaults)
    {
        $options = static::getAnyOptions($userSpecified, $defaults);

        foreach ($options as $key => $null) {
            if (array_key_exists($key, $defaults)) {
                continue;
            }
            throw new \InvalidArgumentException("Unknown parameter (" . $key . ")");
        }

        return $options;
    }
public static function getOptions($userSpecified, $defaults)
    {
        $options = static::getAnyOptions($userSpecified, $defaults);

        foreach ($options as $key => $null) {
            if (array_key_exists($key, $defaults)) {
                continue;
            }
            throw new \InvalidArgumentException("Unknown parameter (" . $key . ")");
        }

        return $options;
    }
public static function getOptions ( $ userSpecified , $ defaults ) { $ options = static :: getAnyOptions ( $ userSpecified , $ defaults ) ; foreach ( $ options as $ key => $ null ) { if ( array_key_exists ( $ key , $ defaults ) ) { continue ; } throw new \ InvalidArgumentException ( "Unknown parameter (" . $ key . ")" ) ; } return $ options ; }
Simulate named arguments using associative arrays.
Basically just merge the two arrays, giving user specified options the preference.
Also ensures that each paramater in the user array is valid and throws an exception if an unknown element is found.

@param array $userSpecified The array of options passed to the function call
@param array $defaults The default options to be used

@return array
Simulate named arguments using associative arrays . Basically just merge the two arrays giving user specified options the preference . Also ensures that each paramater in the user array is valid and throws an exception if an unknown element is found .