Fix auto_loader duplicate classes in interface list (#7416)

* Fix auto_loader duplicate classes in the interface list
This patch will stop the auto_loader from adding the same class to the interface list if it already exists in the list.

* Update auto_loader.php
This commit is contained in:
frytimo
2025-07-09 14:05:37 -03:00
committed by GitHub
parent 221bf3df5a
commit a429852c46

View File

@@ -317,10 +317,15 @@ class auto_loader {
foreach ($interface_list as $interface) {
$interface_name = trim($interface, " \n\r\t\v\x00\\");
// Check that it is declared as an array so we can record the classes
if (empty($this->interfaces[$interface_name]))
if (empty($this->interfaces[$interface_name])) {
$this->interfaces[$interface_name] = [];
// Record the classes that implement interface sorting by namspace and class name
$this->interfaces[$interface_name][] = $full_name;
}
// Ensure we don't already have the class recorded
if (!in_array($full_name, $this->interfaces[$interface_name], true)) {
// Record the classes that implement interface sorting by namspace and class name
$this->interfaces[$interface_name][] = $full_name;
}
}
}
}