Skip to content

Commit 1e2d132

Browse files
committed
Move check below setAccessible as it's necessary for private properties.
1 parent 3344a45 commit 1e2d132

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/DeepCopy/DeepCopy.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,11 +215,6 @@ private function copyObjectProperty($object, ReflectionProperty $property)
215215
return;
216216
}
217217

218-
// Ignore unitialized properties (for PHP >7.4)
219-
if (method_exists($property, 'isInitialized') && !$property->isInitialized($object)) {
220-
return;
221-
}
222-
223218
// Apply the filters
224219
foreach ($this->filters as $item) {
225220
/** @var Matcher $matcher */
@@ -242,6 +237,12 @@ function ($object) {
242237
}
243238

244239
$property->setAccessible(true);
240+
241+
// Ignore unitialized properties (for PHP >7.4)
242+
if (method_exists($property, 'isInitialized') && !$property->isInitialized($object)) {
243+
return;
244+
}
245+
245246
$propertyValue = $property->getValue($object);
246247

247248
// Copy the property

0 commit comments

Comments
 (0)