Skip to content

Commit

Permalink
Fix double access to ArrayAccess methods
Browse files Browse the repository at this point in the history
This is a proposal to fix webonyx#759
  • Loading branch information
brunobg authored Dec 29, 2020
1 parent 5289a54 commit 92cac4b
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/Executor/Executor.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,15 @@ public static function defaultFieldResolver($objectValue, $args, $contextValue,
$fieldName = $info->fieldName;
$property = null;

if (is_array($objectValue) || $objectValue instanceof ArrayAccess) {
if (isset($objectValue[$fieldName])) {
$property = $objectValue[$fieldName];
if (is_array($source)) {
if (isset($source[$fieldName])) {
$property = $source[$fieldName];
}
} elseif (is_object($objectValue)) {
if (isset($objectValue->{$fieldName})) {
$property = $objectValue->{$fieldName};
} elseif ($source instanceof ArrayAccess) {
$property = $source[$fieldName];
} elseif (is_object($source)) {
if (isset($source->{$fieldName})) {
$property = $source->{$fieldName};
}
}

Expand Down

0 comments on commit 92cac4b

Please sign in to comment.