Skip to content

Commit

Permalink
Work around UnitEnum PHPStan issues
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Dec 31, 2022
1 parent c573038 commit a4303f1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/base/Element.php
Expand Up @@ -2037,7 +2037,7 @@ public function __get($name)
// If this is a field, make sure the value has been normalized before returning the CustomFieldBehavior value
if ($this->fieldByHandle($name) !== null) {
$value = $this->getFieldValue($name);
if (is_object($value) && !$value instanceof UnitEnum) {
if (is_object($value) && (!class_exists(UnitEnum::class) || !$value instanceof UnitEnum)) {
$value = clone $value;
}
return $value;
Expand Down
4 changes: 2 additions & 2 deletions src/services/Elements.php
Expand Up @@ -1458,7 +1458,7 @@ public function duplicateElement(

// Clone any field values that are objects
foreach ($mainClone->getFieldValues() as $handle => $value) {
if (is_object($value) && !$value instanceof UnitEnum) {
if (is_object($value) && (!class_exists(UnitEnum::class) || !$value instanceof UnitEnum)) {
$mainClone->setFieldValue($handle, clone $value);
}
}
Expand Down Expand Up @@ -1578,7 +1578,7 @@ public function duplicateElement(

// Clone any field values that are objects
foreach ($siteClone->getFieldValues() as $handle => $value) {
if (is_object($value) && !$value instanceof UnitEnum) {
if (is_object($value) && (!class_exists(UnitEnum::class) || !$value instanceof UnitEnum)) {
$siteClone->setFieldValue($handle, clone $value);
}
}
Expand Down

0 comments on commit a4303f1

Please sign in to comment.