package and depencies

This commit is contained in:
RafficMohammed
2023-01-08 02:57:24 +05:30
parent d5332eb421
commit 1d54b8bc7f
4309 changed files with 193331 additions and 172289 deletions

View File

@@ -23,16 +23,9 @@ use Symfony\Component\Routing\RouteCollection;
class AnnotationDirectoryLoader extends AnnotationFileLoader
{
/**
* Loads from annotations from a directory.
*
* @param string $path A directory path
* @param string|null $type The resource type
*
* @return RouteCollection
*
* @throws \InvalidArgumentException When the directory does not exist or its routes cannot be parsed
*/
public function load($path, string $type = null)
public function load(mixed $path, string $type = null): ?RouteCollection
{
if (!is_dir($dir = $this->locator->locate($path))) {
return parent::supports($path, $type) ? parent::load($path, $type) : new RouteCollection();
@@ -44,7 +37,7 @@ class AnnotationDirectoryLoader extends AnnotationFileLoader
new \RecursiveCallbackFilterIterator(
new \RecursiveDirectoryIterator($dir, \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS),
function (\SplFileInfo $current) {
return '.' !== substr($current->getBasename(), 0, 1);
return !str_starts_with($current->getBasename(), '.');
}
),
\RecursiveIteratorIterator::LEAVES_ONLY
@@ -71,22 +64,23 @@ class AnnotationDirectoryLoader extends AnnotationFileLoader
return $collection;
}
/**
* {@inheritdoc}
*/
public function supports($resource, string $type = null)
public function supports(mixed $resource, string $type = null): bool
{
if ('annotation' === $type) {
if (!\is_string($resource)) {
return false;
}
if (\in_array($type, ['annotation', 'attribute'], true)) {
return true;
}
if ($type || !\is_string($resource)) {
if ($type) {
return false;
}
try {
return is_dir($this->locator->locate($resource));
} catch (\Exception $e) {
} catch (\Exception) {
return false;
}
}