Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Serializer] use method_exists() instead of catching reflection exceptions #48978

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

Merged
merged 1 commit into from
Jan 14, 2023
Merged
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,7 @@ protected function setAttributeValue(object $object, string $attribute, $value,
$key = \get_class($object).':'.$setter;

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

if (self::$setterAccessibleCache[$key]) {
Expand Down