8000 [Serializer] ensure ChainEncoder/ChainDecoder properly consider the context by Guite · Pull Request #43231 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Serializer] ensure ChainEncoder/ChainDecoder properly consider the context #43231

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
avoid explicite bool comparison
  • Loading branch information
Guite committed Oct 28, 2021
commit 4789747fe6ec5864ffb36effb84e9868aca62a41
4 changes: 2 additions & 2 deletions src/Symfony/Component/Serializer/Encoder/ChainDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function getDecoder(string $format, array $context): DecoderInterface
{
$hasContext = 0 < \count($context);
if (
true !== $hasContext
$hasContext
&& isset($this->decoderByFormat[$format])
&& isset($this->decoders[$this->decoderByFormat[$format]])
) {
Expand All @@ -72,7 +72,7 @@ public function getDecoder(string $format, array $context): DecoderInterface

foreach ($this->decoders as $i => $decoder) {
if ($decoder->supportsDecoding($format, $context)) {
if (true !== $hasContext) {
if ($hasContext) {
// cache decoder if no dynamic context is given
$this->decoderByFormat[$format] = $i;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Serializer/Encoder/ChainEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function getEncoder(string $format, array $context): EncoderInterface
{
$hasContext = 0 < \count($context);
if (
true !== $hasContext
$hasContext
&& isset($this->encoderByFormat[$format])
&& isset($this->encoders[$this->encoderByFormat[$format]])
) {
Expand All @@ -90,7 +90,7 @@ public function getEncoder(string $format, array $context): EncoderInterface

foreach ($this->encoders as $i => $encoder) {
if ($encoder->supportsEncoding($format, $context)) {
if (true !== $hasContext) {
if ($hasContext) {
// cache encoder if no dynamic context is given
$this->encoderByFormat[$format] = $i;
}
Expand Down
0