[Serializer] Prevent `GetSetMethodNormalizer` from creating invalid magic method call

by @klaussilveira

Some issues have been detected in this pull request

Issues that can be fixed by applying a patch

Review the proposed patch then download it to apply it manually or execute the following command from the repository root directory:

curl https://fabbot.io/patch/symfony/symfony/48233/4a3448586bdf2bf14f5b12e789444951c5fd247b/cs.diff | patch -p0
diff -ru src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php
--- src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php	2022-11-21 15:00:26.097869103 +0000
+++ src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php	2022-11-21 15:00:27.327917761 +0000
@@ -36,17 +36,11 @@
 {
     private static $setterAccessibleCache = [];
 
-    /**
-     * @param array $context
-     */
     public function supportsNormalization(mixed $data, string $format = null /* , array $context = [] */): bool
     {
         return parent::supportsNormalization($data, $format) && $this->supports($data::class);
     }
 
-    /**
-     * @param array $context
-     */
     public function supportsDenormalization(mixed $data, string $type, string $format = null /* , array $context = [] */): bool
     {
         return parent::supportsDenormalization($data, $type, $format) && $this->supports($type);
@@ -117,17 +111,17 @@
         $ucfirsted = ucfirst($attribute);
 
         $getter = 'get'.$ucfirsted;
-        if (\method_exists($object, $getter)) {
+        if (method_exists($object, $getter)) {
             return $object->$getter();
         }
 
         $isser = 'is'.$ucfirsted;
-        if (\method_exists($object, $isser)) {
+        if (method_exists($object, $isser)) {
             return $object->$isser();
         }
 
         $haser = 'has'.$ucfirsted;
-        if (\method_exists($object, $haser)) {
+        if (method_exists($object, $haser)) {
             return $object->$haser();
         }
 

0
Common Typos

0
License Headers

0
Pull Request Contributor Headers

0
File Permissions

0
Merge Commits

0
Exception Messages Formatting

0
Usage of void in test files

0
Use ::class whenever possible

0
Deprecation Messages