Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0e883a9

Browse filesBrowse files
committed
use method_exists() instead of catching reflection exceptions
1 parent 3ca58ba commit 0e883a9
Copy full SHA for 0e883a9

File tree

1 file changed

+1
-8
lines changed
Filter options

1 file changed

+1
-8
lines changed

‎src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php
+1-8Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,7 @@ protected function setAttributeValue(object $object, string $attribute, $value,
152152
$key = \get_class($object).':'.$setter;
153153

154154
if (!isset(self::$setterAccessibleCache[$key])) {
155-
try {
156-
// We have to use is_callable() here since method_exists()
157-
// does not "see" protected/private methods
158-
self::$setterAccessibleCache[$key] = \is_callable([$object, $setter]) && !(new \ReflectionMethod($object, $setter))->isStatic();
159-
} catch (\ReflectionException $e) {
160-
// Method does not exist in the class, probably a magic method
161-
self::$setterAccessibleCache[$key] = false;
162-
}
155+
self::$setterAccessibleCache[$key] = method_exists($object, $setter) && \is_callable([$object, $setter]) && !(new \ReflectionMethod($object, $setter))->isStatic();
163156
}
164157

165158
if (self::$setterAccessibleCache[$key]) {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.