Skip to content

Commit ff4f4ca

Browse files
committed
bug symfony#24565 [Serializer] YamlEncoder: throw if the Yaml component isn't installed (dunglas)
This PR was squashed before being merged into the 3.3 branch (closes symfony#24565). Discussion ---------- [Serializer] YamlEncoder: throw if the Yaml component isn't installed | Q | A | ------------- | --- | Branch? | 3.3 <!-- see comment below --> | Bug fix? | yes | New feature? | no <!-- don't forget to update src/**/CHANGELOG.md files --> | BC breaks? | no | Deprecations? | no <!-- don't forget to update UPGRADE-*.md files --> | Tests pass? | no | Fixed tickets | #... <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | n/a Similar to symfony#24563 but for the Yaml encoder (not the same branch). Commits ------- 7d21caf [Serializer] YamlEncoder: throw if the Yaml component isn't installed
2 parents 4650592 + 7d21caf commit ff4f4ca

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/Symfony/Component/Serializer/Encoder/YamlEncoder.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Serializer\Encoder;
1313

14+
use Symfony\Component\Serializer\Exception\RuntimeException;
1415
use Symfony\Component\Yaml\Dumper;
1516
use Symfony\Component\Yaml\Parser;
1617

@@ -29,6 +30,10 @@ class YamlEncoder implements EncoderInterface, DecoderInterface
2930

3031
public function __construct(Dumper $dumper = null, Parser $parser = null, array $defaultContext = array())
3132
{
33+
if (!class_exists(Dumper::class)) {
34+
throw new RuntimeException('The YamlEncoder class requires the "Yaml" component. Install "symfony/yaml" to use it.');
35+
}
36+
3237
$this->dumper = $dumper ?: new Dumper();
3338
$this->parser = $parser ?: new Parser();
3439
$this->defaultContext = array_merge($this->defaultContext, $defaultContext);

src/Symfony/Component/Serializer/Normalizer/DataUriNormalizer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public function supportsDenormalization($data, $type, $format = null)
110110
$supportedTypes = array(
111111
\SplFileInfo::class => true,
112112
\SplFileObject::class => true,
113-
'Symfony\Component\HttpFoundation\File\File' => true,
113+
File::class => true,
114114
);
115115

116116
return isset($supportedTypes[$type]);

0 commit comments

Comments
 (0)