Skip to content

Commit 6fa394e

Browse files
dunglasfabpot
authored andcommitted
[Serializer] YamlEncoder: throw if the Yaml component isn't installed
1 parent 6688010 commit 6fa394e

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

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);

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)