Skip to content

Commit 1bb11f2

Browse files
committed
refactor: adicionar cache para verificações de class_exists() no ExtensionManager
1 parent 8f9b014 commit 1bb11f2

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/Providers/ExtensionManager.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ class ExtensionManager
3535
*/
3636
private array $extensionStates = [];
3737

38+
/**
39+
* Cache for class_exists() checks to avoid repeated autoloading
40+
*/
41+
private array $classExistsCache = [];
42+
3843
/**
3944
* Application instance
4045
*/
@@ -78,7 +83,10 @@ public function registerExtension(string $name, mixed $extension): void
7883
// Convert string to callable if needed
7984
if (is_string($extension)) {
8085
// If it's a class name, instantiate and register it
81-
if (class_exists($extension)) {
86+
if (!isset($this->classExistsCache[$extension])) {
87+
$this->classExistsCache[$extension] = class_exists($extension);
88+
}
89+
if ($this->classExistsCache[$extension]) {
8290
$extension = function ($app) use ($extension) {
8391
$instance = new $extension($app);
8492
if (method_exists($instance, 'register')) {

0 commit comments

Comments
 (0)