Today I learned: attribute declaration does not inherit.
This commit is contained in:
parent
bcc7e8066a
commit
a5cfba6b96
10 changed files with 27 additions and 5 deletions
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
0.2403.282019
|
||||
0.2403.282022
|
||||
|
|
|
@ -5,15 +5,13 @@
|
|||
|
||||
namespace Index\Http\Routing;
|
||||
|
||||
use Attribute;
|
||||
use ReflectionAttribute;
|
||||
use ReflectionObject;
|
||||
|
||||
/**
|
||||
* Provides an attribute for marking methods in a class as handlers.
|
||||
* Provides base for attributes that mark methods in a class as handlers.
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)]
|
||||
class HandlerAttribute {
|
||||
abstract class HandlerAttribute {
|
||||
public function __construct(private string $path) {}
|
||||
|
||||
/**
|
||||
|
|
|
@ -5,9 +5,12 @@
|
|||
|
||||
namespace Index\Http\Routing;
|
||||
|
||||
use Attribute;
|
||||
|
||||
/**
|
||||
* Provides an attribute for marking methods in a class as a DELETE route.
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)]
|
||||
class HttpDelete extends HttpRoute {
|
||||
public function __construct(string $path) {
|
||||
parent::__construct('DELETE', $path);
|
||||
|
|
|
@ -5,9 +5,12 @@
|
|||
|
||||
namespace Index\Http\Routing;
|
||||
|
||||
use Attribute;
|
||||
|
||||
/**
|
||||
* Provides an attribute for marking methods in a class as a GET route.
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)]
|
||||
class HttpGet extends HttpRoute {
|
||||
public function __construct(string $path) {
|
||||
parent::__construct('GET', $path);
|
||||
|
|
|
@ -5,7 +5,10 @@
|
|||
|
||||
namespace Index\Http\Routing;
|
||||
|
||||
use Attribute;
|
||||
|
||||
/**
|
||||
* Provides an attribute for marking methods in a class as middleware.
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)]
|
||||
class HttpMiddleware extends HandlerAttribute {}
|
||||
|
|
|
@ -5,9 +5,12 @@
|
|||
|
||||
namespace Index\Http\Routing;
|
||||
|
||||
use Attribute;
|
||||
|
||||
/**
|
||||
* Provides an attribute for marking methods in a class as a OPTIONS route.
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)]
|
||||
class HttpOptions extends HttpRoute {
|
||||
public function __construct(string $path) {
|
||||
parent::__construct('OPTIONS', $path);
|
||||
|
|
|
@ -5,9 +5,12 @@
|
|||
|
||||
namespace Index\Http\Routing;
|
||||
|
||||
use Attribute;
|
||||
|
||||
/**
|
||||
* Provides an attribute for marking methods in a class as a POST route.
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)]
|
||||
class HttpPatch extends HttpRoute {
|
||||
public function __construct(string $path) {
|
||||
parent::__construct('PATCH', $path);
|
||||
|
|
|
@ -5,9 +5,12 @@
|
|||
|
||||
namespace Index\Http\Routing;
|
||||
|
||||
use Attribute;
|
||||
|
||||
/**
|
||||
* Provides an attribute for marking methods in a class as a POST route.
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)]
|
||||
class HttpPost extends HttpRoute {
|
||||
public function __construct(string $path) {
|
||||
parent::__construct('POST', $path);
|
||||
|
|
|
@ -5,9 +5,12 @@
|
|||
|
||||
namespace Index\Http\Routing;
|
||||
|
||||
use Attribute;
|
||||
|
||||
/**
|
||||
* Provides an attribute for marking methods in a class as a PUT route.
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)]
|
||||
class HttpPut extends HttpRoute {
|
||||
public function __construct(string $path) {
|
||||
parent::__construct('PUT', $path);
|
||||
|
|
|
@ -5,9 +5,12 @@
|
|||
|
||||
namespace Index\Http\Routing;
|
||||
|
||||
use Attribute;
|
||||
|
||||
/**
|
||||
* Provides an attribute for marking methods in a class as a route.
|
||||
*/
|
||||
#[Attribute(Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)]
|
||||
class HttpRoute extends HandlerAttribute {
|
||||
private string $method;
|
||||
|
||||
|
|
Loading…
Reference in a new issue