Skip to content

Commit 13a8940

Browse files
Added metadata attributes into Hyperf\Di\ReflectionType. (#7325)
1 parent 964d99b commit 13a8940

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/AbstractCallableDefinitionCollector.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
namespace Hyperf\Di;
1414

15+
use ReflectionAttribute;
1516
use ReflectionNamedType;
1617
use ReflectionParameter;
1718
use ReflectionUnionType;
@@ -30,16 +31,17 @@ protected function getDefinitionsFromParameters(array $parameters): array
3031
$parameter->getType(),
3132
$parameter->allowsNull(),
3233
$parameter->isDefaultValueAvailable(),
33-
$parameter->isDefaultValueAvailable() ? $parameter->getDefaultValue() : null
34+
$parameter->isDefaultValueAvailable() ? $parameter->getDefaultValue() : null,
35+
$parameter->getAttributes()
3436
);
3537
}
3638
return $definitions;
3739
}
3840

3941
/**
40-
* @param mixed $defaultValue
42+
* @param ReflectionAttribute[] $attributes
4143
*/
42-
protected function createType(string $name, ?\ReflectionType $type, bool $allowsNull, bool $hasDefault = false, $defaultValue = null): ReflectionType
44+
protected function createType(string $name, ?\ReflectionType $type, bool $allowsNull, bool $hasDefault = false, mixed $defaultValue = null, array $attributes = []): ReflectionType
4345
{
4446
// TODO: Support ReflectionUnionType.
4547
$typeName = match (true) {
@@ -51,6 +53,7 @@ protected function createType(string $name, ?\ReflectionType $type, bool $allows
5153
'defaultValueAvailable' => $hasDefault,
5254
'defaultValue' => $defaultValue,
5355
'name' => $name,
56+
'attributes' => $attributes,
5457
]);
5558
}
5659
}

0 commit comments

Comments
 (0)