This commit is contained in:
1 parent
f7c532a648
commit
640bd67556
5801 files changed
+484532
-55857
No files matched your search
@@ -34,11 +34,11 @@ class ClassNotFoundErrorEnhancer implements ErrorEnhancerInterface
|
||||
if (false !== $namespaceSeparatorIndex = strrpos($fullyQualifiedClassName, '\\')) {
|
||||
$className = substr($fullyQualifiedClassName, $namespaceSeparatorIndex + 1);
|
||||
$namespacePrefix = substr($fullyQualifiedClassName, 0, $namespaceSeparatorIndex);
|
||||
$message = sprintf('Attempted to load %s "%s" from namespace "%s".', $typeName, $className, $namespacePrefix);
|
||||
$message = \sprintf('Attempted to load %s "%s" from namespace "%s".', $typeName, $className, $namespacePrefix);
|
||||
$tail = ' for another namespace?';
|
||||
} else {
|
||||
$className = $fullyQualifiedClassName;
|
||||
$message = sprintf('Attempted to load %s "%s" from the global namespace.', $typeName, $className);
|
||||
$message = \sprintf('Attempted to load %s "%s" from the global namespace.', $typeName, $className);
|
||||
$tail = '?';
|
||||
}
|
||||
|
||||
@@ -114,10 +114,14 @@ class ClassNotFoundErrorEnhancer implements ErrorEnhancerInterface
|
||||
|
||||
$classes = [];
|
||||
$filename = $class.'.php';
|
||||
foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::LEAVES_ONLY) as $file) {
|
||||
if ($filename == $file->getFileName() && $class = $this->convertFileToClass($path, $file->getPathName(), $prefix)) {
|
||||
$classes[] = $class;
|
||||
try {
|
||||
foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::LEAVES_ONLY) as $file) {
|
||||
if ($filename == $file->getFileName() && $class = $this->convertFileToClass($path, $file->getPathName(), $prefix)) {
|
||||
$classes[] = $class;
|
||||
}
|
||||
}
|
||||
} catch (\UnexpectedValueException) {
|
||||
// a subdirectory may vanish between listing and recursion (e.g. test fixtures)
|
||||
}
|
||||
|
||||
return $classes;
|
||||
@@ -141,7 +145,7 @@ class ClassNotFoundErrorEnhancer implements ErrorEnhancerInterface
|
||||
];
|
||||
|
||||
if ($prefix) {
|
||||
$candidates = array_filter($candidates, fn ($candidate) => str_starts_with($candidate, $prefix));
|
||||
$candidates = array_filter($candidates, static fn ($candidate) => str_starts_with($candidate, $prefix));
|
||||
}
|
||||
|
||||
// We cannot use the autoloader here as most of them use require; but if the class
|
||||
|
||||
Reference in new issue
Block a user