diff --git a/src/Eloquent/EmbedsRelations.php b/src/Eloquent/EmbedsRelations.php index 9e5f77d..95231a5 100644 --- a/src/Eloquent/EmbedsRelations.php +++ b/src/Eloquent/EmbedsRelations.php @@ -23,9 +23,7 @@ protected function embedsMany($related, $localKey = null, $foreignKey = null, $r // the calling method's name and use that as the relationship name as most // of the time this will be what we desire to use for the relationships. if ($relation === null) { - [, $caller] = debug_backtrace(false); - - $relation = $caller['function']; + $relation = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2)[1]['function']; } if ($localKey === null) { @@ -58,9 +56,7 @@ protected function embedsOne($related, $localKey = null, $foreignKey = null, $re // the calling method's name and use that as the relationship name as most // of the time this will be what we desire to use for the relationships. if ($relation === null) { - [, $caller] = debug_backtrace(false); - - $relation = $caller['function']; + $relation = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2)[1]['function']; } if ($localKey === null) { diff --git a/src/Eloquent/HybridRelations.php b/src/Eloquent/HybridRelations.php index 0818ca3..398d26f 100644 --- a/src/Eloquent/HybridRelations.php +++ b/src/Eloquent/HybridRelations.php @@ -134,9 +134,7 @@ public function belongsTo($related, $foreignKey = null, $otherKey = null, $relat // the calling method's name and use that as the relationship name as most // of the time this will be what we desire to use for the relationships. if ($relation === null) { - [$current, $caller] = debug_backtrace(false, 2); - - $relation = $caller['function']; + $relation = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2)[1]['function']; } // Check if it is a relation with an original model. @@ -178,9 +176,7 @@ public function morphTo($name = null, $type = null, $id = null, $ownerKey = null // since that is most likely the name of the polymorphic interface. We can // use that to get both the class and foreign key that will be utilized. if ($name === null) { - [$current, $caller] = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2); - - $name = $caller['function']; + $name = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2)[1]['function']; } [$type, $id] = $this->getMorphs(Str::snake($name), $type, $id);