This commit is contained in:
as2252258@163.com
2021-05-04 03:46:40 +08:00
parent 791f9722f5
commit 17393bb4a4
3 changed files with 0 additions and 77 deletions
-9
View File
@@ -203,13 +203,4 @@ class Annotation extends Component
}
/**
* @param string $filename
* @return mixed
*/
public function getFilename(string $filename): mixed
{
return $this->_loader->getClassByFilepath($filename);
}
}
-18
View File
@@ -27,9 +27,6 @@ class Loader extends BaseObject
private array $_classes = [];
private array $_fileMap = [];
private array $_directory = [];
@@ -178,8 +175,6 @@ class Loader extends BaseObject
$_array = $this->_methods($replace, $_array);
$_array = $this->_properties($replace, $_array);
$this->_fileMap[$replace->getFileName()] = $replace->getName();
$this->_classes[$replace->getName()] = $_array;
} catch (Throwable $throwable) {
$this->addError($throwable, 'throwable');
@@ -320,19 +315,6 @@ class Loader extends BaseObject
}
/**
* @param string $filename
* @return mixed
*/
public function getClassByFilepath(string $filename): mixed
{
if (!isset($this->_fileMap[$filename])) {
return null;
}
return $this->_classes[$this->_fileMap[$filename]];
}
/**
* @param array $classes
*/
-50
View File
@@ -115,56 +115,6 @@ if (!function_exists('swoole')) {
}
if (!function_exists('recursive_directory')) {
/**
* @param DirectoryIterator $file
* @throws Exception
*/
function recursive_callback(DirectoryIterator $file)
{
$attributes = Snowflake::getAnnotation();
$annotations = $attributes->getFilename($file->getRealPath());
if (empty($annotations)) {
return;
}
/** @var Attribute $value */
foreach ($annotations['methods'] as $name => $attribute) {
foreach ($attribute as $value) {
if (!($value instanceof Attribute)) {
continue;
}
$value->execute([$annotations['handler'], $name]);
}
}
}
/**
* @param string $path
*/
function recursive_directory(string $path)
{
$directoryIterators = new \DirectoryIterator($path);
foreach ($directoryIterators as $directoryIterator) {
if ($directoryIterator->getFilename() === '.' || $directoryIterator->getFilename() === '..') {
continue;
}
if ($directoryIterator->isDir()) {
Recursive_directory($directoryIterator->getRealPath());
} else {
call_user_func('recursive_callback', $directoryIterator);
}
}
unset($directoryIterators);
}
}
if (!function_exists('directory')) {
/**