Skip to content

Commit

Permalink
Update helpers.php
Browse files Browse the repository at this point in the history
Instead of using `isset`, it is safer to use `property_exists`. This also ensures that if the value of `$segment = null`, the object key is also removed.
  • Loading branch information
informatJonas authored Oct 17, 2024
1 parent 5c9cb78 commit f58fc01
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Illuminate/Collections/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ function data_forget(&$target, $key)
} elseif (is_object($target)) {
if ($segments && isset($target->{$segment})) {
data_forget($target->{$segment}, $segments);
} elseif (isset($target->{$segment})) {
} elseif (property_exists($target, $segment)) {
unset($target->{$segment});
}
}
Expand Down

0 comments on commit f58fc01

Please sign in to comment.