mirror of
https://gitee.com/hyperf/hyperf.git
synced 2024-12-04 04:37:46 +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)
|
||||
{
|
||||
parent::__construct(...$value);
|
||||
|
||||
$this->value = $this->formatParams($value);
|
||||
$this->value = parent::__construct(...$value);
|
||||
}
|
||||
}
|
||||
|
@ -28,8 +28,7 @@ class Value extends AbstractAnnotation
|
||||
|
||||
public function __construct(...$value)
|
||||
{
|
||||
parent::__construct(...$value);
|
||||
$value = $this->formatParams($value);
|
||||
$value = parent::__construct(...$value);
|
||||
$this->bindMainProperty('key', $value);
|
||||
}
|
||||
}
|
||||
|
@ -76,8 +76,7 @@ class Crontab extends AbstractAnnotation
|
||||
|
||||
public function __construct(...$value)
|
||||
{
|
||||
parent::__construct(...$value);
|
||||
$value = $this->formatParams($value);
|
||||
$value = parent::__construct(...$value);
|
||||
$this->bindMainProperty('rule', $value);
|
||||
if (! empty($this->rule)) {
|
||||
$this->rule = str_replace('\\', '', $this->rule);
|
||||
|
@ -25,6 +25,7 @@ abstract class AbstractAnnotation implements AnnotationInterface, Arrayable
|
||||
$this->{$key} = $val;
|
||||
}
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
protected function formatParams($value): array
|
||||
|
@ -71,7 +71,8 @@ class AnnotationReader implements Reader
|
||||
'example' => true,
|
||||
'filesource' => 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,
|
||||
'method' => 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
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
@ -28,8 +28,7 @@ class Middleware extends AbstractAnnotation
|
||||
|
||||
public function __construct(...$value)
|
||||
{
|
||||
parent::__construct(...$value);
|
||||
$value = $this->formatParams($value);
|
||||
$value = parent::__construct(...$value);
|
||||
$this->bindMainProperty('middleware', $value);
|
||||
}
|
||||
}
|
||||
|
@ -42,8 +42,7 @@ class RequestMapping extends Mapping
|
||||
|
||||
public function __construct(...$value)
|
||||
{
|
||||
parent::__construct(...$value);
|
||||
$value = $this->formatParams($value);
|
||||
$value = parent::__construct(...$value);
|
||||
if (isset($value['methods'])) {
|
||||
if (is_string($value['methods'])) {
|
||||
// Explode a string to a array
|
||||
|
@ -30,8 +30,7 @@ class ModelListener extends AbstractAnnotation
|
||||
|
||||
public function __construct(...$value)
|
||||
{
|
||||
parent::__construct(...$value);
|
||||
$value = $this->formatParams($value);
|
||||
$value = parent::__construct(...$value);
|
||||
|
||||
if ($value = $value['value'] ?? null) {
|
||||
if (is_string($value)) {
|
||||
|
@ -27,8 +27,7 @@ class Event extends AbstractAnnotation
|
||||
|
||||
public function __construct(...$value)
|
||||
{
|
||||
parent::__construct(...$value);
|
||||
$value = $this->formatParams($value);
|
||||
$value = parent::__construct(...$value);
|
||||
$this->bindMainProperty('event', $value);
|
||||
}
|
||||
|
||||
|
@ -26,8 +26,7 @@ class SocketIONamespace extends AbstractAnnotation
|
||||
|
||||
public function __construct(...$value)
|
||||
{
|
||||
parent::__construct(...$value);
|
||||
$value = $this->formatParams($value);
|
||||
$value = parent::__construct(...$value);
|
||||
$this->bindMainProperty('namespace', $value);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user