From bdb0b7e288bbb311454cdf6dacdecacba6dda83e Mon Sep 17 00:00:00 2001 From: Deeka Wong <8337659+huangdijia@users.noreply.github.com> Date: Fri, 28 Nov 2025 21:59:02 +0800 Subject: [PATCH] fix: replace filter with contains method in ClassAliasAutoloader Replace filter()->isEmpty() with contains() for better performance and clarity when checking if aliases exist in the collection. This change improves the efficiency of the class alias autoloading logic by using the more appropriate contains method instead of filtering and checking if the result is empty. --- src/tinker/src/ClassAliasAutoloader.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tinker/src/ClassAliasAutoloader.php b/src/tinker/src/ClassAliasAutoloader.php index 554551f41..c5a5e2257 100644 --- a/src/tinker/src/ClassAliasAutoloader.php +++ b/src/tinker/src/ClassAliasAutoloader.php @@ -118,7 +118,7 @@ public function isAliasable(string $class, string $path): bool return false; } - if (! $this->includedAliases->filter(fn ($alias) => str_starts_with($class, $alias))->isEmpty()) { + if (! $this->includedAliases->contains(fn ($alias) => str_starts_with($class, $alias))) { return true; } @@ -126,7 +126,7 @@ public function isAliasable(string $class, string $path): bool return false; } - if (! $this->excludedAliases->filter(fn ($alias) => str_starts_with($class, $alias))->isEmpty()) { + if (! $this->excludedAliases->contains(fn ($alias) => str_starts_with($class, $alias))) { return false; }