diff --git a/lib/private/AllConfig.php b/lib/private/AllConfig.php
index 6e99e1ac268bd7552843ecea3dc26854409a5d7b..e082cea3305ea6c170ef0387a356feab7eb5a56a 100644
--- a/lib/private/AllConfig.php
+++ b/lib/private/AllConfig.php
@@ -154,7 +154,7 @@ class AllConfig implements \OCP\IConfig {
 	 *
 	 * @param string $appName the appName that we want to store the value under
 	 * @param string $key the key of the value, under which will be saved
-	 * @param string $value the value that should be stored
+	 * @param string|float|int $value the value that should be stored
 	 */
 	public function setAppValue($appName, $key, $value) {
 		\OC::$server->getAppConfig()->setValue($appName, $key, $value);
@@ -198,11 +198,16 @@ class AllConfig implements \OCP\IConfig {
 	 * @param string $userId the userId of the user that we want to store the value under
 	 * @param string $appName the appName that we want to store the value under
 	 * @param string $key the key under which the value is being stored
-	 * @param string $value the value that you want to store
+	 * @param string|float|int $value the value that you want to store
 	 * @param string $preCondition only update if the config value was previously the value passed as $preCondition
 	 * @throws \OCP\PreConditionNotMetException if a precondition is specified and is not met
+	 * @throws \UnexpectedValueException when trying to store an unexpected value
 	 */
 	public function setUserValue($userId, $appName, $key, $value, $preCondition = null) {
+		if (!is_int($value) && !is_float($value) && !is_string($value)) {
+			throw new \UnexpectedValueException('Only integers, floats and strings are allowed as value');
+		}
+
 		// TODO - FIXME
 		$this->fixDIInit();
 
diff --git a/lib/private/AppConfig.php b/lib/private/AppConfig.php
index 24542152ffca9de27f94343ed4eb6c85b5ab3cb6..f84c8a41f17be680ee59afa6422465b90aaac87f 100644
--- a/lib/private/AppConfig.php
+++ b/lib/private/AppConfig.php
@@ -143,7 +143,7 @@ class AppConfig implements IAppConfig {
 	 *
 	 * @param string $app app
 	 * @param string $key key
-	 * @param string $value value
+	 * @param string|float|int $value value
 	 * @return bool True if the value was inserted or updated, false if the value was the same
 	 */
 	public function setValue($app, $key, $value) {
diff --git a/lib/public/IAppConfig.php b/lib/public/IAppConfig.php
index 1406e8a56d6e52cbbb29dd224db2963e1ba39028..22fcdbbb205762c37c3eb1e71f3b4a9c135f5ef5 100644
--- a/lib/public/IAppConfig.php
+++ b/lib/public/IAppConfig.php
@@ -88,7 +88,7 @@ interface IAppConfig {
 	 * sets a value in the appconfig
 	 * @param string $app app
 	 * @param string $key key
-	 * @param string $value value
+	 * @param string|float|int $value value
 	 * @deprecated 8.0.0 use method setAppValue of \OCP\IConfig
 	 *
 	 * Sets a value. If the key did not exist before it will be created.
diff --git a/lib/public/IConfig.php b/lib/public/IConfig.php
index 9e5024545b3a968e7822df465fe6916dff3f0115..05158e9063e030014ca207bf9ed7e98311b05fe4 100644
--- a/lib/public/IConfig.php
+++ b/lib/public/IConfig.php
@@ -104,7 +104,7 @@ interface IConfig {
 	 * Writes a new app wide value
 	 *
 	 * @param string $appName the appName that we want to store the value under
-	 * @param string $key the key of the value, under which will be saved
+	 * @param string|float|int $key the key of the value, under which will be saved
 	 * @param string $value the value that should be stored
 	 * @return void
 	 * @since 6.0.0
@@ -149,6 +149,7 @@ interface IConfig {
 	 * @param string $value the value that you want to store
 	 * @param string $preCondition only update if the config value was previously the value passed as $preCondition
 	 * @throws \OCP\PreConditionNotMetException if a precondition is specified and is not met
+	 * @throws \UnexpectedValueException when trying to store an unexpected value
 	 * @since 6.0.0 - parameter $precondition was added in 8.0.0
 	 */
 	public function setUserValue($userId, $appName, $key, $value, $preCondition = null);
diff --git a/tests/lib/AllConfigTest.php b/tests/lib/AllConfigTest.php
index 4f8b0658b8076430d89cb4359361a093d1c09aeb..3d0a9cb08279229da5ea47ff93a068c6cf99136d 100644
--- a/tests/lib/AllConfigTest.php
+++ b/tests/lib/AllConfigTest.php
@@ -123,6 +123,25 @@ class AllConfigTest extends \Test\TestCase {
 		$config->deleteUserValue('userPreCond', 'appPreCond', 'keyPreCond');
 	}
 
+	public function dataSetUserValueUnexpectedValue() {
+		return [
+			[true],
+			[false],
+			[null],
+			[new \stdClass()],
+		];
+	}
+
+	/**
+	 * @dataProvider dataSetUserValueUnexpectedValue
+	 * @param mixed $value
+	 * @expectedException \UnexpectedValueException
+	 */
+	public function testSetUserValueUnexpectedValue($value) {
+		$config = $this->getConfig();
+		$config->setUserValue('userSetBool', 'appSetBool', 'keySetBool', $value);
+	}
+
 	/**
 	 * @expectedException \OCP\PreConditionNotMetException
 	 */