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;
|
namespace Index\Http\Routing;
|
||||||
|
|
||||||
use Attribute;
|
|
||||||
use ReflectionAttribute;
|
use ReflectionAttribute;
|
||||||
use ReflectionObject;
|
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)]
|
abstract class HandlerAttribute {
|
||||||
class HandlerAttribute {
|
|
||||||
public function __construct(private string $path) {}
|
public function __construct(private string $path) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -5,9 +5,12 @@
|
||||||
|
|
||||||
namespace Index\Http\Routing;
|
namespace Index\Http\Routing;
|
||||||
|
|
||||||
|
use Attribute;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides an attribute for marking methods in a class as a DELETE route.
|
* Provides an attribute for marking methods in a class as a DELETE route.
|
||||||
*/
|
*/
|
||||||
|
#[Attribute(Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)]
|
||||||
class HttpDelete extends HttpRoute {
|
class HttpDelete extends HttpRoute {
|
||||||
public function __construct(string $path) {
|
public function __construct(string $path) {
|
||||||
parent::__construct('DELETE', $path);
|
parent::__construct('DELETE', $path);
|
||||||
|
|
|
@ -5,9 +5,12 @@
|
||||||
|
|
||||||
namespace Index\Http\Routing;
|
namespace Index\Http\Routing;
|
||||||
|
|
||||||
|
use Attribute;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides an attribute for marking methods in a class as a GET route.
|
* Provides an attribute for marking methods in a class as a GET route.
|
||||||
*/
|
*/
|
||||||
|
#[Attribute(Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)]
|
||||||
class HttpGet extends HttpRoute {
|
class HttpGet extends HttpRoute {
|
||||||
public function __construct(string $path) {
|
public function __construct(string $path) {
|
||||||
parent::__construct('GET', $path);
|
parent::__construct('GET', $path);
|
||||||
|
|
|
@ -5,7 +5,10 @@
|
||||||
|
|
||||||
namespace Index\Http\Routing;
|
namespace Index\Http\Routing;
|
||||||
|
|
||||||
|
use Attribute;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides an attribute for marking methods in a class as middleware.
|
* Provides an attribute for marking methods in a class as middleware.
|
||||||
*/
|
*/
|
||||||
|
#[Attribute(Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)]
|
||||||
class HttpMiddleware extends HandlerAttribute {}
|
class HttpMiddleware extends HandlerAttribute {}
|
||||||
|
|
|
@ -5,9 +5,12 @@
|
||||||
|
|
||||||
namespace Index\Http\Routing;
|
namespace Index\Http\Routing;
|
||||||
|
|
||||||
|
use Attribute;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides an attribute for marking methods in a class as a OPTIONS route.
|
* Provides an attribute for marking methods in a class as a OPTIONS route.
|
||||||
*/
|
*/
|
||||||
|
#[Attribute(Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)]
|
||||||
class HttpOptions extends HttpRoute {
|
class HttpOptions extends HttpRoute {
|
||||||
public function __construct(string $path) {
|
public function __construct(string $path) {
|
||||||
parent::__construct('OPTIONS', $path);
|
parent::__construct('OPTIONS', $path);
|
||||||
|
|
|
@ -5,9 +5,12 @@
|
||||||
|
|
||||||
namespace Index\Http\Routing;
|
namespace Index\Http\Routing;
|
||||||
|
|
||||||
|
use Attribute;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides an attribute for marking methods in a class as a POST route.
|
* Provides an attribute for marking methods in a class as a POST route.
|
||||||
*/
|
*/
|
||||||
|
#[Attribute(Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)]
|
||||||
class HttpPatch extends HttpRoute {
|
class HttpPatch extends HttpRoute {
|
||||||
public function __construct(string $path) {
|
public function __construct(string $path) {
|
||||||
parent::__construct('PATCH', $path);
|
parent::__construct('PATCH', $path);
|
||||||
|
|
|
@ -5,9 +5,12 @@
|
||||||
|
|
||||||
namespace Index\Http\Routing;
|
namespace Index\Http\Routing;
|
||||||
|
|
||||||
|
use Attribute;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides an attribute for marking methods in a class as a POST route.
|
* Provides an attribute for marking methods in a class as a POST route.
|
||||||
*/
|
*/
|
||||||
|
#[Attribute(Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)]
|
||||||
class HttpPost extends HttpRoute {
|
class HttpPost extends HttpRoute {
|
||||||
public function __construct(string $path) {
|
public function __construct(string $path) {
|
||||||
parent::__construct('POST', $path);
|
parent::__construct('POST', $path);
|
||||||
|
|
|
@ -5,9 +5,12 @@
|
||||||
|
|
||||||
namespace Index\Http\Routing;
|
namespace Index\Http\Routing;
|
||||||
|
|
||||||
|
use Attribute;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides an attribute for marking methods in a class as a PUT route.
|
* Provides an attribute for marking methods in a class as a PUT route.
|
||||||
*/
|
*/
|
||||||
|
#[Attribute(Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)]
|
||||||
class HttpPut extends HttpRoute {
|
class HttpPut extends HttpRoute {
|
||||||
public function __construct(string $path) {
|
public function __construct(string $path) {
|
||||||
parent::__construct('PUT', $path);
|
parent::__construct('PUT', $path);
|
||||||
|
|
|
@ -5,9 +5,12 @@
|
||||||
|
|
||||||
namespace Index\Http\Routing;
|
namespace Index\Http\Routing;
|
||||||
|
|
||||||
|
use Attribute;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides an attribute for marking methods in a class as a route.
|
* Provides an attribute for marking methods in a class as a route.
|
||||||
*/
|
*/
|
||||||
|
#[Attribute(Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)]
|
||||||
class HttpRoute extends HandlerAttribute {
|
class HttpRoute extends HandlerAttribute {
|
||||||
private string $method;
|
private string $method;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue