-
Notifications
You must be signed in to change notification settings - Fork 703
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2327 from W0rma/param-attributes
Add support for native PHP8 QueryParam, FileParam and RequestParam attributes
- Loading branch information
Showing
8 changed files
with
298 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,10 +21,12 @@ | |
* Represents a file that must be present. | ||
* | ||
* @Annotation | ||
* @NamedArgumentConstructor | ||
* @Target("METHOD") | ||
* | ||
* @author Ener-Getick <[email protected]> | ||
*/ | ||
#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_METHOD)] | ||
class FileParam extends AbstractParam | ||
{ | ||
/** @var bool */ | ||
|
@@ -39,6 +41,32 @@ class FileParam extends AbstractParam | |
/** @var bool */ | ||
public $map = false; | ||
|
||
/** | ||
* @param mixed $requirements | ||
* @param mixed $default | ||
*/ | ||
public function __construct( | ||
string $name = '', | ||
bool $strict = true, | ||
$requirements = null, | ||
bool $image = false, | ||
bool $map = false, | ||
?string $key = null, | ||
$default = null, | ||
string $description = '', | ||
bool $nullable = false | ||
) { | ||
$this->strict = $strict; | ||
$this->requirements = $requirements; | ||
$this->image = $image; | ||
$this->map = $map; | ||
$this->name = $name; | ||
$this->key = $key; | ||
$this->default = $default; | ||
$this->description = $description; | ||
$this->nullable = $nullable; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,12 +17,42 @@ | |
* Represents a parameter that must be present in GET data. | ||
* | ||
* @Annotation | ||
* @NamedArgumentConstructor | ||
* @Target({"CLASS", "METHOD"}) | ||
* | ||
* @author Alexander <[email protected]> | ||
*/ | ||
#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_CLASS | \Attribute::TARGET_METHOD)] | ||
class QueryParam extends AbstractScalarParam | ||
{ | ||
/** | ||
* @param mixed $requirements | ||
* @param mixed $default | ||
*/ | ||
public function __construct( | ||
string $name = '', | ||
?string $key = null, | ||
$requirements = null, | ||
$default = null, | ||
array $incompatibles = [], | ||
string $description = '', | ||
bool $strict = false, | ||
bool $map = false, | ||
bool $nullable = false, | ||
bool $allowBlank = true | ||
) { | ||
$this->name = $name; | ||
$this->key = $key; | ||
$this->requirements = $requirements; | ||
$this->default = $default; | ||
$this->incompatibles = $incompatibles; | ||
$this->description = $description; | ||
$this->strict = $strict; | ||
$this->map = $map; | ||
$this->nullable = $nullable; | ||
$this->allowBlank = $allowBlank; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,16 +17,46 @@ | |
* Represents a parameter that must be present in POST data. | ||
* | ||
* @Annotation | ||
* @NamedArgumentConstructor | ||
* @Target("METHOD") | ||
* | ||
* @author Jordi Boggiano <[email protected]> | ||
* @author Boris Guéry <[email protected]> | ||
*/ | ||
#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_METHOD)] | ||
class RequestParam extends AbstractScalarParam | ||
{ | ||
/** @var bool */ | ||
public $strict = true; | ||
|
||
/** | ||
* @param mixed $requirements | ||
* @param mixed $default | ||
*/ | ||
public function __construct( | ||
string $name = '', | ||
?string $key = null, | ||
$requirements = null, | ||
$default = null, | ||
string $description = '', | ||
array $incompatibles = [], | ||
bool $strict = false, | ||
bool $map = false, | ||
bool $nullable = false, | ||
bool $allowBlank = true | ||
) { | ||
$this->name = $name; | ||
$this->key = $key; | ||
$this->requirements = $requirements; | ||
$this->default = $default; | ||
$this->description = $description; | ||
$this->incompatibles = $incompatibles; | ||
$this->strict = $strict; | ||
$this->map = $map; | ||
$this->nullable = $nullable; | ||
$this->allowBlank = $allowBlank; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.