Freek recently shared a post on X about a bug related to Laravel Collections. The issue was surprising to me because the fix looks almost identical to the original code. The code that triggered the issue: collect ([]) -> each ( fn ( string $hash ) => $this -> taggedCache ( $this -> tags ) -> forget ( $hash )); Enter fullscreen mode Exit fullscreen mode After the fix: collect ([]) -> each ( function ( string $hash ) { $this -> taggedCache ( $this -> tags ) -> forget ( $hash ); }); Enter fullscreen mode Exit fullscreen mode At first glance, nothing seems to have changed except for replacing the arrow function with an anonymous function. However, that small difference was enough to cause the bug. Lito highlighted the reason in a comment on the post. The each() method stops iterating when the callback returns false .…