diff -u b/core/lib/Drupal/Core/TypedData/Plugin/DataType/Boolean.php b/core/lib/Drupal/Core/TypedData/Plugin/DataType/Boolean.php --- b/core/lib/Drupal/Core/TypedData/Plugin/DataType/Boolean.php +++ b/core/lib/Drupal/Core/TypedData/Plugin/DataType/Boolean.php @@ -30,5 +30,5 @@ */ public function getCastedValue() { - return ($this->value !== '' ? (bool) $this->value : NULL); + return (bool) $this->value; } } diff -u b/core/lib/Drupal/Core/TypedData/PrimitiveInterface.php b/core/lib/Drupal/Core/TypedData/PrimitiveInterface.php --- b/core/lib/Drupal/Core/TypedData/PrimitiveInterface.php +++ b/core/lib/Drupal/Core/TypedData/PrimitiveInterface.php @@ -29,7 +29,7 @@ public function setValue($value); /** - * Gets the primitive data value casted to the correct type. + * Gets the primitive data value casted to the correct PHP type. * * @return mixed */ diff -u b/core/modules/config/lib/Drupal/config/Tests/ConfigSchemaTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigSchemaTest.php --- b/core/modules/config/lib/Drupal/config/Tests/ConfigSchemaTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigSchemaTest.php @@ -266,6 +266,8 @@ 'null_float' => '', // Not in schema and therefore should be left untouched. 'not_present_in_schema' => TRUE, + // Test a custom type. + 'config_test_integer' => '1', ); $untyped_to_typed = $untyped_values; @@ -283,6 +285,7 @@ 'float' => 3.14, 'null_float' => NULL, 'not_present_in_schema' => TRUE, + 'config_test_integer' => 1, ); // Save config which has a schema that enforces types. @@ -293,8 +296,8 @@ // Save config which does not have a schema that enforces types. \Drupal::config('config_test.no_schema_data_types') - ->setData($untyped_values) - ->save(); + ->setData($untyped_values) + ->save(); $this->assertIdentical(\Drupal::config('config_test.no_schema_data_types')->get(), $untyped_values); } diff -u b/core/modules/config/tests/config_test/config/schema/config_test.schema.yml b/core/modules/config/tests/config_test/config/schema/config_test.schema.yml --- b/core/modules/config/tests/config_test/config/schema/config_test.schema.yml +++ b/core/modules/config/tests/config_test/config/schema/config_test.schema.yml @@ -92,10 +92,16 @@ type: string label: 'Protected property' +config_test_integer: + type: integer + label: 'Config test integer' + config_test.schema_data_types: type: mapping label: 'Config test schema' mapping: + config_test_integer: + type: config_test_integer integer: type: integer null_integer: