diff --git a/src/Symfony/Component/Serializer/CHANGELOG.md b/src/Symfony/Component/Serializer/CHANGELOG.md index 1b5c95cd3944..5f6482a90dc7 100644 --- a/src/Symfony/Component/Serializer/CHANGELOG.md +++ b/src/Symfony/Component/Serializer/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +7.4 +--- + + * Add support for `can*()` methods to `AttributeLoader` + 7.3 --- diff --git a/src/Symfony/Component/Serializer/Mapping/Loader/AttributeLoader.php b/src/Symfony/Component/Serializer/Mapping/Loader/AttributeLoader.php index bf8ab356e8f1..f401074679bf 100644 --- a/src/Symfony/Component/Serializer/Mapping/Loader/AttributeLoader.php +++ b/src/Symfony/Component/Serializer/Mapping/Loader/AttributeLoader.php @@ -114,7 +114,7 @@ public function loadClassMetadata(ClassMetadataInterface $classMetadata): bool continue; /* matches the BC behavior in `Symfony\Component\Serializer\Normalizer\ObjectNormalizer::extractAttributes` */ } - $accessorOrMutator = preg_match('/^(get|is|has|set)(.+)$/i', $method->name, $matches); + $accessorOrMutator = preg_match('/^(get|is|has|set|can)(.+)$/i', $method->name, $matches); if ($accessorOrMutator && !ctype_lower($matches[2][0])) { $attributeName = lcfirst($matches[2]); diff --git a/src/Symfony/Component/Serializer/Tests/Fixtures/Attributes/IgnoreDummy.php b/src/Symfony/Component/Serializer/Tests/Fixtures/Attributes/IgnoreDummy.php index 6e12f7c00cb4..4fdf996f0366 100644 --- a/src/Symfony/Component/Serializer/Tests/Fixtures/Attributes/IgnoreDummy.php +++ b/src/Symfony/Component/Serializer/Tests/Fixtures/Attributes/IgnoreDummy.php @@ -28,4 +28,10 @@ public function getIgnored2() { return $this->ignored2; } + + #[Ignore] + public function canBeIgnored(): bool + { + return true; + } } diff --git a/src/Symfony/Component/Serializer/Tests/Mapping/Loader/AttributeLoaderTest.php b/src/Symfony/Component/Serializer/Tests/Mapping/Loader/AttributeLoaderTest.php index 16d64f25d5b5..b4550ba9f532 100644 --- a/src/Symfony/Component/Serializer/Tests/Mapping/Loader/AttributeLoaderTest.php +++ b/src/Symfony/Component/Serializer/Tests/Mapping/Loader/AttributeLoaderTest.php @@ -153,6 +153,7 @@ public function testLoadIgnore() $attributesMetadata = $classMetadata->getAttributesMetadata(); $this->assertTrue($attributesMetadata['ignored1']->isIgnored()); $this->assertTrue($attributesMetadata['ignored2']->isIgnored()); + $this->assertTrue($attributesMetadata['beIgnored']->isIgnored()); } public function testLoadContextsPropertiesPromoted() pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy