mirror of
https://gitee.com/hyperf/hyperf.git
synced 2024-12-05 05:07:58 +08:00
optimization code
This commit is contained in:
parent
a3f4d0c0e6
commit
934058c479
@ -59,8 +59,6 @@ class CircuitBreaker extends AbstractAnnotation
|
|||||||
|
|
||||||
public function __construct(...$value)
|
public function __construct(...$value)
|
||||||
{
|
{
|
||||||
parent::__construct(...$value);
|
$this->value = parent::__construct(...$value);
|
||||||
|
|
||||||
$this->value = $this->formatParams($value);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,8 +28,7 @@ class Value extends AbstractAnnotation
|
|||||||
|
|
||||||
public function __construct(...$value)
|
public function __construct(...$value)
|
||||||
{
|
{
|
||||||
parent::__construct(...$value);
|
$value = parent::__construct(...$value);
|
||||||
$value = $this->formatParams($value);
|
|
||||||
$this->bindMainProperty('key', $value);
|
$this->bindMainProperty('key', $value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,8 +76,7 @@ class Crontab extends AbstractAnnotation
|
|||||||
|
|
||||||
public function __construct(...$value)
|
public function __construct(...$value)
|
||||||
{
|
{
|
||||||
parent::__construct(...$value);
|
$value = parent::__construct(...$value);
|
||||||
$value = $this->formatParams($value);
|
|
||||||
$this->bindMainProperty('rule', $value);
|
$this->bindMainProperty('rule', $value);
|
||||||
if (! empty($this->rule)) {
|
if (! empty($this->rule)) {
|
||||||
$this->rule = str_replace('\\', '', $this->rule);
|
$this->rule = str_replace('\\', '', $this->rule);
|
||||||
|
@ -25,6 +25,7 @@ abstract class AbstractAnnotation implements AnnotationInterface, Arrayable
|
|||||||
$this->{$key} = $val;
|
$this->{$key} = $val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function formatParams($value): array
|
protected function formatParams($value): array
|
||||||
|
@ -71,7 +71,8 @@ class AnnotationReader implements Reader
|
|||||||
'example' => true,
|
'example' => true,
|
||||||
'filesource' => true,
|
'filesource' => true,
|
||||||
'global' => true,
|
'global' => true,
|
||||||
'ignore' => true, /* Can we enable this? 'index' => true, */ 'internal' => true,
|
'ignore' => true, /* Can we enable this? 'index' => true, */
|
||||||
|
'internal' => true,
|
||||||
'license' => true, 'link' => true,
|
'license' => true, 'link' => true,
|
||||||
'method' => true,
|
'method' => true,
|
||||||
'package' => true, 'param' => true, 'property' => true, 'property-read' => true, 'property-write' => true,
|
'package' => true, 'param' => true, 'property' => true, 'property-read' => true, 'property-write' => true,
|
||||||
@ -232,7 +233,9 @@ class AnnotationReader implements Reader
|
|||||||
public function getAttributes(\Reflector $reflection): ?array
|
public function getAttributes(\Reflector $reflection): ?array
|
||||||
{
|
{
|
||||||
if (method_exists($reflection, 'getAttributes') && $attributes = $reflection->getAttributes()) {
|
if (method_exists($reflection, 'getAttributes') && $attributes = $reflection->getAttributes()) {
|
||||||
return array_map(fn(\ReflectionAttribute $attribute) => $attribute->newInstance(), $attributes);
|
return array_map(function (\ReflectionAttribute $attribute) {
|
||||||
|
return $attribute->newInstance();
|
||||||
|
}, $attributes);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -28,8 +28,7 @@ class Middleware extends AbstractAnnotation
|
|||||||
|
|
||||||
public function __construct(...$value)
|
public function __construct(...$value)
|
||||||
{
|
{
|
||||||
parent::__construct(...$value);
|
$value = parent::__construct(...$value);
|
||||||
$value = $this->formatParams($value);
|
|
||||||
$this->bindMainProperty('middleware', $value);
|
$this->bindMainProperty('middleware', $value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,8 +42,7 @@ class RequestMapping extends Mapping
|
|||||||
|
|
||||||
public function __construct(...$value)
|
public function __construct(...$value)
|
||||||
{
|
{
|
||||||
parent::__construct(...$value);
|
$value = parent::__construct(...$value);
|
||||||
$value = $this->formatParams($value);
|
|
||||||
if (isset($value['methods'])) {
|
if (isset($value['methods'])) {
|
||||||
if (is_string($value['methods'])) {
|
if (is_string($value['methods'])) {
|
||||||
// Explode a string to a array
|
// Explode a string to a array
|
||||||
|
@ -30,8 +30,7 @@ class ModelListener extends AbstractAnnotation
|
|||||||
|
|
||||||
public function __construct(...$value)
|
public function __construct(...$value)
|
||||||
{
|
{
|
||||||
parent::__construct(...$value);
|
$value = parent::__construct(...$value);
|
||||||
$value = $this->formatParams($value);
|
|
||||||
|
|
||||||
if ($value = $value['value'] ?? null) {
|
if ($value = $value['value'] ?? null) {
|
||||||
if (is_string($value)) {
|
if (is_string($value)) {
|
||||||
|
@ -27,8 +27,7 @@ class Event extends AbstractAnnotation
|
|||||||
|
|
||||||
public function __construct(...$value)
|
public function __construct(...$value)
|
||||||
{
|
{
|
||||||
parent::__construct(...$value);
|
$value = parent::__construct(...$value);
|
||||||
$value = $this->formatParams($value);
|
|
||||||
$this->bindMainProperty('event', $value);
|
$this->bindMainProperty('event', $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,8 +26,7 @@ class SocketIONamespace extends AbstractAnnotation
|
|||||||
|
|
||||||
public function __construct(...$value)
|
public function __construct(...$value)
|
||||||
{
|
{
|
||||||
parent::__construct(...$value);
|
$value = parent::__construct(...$value);
|
||||||
$value = $this->formatParams($value);
|
|
||||||
$this->bindMainProperty('namespace', $value);
|
$this->bindMainProperty('namespace', $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user