Skip to content

Commit 56c1b11

Browse files
authored
Format code (#5172)
1 parent 67d3ca4 commit 56c1b11

21 files changed

+68
-39
lines changed

src/AbstractCallableDefinitionCollector.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,14 @@
1111
*/
1212
namespace Hyperf\Di;
1313

14+
use ReflectionNamedType;
15+
use ReflectionParameter;
16+
use ReflectionUnionType;
17+
1418
abstract class AbstractCallableDefinitionCollector extends MetadataCollector
1519
{
1620
/**
17-
* @param array<\ReflectionParameter> $parameters
21+
* @param array<ReflectionParameter> $parameters
1822
*/
1923
protected function getDefinitionsFromParameters(array $parameters): array
2024
{
@@ -38,8 +42,8 @@ protected function createType(string $name, ?\ReflectionType $type, bool $allows
3842
{
3943
// TODO: Support ReflectionUnionType.
4044
$typeName = match (true) {
41-
$type instanceof \ReflectionNamedType => $type->getName(),
42-
$type instanceof \ReflectionUnionType => $type->getTypes()[0]->getName(),
45+
$type instanceof ReflectionNamedType => $type->getName(),
46+
$type instanceof ReflectionUnionType => $type->getTypes()[0]->getName(),
4347
default => 'mixed'
4448
};
4549
return new ReflectionType($typeName, $allowsNull, [

src/Annotation/AnnotationReader.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use ReflectionClass;
1616
use ReflectionMethod;
1717
use ReflectionProperty;
18+
use Reflector;
1819

1920
/**
2021
* A reader for docblock annotations.
@@ -79,7 +80,7 @@ public function getMethodAnnotation(ReflectionMethod $method, $annotationName)
7980
return null;
8081
}
8182

82-
public function getAttributes(\Reflector $reflection): array
83+
public function getAttributes(Reflector $reflection): array
8384
{
8485
$result = [];
8586
if (! method_exists($reflection, 'getAttributes')) {

src/Annotation/Aspect.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Hyperf\Di\Annotation;
1313

1414
use Attribute;
15+
use InvalidArgumentException;
1516

1617
#[Attribute(Attribute::TARGET_CLASS)]
1718
class Aspect extends AbstractAnnotation
@@ -40,7 +41,7 @@ protected function collect(string $className)
4041
$annotationPriority = $this->priority;
4142
$propertyPriority = $instancePriority ?: null;
4243
if (! is_null($annotationPriority) && ! is_null($propertyPriority) && $annotationPriority !== $propertyPriority) {
43-
throw new \InvalidArgumentException('Cannot define two difference priority of Aspect.');
44+
throw new InvalidArgumentException('Cannot define two difference priority of Aspect.');
4445
}
4546
$priority = $annotationPriority ?? $propertyPriority;
4647
// Save the metadata to AspectCollector

src/Annotation/Inject.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Hyperf\Di\ReflectionManager;
1717
use Hyperf\Utils\CodeGen\PhpDocReaderManager;
1818
use PhpDocReader\AnnotationException as DocReaderAnnotationException;
19+
use Throwable;
1920

2021
#[Attribute(Attribute::TARGET_PROPERTY)]
2122
class Inject extends AbstractAnnotation
@@ -53,7 +54,7 @@ public function collectProperty(string $className, ?string $target): void
5354
throw new AnnotationException($exception->getMessage());
5455
}
5556
$this->value = '';
56-
} catch (\Throwable $exception) {
57+
} catch (Throwable $exception) {
5758
throw new AnnotationException("The @Inject value is invalid for {$className}->{$target}. Because {$exception->getMessage()}");
5859
}
5960
}

src/Aop/AstVisitorRegistry.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
*/
1212
namespace Hyperf\Di\Aop;
1313

14+
use InvalidArgumentException;
1415
use SplPriorityQueue;
1516

1617
/**
@@ -28,7 +29,7 @@ public static function __callStatic($name, $arguments)
2829
if (method_exists($queue, $name)) {
2930
return $queue->{$name}(...$arguments);
3031
}
31-
throw new \InvalidArgumentException('Invalid method for ' . __CLASS__);
32+
throw new InvalidArgumentException('Invalid method for ' . __CLASS__);
3233
}
3334

3435
public static function insert($value, $priority = 0)

src/Aop/ProceedingJoinPoint.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
use Hyperf\Di\Annotation\AnnotationCollector;
1616
use Hyperf\Di\Exception\Exception;
1717
use Hyperf\Di\ReflectionManager;
18+
use ReflectionFunction;
19+
use ReflectionMethod;
1820

1921
class ProceedingJoinPoint
2022
{
@@ -78,7 +80,7 @@ public function getArguments()
7880
});
7981
}
8082

81-
public function getReflectMethod(): \ReflectionMethod
83+
public function getReflectMethod(): ReflectionMethod
8284
{
8385
return ReflectionManager::reflectMethod(
8486
$this->className,
@@ -88,7 +90,7 @@ public function getReflectMethod(): \ReflectionMethod
8890

8991
public function getInstance(): ?object
9092
{
91-
$ref = new \ReflectionFunction($this->originalMethod);
93+
$ref = new ReflectionFunction($this->originalMethod);
9294

9395
return $ref->getClosureThis();
9496
}

src/Aop/PropertyHandlerTrait.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Hyperf\Di\Annotation\AnnotationCollector;
1515
use Hyperf\Di\Definition\PropertyHandlerManager;
1616
use Hyperf\Di\ReflectionManager;
17+
use ReflectionClass;
1718

1819
trait PropertyHandlerTrait
1920
{
@@ -54,7 +55,7 @@ protected function __handlePropertyHandler(string $className)
5455
}
5556
}
5657

57-
protected function __handleTrait(\ReflectionClass $reflectionClass, array $handled, string $className): array
58+
protected function __handleTrait(ReflectionClass $reflectionClass, array $handled, string $className): array
5859
{
5960
foreach ($reflectionClass->getTraits() ?? [] as $reflectionTrait) {
6061
if (in_array($reflectionTrait->getName(), [ProxyTrait::class, PropertyHandlerTrait::class])) {

src/Aop/ProxyTrait.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Hyperf\Di\Annotation\AspectCollector;
1717
use Hyperf\Di\ReflectionManager;
1818
use Hyperf\Utils\ApplicationContext;
19+
use SplPriorityQueue;
1920

2021
trait ProxyTrait
2122
{
@@ -62,7 +63,7 @@ protected static function handleAround(ProceedingJoinPoint $proceedingJoinPoint)
6263
if (! AspectManager::has($className, $methodName)) {
6364
AspectManager::set($className, $methodName, []);
6465
$aspects = array_unique(array_merge(static::getClassesAspects($className, $methodName), static::getAnnotationAspects($className, $methodName)));
65-
$queue = new \SplPriorityQueue();
66+
$queue = new SplPriorityQueue();
6667
foreach ($aspects as $aspect) {
6768
$queue->insert($aspect, AspectCollector::getPriority($aspect));
6869
}

src/Aop/RegisterInjectPropertyHandler.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Hyperf\Di\Exception\NotFoundException;
1717
use Hyperf\Di\ReflectionManager;
1818
use Hyperf\Utils\ApplicationContext;
19+
use Throwable;
1920

2021
class RegisterInjectPropertyHandler
2122
{
@@ -41,7 +42,7 @@ public static function register()
4142
} elseif ($annotation->required) {
4243
throw new NotFoundException("No entry or class found for '{$annotation->value}'");
4344
}
44-
} catch (\Throwable $throwable) {
45+
} catch (Throwable $throwable) {
4546
if ($annotation->required) {
4647
throw $throwable;
4748
}

src/ClosureDefinitionCollector.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,31 +11,34 @@
1111
*/
1212
namespace Hyperf\Di;
1313

14+
use Closure;
15+
use ReflectionFunction;
16+
1417
class ClosureDefinitionCollector extends AbstractCallableDefinitionCollector implements ClosureDefinitionCollectorInterface
1518
{
1619
protected static array $container = [];
1720

18-
public function getParameters(\Closure $closure): array
21+
public function getParameters(Closure $closure): array
1922
{
2023
$key = spl_object_hash($closure);
2124
if (static::has($key)) {
2225
return static::get($key);
2326
}
24-
$reflectionFunction = new \ReflectionFunction($closure);
27+
$reflectionFunction = new ReflectionFunction($closure);
2528
$parameters = $reflectionFunction->getParameters();
2629

2730
$definitions = $this->getDefinitionsFromParameters($parameters);
2831
static::set($key, $definitions);
2932
return $definitions;
3033
}
3134

32-
public function getReturnType(\Closure $closure): ReflectionType
35+
public function getReturnType(Closure $closure): ReflectionType
3336
{
3437
$key = spl_object_hash($closure) . '@return';
3538
if (static::has($key)) {
3639
return static::get($key);
3740
}
38-
$returnType = (new \ReflectionFunction($closure))->getReturnType();
41+
$returnType = (new ReflectionFunction($closure))->getReturnType();
3942
$type = $this->createType('', $returnType, $returnType ? $returnType->allowsNull() : true);
4043
static::set($key, $type);
4144
return $type;

0 commit comments

Comments
 (0)