Skip to content

Commit bd614cc

Browse files
committed
Replaced ReflectionClass usages with procedural function calls
1 parent 023911f commit bd614cc

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

src/AbstractTrackingListener.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,14 +237,19 @@ protected function updateField($object, $eventAdapter, $meta, $field, array $con
237237
}
238238

239239
if (!empty($config['setterMethod'][$field])) {
240-
$reflectionClass = $meta->getReflectionClass();
241240
$setterName = $config['setterMethod'][$field];
242241

243-
if (!$reflectionClass->hasMethod($setterName)) {
244-
throw new InvalidMappingException("Setter method - [{$setterName}] does not exist in class - {$meta->getName()}");
242+
if (!method_exists($object, $setterName)) {
243+
throw new InvalidMappingException(
244+
sprintf(
245+
"Setter method [%s] does not exist in class %s",
246+
$setterName,
247+
$meta->getName(),
248+
),
249+
);
245250
}
246251

247-
$reflectionClass->getMethod($setterName)->invoke($object, $newValue);
252+
$object->{$setterName}($newValue);
248253
} else {
249254
$property->setValue($object, $newValue);
250255
}

src/SoftDeleteable/SoftDeleteableListener.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,19 @@ public function onFlush(EventArgs $args)
104104
}
105105

106106
if (!empty($config['setterMethod'][$config['fieldName']])) {
107-
$reflectionClass = $meta->getReflectionClass();
108107
$setterName = $config['setterMethod'][$config['fieldName']];
109108

110-
if (!$reflectionClass->hasMethod($setterName)) {
111-
throw new InvalidMappingException("Setter method - [{$setterName}] does not exist in class - {$meta->getName()}");
109+
if (!method_exists($object, $setterName)) {
110+
throw new InvalidMappingException(
111+
sprintf(
112+
"Setter method [%s] does not exist in class %s",
113+
$setterName,
114+
$meta->getName(),
115+
),
116+
);
112117
}
113118

114-
$reflectionClass->getMethod($setterName)->invoke($object, $date);
119+
$object->{$setterName}($date);
115120
} else {
116121
$reflProp->setValue($object, $date);
117122
}

0 commit comments

Comments
 (0)