mirror of
https://gitee.com/hyperf/hyperf.git
synced 2024-12-04 04:37:46 +08:00
php8 attribute annotation
This commit is contained in:
parent
08f9a78db8
commit
99b3eefa81
@ -11,12 +11,14 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\Amqp\Annotation;
|
||||
|
||||
use Attribute;
|
||||
use Hyperf\Di\Annotation\AbstractAnnotation;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target({"CLASS"})
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_CLASS)]
|
||||
class Consumer extends AbstractAnnotation
|
||||
{
|
||||
/**
|
||||
|
@ -11,12 +11,14 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\Amqp\Annotation;
|
||||
|
||||
use Attribute;
|
||||
use Hyperf\Di\Annotation\AbstractAnnotation;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target({"CLASS"})
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_CLASS)]
|
||||
class Producer extends AbstractAnnotation
|
||||
{
|
||||
/**
|
||||
|
@ -11,12 +11,14 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\AsyncQueue\Annotation;
|
||||
|
||||
use Attribute;
|
||||
use Hyperf\Di\Annotation\AbstractAnnotation;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target({"CLASS", "METHOD"})
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_CLASS | Attribute::TARGET_METHOD)]
|
||||
class AsyncQueueMessage extends AbstractAnnotation
|
||||
{
|
||||
/**
|
||||
|
2
src/cache/src/Annotation/CacheEvict.php
vendored
2
src/cache/src/Annotation/CacheEvict.php
vendored
@ -11,12 +11,14 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\Cache\Annotation;
|
||||
|
||||
use Attribute;
|
||||
use Hyperf\Di\Annotation\AbstractAnnotation;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target({"METHOD"})
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_METHOD)]
|
||||
class CacheEvict extends AbstractAnnotation
|
||||
{
|
||||
/**
|
||||
|
6
src/cache/src/Annotation/CachePut.php
vendored
6
src/cache/src/Annotation/CachePut.php
vendored
@ -11,12 +11,14 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\Cache\Annotation;
|
||||
|
||||
use Attribute;
|
||||
use Hyperf\Di\Annotation\AbstractAnnotation;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target({"METHOD"})
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_METHOD)]
|
||||
class CachePut extends AbstractAnnotation
|
||||
{
|
||||
/**
|
||||
@ -45,9 +47,9 @@ class CachePut extends AbstractAnnotation
|
||||
*/
|
||||
public $group = 'default';
|
||||
|
||||
public function __construct($value = null)
|
||||
public function __construct(...$value)
|
||||
{
|
||||
parent::__construct($value);
|
||||
parent::__construct(...$value);
|
||||
if ($this->ttl !== null) {
|
||||
$this->ttl = (int) $this->ttl;
|
||||
}
|
||||
|
6
src/cache/src/Annotation/Cacheable.php
vendored
6
src/cache/src/Annotation/Cacheable.php
vendored
@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\Cache\Annotation;
|
||||
|
||||
use Attribute;
|
||||
use Hyperf\Cache\CacheListenerCollector;
|
||||
use Hyperf\Di\Annotation\AbstractAnnotation;
|
||||
use Hyperf\Di\Annotation\AnnotationCollector;
|
||||
@ -19,6 +20,7 @@ use Hyperf\Di\Annotation\AnnotationCollector;
|
||||
* @Annotation
|
||||
* @Target({"METHOD"})
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_METHOD)]
|
||||
class Cacheable extends AbstractAnnotation
|
||||
{
|
||||
/**
|
||||
@ -57,9 +59,9 @@ class Cacheable extends AbstractAnnotation
|
||||
*/
|
||||
public $collect = false;
|
||||
|
||||
public function __construct($value = null)
|
||||
public function __construct(...$value)
|
||||
{
|
||||
parent::__construct($value);
|
||||
parent::__construct(...$value);
|
||||
if ($this->ttl !== null) {
|
||||
$this->ttl = (int) $this->ttl;
|
||||
}
|
||||
|
2
src/cache/src/Annotation/FailCache.php
vendored
2
src/cache/src/Annotation/FailCache.php
vendored
@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\Cache\Annotation;
|
||||
|
||||
use Attribute;
|
||||
use Hyperf\Cache\CacheListenerCollector;
|
||||
use Hyperf\Di\Annotation\AbstractAnnotation;
|
||||
use Hyperf\Di\Annotation\AnnotationCollector;
|
||||
@ -19,6 +20,7 @@ use Hyperf\Di\Annotation\AnnotationCollector;
|
||||
* @Annotation
|
||||
* @Target({"METHOD"})
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_METHOD)]
|
||||
class FailCache extends AbstractAnnotation
|
||||
{
|
||||
public $prefix;
|
||||
|
@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\CircuitBreaker\Annotation;
|
||||
|
||||
use Attribute;
|
||||
use Doctrine\Common\Annotations\Annotation\Target;
|
||||
use Hyperf\CircuitBreaker\Handler\TimeoutHandler;
|
||||
use Hyperf\Di\Annotation\AbstractAnnotation;
|
||||
@ -20,6 +21,7 @@ use Hyperf\Di\Annotation\AbstractAnnotation;
|
||||
* @Target({"METHOD"})
|
||||
* @property float $timeout
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_METHOD)]
|
||||
class CircuitBreaker extends AbstractAnnotation
|
||||
{
|
||||
/**
|
||||
@ -55,10 +57,10 @@ class CircuitBreaker extends AbstractAnnotation
|
||||
*/
|
||||
public $value;
|
||||
|
||||
public function __construct($value = null)
|
||||
public function __construct(...$value)
|
||||
{
|
||||
parent::__construct($value);
|
||||
parent::__construct(...$value);
|
||||
|
||||
$this->value = $value ?? [];
|
||||
$this->value = $this->formatParams($value);
|
||||
}
|
||||
}
|
||||
|
@ -11,12 +11,14 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\Command\Annotation;
|
||||
|
||||
use Attribute;
|
||||
use Hyperf\Di\Annotation\AbstractAnnotation;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target({"CLASS"})
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_CLASS)]
|
||||
class Command extends AbstractAnnotation
|
||||
{
|
||||
}
|
||||
|
@ -11,12 +11,14 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\Config\Annotation;
|
||||
|
||||
use Attribute;
|
||||
use Hyperf\Di\Annotation\AbstractAnnotation;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target({"PROPERTY"})
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_PROPERTY)]
|
||||
class Value extends AbstractAnnotation
|
||||
{
|
||||
/**
|
||||
@ -24,9 +26,10 @@ class Value extends AbstractAnnotation
|
||||
*/
|
||||
public $key;
|
||||
|
||||
public function __construct($value = null)
|
||||
public function __construct(...$value)
|
||||
{
|
||||
parent::__construct($value);
|
||||
parent::__construct(...$value);
|
||||
$value = $this->formatParams($value);
|
||||
$this->bindMainProperty('key', $value);
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\Constants\Annotation;
|
||||
|
||||
use Attribute;
|
||||
use Hyperf\Constants\AnnotationReader;
|
||||
use Hyperf\Constants\ConstantsCollector;
|
||||
use Hyperf\Di\Annotation\AbstractAnnotation;
|
||||
@ -19,6 +20,7 @@ use Hyperf\Di\Annotation\AbstractAnnotation;
|
||||
* @Annotation
|
||||
* @Target({"CLASS"})
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_CLASS)]
|
||||
class Constants extends AbstractAnnotation
|
||||
{
|
||||
public function collectClass(string $className): void
|
||||
|
@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\Crontab\Annotation;
|
||||
|
||||
use Attribute;
|
||||
use Hyperf\Di\Annotation\AbstractAnnotation;
|
||||
use Hyperf\Di\ReflectionManager;
|
||||
use Hyperf\Utils\Str;
|
||||
@ -20,6 +21,7 @@ use ReflectionMethod;
|
||||
* @Annotation
|
||||
* @Target({"CLASS", "METHOD"})
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_CLASS | Attribute::TARGET_METHOD)]
|
||||
class Crontab extends AbstractAnnotation
|
||||
{
|
||||
/**
|
||||
@ -72,9 +74,10 @@ class Crontab extends AbstractAnnotation
|
||||
*/
|
||||
public $enable = true;
|
||||
|
||||
public function __construct($value = null)
|
||||
public function __construct(...$value)
|
||||
{
|
||||
parent::__construct($value);
|
||||
parent::__construct(...$value);
|
||||
$value = $this->formatParams($value);
|
||||
$this->bindMainProperty('rule', $value);
|
||||
if (! empty($this->rule)) {
|
||||
$this->rule = str_replace('\\', '', $this->rule);
|
||||
|
@ -11,12 +11,14 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\DbConnection\Annotation;
|
||||
|
||||
use Attribute;
|
||||
use Hyperf\Di\Annotation\AbstractAnnotation;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target({"METHOD"})
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_METHOD)]
|
||||
class Transactional extends AbstractAnnotation
|
||||
{
|
||||
/**
|
||||
|
@ -17,17 +17,27 @@ use ReflectionProperty;
|
||||
|
||||
abstract class AbstractAnnotation implements AnnotationInterface, Arrayable
|
||||
{
|
||||
public function __construct($value = null)
|
||||
public function __construct(...$value)
|
||||
{
|
||||
if (is_array($value)) {
|
||||
foreach ($value as $key => $val) {
|
||||
if (property_exists($this, $key)) {
|
||||
$this->{$key} = $val;
|
||||
}
|
||||
$value = $this->formatParams($value);
|
||||
foreach ($value as $key => $val) {
|
||||
if (property_exists($this, $key)) {
|
||||
$this->{$key} = $val;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function formatParams($value): array
|
||||
{
|
||||
if (isset($value[0])) {
|
||||
$value = $value[0];
|
||||
}
|
||||
if (! is_array($value)) {
|
||||
$value = ['value' => $value];
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function toArray(): array
|
||||
{
|
||||
$properties = ReflectionManager::reflectClass(static::class)->getProperties(ReflectionProperty::IS_PUBLIC);
|
||||
|
@ -205,6 +205,9 @@ class AnnotationReader implements Reader
|
||||
|
||||
public function getClassAnnotations(ReflectionClass $class)
|
||||
{
|
||||
if (method_exists($class, 'getAttributes') && $attributes = $class->getAttributes()) {
|
||||
return array_map(fn(\ReflectionAttribute $attribute) => $attribute->newInstance(), $attributes);
|
||||
}
|
||||
$this->parser->setTarget(Target::TARGET_CLASS);
|
||||
$this->parser->setImports($this->getClassImports($class));
|
||||
$this->parser->setIgnoredAnnotationNames($this->getIgnoredAnnotationNames($class));
|
||||
@ -228,6 +231,9 @@ class AnnotationReader implements Reader
|
||||
|
||||
public function getPropertyAnnotations(ReflectionProperty $property)
|
||||
{
|
||||
if (method_exists($property, 'getAttributes') && $attributes = $property->getAttributes()) {
|
||||
return array_map(fn(\ReflectionAttribute $attribute) => $attribute->newInstance(), $attributes);
|
||||
}
|
||||
$class = $property->getDeclaringClass();
|
||||
$context = 'property ' . $class->getName() . '::$' . $property->getName();
|
||||
|
||||
@ -254,6 +260,9 @@ class AnnotationReader implements Reader
|
||||
|
||||
public function getMethodAnnotations(ReflectionMethod $method)
|
||||
{
|
||||
if (method_exists($method, 'getAttributes') && $attributes = $method->getAttributes()) {
|
||||
return array_map(fn(\ReflectionAttribute $attribute) => $attribute->newInstance(), $attributes);
|
||||
}
|
||||
$class = $method->getDeclaringClass();
|
||||
$context = 'method ' . $class->getName() . '::' . $method->getName() . '()';
|
||||
|
||||
|
@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\Di\Annotation;
|
||||
|
||||
use Attribute;
|
||||
use Hyperf\Di\ReflectionManager;
|
||||
use ReflectionProperty;
|
||||
|
||||
@ -18,6 +19,7 @@ use ReflectionProperty;
|
||||
* @Annotation
|
||||
* @Target({"CLASS"})
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_CLASS)]
|
||||
class Aspect extends AbstractAnnotation
|
||||
{
|
||||
/**
|
||||
|
@ -11,10 +11,13 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\Di\Annotation;
|
||||
|
||||
use Attribute;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target({"ALL"})
|
||||
*/
|
||||
#[Attribute]
|
||||
class Debug extends AbstractAnnotation
|
||||
{
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\Di\Annotation;
|
||||
|
||||
use Attribute;
|
||||
use Hyperf\Di\Exception\AnnotationException;
|
||||
use Hyperf\Di\ReflectionManager;
|
||||
use Hyperf\Utils\CodeGen\PhpDocReaderManager;
|
||||
@ -20,6 +21,7 @@ use PhpDocReader\AnnotationException as DocReaderAnnotationException;
|
||||
* @Annotation
|
||||
* @Target({"PROPERTY"})
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_PROPERTY)]
|
||||
class Inject extends AbstractAnnotation
|
||||
{
|
||||
/**
|
||||
@ -37,11 +39,6 @@ class Inject extends AbstractAnnotation
|
||||
*/
|
||||
public $lazy = false;
|
||||
|
||||
public function __construct($value = null)
|
||||
{
|
||||
parent::__construct($value);
|
||||
}
|
||||
|
||||
public function collectProperty(string $className, ?string $target): void
|
||||
{
|
||||
try {
|
||||
|
@ -11,12 +11,14 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace HyperfTest\Di\Stub;
|
||||
|
||||
use Attribute;
|
||||
use Hyperf\Di\Annotation\AbstractAnnotation;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target({"CLASS"})
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_CLASS)]
|
||||
class IgnoreDemoAnnotation extends AbstractAnnotation
|
||||
{
|
||||
}
|
||||
|
@ -11,12 +11,14 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\Event\Annotation;
|
||||
|
||||
use Attribute;
|
||||
use Hyperf\Di\Annotation\AbstractAnnotation;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target({"CLASS"})
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_CLASS)]
|
||||
class Listener extends AbstractAnnotation
|
||||
{
|
||||
/**
|
||||
@ -24,8 +26,9 @@ class Listener extends AbstractAnnotation
|
||||
*/
|
||||
public $priority = 1;
|
||||
|
||||
public function __construct($value = null)
|
||||
public function __construct(...$value)
|
||||
{
|
||||
$value = $this->formatParams($value);
|
||||
if (isset($value['priority']) && is_numeric($value['priority'])) {
|
||||
$this->priority = (int) $value['priority'];
|
||||
}
|
||||
|
@ -11,12 +11,14 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\ExceptionHandler\Annotation;
|
||||
|
||||
use Attribute;
|
||||
use Hyperf\Di\Annotation\AbstractAnnotation;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target({"CLASS"})
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_CLASS)]
|
||||
class ExceptionHandler extends AbstractAnnotation
|
||||
{
|
||||
/**
|
||||
|
@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\GraphQL\Annotation;
|
||||
|
||||
use Attribute;
|
||||
use Hyperf\Di\Annotation\AnnotationInterface;
|
||||
|
||||
/**
|
||||
@ -20,6 +21,7 @@ use Hyperf\Di\Annotation\AnnotationInterface;
|
||||
* @Attribute("class", type="string"),
|
||||
* })
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_CLASS)]
|
||||
class ExtendType extends \TheCodingMachine\GraphQLite\Annotations\ExtendType implements AnnotationInterface
|
||||
{
|
||||
use AnnotationTrait;
|
||||
|
@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\GraphQL\Annotation;
|
||||
|
||||
use Attribute;
|
||||
use Hyperf\Di\Annotation\AnnotationInterface;
|
||||
|
||||
/**
|
||||
@ -20,6 +21,7 @@ use Hyperf\Di\Annotation\AnnotationInterface;
|
||||
* @Attribute("name", type="string")
|
||||
* })
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_METHOD)]
|
||||
class Factory extends \TheCodingMachine\GraphQLite\Annotations\Factory implements AnnotationInterface
|
||||
{
|
||||
use AnnotationTrait;
|
||||
|
@ -11,12 +11,14 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\GraphQL\Annotation;
|
||||
|
||||
use Attribute;
|
||||
use Hyperf\Di\Annotation\AnnotationInterface;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target({"METHOD"})
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_METHOD)]
|
||||
class FailWith extends \TheCodingMachine\GraphQLite\Annotations\FailWith implements AnnotationInterface
|
||||
{
|
||||
use AnnotationTrait;
|
||||
|
@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\GraphQL\Annotation;
|
||||
|
||||
use Attribute;
|
||||
use Hyperf\Di\Annotation\AnnotationInterface;
|
||||
|
||||
/**
|
||||
@ -20,6 +21,7 @@ use Hyperf\Di\Annotation\AnnotationInterface;
|
||||
* @Attribute("outputType", type="string"),
|
||||
* })
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_METHOD)]
|
||||
class Field extends \TheCodingMachine\GraphQLite\Annotations\Field implements AnnotationInterface
|
||||
{
|
||||
use AnnotationTrait;
|
||||
|
@ -11,12 +11,14 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\GraphQL\Annotation;
|
||||
|
||||
use Attribute;
|
||||
use Hyperf\Di\Annotation\AnnotationInterface;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target({"METHOD"})
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_METHOD)]
|
||||
class Logged extends \TheCodingMachine\GraphQLite\Annotations\Logged implements AnnotationInterface
|
||||
{
|
||||
use AnnotationTrait;
|
||||
|
@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\GraphQL\Annotation;
|
||||
|
||||
use Attribute;
|
||||
use Hyperf\Di\Annotation\AnnotationInterface;
|
||||
|
||||
/**
|
||||
@ -20,6 +21,7 @@ use Hyperf\Di\Annotation\AnnotationInterface;
|
||||
* @Attribute("outputType", type="string"),
|
||||
* })
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_METHOD)]
|
||||
class Mutation extends \TheCodingMachine\GraphQLite\Annotations\Mutation implements AnnotationInterface
|
||||
{
|
||||
use AnnotationTrait;
|
||||
|
@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\GraphQL\Annotation;
|
||||
|
||||
use Attribute;
|
||||
use Hyperf\Di\Annotation\AnnotationInterface;
|
||||
|
||||
/**
|
||||
@ -20,6 +21,7 @@ use Hyperf\Di\Annotation\AnnotationInterface;
|
||||
* @Attribute("outputType", type="string"),
|
||||
* })
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_METHOD)]
|
||||
class Query extends \TheCodingMachine\GraphQLite\Annotations\Query implements AnnotationInterface
|
||||
{
|
||||
use AnnotationTrait;
|
||||
|
@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\GraphQL\Annotation;
|
||||
|
||||
use Attribute;
|
||||
use Hyperf\Di\Annotation\AnnotationInterface;
|
||||
|
||||
/**
|
||||
@ -20,6 +21,7 @@ use Hyperf\Di\Annotation\AnnotationInterface;
|
||||
* @Attribute("name", type="string"),
|
||||
* })
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_METHOD)]
|
||||
class Right extends \TheCodingMachine\GraphQLite\Annotations\Right implements AnnotationInterface
|
||||
{
|
||||
use AnnotationTrait;
|
||||
|
@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\GraphQL\Annotation;
|
||||
|
||||
use Attribute;
|
||||
use Hyperf\Di\Annotation\AnnotationInterface;
|
||||
|
||||
/**
|
||||
@ -25,6 +26,7 @@ use Hyperf\Di\Annotation\AnnotationInterface;
|
||||
* @Attribute("failWith", type="mixed"),
|
||||
* })
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_CLASS)]
|
||||
class SourceField extends \TheCodingMachine\GraphQLite\Annotations\SourceField implements AnnotationInterface
|
||||
{
|
||||
use AnnotationTrait;
|
||||
|
@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\GraphQL\Annotation;
|
||||
|
||||
use Attribute;
|
||||
use Hyperf\Di\Annotation\AnnotationInterface;
|
||||
|
||||
/**
|
||||
@ -20,6 +21,7 @@ use Hyperf\Di\Annotation\AnnotationInterface;
|
||||
* @Attribute("class", type="string"),
|
||||
* })
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_CLASS)]
|
||||
class Type extends \TheCodingMachine\GraphQLite\Annotations\Type implements AnnotationInterface
|
||||
{
|
||||
use AnnotationTrait;
|
||||
|
@ -11,12 +11,14 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\HttpServer\Annotation;
|
||||
|
||||
use Attribute;
|
||||
use Hyperf\Di\Annotation\AbstractAnnotation;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target({"CLASS"})
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_CLASS)]
|
||||
class AutoController extends AbstractAnnotation
|
||||
{
|
||||
/**
|
||||
|
@ -11,12 +11,14 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\HttpServer\Annotation;
|
||||
|
||||
use Attribute;
|
||||
use Hyperf\Di\Annotation\AbstractAnnotation;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target({"CLASS"})
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_CLASS)]
|
||||
class Controller extends AbstractAnnotation
|
||||
{
|
||||
/**
|
||||
|
@ -11,10 +11,13 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\HttpServer\Annotation;
|
||||
|
||||
use Attribute;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target({"METHOD"})
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_METHOD)]
|
||||
class DeleteMapping extends Mapping
|
||||
{
|
||||
public $methods = ['DELETE'];
|
||||
|
@ -11,10 +11,13 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\HttpServer\Annotation;
|
||||
|
||||
use Attribute;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target({"METHOD"})
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_METHOD)]
|
||||
class GetMapping extends Mapping
|
||||
{
|
||||
public $methods = ['GET'];
|
||||
|
@ -30,8 +30,10 @@ abstract class Mapping extends AbstractAnnotation
|
||||
*/
|
||||
public $options = [];
|
||||
|
||||
public function __construct($value = null)
|
||||
public function __construct(...$value)
|
||||
{
|
||||
$value = $this->formatParams($value);
|
||||
|
||||
if (isset($value['path'])) {
|
||||
$this->path = $value['path'];
|
||||
}
|
||||
|
@ -11,12 +11,14 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\HttpServer\Annotation;
|
||||
|
||||
use Attribute;
|
||||
use Hyperf\Di\Annotation\AbstractAnnotation;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target({"ALL"})
|
||||
*/
|
||||
#[Attribute]
|
||||
class Middleware extends AbstractAnnotation
|
||||
{
|
||||
/**
|
||||
@ -24,9 +26,10 @@ class Middleware extends AbstractAnnotation
|
||||
*/
|
||||
public $middleware = '';
|
||||
|
||||
public function __construct($value = null)
|
||||
public function __construct(...$value)
|
||||
{
|
||||
parent::__construct($value);
|
||||
parent::__construct(...$value);
|
||||
$value = $this->formatParams($value);
|
||||
$this->bindMainProperty('middleware', $value);
|
||||
}
|
||||
}
|
||||
|
@ -11,12 +11,14 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\HttpServer\Annotation;
|
||||
|
||||
use Attribute;
|
||||
use Hyperf\Di\Annotation\AbstractAnnotation;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target({"ALL"})
|
||||
*/
|
||||
#[Attribute]
|
||||
class Middlewares extends AbstractAnnotation
|
||||
{
|
||||
/**
|
||||
@ -24,8 +26,9 @@ class Middlewares extends AbstractAnnotation
|
||||
*/
|
||||
public $middlewares = [];
|
||||
|
||||
public function __construct($value = null)
|
||||
public function __construct(...$value)
|
||||
{
|
||||
$value = $this->formatParams($value);
|
||||
$this->bindMainProperty('middlewares', $value);
|
||||
}
|
||||
}
|
||||
|
@ -11,10 +11,13 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\HttpServer\Annotation;
|
||||
|
||||
use Attribute;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target({"METHOD"})
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_METHOD)]
|
||||
class PatchMapping extends Mapping
|
||||
{
|
||||
public $methods = ['PATCH'];
|
||||
|
@ -11,10 +11,13 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\HttpServer\Annotation;
|
||||
|
||||
use Attribute;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target({"METHOD"})
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_METHOD)]
|
||||
class PostMapping extends Mapping
|
||||
{
|
||||
public $methods = ['POST'];
|
||||
|
@ -11,10 +11,13 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\HttpServer\Annotation;
|
||||
|
||||
use Attribute;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target({"METHOD"})
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_METHOD)]
|
||||
class PutMapping extends Mapping
|
||||
{
|
||||
public $methods = ['PUT'];
|
||||
|
@ -11,12 +11,14 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\HttpServer\Annotation;
|
||||
|
||||
use Attribute;
|
||||
use Hyperf\Utils\Str;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target({"METHOD"})
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_METHOD)]
|
||||
class RequestMapping extends Mapping
|
||||
{
|
||||
public const GET = 'GET';
|
||||
@ -38,9 +40,10 @@ class RequestMapping extends Mapping
|
||||
*/
|
||||
public $methods = ['GET', 'POST'];
|
||||
|
||||
public function __construct($value = null)
|
||||
public function __construct(...$value)
|
||||
{
|
||||
parent::__construct($value);
|
||||
parent::__construct(...$value);
|
||||
$value = $this->formatParams($value);
|
||||
if (isset($value['methods'])) {
|
||||
if (is_string($value['methods'])) {
|
||||
// Explode a string to a array
|
||||
|
@ -11,12 +11,14 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\Kafka\Annotation;
|
||||
|
||||
use Attribute;
|
||||
use Hyperf\Di\Annotation\AbstractAnnotation;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target({"CLASS"})
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_CLASS)]
|
||||
class Consumer extends AbstractAnnotation
|
||||
{
|
||||
/**
|
||||
|
@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\Metric\Annotation;
|
||||
|
||||
use Attribute;
|
||||
use Doctrine\Common\Annotations\Annotation\Target;
|
||||
use Hyperf\Di\Annotation\AbstractAnnotation;
|
||||
|
||||
@ -18,6 +19,7 @@ use Hyperf\Di\Annotation\AbstractAnnotation;
|
||||
* @Annotation
|
||||
* @Target({"CLASS", "METHOD"})
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_CLASS | Attribute::TARGET_METHOD)]
|
||||
class Counter extends AbstractAnnotation
|
||||
{
|
||||
/**
|
||||
|
@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\Metric\Annotation;
|
||||
|
||||
use Attribute;
|
||||
use Doctrine\Common\Annotations\Annotation\Target;
|
||||
use Hyperf\Di\Annotation\AbstractAnnotation;
|
||||
|
||||
@ -18,6 +19,7 @@ use Hyperf\Di\Annotation\AbstractAnnotation;
|
||||
* @Annotation
|
||||
* @Target({"CLASS", "METHOD"})
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_CLASS | Attribute::TARGET_METHOD)]
|
||||
class Histogram extends AbstractAnnotation
|
||||
{
|
||||
/**
|
||||
|
@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\ModelListener\Annotation;
|
||||
|
||||
use Attribute;
|
||||
use Hyperf\Di\Annotation\AbstractAnnotation;
|
||||
use Hyperf\ModelListener\Collector\ListenerCollector;
|
||||
use Hyperf\Utils\Arr;
|
||||
@ -19,6 +20,7 @@ use Hyperf\Utils\Arr;
|
||||
* @Annotation
|
||||
* @Target({"CLASS"})
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_CLASS)]
|
||||
class ModelListener extends AbstractAnnotation
|
||||
{
|
||||
/**
|
||||
@ -26,9 +28,10 @@ class ModelListener extends AbstractAnnotation
|
||||
*/
|
||||
public $models = [];
|
||||
|
||||
public function __construct($value = null)
|
||||
public function __construct(...$value)
|
||||
{
|
||||
parent::__construct($value);
|
||||
parent::__construct(...$value);
|
||||
$value = $this->formatParams($value);
|
||||
|
||||
if ($value = $value['value'] ?? null) {
|
||||
if (is_string($value)) {
|
||||
|
@ -11,12 +11,14 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\Nats\Annotation;
|
||||
|
||||
use Attribute;
|
||||
use Hyperf\Di\Annotation\AbstractAnnotation;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target({"CLASS"})
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_CLASS)]
|
||||
class Consumer extends AbstractAnnotation
|
||||
{
|
||||
/**
|
||||
|
@ -11,12 +11,14 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\Nsq\Annotation;
|
||||
|
||||
use Attribute;
|
||||
use Hyperf\Di\Annotation\AbstractAnnotation;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target({"CLASS"})
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_CLASS)]
|
||||
class Consumer extends AbstractAnnotation
|
||||
{
|
||||
/**
|
||||
|
@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\Process\Annotation;
|
||||
|
||||
use Attribute;
|
||||
use Doctrine\Common\Annotations\Annotation\Target;
|
||||
use Hyperf\Di\Annotation\AbstractAnnotation;
|
||||
|
||||
@ -18,6 +19,7 @@ use Hyperf\Di\Annotation\AbstractAnnotation;
|
||||
* @Annotation
|
||||
* @Target("CLASS")
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_CLASS)]
|
||||
class Process extends AbstractAnnotation
|
||||
{
|
||||
/**
|
||||
|
@ -11,12 +11,14 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\RateLimit\Annotation;
|
||||
|
||||
use Attribute;
|
||||
use Hyperf\Di\Annotation\AbstractAnnotation;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target({"CLASS", "METHOD"})
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_CLASS | Attribute::TARGET_METHOD)]
|
||||
class RateLimit extends AbstractAnnotation
|
||||
{
|
||||
/**
|
||||
|
@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\Retry\Annotation;
|
||||
|
||||
use Attribute;
|
||||
use Doctrine\Common\Annotations\Annotation\Target;
|
||||
use Hyperf\Retry\BackoffStrategy;
|
||||
|
||||
@ -18,6 +19,7 @@ use Hyperf\Retry\BackoffStrategy;
|
||||
* @Annotation
|
||||
* @Target({"METHOD"})
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_METHOD)]
|
||||
class BackoffRetryFalsy extends RetryFalsy
|
||||
{
|
||||
public $base = 100;
|
||||
|
@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\Retry\Annotation;
|
||||
|
||||
use Attribute;
|
||||
use Doctrine\Common\Annotations\Annotation\Target;
|
||||
use Hyperf\Retry\BackoffStrategy;
|
||||
|
||||
@ -18,6 +19,7 @@ use Hyperf\Retry\BackoffStrategy;
|
||||
* @Annotation
|
||||
* @Target({"METHOD"})
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_METHOD)]
|
||||
class BackoffRetryThrowable extends RetryThrowable
|
||||
{
|
||||
public $base = 100;
|
||||
|
@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\Retry\Annotation;
|
||||
|
||||
use Attribute;
|
||||
use Hyperf\Retry\CircuitBreakerState;
|
||||
use Hyperf\Retry\Policy\CircuitBreakerRetryPolicy;
|
||||
use Hyperf\Retry\Policy\ClassifierRetryPolicy;
|
||||
@ -23,6 +24,7 @@ use Hyperf\Retry\SleepStrategyInterface;
|
||||
* @Annotation
|
||||
* @Target({"METHOD"})
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_METHOD)]
|
||||
class CircuitBreaker extends AbstractRetry
|
||||
{
|
||||
/**
|
||||
|
@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\Retry\Annotation;
|
||||
|
||||
use Attribute;
|
||||
use Doctrine\Common\Annotations\Annotation\Target;
|
||||
use Hyperf\Retry\Policy\BudgetRetryPolicy;
|
||||
use Hyperf\Retry\Policy\ClassifierRetryPolicy;
|
||||
@ -25,6 +26,7 @@ use Hyperf\Retry\SleepStrategyInterface;
|
||||
* @Annotation
|
||||
* @Target({"METHOD"})
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_METHOD)]
|
||||
class Retry extends AbstractRetry
|
||||
{
|
||||
/**
|
||||
@ -113,9 +115,9 @@ class Retry extends AbstractRetry
|
||||
*/
|
||||
public $fallback = '';
|
||||
|
||||
public function __construct($value = null)
|
||||
public function __construct(...$value)
|
||||
{
|
||||
parent::__construct($value);
|
||||
parent::__construct(...$value);
|
||||
$this->retryBudget = make(RetryBudget::class, $this->retryBudget);
|
||||
}
|
||||
}
|
||||
|
@ -11,12 +11,14 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\Retry\Annotation;
|
||||
|
||||
use Attribute;
|
||||
use Doctrine\Common\Annotations\Annotation\Target;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target({"METHOD"})
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_METHOD)]
|
||||
class RetryFalsy extends Retry
|
||||
{
|
||||
/**
|
||||
|
@ -11,12 +11,14 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\Retry\Annotation;
|
||||
|
||||
use Attribute;
|
||||
use Doctrine\Common\Annotations\Annotation\Target;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target({"METHOD"})
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_METHOD)]
|
||||
class RetryThrowable extends Retry
|
||||
{
|
||||
/**
|
||||
|
@ -11,12 +11,14 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\RpcServer\Annotation;
|
||||
|
||||
use Attribute;
|
||||
use Hyperf\Di\Annotation\AbstractAnnotation;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target({"CLASS"})
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_CLASS)]
|
||||
class RpcService extends AbstractAnnotation
|
||||
{
|
||||
/**
|
||||
|
@ -11,12 +11,14 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\Signal\Annotation;
|
||||
|
||||
use Attribute;
|
||||
use Hyperf\Di\Annotation\AbstractAnnotation;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target({"CLASS"})
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_CLASS)]
|
||||
class Signal extends AbstractAnnotation
|
||||
{
|
||||
/**
|
||||
|
@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\SocketIOServer\Annotation;
|
||||
|
||||
use Attribute;
|
||||
use Hyperf\Di\Annotation\AbstractAnnotation;
|
||||
use Hyperf\Di\ReflectionManager;
|
||||
use Hyperf\SocketIOServer\Collector\EventAnnotationCollector;
|
||||
@ -19,13 +20,15 @@ use Hyperf\SocketIOServer\Collector\EventAnnotationCollector;
|
||||
* @Annotation
|
||||
* @Target({"CLASS", "METHOD"})
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_CLASS | Attribute::TARGET_METHOD)]
|
||||
class Event extends AbstractAnnotation
|
||||
{
|
||||
public $event = 'event';
|
||||
|
||||
public function __construct($value = [])
|
||||
public function __construct(...$value)
|
||||
{
|
||||
parent::__construct();
|
||||
parent::__construct(...$value);
|
||||
$value = $this->formatParams($value);
|
||||
$this->bindMainProperty('event', $value);
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\SocketIOServer\Annotation;
|
||||
|
||||
use Attribute;
|
||||
use Hyperf\Di\Annotation\AbstractAnnotation;
|
||||
use Hyperf\SocketIOServer\Collector\SocketIORouter;
|
||||
|
||||
@ -18,13 +19,15 @@ use Hyperf\SocketIOServer\Collector\SocketIORouter;
|
||||
* @Annotation
|
||||
* @Target({"CLASS"})
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_CLASS)]
|
||||
class SocketIONamespace extends AbstractAnnotation
|
||||
{
|
||||
public $namespace = '/';
|
||||
|
||||
public function __construct($value = [])
|
||||
public function __construct(...$value)
|
||||
{
|
||||
parent::__construct();
|
||||
parent::__construct(...$value);
|
||||
$value = $this->formatParams($value);
|
||||
$this->bindMainProperty('namespace', $value);
|
||||
}
|
||||
|
||||
|
@ -11,12 +11,14 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\Task\Annotation;
|
||||
|
||||
use Attribute;
|
||||
use Hyperf\Di\Annotation\AbstractAnnotation;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target({"CLASS", "METHOD"})
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_CLASS | Attribute::TARGET_METHOD)]
|
||||
class Task extends AbstractAnnotation
|
||||
{
|
||||
/**
|
||||
|
@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\Tracer\Annotation;
|
||||
|
||||
use Attribute;
|
||||
use Doctrine\Common\Annotations\Annotation\Target;
|
||||
use Hyperf\Di\Annotation\AbstractAnnotation;
|
||||
|
||||
@ -18,6 +19,7 @@ use Hyperf\Di\Annotation\AbstractAnnotation;
|
||||
* @Annotation
|
||||
* @Target({"CLASS", "METHOD"})
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_CLASS | Attribute::TARGET_METHOD)]
|
||||
class Trace extends AbstractAnnotation
|
||||
{
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user