diff --git a/core/lib/Drupal/Component/Serialization/Yaml.php b/core/lib/Drupal/Component/Serialization/Yaml.php index f7bc09a..3df8f84 100644 --- a/core/lib/Drupal/Component/Serialization/Yaml.php +++ b/core/lib/Drupal/Component/Serialization/Yaml.php @@ -45,12 +45,12 @@ public static function getFileExtension() { } /** - * Determines the optimal implementation to use for encoding and parsing Yaml. + * Determines the optimal implementation to use for encoding and parsing YAML. */ protected static function getSerializer() { if (!isset(static::$serializer)) { - // If the PECL YAML extension installed, use that. + // Use the PECL Yaml extension if it is available. if (extension_loaded('yaml')) { static::$serializer = '\Drupal\Component\Serialization\YamlPecl'; } @@ -61,4 +61,5 @@ protected static function getSerializer() { } return static::$serializer; } + } diff --git a/core/lib/Drupal/Core/Serialization/Yaml.php b/core/lib/Drupal/Core/Serialization/Yaml.php index 6b70775..03effff 100644 --- a/core/lib/Drupal/Core/Serialization/Yaml.php +++ b/core/lib/Drupal/Core/Serialization/Yaml.php @@ -20,8 +20,8 @@ class Yaml extends ComponentYaml { /** * {@inheritdoc} */ - protected static function getSerializer(){ - // If there is a settings.php override, use that. + protected static function getSerializer() { + // Allow settings.php to override the YAML serializer. if (!isset(static::$serializer) && $class = Settings::get('yaml_parser_class')) { diff --git a/core/tests/Drupal/Tests/Component/Serialization/YamlBaseTest.php b/core/tests/Drupal/Tests/Component/Serialization/YamlBaseTest.php index 36d0637..79ab00e 100644 --- a/core/tests/Drupal/Tests/Component/Serialization/YamlBaseTest.php +++ b/core/tests/Drupal/Tests/Component/Serialization/YamlBaseTest.php @@ -8,15 +8,12 @@ namespace Drupal\Tests\Component\Serialization; /** - * Provides test cases for Yaml tests so we can assert certain things parse the - * same. + * Provides standard data to validate different YAML implementations. */ abstract class YamlBaseTest extends \PHPUnit_Framework_TestCase { /** - * Some data sets that should be able to be serialized. - * - * @return array + * Some data that should be able to be serialized. */ public function providerEncodeDecodeTests() { return [ @@ -27,7 +24,7 @@ public function providerEncodeDecodeTests() { 'how' => [ 'about' => 'if', 'i' => 'ask', - 'nicely' + 'nicely', ], 'the' => [ 'answer' => [ @@ -47,14 +44,17 @@ public function providerEncodeDecodeTests() { ]; } + /** + * Some data that should be able to be de-serialized. + */ public function providerDecodeTests() { $data = [ - // Null files. + // NULL files. ['', NULL], ["\n", NULL], ["---\n...\n", NULL], - // Node Anchors. + // Node anchors. [ " jquery.ui: @@ -65,10 +65,10 @@ public function providerDecodeTests() { ", [ 'jquery.ui' => [ - 'version' => '1.10.2' + 'version' => '1.10.2', ], 'jquery.ui.accordion' => [ - 'version' => '1.10.2' + 'version' => '1.10.2', ], ], ], @@ -83,6 +83,9 @@ public function providerDecodeTests() { return $data; } + /** + * Test different boolean serialization and de-serialization. + */ public function providerBoolTest() { return [ ['true', TRUE], diff --git a/core/tests/Drupal/Tests/Component/Serialization/YamlPeclTest.php b/core/tests/Drupal/Tests/Component/Serialization/YamlPeclTest.php index 33030f9..f1a463e 100644 --- a/core/tests/Drupal/Tests/Component/Serialization/YamlPeclTest.php +++ b/core/tests/Drupal/Tests/Component/Serialization/YamlPeclTest.php @@ -83,4 +83,5 @@ public function testGetFileExtension() { public function testError() { YamlPecl::decode('foo: [ads'); } + } diff --git a/core/tests/Drupal/Tests/Component/Serialization/YamlSymfonyTest.php b/core/tests/Drupal/Tests/Component/Serialization/YamlSymfonyTest.php index 0836be4..324c4db 100644 --- a/core/tests/Drupal/Tests/Component/Serialization/YamlSymfonyTest.php +++ b/core/tests/Drupal/Tests/Component/Serialization/YamlSymfonyTest.php @@ -67,4 +67,5 @@ public function testGetFileExtension() { public function testError() { YamlSymfony::decode('foo: [ads'); } + } diff --git a/core/tests/Drupal/Tests/Component/Serialization/YamlTest.php b/core/tests/Drupal/Tests/Component/Serialization/YamlTest.php index 19d21af..972fa31 100644 --- a/core/tests/Drupal/Tests/Component/Serialization/YamlTest.php +++ b/core/tests/Drupal/Tests/Component/Serialization/YamlTest.php @@ -69,7 +69,7 @@ public function testGetFileExtension() { * in our YAML that might not be decoded correctly in on of our * implementations. * - * @TODO this should exist as an integration test no as part of our unit tests. + * @todo This should exist as an integration test not part of our unit tests. * * @requires extension yaml * @dataProvider providerYamlFilesInCore @@ -86,8 +86,7 @@ public function testYamlFiles($file) { } /** - * Data provider that lists all YAML files core. - * @return array + * Data provider that lists all YAML files in core. */ public function providerYamlFilesInCore() { $files = []; @@ -113,6 +112,7 @@ class YamlStub extends Yaml { public static function getSerializer() { return '\Drupal\Tests\Component\Serialization\YamlParserProxy'; } + } class YamlParserProxy implements SerializationInterface { @@ -137,4 +137,5 @@ public static function decode($raw) { public static function getFileExtension() { return static::$mock->getFileExtension(); } + }