Skip to content

Commit 3eb823d

Browse files
dantleechfabpot
authored andcommitted
Enforce sprintf for exceptions
1 parent 346effa commit 3eb823d

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

Encoder/XmlEncoder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ private function buildXml($parentNode, $data, $xmlRootNodeName = null)
341341
return $this->appendNode($parentNode, $data, 'data');
342342
}
343343

344-
throw new UnexpectedValueException('An unexpected value could not be serialized: '.var_export($data, true));
344+
throw new UnexpectedValueException(sprintf('An unexpected value could not be serialized: %s', var_export($data, true)));
345345
}
346346

347347
/**

Serializer.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function __construct(array $normalizers = array(), array $encoders = arra
7575
final public function serialize($data, $format, array $context = array())
7676
{
7777
if (!$this->supportsEncoding($format)) {
78-
throw new UnexpectedValueException('Serialization for the format '.$format.' is not supported');
78+
throw new UnexpectedValueException(sprintf('Serialization for the format %s is not supported', $format));
7979
}
8080

8181
if ($this->encoder->needsNormalization($format)) {
@@ -91,7 +91,7 @@ final public function serialize($data, $format, array $context = array())
9191
final public function deserialize($data, $type, $format, array $context = array())
9292
{
9393
if (!$this->supportsDecoding($format)) {
94-
throw new UnexpectedValueException('Deserialization for the format '.$format.' is not supported');
94+
throw new UnexpectedValueException(sprintf('Deserialization for the format %s is not supported', $format));
9595
}
9696

9797
$data = $this->decode($data, $format, $context);
@@ -128,7 +128,7 @@ public function normalize($data, $format = null, array $context = array())
128128

129129
return $data;
130130
}
131-
throw new UnexpectedValueException('An unexpected value could not be normalized: '.var_export($data, true));
131+
throw new UnexpectedValueException(sprintf('An unexpected value could not be normalized: %s', var_export($data, true)));
132132
}
133133

134134
/**
@@ -246,7 +246,7 @@ private function normalizeObject($object, $format = null, array $context = array
246246
}
247247
}
248248

249-
throw new UnexpectedValueException('Could not normalize object of type '.$class.', no supporting normalizer found.');
249+
throw new UnexpectedValueException(sprintf('Could not normalize object of type %s, no supporting normalizer found.', $class));
250250
}
251251

252252
/**
@@ -280,7 +280,7 @@ private function denormalizeObject($data, $class, $format = null, array $context
280280
}
281281
}
282282

283-
throw new UnexpectedValueException('Could not denormalize object of type '.$class.', no supporting normalizer found.');
283+
throw new UnexpectedValueException(sprintf('Could not denormalize object of type %s, no supporting normalizer found.', $class));
284284
}
285285

286286
/**

0 commit comments

Comments
 (0)