You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
minor #31693 [Serializer] Throw exception on invalid normalizers/encoders passed to Serializer (ogizanagi)
This PR was merged into the 5.0-dev branch.
Discussion
----------
[Serializer] Throw exception on invalid normalizers/encoders passed to Serializer
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | no <!-- please update src/**/CHANGELOG.md files -->
| BC breaks? | no <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass? | yes <!-- please add some, will be required by reviewers -->
| Fixed tickets | #27819 <!-- #-prefixed issue number(s), if any -->
| License | MIT
| Doc PR | N/A <!-- required for new features -->
As planned in #27819
Commits
-------
5ab6ad4 [Serializer] Throw exception on invalid normalizers/encoders passed to Serializer
@@ -84,8 +85,7 @@ public function __construct(array $normalizers = [], array $encoders = [])
84
85
}
85
86
86
87
if (!($normalizerinstanceof NormalizerInterface || $normalizerinstanceof DenormalizerInterface)) {
87
-
@trigger_error(\sprintf('Passing normalizers ("%s") which do not implement either "%s" or "%s" has been deprecated since Symfony 4.2.', \get_class($normalizer), NormalizerInterface::class, DenormalizerInterface::class), E_USER_DEPRECATED);
88
-
// throw new \InvalidArgumentException(\sprintf('The class "%s" does not implement "%s" or "%s".', \get_class($normalizer), NormalizerInterface::class, DenormalizerInterface::class));
88
+
thrownewInvalidArgumentException(\sprintf('The class "%s" neither implements "%s" nor "%s".', \get_class($normalizer), NormalizerInterface::class, DenormalizerInterface::class));
89
89
}
90
90
}
91
91
$this->normalizers = $normalizers;
@@ -104,8 +104,7 @@ public function __construct(array $normalizers = [], array $encoders = [])
104
104
}
105
105
106
106
if (!($encoderinstanceof EncoderInterface || $encoderinstanceof DecoderInterface)) {
107
-
@trigger_error(\sprintf('Passing encoders ("%s") which do not implement either "%s" or "%s" has been deprecated since Symfony 4.2.', \get_class($encoder), EncoderInterface::class, DecoderInterface::class), E_USER_DEPRECATED);
108
-
// throw new \InvalidArgumentException(\sprintf('The class "%s" does not implement "%s" or "%s".', \get_class($normalizer), EncoderInterface::class, DecoderInterface::class));
107
+
thrownewInvalidArgumentException(\sprintf('The class "%s" neither implements "%s" nor "%s".', \get_class($encoder), EncoderInterface::class, DecoderInterface::class));
Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Tests/SerializerTest.php
+6-6Lines changed: 6 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -56,19 +56,19 @@ public function testInterface()
56
56
}
57
57
58
58
/**
59
-
* @expectedDeprecation Passing normalizers ("stdClass") which do not implement either "Symfony\Component\Serializer\Normalizer\NormalizerInterface" or "Symfony\Component\Serializer\Normalizer\DenormalizerInterface" has been deprecated since Symfony 4.2.
* @expectedExceptionMessage The class "stdClass" neither implements "Symfony\Component\Serializer\Normalizer\NormalizerInterface" nor "Symfony\Component\Serializer\Normalizer\DenormalizerInterface".
* @expectedDeprecation Passing encoders ("stdClass") which do not implement either "Symfony\Component\Serializer\Encoder\EncoderInterface" or "Symfony\Component\Serializer\Encoder\DecoderInterface" has been deprecated since Symfony 4.2.
* @expectedExceptionMessage The class "stdClass" neither implements "Symfony\Component\Serializer\Encoder\EncoderInterface" nor "Symfony\Component\Serializer\Encoder\DecoderInterface"
0 commit comments