apply php styler
Signed-off-by: lubiana <lubiana123@gmail.com>
This commit is contained in:
parent
1667fd3253
commit
8b353ec62a
14 changed files with 69 additions and 67 deletions
|
@ -44,7 +44,8 @@ final class Finder
|
|||
{
|
||||
$this->populateClassnames();
|
||||
return array_map(
|
||||
static fn (array $h): Listener => new Listener($h[0]->eventClass, $h[0]->priority, $h[1], $h[2]),
|
||||
static fn (array $h): Listener
|
||||
=> new Listener($h[0]->eventClass, $h[0]->priority, $h[1], $h[2]),
|
||||
iterator_to_array($this->getAttributes(AsListener::class)),
|
||||
);
|
||||
}
|
||||
|
@ -56,7 +57,8 @@ final class Finder
|
|||
{
|
||||
$this->populateClassnames();
|
||||
return array_map(
|
||||
static fn (array $h): Handler => new Handler($h[0]->method, $h[0]->path, $h[1], $h[2]),
|
||||
static fn (array $h): Handler
|
||||
=> new Handler($h[0]->method, $h[0]->path, $h[1], $h[2]),
|
||||
iterator_to_array($this->getAttributes(AsHandler::class)),
|
||||
);
|
||||
}
|
||||
|
@ -69,6 +71,7 @@ final class Finder
|
|||
|
||||
if ($this->cached === true && file_exists(self::CACHE_FILE)) {
|
||||
$data = file_get_contents(self::CACHE_FILE);
|
||||
|
||||
if ($data === false) {
|
||||
return;
|
||||
}
|
||||
|
@ -79,7 +82,10 @@ final class Finder
|
|||
return;
|
||||
}
|
||||
|
||||
$it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($this->path));
|
||||
$it = new RecursiveIteratorIterator(
|
||||
new RecursiveDirectoryIterator($this->path),
|
||||
);
|
||||
|
||||
/** @var SplFileInfo $file */
|
||||
foreach ($it as $file) {
|
||||
if (! str_ends_with((string) $file, '.php')) {
|
||||
|
@ -89,7 +95,10 @@ final class Finder
|
|||
$classesBeforeLoad = get_declared_classes();
|
||||
require_once (string) $file;
|
||||
$classesAfterLoad = get_declared_classes();
|
||||
$this->classNames = [...$this->classNames, ...array_diff($classesAfterLoad, $classesBeforeLoad)];
|
||||
$this->classNames = [
|
||||
...$this->classNames,
|
||||
...array_diff($classesAfterLoad, $classesBeforeLoad),
|
||||
];
|
||||
}
|
||||
|
||||
if ($this->cached === true) {
|
||||
|
@ -102,18 +111,14 @@ final class Finder
|
|||
* @param class-string<T> $attributeClass
|
||||
* @return Iterator<array{T, class-string, non-empty-string}>
|
||||
*/
|
||||
private function getAttributes(
|
||||
string $attributeClass
|
||||
): Iterator {
|
||||
private function getAttributes(string $attributeClass): Iterator
|
||||
{
|
||||
foreach ($this->classNames as $class) {
|
||||
$reflectionClass = new ReflectionClass($class);
|
||||
|
||||
foreach ($reflectionClass->getMethods() as $method) {
|
||||
foreach ($method->getAttributes($attributeClass) as $attribute) {
|
||||
yield [
|
||||
$attribute->newInstance(),
|
||||
$class,
|
||||
$method->getName(),
|
||||
];
|
||||
yield [$attribute->newInstance(), $class, $method->getName()];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue